summaryrefslogtreecommitdiff
path: root/compilerplugins/clang
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2019-10-24 15:43:06 +0200
committerStephan Bergmann <sbergman@redhat.com>2019-10-24 17:17:46 +0200
commit6d6fad522a2cd6a2959ea774969a86288f5a3cb7 (patch)
tree392503346dc17a8573f4a33c51155ffdb6f95cfa /compilerplugins/clang
parentaaff73401318a7fd1b3e936555f933538b2407bc (diff)
Introduce OStringChar
...similar to OUStringChar, to be used in string concatenation expressions. And enable the corresponding loplugin:stringadd check, and fix its findings. Change-Id: I35ebb2253ba82bda6c98ae6ebd2ad4f27cf9abf9 Reviewed-on: https://gerrit.libreoffice.org/81456 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'compilerplugins/clang')
-rw-r--r--compilerplugins/clang/stringadd.cxx9
-rw-r--r--compilerplugins/clang/test/stringadd.cxx2
2 files changed, 1 insertions, 10 deletions
diff --git a/compilerplugins/clang/stringadd.cxx b/compilerplugins/clang/stringadd.cxx
index 67d3adc6c131..399af5138fd9 100644
--- a/compilerplugins/clang/stringadd.cxx
+++ b/compilerplugins/clang/stringadd.cxx
@@ -202,15 +202,6 @@ bool StringAdd::VisitCXXOperatorCallExpr(CXXOperatorCallExpr const* operatorCall
if (!tc3.Class("OUString").Namespace("rtl").GlobalNamespace()
&& !tc3.Class("OString").Namespace("rtl").GlobalNamespace())
return;
- // we don't have OStringLiteral1, so char needs to generate a temporary
- if (tc.Class("OString").Namespace("rtl").GlobalNamespace()
- || tc.Struct("OStringConcat").Namespace("rtl").GlobalNamespace())
- if (auto bindTemp = dyn_cast<CXXBindTemporaryExpr>(e->getSubExpr()))
- if (auto cxxConstruct = dyn_cast<CXXConstructExpr>(bindTemp->getSubExpr()))
- if (loplugin::TypeCheck(
- cxxConstruct->getConstructor()->getParamDecl(0)->getType())
- .Char())
- return;
report(DiagnosticsEngine::Warning,
("avoid constructing %0 from %1 on %select{L|R}2HS of + (where %select{R|L}2HS is of"
" type %3)"),
diff --git a/compilerplugins/clang/test/stringadd.cxx b/compilerplugins/clang/test/stringadd.cxx
index 27cc57f1395e..a8469026e509 100644
--- a/compilerplugins/clang/test/stringadd.cxx
+++ b/compilerplugins/clang/test/stringadd.cxx
@@ -191,7 +191,7 @@ void f2(char ch)
OString s;
// expected-error@+1 {{avoid constructing 'rtl::OString' from 'const char [4]' on RHS of + (where LHS is of type 'rtl::OString') [loplugin:stringadd]}}
s = s + OString("xxx");
- // no warning expected, no OStringLiteral1
+ // expected-error@+1 {{avoid constructing 'rtl::OString' from 'char' on RHS of + (where LHS is of type 'rtl::OString') [loplugin:stringadd]}}
s = s + OString(ch);
}
}