compilerplugins/clang/stringview.cxx      |   15 +--------------
 compilerplugins/clang/test/stringview.cxx |    2 --
 2 files changed, 1 insertion(+), 16 deletions(-)

New commits:
commit fe3234718539ef65e384f1393cfd859cb81b8233
Author:     Stephan Bergmann <sberg...@redhat.com>
AuthorDate: Thu Mar 23 10:35:31 2023 +0100
Commit:     Stephan Bergmann <sberg...@redhat.com>
CommitDate: Thu Mar 23 10:51:14 2023 +0000

    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 <sberg...@redhat.com>

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")));

Reply via email to