compilerplugins/clang/compat.hxx | 11 +++++++++++ compilerplugins/clang/redundantcast.cxx | 24 ++++++++++++------------ 2 files changed, 23 insertions(+), 12 deletions(-)
New commits: commit d44621c7a7eb8fd0bd571d19ab6540f6022502b2 Author: Stephan Bergmann <stephan.bergm...@allotropia.de> AuthorDate: Tue Nov 19 10:14:24 2024 +0100 Commit: Stephan Bergmann <stephan.bergm...@allotropia.de> CommitDate: Tue Nov 19 12:22:57 2024 +0100 Adapt to LLVM 20 trunk QualType::isAtLeastAsQualifiedAs change ...in <https://github.com/llvm/llvm-project/commit/b9d678d22f74ebd6e34f0a3501fb01d3d80984e7> "[Clang] Use TargetInfo when deciding if an address space is compatible (#115777)" Change-Id: Ibe9e4882057edbdcdbd286416c3d317c292b2298 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/176760 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <stephan.bergm...@allotropia.de> 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,