summaryrefslogtreecommitdiffstats
path: root/include/sax
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2017-11-10 17:46:57 +0100
committerStephan Bergmann <sbergman@redhat.com>2017-11-11 00:03:37 +0100
commit1fc79c3491906d85ed9972e161112459035b62ed (patch)
tree29f284f4a814b2b7a61417046364b489ce2187d7 /include/sax
parentRemove unnecessary makePropertyValue specialization for Any (diff)
downloadcore-1fc79c3491906d85ed9972e161112459035b62ed.tar.gz
core-1fc79c3491906d85ed9972e161112459035b62ed.zip
Avoid using O[U]StringConcat lvalues containing dangling refs to temporaries
...in code accidentally using auto like > auto const aURL = uri->getUriReference() + "/" > + INetURLObject::encode( > m_sEmbeddedName, INetURLObject::PART_FPATH, > INetURLObject::EncodeMechanism::All); > > uno::Reference<uno::XInterface> xDataSource(xDatabaseContext->getByName(aURL), uno::UNO_QUERY); in <https://gerrit.libreoffice.org/#/c/44569/1> "Properly construct vnd.sun.star.pkg URL" did (causing hard to debug test failures there). So make functions taking O[U]StringConcat take those by rvalue reference. Unfortunately, that also needed adaption of various functions that just forward their arguments. And some code in sc/qa/unit/ucalc_formula.cxx used CPPUNIT_ASSERT_EQUAL on OUStringConcat arguments in cases where that happened to actually compile (because the structure of the two OUStringConcats was identical), which needed adaption too (but which would arguably better use CPPUNIT_ASSERT_EQUAL_MESSAGE, anyway). Change-Id: I8994d932aaedb2a491c7c81c167e93379d4fb6e3 Reviewed-on: https://gerrit.libreoffice.org/44608 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'include/sax')
-rw-r--r--include/sax/fshelper.hxx33
1 files changed, 17 insertions, 16 deletions
diff --git a/include/sax/fshelper.hxx b/include/sax/fshelper.hxx
index 6b3dc1e68318..5be3b3bfc697 100644
--- a/include/sax/fshelper.hxx
+++ b/include/sax/fshelper.hxx
@@ -24,6 +24,7 @@
#include <sax/fastattribs.hxx>
#include <stdarg.h>
#include <memory>
+#include <utility>
#define FSNS(namespc, element) ((namespc << 16) | element)
// Backwards compatibility for code that used FSEND to terminate the vararg.
@@ -76,11 +77,11 @@ public:
/// Start an element. After the first argument there can be a number of (attribute, value) pairs.
template<typename... Args>
- void startElement(sal_Int32 elementTokenId, sal_Int32 attribute, const char* value, Args... args)
+ void startElement(sal_Int32 elementTokenId, sal_Int32 attribute, const char* value, Args &&... args)
{
if (value)
pushAttributeValue(attribute, value);
- startElement(elementTokenId, args...);
+ startElement(elementTokenId, std::forward<Args>(args)...);
}
void startElement(sal_Int32 elementTokenId, sal_Int32 attribute, const char* value, FSEND_t)
{
@@ -89,10 +90,10 @@ public:
startElement(elementTokenId, FSEND);
}
template<typename... Args>
- void startElement(sal_Int32 elementTokenId, sal_Int32 attribute, const OString& value, Args... args)
+ void startElement(sal_Int32 elementTokenId, sal_Int32 attribute, const OString& value, Args &&... args)
{
pushAttributeValue(attribute, value);
- startElement(elementTokenId, args...);
+ startElement(elementTokenId, std::forward<Args>(args)...);
}
void startElement(sal_Int32 elementTokenId, sal_Int32 attribute, const OString& value, FSEND_t)
{
@@ -103,11 +104,11 @@ public:
/// Start an element. After the first two arguments there can be a number of (attribute, value) pairs.
template<typename... Args>
- void startElementNS(sal_Int32 namespaceTokenId, sal_Int32 elementTokenId, sal_Int32 attribute, const char* value, Args... args)
+ void startElementNS(sal_Int32 namespaceTokenId, sal_Int32 elementTokenId, sal_Int32 attribute, const char* value, Args &&... args)
{
if (value)
pushAttributeValue(attribute, value);
- startElementNS(namespaceTokenId, elementTokenId, args...);
+ startElementNS(namespaceTokenId, elementTokenId, std::forward<Args>(args)...);
}
void startElementNS(sal_Int32 namespaceTokenId, sal_Int32 elementTokenId, sal_Int32 attribute, const char* value, FSEND_t)
{
@@ -116,10 +117,10 @@ public:
startElementNS(namespaceTokenId, elementTokenId, FSEND);
}
template<typename... Args>
- void startElementNS(sal_Int32 namespaceTokenId, sal_Int32 elementTokenId, sal_Int32 attribute, const OString& value, Args... args)
+ void startElementNS(sal_Int32 namespaceTokenId, sal_Int32 elementTokenId, sal_Int32 attribute, const OString& value, Args &&... args)
{
pushAttributeValue(attribute, value);
- startElementNS(namespaceTokenId, elementTokenId, args...);
+ startElementNS(namespaceTokenId, elementTokenId, std::forward<Args>(args)...);
}
void startElementNS(sal_Int32 namespaceTokenId, sal_Int32 elementTokenId, sal_Int32 attribute, const OString& value, FSEND_t)
{
@@ -133,11 +134,11 @@ public:
/// Create a single element. After the first argument there can be a number of (attribute, value) pairs.
template<typename... Args>
- void singleElement(sal_Int32 elementTokenId, sal_Int32 attribute, const char* value, Args... args)
+ void singleElement(sal_Int32 elementTokenId, sal_Int32 attribute, const char* value, Args &&... args)
{
if (value)
pushAttributeValue(attribute, value);
- singleElement(elementTokenId, args...);
+ singleElement(elementTokenId, std::forward<Args>(args)...);
}
void singleElement(sal_Int32 elementTokenId, sal_Int32 attribute, const char* value, FSEND_t)
{
@@ -146,10 +147,10 @@ public:
singleElement(elementTokenId, FSEND);
}
template<typename... Args>
- void singleElement(sal_Int32 elementTokenId, sal_Int32 attribute, const OString& value, Args... args)
+ void singleElement(sal_Int32 elementTokenId, sal_Int32 attribute, const OString& value, Args &&... args)
{
pushAttributeValue(attribute, value);
- singleElement(elementTokenId, args...);
+ singleElement(elementTokenId, std::forward<Args>(args)...);
}
void singleElement(sal_Int32 elementTokenId, sal_Int32 attribute, const OString& value, FSEND_t)
{
@@ -160,11 +161,11 @@ public:
/// Create a single element. After the first two arguments there can be a number of (attribute, value) pairs.
template<typename... Args>
- void singleElementNS(sal_Int32 namespaceTokenId, sal_Int32 elementTokenId, sal_Int32 attribute, const char* value, Args... args)
+ void singleElementNS(sal_Int32 namespaceTokenId, sal_Int32 elementTokenId, sal_Int32 attribute, const char* value, Args &&... args)
{
if (value)
pushAttributeValue(attribute, value);
- singleElementNS(namespaceTokenId, elementTokenId, args...);
+ singleElementNS(namespaceTokenId, elementTokenId, std::forward<Args>(args)...);
}
void singleElementNS(sal_Int32 namespaceTokenId, sal_Int32 elementTokenId, sal_Int32 attribute, const char* value, FSEND_t)
{
@@ -173,10 +174,10 @@ public:
singleElementNS(namespaceTokenId, elementTokenId, FSEND);
}
template<typename... Args>
- void singleElementNS(sal_Int32 namespaceTokenId, sal_Int32 elementTokenId, sal_Int32 attribute, const OString& value, Args... args)
+ void singleElementNS(sal_Int32 namespaceTokenId, sal_Int32 elementTokenId, sal_Int32 attribute, const OString& value, Args &&... args)
{
pushAttributeValue(attribute, value);
- singleElementNS(namespaceTokenId, elementTokenId, args...);
+ singleElementNS(namespaceTokenId, elementTokenId, std::forward<Args>(args)...);
}
void singleElementNS(sal_Int32 namespaceTokenId, sal_Int32 elementTokenId, sal_Int32 attribute, const OString& value, FSEND_t)
{