diff options
-rw-r--r-- | compilerplugins/clang/staticconstfield.cxx | 11 | ||||
-rw-r--r-- | solenv/CompilerTest_compilerplugins_clang.mk | 1 |
2 files changed, 7 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; diff --git a/solenv/CompilerTest_compilerplugins_clang.mk b/solenv/CompilerTest_compilerplugins_clang.mk index 96f71a5beda2..5b07568c1f75 100644 --- a/solenv/CompilerTest_compilerplugins_clang.mk +++ b/solenv/CompilerTest_compilerplugins_clang.mk @@ -53,6 +53,7 @@ $(eval $(call gb_CompilerTest_add_exception_objects,compilerplugins_clang, \ compilerplugins/clang/test/simplifyconstruct \ compilerplugins/clang/test/simplifydynamiccast \ compilerplugins/clang/test/singlevalfields \ + compilerplugins/clang/test/staticconstfield \ compilerplugins/clang/test/staticvar \ compilerplugins/clang/test/stringbuffer \ compilerplugins/clang/test/stringconstant \ |