diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2023-04-17 09:09:14 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2023-04-17 10:48:52 +0200 |
commit | 856fc80439c23d4473930b92e201ebd33b20fc8b (patch) | |
tree | d2c9f36f787177dfb85d51a25ec40b4113e05038 /compilerplugins | |
parent | 5955a453165f6d8117b44e8ad37fb5ca0134add4 (diff) |
loplugin:stringadd: Adapt O[U]StringBuffer ctor detection for Windows
...where sal_Int32 is not int, so a literal argument like 16 actually calls the
O[U]StringBuffer(T length, std::enable_if_t<std::is_integral_v<T>, int> = 0)
overload
Change-Id: I1d151efbc723cbfa76690e02491b05a9a4147e91
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150473
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'compilerplugins')
-rw-r--r-- | compilerplugins/clang/stringadd.cxx | 14 | ||||
-rw-r--r-- | compilerplugins/clang/test/stringadd.cxx | 15 |
2 files changed, 25 insertions, 4 deletions
diff --git a/compilerplugins/clang/stringadd.cxx b/compilerplugins/clang/stringadd.cxx index bf00ef2dc1d9..022bffa804fc 100644 --- a/compilerplugins/clang/stringadd.cxx +++ b/compilerplugins/clang/stringadd.cxx @@ -160,10 +160,16 @@ StringAdd::VarDeclAndSummands StringAdd::findAssignOrAdd(Stmt const* stmt) // ignore the constructor that gives the buffer a default size if (auto cxxConstructor = dyn_cast<CXXConstructExpr>(varDeclLHS->getInit())) if (auto constructorDecl = cxxConstructor->getConstructor()) - if (constructorDecl->getNumParams() == 1 - && loplugin::TypeCheck(constructorDecl->getParamDecl(0)->getType()) - .Typedef("sal_Int32") - .GlobalNamespace()) + if ((constructorDecl->getNumParams() == 1 + && loplugin::TypeCheck(constructorDecl->getParamDecl(0)->getType()) + .Typedef("sal_Int32") + .GlobalNamespace()) + || (constructorDecl->getNumParams() == 2 + && constructorDecl->getParamDecl(0)->getType()->isIntegralType( + compiler.getASTContext()) + && constructorDecl->getParamDecl(1) + ->getType() + ->isSpecificBuiltinType(BuiltinType::Int))) return {}; } return { varDeclLHS, (isCompileTimeConstant(varDeclLHS->getInit()) diff --git a/compilerplugins/clang/test/stringadd.cxx b/compilerplugins/clang/test/stringadd.cxx index 3ac2bb60ebe8..7c1193643303 100644 --- a/compilerplugins/clang/test/stringadd.cxx +++ b/compilerplugins/clang/test/stringadd.cxx @@ -297,4 +297,19 @@ void f1() } } +namespace test14 +{ +void f1() +{ + OUStringBuffer b(16); + b.append("..."); +} + +void f2(long long n) +{ + OUStringBuffer b(n); + b.append("..."); +} +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ |