compilerplugins/clang/stringviewparam.cxx | 2 +- compilerplugins/clang/test/stringviewparam.cxx | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-)
New commits: commit fdce0a04bd8b23200631e09979b3880adf754b2a Author: Stephan Bergmann <sberg...@redhat.com> AuthorDate: Thu Sep 23 10:16:21 2021 +0200 Commit: Stephan Bergmann <sberg...@redhat.com> CommitDate: Thu Sep 23 12:19:55 2021 +0200 Extend loplugin:stringviewparam to starts/endsWith Change-Id: I4b8fb5e963e582836440587dcaa2922cb5d05bc7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122512 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sberg...@redhat.com> diff --git a/compilerplugins/clang/stringviewparam.cxx b/compilerplugins/clang/stringviewparam.cxx index 862e9f331133..aa0899ca10a0 100644 --- a/compilerplugins/clang/stringviewparam.cxx +++ b/compilerplugins/clang/stringviewparam.cxx @@ -168,7 +168,7 @@ DeclRefExpr const* relevantCXXMemberCallExpr(CXXMemberCallExpr const* expr) else if (auto const i = d->getIdentifier()) { auto const n = i->getName(); - if (n == "isEmpty" || n == "subView") + if (n == "endsWith" || n == "isEmpty" || n == "startsWith" || n == "subView") { good = true; } diff --git a/compilerplugins/clang/test/stringviewparam.cxx b/compilerplugins/clang/test/stringviewparam.cxx index db57c8ac415f..f5f165804490 100644 --- a/compilerplugins/clang/test/stringviewparam.cxx +++ b/compilerplugins/clang/test/stringviewparam.cxx @@ -23,7 +23,8 @@ void f1a(std::string_view); char f1b(OString const& s) { f1a(s); - if (s.isEmpty()) + OString rest; + if (s.isEmpty() || s.startsWith("foo", &rest) || s.endsWith("foo")) { f1a(std::string_view(s)); } @@ -35,7 +36,8 @@ void f2a(std::u16string_view); sal_Unicode f2b(OUString const& s) { f2a(s); - if (s.isEmpty()) + OUString rest; + if (s.isEmpty() || s.startsWith("foo", &rest) || s.endsWith("foo")) { f2a(std::u16string_view(s)); }