compilerplugins/clang/unnecessarygetstr.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
New commits: commit 671d1c6cd14b28b5960ad56086299bd69533dfd8 Author: Stephan Bergmann <[email protected]> AuthorDate: Thu May 4 15:28:35 2023 +0200 Commit: Stephan Bergmann <[email protected]> CommitDate: Fri May 5 08:05:09 2023 +0200 Adapt loplugin:unnecessarygetstr to libc++ > [CPT] compilerplugins/clang/test/unnecessarygetstr.cxx > error: 'error' diagnostics expected but not seen: > File compilerplugins/clang/test/unnecessarygetstr.cxx Line 119 (directive at compilerplugins/clang/test/unnecessarygetstr.cxx:118): unnecessary call to 'getStr' when passing to string constructor [loplugin:unnecessarygetstr] because libcxx's <string> declares > template <__enable_if_t<__is_allocator<_Allocator>::value, int> = 0> > _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(const _CharT* __s) and > template <__enable_if_t<__is_allocator<_Allocator>::value, int> = 0> > _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(const _CharT* __s, const _Allocator& __a) instead of single > basic_string(const charT* s, const Allocator& a = Allocator()) Change-Id: I8d64b140618337adfba01c02d5d02fda093628f2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151392 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <[email protected]> diff --git a/compilerplugins/clang/unnecessarygetstr.cxx b/compilerplugins/clang/unnecessarygetstr.cxx index 7a9610f7618b..681070356108 100644 --- a/compilerplugins/clang/unnecessarygetstr.cxx +++ b/compilerplugins/clang/unnecessarygetstr.cxx @@ -61,7 +61,7 @@ public: auto tc = loplugin::TypeCheck(constructExpr->getType()); if (tc.ClassOrStruct("basic_string").StdNamespace()) { - if (constructExpr->getNumArgs() == 2) + if (constructExpr->getNumArgs() == 1 || constructExpr->getNumArgs() == 2) checkForGetStr(constructExpr->getArg(0), "string constructor"); } else if (tc.ClassOrStruct("basic_string_view").StdNamespace())
