summaryrefslogtreecommitdiff
path: root/compilerplugins
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2023-03-23 10:35:31 +0100
committerStephan Bergmann <sbergman@redhat.com>2023-03-23 10:51:14 +0000
commitfe3234718539ef65e384f1393cfd859cb81b8233 (patch)
treeecf94e784ffde42fcce6b29b538b1881c7515d64 /compilerplugins
parent71311f88f7d83d8669576a98d300780d3d8bd02a (diff)
loplugin:stringview: Constructing O[U]String from O[U]StringLiteral is cheap
...so don't warn about those, as requested in the comment at <https://gerrit.libreoffice.org/c/core/+/149254/8#message-6430dc5397ab7b60bf4e78e6856b44ab6cd72c97> "tdf#154319: fix TOC field codes parsing" Change-Id: I25989cd4b42bc3fe9062a8a0d6896d32a18635d3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149417 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'compilerplugins')
-rw-r--r--compilerplugins/clang/stringview.cxx15
-rw-r--r--compilerplugins/clang/test/stringview.cxx2
2 files changed, 1 insertions, 16 deletions
diff --git a/compilerplugins/clang/stringview.cxx b/compilerplugins/clang/stringview.cxx
index feb91ccc253c..7d6d38ba3b60 100644
--- a/compilerplugins/clang/stringview.cxx
+++ b/compilerplugins/clang/stringview.cxx
@@ -196,20 +196,7 @@ void StringView::handleCXXConstructExpr(CXXConstructExpr const* expr)
break;
}
loplugin::TypeCheck tc(t);
- if (tc.LvalueReference()
- .Const()
- .Class("OStringLiteral")
- .Namespace("rtl")
- .GlobalNamespace()
- || tc.LvalueReference()
- .Const()
- .Class("OUStringLiteral")
- .Namespace("rtl")
- .GlobalNamespace()
- || tc.RvalueReference()
- .Struct("StringNumberBase")
- .Namespace("rtl")
- .GlobalNamespace()
+ if (tc.RvalueReference().Struct("StringNumberBase").Namespace("rtl").GlobalNamespace()
|| tc.RvalueReference().Struct("OStringNumber").Namespace("rtl").GlobalNamespace()
|| tc.RvalueReference().Struct("OUStringNumber").Namespace("rtl").GlobalNamespace()
|| tc.ClassOrStruct("basic_string_view").StdNamespace())
diff --git a/compilerplugins/clang/test/stringview.cxx b/compilerplugins/clang/test/stringview.cxx
index 2ba87c13c31d..f1a63a058bdf 100644
--- a/compilerplugins/clang/test/stringview.cxx
+++ b/compilerplugins/clang/test/stringview.cxx
@@ -161,7 +161,6 @@ void f5(char const* s1, sal_Int32 n1, char16_t const* s2, sal_Int32 n2, OString
// expected-error-re@+1 {{instead of an '{{(rtl::)?}}OString' constructed from a 'const char *', pass a 'std::string_view' [loplugin:stringview]}}
call_view(OString(s1, n1));
constexpr OStringLiteral l1("foo");
- // expected-error-re@+1 {{instead of an '{{(rtl::)?}}OString' constructed from a 'const {{(rtl::)?}}OStringLiteral<4>'{{( \(aka 'const rtl::OStringLiteral<4>'\))?}}, pass a 'std::string_view' [loplugin:stringview]}}
call_view(OString(l1));
// expected-error-re@+1 {{instead of an '{{(rtl::)?}}OString' constructed from a 'std::string_view' (aka 'basic_string_view<char>'), pass a 'std::string_view' [loplugin:stringview]}}
call_view(OString(std::string_view("foo")));
@@ -186,7 +185,6 @@ void f5(char const* s1, sal_Int32 n1, char16_t const* s2, sal_Int32 n2, OString
// expected-error-re@+1 {{instead of an '{{(rtl::)?}}OUString' constructed from a 'const char16_t *', pass a 'std::u16string_view' (or an 'rtl::OUStringChar') [loplugin:stringview]}}
call_view(OUString(s2, 1));
constexpr OUStringLiteral l2(u"foo");
- // expected-error-re@+1 {{instead of an '{{(rtl::)?}}OUString' constructed from a 'const {{(rtl::)?}}OUStringLiteral<4>'{{( \(aka 'const rtl::OUStringLiteral<4>'\))?}}, pass a 'std::u16string_view' [loplugin:stringview]}}
call_view(OUString(l2));
// expected-error-re@+1 {{instead of an '{{(rtl::)?}}OUString' constructed from a 'std::u16string_view' (aka 'basic_string_view<char16_t>'), pass a 'std::u16string_view' [loplugin:stringview]}}
call_view(OUString(std::u16string_view(u"foo")));