diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2023-10-10 13:41:35 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2023-10-11 09:19:35 +0200 |
commit | f99bee8103ad82dac2e53e114527399c4af5485c (patch) | |
tree | 0708413c61a0a2b7ee8a7e5a7ee633c410d972b6 /sal/qa | |
parent | a822df6379606ab9f62d6ebb2318d0294d9c959c (diff) |
Delete OUString UTF-16 string literal ctor/assignment op
...that have been made unused by 7ef3d937415185ef66e32dd3043783eddcd03db5
"loplugin:ostr: Rewrite some uses of O[U]String to use ""_ostr/u""_ustr
literals". (And which means we can remove the relevant code from that plugin
again.)
(This also found a handful of remaining uses that had been hard for the plugin
to discover, along the lines of
> std::map<OUString, int> m = {{u"foo", 0}};
being represented by a
> DeclStmt 0xdaca578 <line:103:5, col:50>
> `-VarDecl 0xdac9150 <col:5, col:49> col:29 s11 'std::map<OUString, int>':'std::map<rtl::OUString, int>' cinit destroyed
> `-ExprWithCleanups 0xdaca548 <col:35, col:49> 'std::map<OUString, int>':'std::map<rtl::OUString, int>'
> `-CXXConstructExpr 0xdaca508 <col:35, col:49> 'std::map<OUString, int>':'std::map<rtl::OUString, int>' 'void (initializer_list<value_type>, const std::less<rtl::OUString> &, const allocator_type &)' list std::initializer_list
> |-CXXStdInitializerListExpr 0xdaca480 <col:35, col:49> 'initializer_list<value_type>':'std::initializer_list<std::pair<const rtl::OUString, int>>'
> | `-MaterializeTemporaryExpr 0xdaca468 <col:35, col:49> 'const std::pair<const rtl::OUString, int>[1]' xvalue
> | `-CXXBindTemporaryExpr 0xdaca448 <col:35, col:49> 'const std::pair<const rtl::OUString, int>[1]' (CXXTemporary 0xdaca448)
> | `-InitListExpr 0xdac9df0 <col:35, col:49> 'const std::pair<const rtl::OUString, int>[1]'
> | `-CXXConstructExpr 0xdaca408 <col:36, col:48> 'const std::pair<const rtl::OUString, int>' 'void (const char16_t (&)[4], int &&) noexcept(_S_nothrow_constructible<const char16_t (&)[4], int>())' list
> | |-StringLiteral 0xdac91b8 <col:38> 'const char16_t[4]' lvalue u"foo"
> | `-MaterializeTemporaryExpr 0xdaca3f0 <col:46> 'int' xvalue
> | `-IntegerLiteral 0xdac91d8 <col:46> 'int' 0
> |-CXXDefaultArgExpr 0xdaca498 <<invalid sloc>> 'const std::less<rtl::OUString>':'const std::less<rtl::OUString>' lvalue
> `-CXXDefaultArgExpr 0xdaca4b8 <<invalid sloc>> 'const allocator_type':'const std::allocator<std::pair<const rtl::OUString, int>>' lvalue
Clang AST.)
Change-Id: I496fe9d4d5e1a033cb7b27b4e04b303f8ddbed4a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157756
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'sal/qa')
-rw-r--r-- | sal/qa/osl/file/osl_old_test_file.cxx | 32 | ||||
-rw-r--r-- | sal/qa/rtl/strings/nonconstarray.cxx | 10 | ||||
-rw-r--r-- | sal/qa/rtl/strings/test_oustring_stringliterals.cxx | 32 |
3 files changed, 35 insertions, 39 deletions
diff --git a/sal/qa/osl/file/osl_old_test_file.cxx b/sal/qa/osl/file/osl_old_test_file.cxx index 7b0ef6e6dd25..bb37e8f3384a 100644 --- a/sal/qa/osl/file/osl_old_test_file.cxx +++ b/sal/qa/osl/file/osl_old_test_file.cxx @@ -49,27 +49,27 @@ public: }; const std::pair<OUString, OUString> aSource1[] = { - { u"a", u"file:///" TEST_VOLUME "bla/a" }, + { u"a"_ustr, u"file:///" TEST_VOLUME "bla/a"_ustr }, ///TODO: check if last slash must be omitted in resolved path. -// { u"a/", u"file:///" TEST_VOLUME "bla/a" }, - { u"../a", u"file:///" TEST_VOLUME "a" }, - { u"a/..", u"file:///" TEST_VOLUME "bla/" }, - { u"a/../b", u"file:///" TEST_VOLUME "bla/b" }, - { u"..", u"file:///" TEST_VOLUME "" }, - { u"a/b/c/d", u"file:///" TEST_VOLUME "bla/a/b/c/d" }, - { u"a/./c", u"file:///" TEST_VOLUME "bla/a/c" }, - { u"a/././c", u"file:///" TEST_VOLUME "bla/a/c" }, - { u"file:///" TEST_VOLUME "bla1/blub", u"file:///" TEST_VOLUME "bla1/blub" }, +// { u"a/"_ustr, u"file:///" TEST_VOLUME "bla/a"_ustr }, + { u"../a"_ustr, u"file:///" TEST_VOLUME "a"_ustr }, + { u"a/.."_ustr, u"file:///" TEST_VOLUME "bla/"_ustr }, + { u"a/../b"_ustr, u"file:///" TEST_VOLUME "bla/b"_ustr }, + { u".."_ustr, u"file:///" TEST_VOLUME ""_ustr }, + { u"a/b/c/d"_ustr, u"file:///" TEST_VOLUME "bla/a/b/c/d"_ustr }, + { u"a/./c"_ustr, u"file:///" TEST_VOLUME "bla/a/c"_ustr }, + { u"a/././c"_ustr, u"file:///" TEST_VOLUME "bla/a/c"_ustr }, + { u"file:///" TEST_VOLUME "bla1/blub"_ustr, u"file:///" TEST_VOLUME "bla1/blub"_ustr }, }; const std::pair<OUString, OUString> aSource2[] = { - { u"a", u"file:///" TEST_VOLUME "bla/blubs/schnubbel/a" }, + { u"a"_ustr, u"file:///" TEST_VOLUME "bla/blubs/schnubbel/a"_ustr }, ///TODO: check if last slash must be omitted in resolved path. -// { u"a/", u"file:///" TEST_VOLUME "bla/blubs/schnubbel/a" }, - { u"../a", u"file:///" TEST_VOLUME "bla/blubs/a" }, - { u"../../a", u"file:///" TEST_VOLUME "bla/a" }, - { u"../../../a", u"file:///" TEST_VOLUME "a" }, - { u"../../../a/b/c/d", u"file:///" TEST_VOLUME "a/b/c/d" }, +// { u"a/"_ustr, u"file:///" TEST_VOLUME "bla/blubs/schnubbel/a"_ustr }, + { u"../a"_ustr, u"file:///" TEST_VOLUME "bla/blubs/a"_ustr }, + { u"../../a"_ustr, u"file:///" TEST_VOLUME "bla/a"_ustr }, + { u"../../../a"_ustr, u"file:///" TEST_VOLUME "a"_ustr }, + { u"../../../a/b/c/d"_ustr, u"file:///" TEST_VOLUME "a/b/c/d"_ustr }, }; void oldtestfile::test_file_001() diff --git a/sal/qa/rtl/strings/nonconstarray.cxx b/sal/qa/rtl/strings/nonconstarray.cxx index d759049582d0..167b427cfbec 100644 --- a/sal/qa/rtl/strings/nonconstarray.cxx +++ b/sal/qa/rtl/strings/nonconstarray.cxx @@ -85,13 +85,9 @@ private: CPPUNIT_ASSERT_EQUAL(sal_Int32(1), OUString(s.a).getLength()); // Ideally, the below would work the same as the above. However, the const reference makes // the ConstCharArrayDetector instead of the NonConstCharArrayDetector kick in, so that the - // call to OUString(r.a) would fire the ConstCharArrayDetector<T>::isValid assert (and in - // NDEBUG builds the CPPUNIT_ASSERT_EQUAL would fail with 3 != 1):: - if ((false)) - { - S const& r = s; - CPPUNIT_ASSERT_EQUAL(sal_Int32(1), OUString(r.a).getLength()); - } + // call to OUString(r.a) would pick the deleted ConstCharArrayDetector overload: + // S const& r = s; + // CPPUNIT_ASSERT_EQUAL(sal_Int32(1), OUString(r.a).getLength()); } void testP2266R3() diff --git a/sal/qa/rtl/strings/test_oustring_stringliterals.cxx b/sal/qa/rtl/strings/test_oustring_stringliterals.cxx index a7041c75959b..25bc346fb495 100644 --- a/sal/qa/rtl/strings/test_oustring_stringliterals.cxx +++ b/sal/qa/rtl/strings/test_oustring_stringliterals.cxx @@ -339,9 +339,9 @@ void test::oustring::StringLiterals::checkOUStringChar() } void test::oustring::StringLiterals::checkUtf16() { - rtl::OUString s1(u"abc"); + rtl::OUString s1(u"abc"_ustr); CPPUNIT_ASSERT_EQUAL(rtl::OUString("abc"), s1); - s1 = u"de"; + s1 = u"de"_ustr; CPPUNIT_ASSERT_EQUAL(rtl::OUString("de"), s1); s1 += u"fde"; CPPUNIT_ASSERT_EQUAL(rtl::OUString("defde"), s1); @@ -351,13 +351,13 @@ void test::oustring::StringLiterals::checkUtf16() { CPPUNIT_ASSERT(s1.matchIgnoreAsciiCase(u"FDE", 2)); rtl::OUString s2; CPPUNIT_ASSERT(s1.startsWith(u"de", &s2)); - CPPUNIT_ASSERT_EQUAL(rtl::OUString(u"fde"), s2); + CPPUNIT_ASSERT_EQUAL(u"fde"_ustr, s2); CPPUNIT_ASSERT(s1.startsWithIgnoreAsciiCase(u"DEFD", &s2)); - CPPUNIT_ASSERT_EQUAL(rtl::OUString(u"e"), s2); + CPPUNIT_ASSERT_EQUAL(u"e"_ustr, s2); CPPUNIT_ASSERT(s1.endsWith(u"de", &s2)); - CPPUNIT_ASSERT_EQUAL(rtl::OUString(u"def"), s2); + CPPUNIT_ASSERT_EQUAL(u"def"_ustr, s2); CPPUNIT_ASSERT(s1.endsWithIgnoreAsciiCase(u"EFDE", &s2)); - CPPUNIT_ASSERT_EQUAL(rtl::OUString(u"d"), s2); + CPPUNIT_ASSERT_EQUAL(u"d"_ustr, s2); CPPUNIT_ASSERT(bool(s1 == u"defde")); CPPUNIT_ASSERT(bool(u"defde" == s1)); CPPUNIT_ASSERT(s1 != u"abc"); @@ -366,32 +366,32 @@ void test::oustring::StringLiterals::checkUtf16() { CPPUNIT_ASSERT_EQUAL(sal_Int32(3), s1.lastIndexOf(u"de")); sal_Int32 i = 0; CPPUNIT_ASSERT_EQUAL( - rtl::OUString(u"abcfde"), + u"abcfde"_ustr, s1.replaceFirst(u"de", rtl::OUString("abc"), &i)); CPPUNIT_ASSERT_EQUAL(sal_Int32(0), i); CPPUNIT_ASSERT_EQUAL( - rtl::OUString(u"abcfde"), + u"abcfde"_ustr, s1.replaceFirst(rtl::OUString("de"), u"abc", &i)); CPPUNIT_ASSERT_EQUAL(sal_Int32(0), i); CPPUNIT_ASSERT_EQUAL( - rtl::OUString(u"abcfde"), s1.replaceFirst(u"de", u"abc", &i)); + u"abcfde"_ustr, s1.replaceFirst(u"de", u"abc", &i)); CPPUNIT_ASSERT_EQUAL(sal_Int32(0), i); CPPUNIT_ASSERT_EQUAL( - rtl::OUString(u"abcfde"), s1.replaceFirst(u"de", "abc", &i)); + u"abcfde"_ustr, s1.replaceFirst(u"de", "abc", &i)); CPPUNIT_ASSERT_EQUAL(sal_Int32(0), i); CPPUNIT_ASSERT_EQUAL( - rtl::OUString(u"abcfde"), s1.replaceFirst("de", u"abc", &i)); + u"abcfde"_ustr, s1.replaceFirst("de", u"abc", &i)); CPPUNIT_ASSERT_EQUAL(sal_Int32(0), i); CPPUNIT_ASSERT_EQUAL( - rtl::OUString(u"abcfabc"), s1.replaceAll(u"de", rtl::OUString("abc"))); + u"abcfabc"_ustr, s1.replaceAll(u"de", rtl::OUString("abc"))); CPPUNIT_ASSERT_EQUAL( - rtl::OUString(u"abcfabc"), s1.replaceAll(rtl::OUString("de"), u"abc")); + u"abcfabc"_ustr, s1.replaceAll(rtl::OUString("de"), u"abc")); CPPUNIT_ASSERT_EQUAL( - rtl::OUString(u"abcfabc"), s1.replaceAll(u"de", u"abc")); + u"abcfabc"_ustr, s1.replaceAll(u"de", u"abc")); CPPUNIT_ASSERT_EQUAL( - rtl::OUString(u"abcfabc"), s1.replaceAll(u"de", "abc")); + u"abcfabc"_ustr, s1.replaceAll(u"de", "abc")); CPPUNIT_ASSERT_EQUAL( - rtl::OUString(u"abcfabc"), s1.replaceAll("de", u"abc")); + u"abcfabc"_ustr, s1.replaceAll("de", u"abc")); CPPUNIT_ASSERT_EQUAL( rtl::OUString("abcdef"), rtl::OUString(rtl::OUString("abc") + u"def")); CPPUNIT_ASSERT_EQUAL( |