summaryrefslogtreecommitdiff
path: root/compilerplugins/clang
diff options
context:
space:
mode:
authorStephan Bergmann <stephan.bergmann@allotropia.de>2024-11-19 10:14:24 +0100
committerStephan Bergmann <stephan.bergmann@allotropia.de>2024-11-19 12:22:57 +0100
commitd44621c7a7eb8fd0bd571d19ab6540f6022502b2 (patch)
tree1598f4cacc16d64d381f5a3174a5df0489390669 /compilerplugins/clang
parent69817b8a8c088e840c958ad1c0b6fdde6e155698 (diff)
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.bergmann@allotropia.de>
Diffstat (limited to 'compilerplugins/clang')
-rw-r--r--compilerplugins/clang/compat.hxx11
-rw-r--r--compilerplugins/clang/redundantcast.cxx24
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,