summaryrefslogtreecommitdiff
path: root/compilerplugins
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2020-08-28 16:05:56 +0200
committerStephan Bergmann <sbergman@redhat.com>2020-08-29 08:12:33 +0200
commita1570b6052ae9c9349282027c9007b071589bce6 (patch)
treea9dac1f01e6dd7e23772d020294efaab33eb762d /compilerplugins
parent927fad8d2407e6ffd34b843549271140c3abd1b2 (diff)
Make the OUString ConstCharArrayDetector::TypeUtf16 overloads are actually used
0c8fa58a2d73702770687ed15b98822d09f96ac3 "Support ConstCharArrayDetector also for UTF-16 arrays" had introduced those LIBO_INTERNAL_ONLY ctor and operator == overloads, but they never got called because the existing 'sal_Unicode const *' overloads always won. (The other function overloads introduced with 0c8fa58a2d73702770687ed15b98822d09f96ac3 should be unproblematic, as they do not have any 'sal_Unicode const *' overload counterparts.) Also fix the resulting loplugin:elidestringvar and loplugin:stringconstant fallout. For one, those plugins look at the actual ctor overloads being used, so had missed those cases that accidentally had used an unexpected overload. And for another, the heuristic the plugins used to detect the ConstCharArrayDetector overloads turned out to be too simplistic now and would have started to cause false positives. Change-Id: I4426890979fb832d53f391c7e1b62bc1ad501a65 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101582 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'compilerplugins')
-rw-r--r--compilerplugins/clang/elidestringvar.cxx5
-rw-r--r--compilerplugins/clang/stringconstant.cxx4
2 files changed, 9 insertions, 0 deletions
diff --git a/compilerplugins/clang/elidestringvar.cxx b/compilerplugins/clang/elidestringvar.cxx
index d091f8175783..561e14c17a40 100644
--- a/compilerplugins/clang/elidestringvar.cxx
+++ b/compilerplugins/clang/elidestringvar.cxx
@@ -139,6 +139,11 @@ public:
}
case 2:
{
+ auto const t = e1->getArg(0)->getType();
+ if (!(t.isConstQualified() && t->isConstantArrayType()))
+ {
+ return true;
+ }
auto const e2 = e1->getArg(1);
if (!(isa<CXXDefaultArgExpr>(e2)
&& loplugin::TypeCheck(e2->getType())
diff --git a/compilerplugins/clang/stringconstant.cxx b/compilerplugins/clang/stringconstant.cxx
index cafcd0763a14..372dbceb92ba 100644
--- a/compilerplugins/clang/stringconstant.cxx
+++ b/compilerplugins/clang/stringconstant.cxx
@@ -1297,6 +1297,10 @@ bool StringConstant::VisitReturnStmt(ReturnStmt const * stmt) {
if (e4->getNumArgs() != 2) {
return true;
}
+ auto const t = e4->getArg(0)->getType();
+ if (!(t.isConstQualified() && t->isConstantArrayType())) {
+ return true;
+ }
auto const e5 = e4->getArg(1);
if (!(isa<CXXDefaultArgExpr>(e5)
&& (loplugin::TypeCheck(e5->getType()).Struct("Dummy").Namespace("libreoffice_internal")