diff options
Diffstat (limited to 'compilerplugins/clang')
-rw-r--r-- | compilerplugins/clang/compat.hxx | 11 | ||||
-rw-r--r-- | compilerplugins/clang/redundantcast.cxx | 24 |
2 files changed, 23 insertions, 12 deletions
diff --git a/compilerplugins/clang/compat.hxx b/compilerplugins/clang/compat.hxx index ac2a282c4fd8..829eb083a8e0 100644 --- a/compilerplugins/clang/compat.hxx +++ b/compilerplugins/clang/compat.hxx @@ -89,6 +89,17 @@ inline std::pair<clang::SourceLocation, clang::SourceLocation> getImmediateExpan return {csr.getBegin(), csr.getEnd()}; } +inline bool isAtLeastAsQualifiedAs( + clang::QualType type1, clang::QualType type2, clang::ASTContext const & context) +{ +#if CLANG_VERSION >= 200000 + return type1.isAtLeastAsQualifiedAs(type2, context); +#else + (void) context; + return type1.isAtLeastAsQualifiedAs(type2); +#endif +} + /// Utility method inline clang::Expr const * IgnoreParenImplicit(clang::Expr const * expr) { return expr->IgnoreImplicit()->IgnoreParens()->IgnoreImplicit(); diff --git a/compilerplugins/clang/redundantcast.cxx b/compilerplugins/clang/redundantcast.cxx index 5d34d6b02936..07efeb568606 100644 --- a/compilerplugins/clang/redundantcast.cxx +++ b/compilerplugins/clang/redundantcast.cxx @@ -212,10 +212,10 @@ bool RedundantCast::VisitImplicitCastExpr(const ImplicitCastExpr * expr) { Expr const * e = expr->getSubExpr()->IgnoreParenImpCasts(); while (isa<CXXConstCastExpr>(e)) { auto cc = dyn_cast<CXXConstCastExpr>(e); - if (expr->getType()->getAs<clang::PointerType>() - ->getPointeeType().isAtLeastAsQualifiedAs( - cc->getSubExpr()->getType() - ->getAs<clang::PointerType>()->getPointeeType())) + if (compat::isAtLeastAsQualifiedAs( + expr->getType()->getAs<clang::PointerType>()->getPointeeType(), + cc->getSubExpr()->getType()->getAs<clang::PointerType>()->getPointeeType(), + compiler.getASTContext())) { report( DiagnosticsEngine::Warning, @@ -256,10 +256,10 @@ bool RedundantCast::VisitImplicitCastExpr(const ImplicitCastExpr * expr) { Expr const * e = expr->getSubExpr()->IgnoreParenImpCasts(); while (isa<CXXConstCastExpr>(e)) { auto cc = dyn_cast<CXXConstCastExpr>(e); - if (expr->getType()->getAs<clang::PointerType>() - ->getPointeeType().isAtLeastAsQualifiedAs( - cc->getSubExpr()->getType() - ->getAs<clang::PointerType>()->getPointeeType())) + if (compat::isAtLeastAsQualifiedAs( + expr->getType()->getAs<clang::PointerType>()->getPointeeType(), + cc->getSubExpr()->getType()->getAs<clang::PointerType>()->getPointeeType(), + compiler.getASTContext())) { report( DiagnosticsEngine::Warning, @@ -275,10 +275,10 @@ bool RedundantCast::VisitImplicitCastExpr(const ImplicitCastExpr * expr) { Expr const * e = expr->getSubExpr()->IgnoreParenImpCasts(); while (isa<CXXConstCastExpr>(e)) { auto cc = dyn_cast<CXXConstCastExpr>(e); - if (expr->getType()->getAs<ReferenceType>()->getPointeeType() - .isAtLeastAsQualifiedAs( - cc->getSubExpr()->getType() - ->getAs<ReferenceType>()->getPointeeType())) + if (compat::isAtLeastAsQualifiedAs( + expr->getType()->getAs<ReferenceType>()->getPointeeType(), + cc->getSubExpr()->getType()->getAs<ReferenceType>()->getPointeeType(), + compiler.getASTContext())) { report( DiagnosticsEngine::Warning, |