summaryrefslogtreecommitdiff
path: root/sal/qa/rtl
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 /sal/qa/rtl
parentf697d06b67e91c704c088dceafade209462e0b95 (diff)
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 'sal/qa/rtl')
-rw-r--r--sal/qa/rtl/strings/test_ostring_concat.cxx7
-rw-r--r--sal/qa/rtl/strings/test_oustring_concat.cxx7
2 files changed, 14 insertions, 0 deletions
diff --git a/sal/qa/rtl/strings/test_ostring_concat.cxx b/sal/qa/rtl/strings/test_ostring_concat.cxx
index b2adc17272d6..80fa62df6be5 100644
--- a/sal/qa/rtl/strings/test_ostring_concat.cxx
+++ b/sal/qa/rtl/strings/test_ostring_concat.cxx
@@ -147,6 +147,13 @@ void test::ostring::StringConcat::checkInvalid()
rtl_uString* rus = nullptr;
CPPUNIT_ASSERT( INVALID_CONCAT( OUString( "b" ) + rs ));
CPPUNIT_ASSERT( INVALID_CONCAT( OUString( "b" ) + rus ));
+
+#if 0
+ // Should fail to compile, to avoid use of OStringConcat lvalues that
+ // contain dangling references to temporaries:
+ auto const conc = OStringLiteral("foo") + "bar";
+ (void) OString(conc);
+#endif
}
}} // namespace
diff --git a/sal/qa/rtl/strings/test_oustring_concat.cxx b/sal/qa/rtl/strings/test_oustring_concat.cxx
index 0cf305f9b133..1af3f60dd3aa 100644
--- a/sal/qa/rtl/strings/test_oustring_concat.cxx
+++ b/sal/qa/rtl/strings/test_oustring_concat.cxx
@@ -157,6 +157,13 @@ void test::oustring::StringConcat::checkInvalid()
rtl_uString* rus = nullptr;
CPPUNIT_ASSERT( INVALID_CONCAT( OUString( "b" ) + rs ));
CPPUNIT_ASSERT( INVALID_CONCAT( OUString( "b" ) + rus ));
+
+#if 0
+ // Should fail to compile, to avoid use of OUStringConcat lvalues that
+ // contain dangling references to temporaries:
+ auto const conc = OUStringLiteral("foo") + "bar";
+ (void) OUString(conc);
+#endif
}
}} // namespace