summaryrefslogtreecommitdiff
path: root/compilerplugins
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2018-11-20 08:58:39 +0100
committerStephan Bergmann <sbergman@redhat.com>2018-11-20 13:46:51 +0100
commit8bd306d6f76e6787a71e7e1d99b0bcae48986de3 (patch)
tree06aa2c84548fb1446a2ae3258f1ff90ac1b4b8bd /compilerplugins
parent9ed0d9bac931e24461cbc1459286910520e44a33 (diff)
Fix loplugin:staticconstfield
...(ExprWithCleanups around the CXXConstructExpr in initializers for members of O[U]String type, with older Clang, as used in compilerplugins/clang/test/staticconstfield.cxx), and thus revert e3e8d52625c2dc7a277a955d4ae2ad10c60c5f1b "Temporarily disable compilerplugins/clang/test/staticconstfield" again. Change-Id: Ic5fcdd1a26e4a6810369e4f9d909200d25feb12e Reviewed-on: https://gerrit.libreoffice.org/63628 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com> (cherry picked from commit b0e819bbc0b3ff20de04f31b593f7d5213659045) Reviewed-on: https://gerrit.libreoffice.org/63657 Tested-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'compilerplugins')
-rw-r--r--compilerplugins/clang/staticconstfield.cxx11
1 files changed, 6 insertions, 5 deletions
diff --git a/compilerplugins/clang/staticconstfield.cxx b/compilerplugins/clang/staticconstfield.cxx
index b10953a75617..eadbd26bef78 100644
--- a/compilerplugins/clang/staticconstfield.cxx
+++ b/compilerplugins/clang/staticconstfield.cxx
@@ -95,10 +95,11 @@ bool StaticConstField::TraverseConstructorInitializer(CXXCtorInitializer* init)
bool found = false;
std::string value;
+ auto const initexpr = compat::IgnoreImplicit(init->getInit());
if (tc.Const().Class("OUString").Namespace("rtl").GlobalNamespace()
|| tc.Const().Class("OString").Namespace("rtl").GlobalNamespace())
{
- if (auto constructExpr = dyn_cast<CXXConstructExpr>(init->getInit()))
+ if (auto constructExpr = dyn_cast<CXXConstructExpr>(initexpr))
{
if (constructExpr->getNumArgs() >= 1
&& isa<clang::StringLiteral>(constructExpr->getArg(0)))
@@ -112,7 +113,7 @@ bool StaticConstField::TraverseConstructorInitializer(CXXCtorInitializer* init)
else if (type->isFloatingType())
{
APFloat x1(0.0f);
- if (init->getInit()->EvaluateAsFloat(x1, compiler.getASTContext()))
+ if (initexpr->EvaluateAsFloat(x1, compiler.getASTContext()))
{
std::string s;
llvm::raw_string_ostream os(s);
@@ -123,15 +124,15 @@ bool StaticConstField::TraverseConstructorInitializer(CXXCtorInitializer* init)
}
#endif
// ignore this, it seems to trigger an infinite recursion
- else if (isa<UnaryExprOrTypeTraitExpr>(init->getInit()))
+ else if (isa<UnaryExprOrTypeTraitExpr>(initexpr))
;
// ignore this, calling EvaluateAsInt on it will crash clang
- else if (init->getInit()->isValueDependent())
+ else if (initexpr->isValueDependent())
;
else
{
APSInt x1;
- if (init->getInit()->EvaluateAsInt(x1, compiler.getASTContext()))
+ if (initexpr->EvaluateAsInt(x1, compiler.getASTContext()))
{
value = x1.toString(10);
found = true;