diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2019-11-25 13:04:02 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2019-11-26 07:12:38 +0100 |
commit | 95d8b368d11eeccc276c0c6ac225144566a1206d (patch) | |
tree | 4d287bb64dbc21a09803594e9f0a103658b6f255 /compilerplugins | |
parent | 28f8a26fa12c2f78696864189356db46c1cae30c (diff) |
Adapt to clang::MaterializeTemporaryExpr::GetTemparyExpr rename
...in <https://github.com/llvm/llvm-project/commit/
b0561b3346e7bf0ae974995ca95b917eebde18e1> "[NFC] Refactor representation of
materialized temporaries"
Change-Id: I02fbf6765f9713e4d457f07521129cc9d8db5751
Reviewed-on: https://gerrit.libreoffice.org/83669
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'compilerplugins')
-rw-r--r-- | compilerplugins/clang/compat.hxx | 10 | ||||
-rw-r--r-- | compilerplugins/clang/conditionalstring.cxx | 2 | ||||
-rw-r--r-- | compilerplugins/clang/doubleconvert.cxx | 2 | ||||
-rw-r--r-- | compilerplugins/clang/implicitboolconversion.cxx | 4 | ||||
-rw-r--r-- | compilerplugins/clang/plugin.cxx | 3 | ||||
-rw-r--r-- | compilerplugins/clang/redundantfcast.cxx | 4 | ||||
-rw-r--r-- | compilerplugins/clang/referencecasting.cxx | 5 | ||||
-rw-r--r-- | compilerplugins/clang/simplifybool.cxx | 3 | ||||
-rw-r--r-- | compilerplugins/clang/stringbuffer.cxx | 3 | ||||
-rw-r--r-- | compilerplugins/clang/stringconstant.cxx | 4 | ||||
-rw-r--r-- | compilerplugins/clang/stringstatic.cxx | 3 | ||||
-rw-r--r-- | compilerplugins/clang/unnecessaryparen.cxx | 2 | ||||
-rw-r--r-- | compilerplugins/clang/unoany.cxx | 5 | ||||
-rw-r--r-- | compilerplugins/clang/unoquery.cxx | 3 |
14 files changed, 34 insertions, 19 deletions
diff --git a/compilerplugins/clang/compat.hxx b/compilerplugins/clang/compat.hxx index c091c51601f7..ca752552f677 100644 --- a/compilerplugins/clang/compat.hxx +++ b/compilerplugins/clang/compat.hxx @@ -168,6 +168,14 @@ inline bool EvaluateAsInt(clang::Expr const * expr, llvm::APSInt& intRes, const #endif } +inline clang::Expr * getSubExpr(clang::MaterializeTemporaryExpr const * expr) { +#if CLANG_VERSION >= 100000 + return expr->getSubExpr(); +#else + return expr->GetTemporaryExpr(); +#endif +} + // Work around <http://reviews.llvm.org/D22128>: // // SfxErrorHandler::GetClassString (svtools/source/misc/ehdl.cxx): @@ -202,7 +210,7 @@ namespace detail { // Skip through reference binding to temporary. if (clang::MaterializeTemporaryExpr *Materialize = clang::dyn_cast<clang::MaterializeTemporaryExpr>(expr)) - expr = Materialize->GetTemporaryExpr(); + expr = compat::getSubExpr(Materialize); // Skip any temporary bindings; they're implicit. if (clang::CXXBindTemporaryExpr *Binder = clang::dyn_cast<clang::CXXBindTemporaryExpr>(expr)) diff --git a/compilerplugins/clang/conditionalstring.cxx b/compilerplugins/clang/conditionalstring.cxx index d09472c25446..2d40c1b3aebf 100644 --- a/compilerplugins/clang/conditionalstring.cxx +++ b/compilerplugins/clang/conditionalstring.cxx @@ -40,7 +40,7 @@ Expr const* ignoreImplicit(Expr const* expr) #endif else if (auto const e3 = dyn_cast<MaterializeTemporaryExpr>(e)) { - e = e3->GetTemporaryExpr(); + e = compat::getSubExpr(e3); } else if (auto const e4 = dyn_cast<CXXBindTemporaryExpr>(e)) { diff --git a/compilerplugins/clang/doubleconvert.cxx b/compilerplugins/clang/doubleconvert.cxx index 95565301b751..2dbff56ca30b 100644 --- a/compilerplugins/clang/doubleconvert.cxx +++ b/compilerplugins/clang/doubleconvert.cxx @@ -53,7 +53,7 @@ bool DoubleConvert::VisitMaterializeTemporaryExpr(MaterializeTemporaryExpr const if (ignoreLocation(materializetemp)) return true; auto cxxConstruct - = dyn_cast<CXXConstructExpr>(materializetemp->GetTemporaryExpr()->IgnoreParenCasts()); + = dyn_cast<CXXConstructExpr>(compat::getSubExpr(materializetemp)->IgnoreParenCasts()); if (!cxxConstruct) return true; if (cxxConstruct->getNumArgs() == 0) diff --git a/compilerplugins/clang/implicitboolconversion.cxx b/compilerplugins/clang/implicitboolconversion.cxx index 3adbf7197f47..5b713ce77ecb 100644 --- a/compilerplugins/clang/implicitboolconversion.cxx +++ b/compilerplugins/clang/implicitboolconversion.cxx @@ -30,7 +30,7 @@ Expr const * ignoreParenAndTemporaryMaterialization(Expr const * expr) { if (e == nullptr) { return expr; } - expr = e->GetTemporaryExpr(); + expr = compat::getSubExpr(e); } } @@ -908,7 +908,7 @@ bool ImplicitBoolConversion::VisitMaterializeTemporaryExpr( if (ignoreLocation(expr)) { return true; } - if (auto const sub = dyn_cast<ExplicitCastExpr>(expr->GetTemporaryExpr())) { + if (auto const sub = dyn_cast<ExplicitCastExpr>(compat::getSubExpr(expr))) { auto const subsub = compat::getSubExprAsWritten(sub); if (subsub->getType().IgnoreParens() == expr->getType().IgnoreParens() && isBool(subsub)) diff --git a/compilerplugins/clang/plugin.cxx b/compilerplugins/clang/plugin.cxx index 01484bddc432..eb4ac24c9743 100644 --- a/compilerplugins/clang/plugin.cxx +++ b/compilerplugins/clang/plugin.cxx @@ -18,6 +18,7 @@ #include <clang/Basic/FileManager.h> #include <clang/Lex/Lexer.h> +#include "compat.hxx" #include "pluginhandler.hxx" /* @@ -30,7 +31,7 @@ namespace { Expr const * skipImplicit(Expr const * expr) { if (auto const e = dyn_cast<MaterializeTemporaryExpr>(expr)) { - expr = e->GetTemporaryExpr()->IgnoreImpCasts(); + expr = compat::getSubExpr(e)->IgnoreImpCasts(); } if (auto const e = dyn_cast<CXXBindTemporaryExpr>(expr)) { expr = e->getSubExpr(); diff --git a/compilerplugins/clang/redundantfcast.cxx b/compilerplugins/clang/redundantfcast.cxx index 5084d5a29ab3..0dca2a1c60cb 100644 --- a/compilerplugins/clang/redundantfcast.cxx +++ b/compilerplugins/clang/redundantfcast.cxx @@ -42,7 +42,7 @@ public: expr = cxxConstructExpr->getArg(0); } if (auto materializeTemporaryExpr = dyn_cast<MaterializeTemporaryExpr>(expr)) - expr = materializeTemporaryExpr->GetTemporaryExpr(); + expr = compat::getSubExpr(materializeTemporaryExpr); auto cxxFunctionalCastExpr = dyn_cast<CXXFunctionalCastExpr>(expr); if (!cxxFunctionalCastExpr) return true; @@ -94,7 +94,7 @@ public: if (!materializeTemporaryExpr) continue; auto functionalCast = dyn_cast<CXXFunctionalCastExpr>( - materializeTemporaryExpr->GetTemporaryExpr()->IgnoreImpCasts()); + compat::getSubExpr(materializeTemporaryExpr)->IgnoreImpCasts()); if (!functionalCast) continue; auto const t1 = functionalCast->getTypeAsWritten(); diff --git a/compilerplugins/clang/referencecasting.cxx b/compilerplugins/clang/referencecasting.cxx index 45b65d3e7f26..1f8e13173811 100644 --- a/compilerplugins/clang/referencecasting.cxx +++ b/compilerplugins/clang/referencecasting.cxx @@ -10,6 +10,7 @@ */ #ifndef LO_CLANG_SHARED_PLUGINS +#include "compat.hxx" #include "plugin.hxx" #include "check.hxx" #include <iostream> @@ -111,7 +112,7 @@ bool ReferenceCasting::VisitCXXConstructExpr(const CXXConstructExpr* cce) } if (auto matTempExpr = dyn_cast<MaterializeTemporaryExpr>(constructorArg0)) { - constructorArg0 = matTempExpr->GetTemporaryExpr(); + constructorArg0 = compat::getSubExpr(matTempExpr); continue; } if (auto bindTempExpr = dyn_cast<CXXBindTemporaryExpr>(constructorArg0)) @@ -223,7 +224,7 @@ bool ReferenceCasting::VisitCXXMemberCallExpr(const CXXMemberCallExpr* mce) } if (auto matTempExpr = dyn_cast<MaterializeTemporaryExpr>(arg0)) { - arg0 = matTempExpr->GetTemporaryExpr(); + arg0 = compat::getSubExpr(matTempExpr); continue; } if (auto bindTempExpr = dyn_cast<CXXBindTemporaryExpr>(arg0)) diff --git a/compilerplugins/clang/simplifybool.cxx b/compilerplugins/clang/simplifybool.cxx index 83cbf2dc56f6..b1cd6b8c2abd 100644 --- a/compilerplugins/clang/simplifybool.cxx +++ b/compilerplugins/clang/simplifybool.cxx @@ -9,6 +9,7 @@ #include <cassert> +#include "compat.hxx" #include "plugin.hxx" #include "clang/AST/CXXInheritance.h" @@ -21,7 +22,7 @@ Expr const * ignoreAllImplicit(Expr const * expr) { expr = e->getSubExpr(); } if (auto const e = dyn_cast<MaterializeTemporaryExpr>(expr)) { - expr = e->GetTemporaryExpr(); + expr = compat::getSubExpr(e); } if (auto const e = dyn_cast<CXXBindTemporaryExpr>(expr)) { expr = e->getSubExpr(); diff --git a/compilerplugins/clang/stringbuffer.cxx b/compilerplugins/clang/stringbuffer.cxx index b68a8ba32700..61df3069a51c 100644 --- a/compilerplugins/clang/stringbuffer.cxx +++ b/compilerplugins/clang/stringbuffer.cxx @@ -9,6 +9,7 @@ #ifndef LO_CLANG_SHARED_PLUGINS #include "check.hxx" +#include "compat.hxx" #include "plugin.hxx" #include <vector> @@ -57,7 +58,7 @@ bool StringBuffer::VisitCXXMemberCallExpr(CXXMemberCallExpr const* memberCallExp auto matTemp = dyn_cast<MaterializeTemporaryExpr>(memberCallExpr->getArg(0)); if (!matTemp) return true; - if (!isa<CXXOperatorCallExpr>(matTemp->GetTemporaryExpr())) + if (!isa<CXXOperatorCallExpr>(compat::getSubExpr(matTemp))) return true; report(DiagnosticsEngine::Warning, "appending added result of OUString to OUStringBuffer, rather do .append(x).append(y)", diff --git a/compilerplugins/clang/stringconstant.cxx b/compilerplugins/clang/stringconstant.cxx index 2360ef2e3620..389691796dd7 100644 --- a/compilerplugins/clang/stringconstant.cxx +++ b/compilerplugins/clang/stringconstant.cxx @@ -86,7 +86,7 @@ bool hasOverloads(FunctionDecl const * decl, unsigned arguments) { CXXConstructExpr const * lookForCXXConstructExpr(Expr const * expr) { if (auto e = dyn_cast<MaterializeTemporaryExpr>(expr)) { - expr = e->GetTemporaryExpr(); + expr = compat::getSubExpr(e); } if (auto e = dyn_cast<CXXFunctionalCastExpr>(expr)) { expr = e->getSubExpr(); @@ -1072,7 +1072,7 @@ bool StringConstant::VisitCXXConstructExpr(CXXConstructExpr const * expr) { for (auto i(argsBeg); i != argsEnd; ++i) { Expr const * e = (*i)->IgnoreParenImpCasts(); if (isa<MaterializeTemporaryExpr>(e)) { - e = cast<MaterializeTemporaryExpr>(e)->GetTemporaryExpr() + e = compat::getSubExpr(cast<MaterializeTemporaryExpr>(e)) ->IgnoreParenImpCasts(); } if (isa<CXXFunctionalCastExpr>(e)) { diff --git a/compilerplugins/clang/stringstatic.cxx b/compilerplugins/clang/stringstatic.cxx index a923da405f25..69e6c427f90e 100644 --- a/compilerplugins/clang/stringstatic.cxx +++ b/compilerplugins/clang/stringstatic.cxx @@ -12,6 +12,7 @@ #include <set> #include "check.hxx" +#include "compat.hxx" #include "plugin.hxx" /** Look for static OUString and OUString[], they can be more efficiently declared as: @@ -100,7 +101,7 @@ bool StringStatic::VisitVarDecl(VarDecl const* varDecl) expr = castExpr->getSubExpr(); } else if (MaterializeTemporaryExpr const * materializeExpr = dyn_cast<MaterializeTemporaryExpr>(expr)) { - expr = materializeExpr->GetTemporaryExpr(); + expr = compat::getSubExpr(materializeExpr); } else if (CXXBindTemporaryExpr const * bindExpr = dyn_cast<CXXBindTemporaryExpr>(expr)) { expr = bindExpr->getSubExpr(); diff --git a/compilerplugins/clang/unnecessaryparen.cxx b/compilerplugins/clang/unnecessaryparen.cxx index 9fb8fb85aa82..f1c17c830207 100644 --- a/compilerplugins/clang/unnecessaryparen.cxx +++ b/compilerplugins/clang/unnecessaryparen.cxx @@ -44,7 +44,7 @@ Expr const * ignoreAllImplicit(Expr const * expr) { } } else if (auto const e = dyn_cast<MaterializeTemporaryExpr>(expr)) { - expr = e->GetTemporaryExpr(); + expr = compat::getSubExpr(e); } else if (auto const e = dyn_cast<CXXBindTemporaryExpr>(expr)) { expr = e->getSubExpr(); diff --git a/compilerplugins/clang/unoany.cxx b/compilerplugins/clang/unoany.cxx index e0360c6cd2de..d44fce1d434c 100644 --- a/compilerplugins/clang/unoany.cxx +++ b/compilerplugins/clang/unoany.cxx @@ -10,6 +10,7 @@ #ifndef LO_CLANG_SHARED_PLUGINS #include "check.hxx" +#include "compat.hxx" #include "plugin.hxx" namespace { @@ -52,7 +53,7 @@ bool UnoAny::VisitCXXOperatorCallExpr(CXXOperatorCallExpr const * expr) return true; } if (auto expr2 = dyn_cast<MaterializeTemporaryExpr>(expr->getArg(1))) { - if (auto expr3 = dyn_cast<CXXBindTemporaryExpr>(expr2->GetTemporaryExpr())) { + if (auto expr3 = dyn_cast<CXXBindTemporaryExpr>(compat::getSubExpr(expr2))) { if (auto expr4 = dyn_cast<CallExpr>(expr3->getSubExpr())) { if (loplugin::DeclCheck(expr4->getDirectCallee()).Function("makeAny"). Namespace("uno").Namespace("star").Namespace("sun").Namespace("com").GlobalNamespace()) { @@ -66,7 +67,7 @@ bool UnoAny::VisitCXXOperatorCallExpr(CXXOperatorCallExpr const * expr) } } } - if (isa<CXXFunctionalCastExpr>(expr2->GetTemporaryExpr())) { + if (isa<CXXFunctionalCastExpr>(compat::getSubExpr(expr2))) { //expr->getArg(1)->dump(); report( DiagnosticsEngine::Warning, diff --git a/compilerplugins/clang/unoquery.cxx b/compilerplugins/clang/unoquery.cxx index 82427555fef9..fd7715fe1df3 100644 --- a/compilerplugins/clang/unoquery.cxx +++ b/compilerplugins/clang/unoquery.cxx @@ -10,6 +10,7 @@ #ifndef LO_CLANG_SHARED_PLUGINS #include "check.hxx" +#include "compat.hxx" #include "plugin.hxx" // TODO it would be better if we were running some kind of nullability analysis here, where we marked @@ -63,7 +64,7 @@ bool UnoQuery::VisitCXXMemberCallExpr(CXXMemberCallExpr const* memberCallExpr) Expr const* expr = operatorCallExpr->getArg(0)->IgnoreImplicit(); // depending on the version of clang, the IgnoreImplicit may or may not look through these nodes if (auto matTemp = dyn_cast<MaterializeTemporaryExpr>(expr)) - expr = matTemp->GetTemporaryExpr(); + expr = compat::getSubExpr(matTemp); if (auto bindTemp = dyn_cast<CXXBindTemporaryExpr>(expr)) expr = bindTemp->getSubExpr(); |