compilerplugins/clang/check.cxx        |    3 ++-
 compilerplugins/clang/compat.hxx       |    8 ++++++++
 compilerplugins/clang/cstylecast.cxx   |    4 ++--
 compilerplugins/clang/external.cxx     |    2 +-
 compilerplugins/clang/typedefparam.cxx |    3 ++-
 5 files changed, 15 insertions(+), 5 deletions(-)

New commits:
commit b936f80d96b9a1f4646e0ba5371b67eccf302527
Author:     Stephan Bergmann <stephan.bergm...@allotropia.de>
AuthorDate: Sun Mar 23 22:06:42 2025 +0100
Commit:     Stephan Bergmann <stephan.bergm...@allotropia.de>
CommitDate: Mon Mar 24 07:29:56 2025 +0100

    Adapt to LLVM 21 trunk MemberPointerType change
    
    
<github.com/llvm/llvm-project/commit/14f7bd63b95d0f61a6f47119ac66398ca230559a>
    "Reland: [clang] preserve class type sugar when taking pointer to member
    (#132401)"
    
    Change-Id: Ie409324fcf3b98cd733cc46e06ee9e99dc140968
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/183250
    Tested-by: Jenkins
    Reviewed-by: Stephan Bergmann <stephan.bergm...@allotropia.de>

diff --git a/compilerplugins/clang/check.cxx b/compilerplugins/clang/check.cxx
index 9fe576db612f..524885ce16e4 100644
--- a/compilerplugins/clang/check.cxx
+++ b/compilerplugins/clang/check.cxx
@@ -13,6 +13,7 @@
 #include <clang/AST/DeclTemplate.h>
 
 #include "check.hxx"
+#include "compat.hxx"
 
 namespace loplugin {
 
@@ -137,7 +138,7 @@ TypeCheck TypeCheck::MemberPointerOf() const {
     if (!type_.isNull()) {
         auto const t = type_->getAs<clang::MemberPointerType>();
         if (t != nullptr) {
-            return TypeCheck(t->getClass());
+            return TypeCheck(compat::getClass(t));
         }
     }
     return TypeCheck();
diff --git a/compilerplugins/clang/compat.hxx b/compilerplugins/clang/compat.hxx
index 6ce5dccfe309..d0965f26902e 100644
--- a/compilerplugins/clang/compat.hxx
+++ b/compilerplugins/clang/compat.hxx
@@ -278,6 +278,14 @@ inline unsigned getBitWidthValue(clang::FieldDecl const * 
decl, clang::ASTContex
 #endif
 }
 
+inline clang::Type const * getClass(clang::MemberPointerType const * type) {
+#if CLANG_VERSION >= 210000
+    return type->getQualifier()->getAsType();
+#else
+    return type->getClass();
+#endif
+}
+
 inline clang::TemplateTypeParmDecl const * getReplacedParameter(
     clang::SubstTemplateTypeParmType const * type)
 {
diff --git a/compilerplugins/clang/cstylecast.cxx 
b/compilerplugins/clang/cstylecast.cxx
index f548b1fd8123..ff63ec0e8f97 100644
--- a/compilerplugins/clang/cstylecast.cxx
+++ b/compilerplugins/clang/cstylecast.cxx
@@ -42,8 +42,8 @@ bool areSimilar(QualType type1, QualType type2) {
             }
             auto t1a = t1->getAs<MemberPointerType>();
             auto t2a = t2->getAs<MemberPointerType>();
-            if (t1a->getClass()->getCanonicalTypeInternal()
-                != t2a->getClass()->getCanonicalTypeInternal())
+            if (compat::getClass(t1a)->getCanonicalTypeInternal()
+                != compat::getClass(t2a)->getCanonicalTypeInternal())
             {
                 return false;
             }
diff --git a/compilerplugins/clang/external.cxx 
b/compilerplugins/clang/external.cxx
index 8c8733553907..f71c5947a3ed 100644
--- a/compilerplugins/clang/external.cxx
+++ b/compilerplugins/clang/external.cxx
@@ -114,7 +114,7 @@ bool mentions(QualType type1, QualType type2)
     }
     if (auto const t2 = t1->getAs<MemberPointerType>())
     {
-        if (t2->getClass()->getUnqualifiedDesugaredType() == 
type2.getTypePtr())
+        if (compat::getClass(t2)->getUnqualifiedDesugaredType() == 
type2.getTypePtr())
         {
             return true;
         }
diff --git a/compilerplugins/clang/typedefparam.cxx 
b/compilerplugins/clang/typedefparam.cxx
index 6fffe66c8483..aa132eb1547b 100644
--- a/compilerplugins/clang/typedefparam.cxx
+++ b/compilerplugins/clang/typedefparam.cxx
@@ -18,6 +18,7 @@
 #include "config_clang.h"
 
 #include "check.hxx"
+#include "compat.hxx"
 #include "plugin.hxx"
 
 /**
@@ -290,7 +291,7 @@ static bool areTypesEqual(QualType lhs, QualType rhs)
         auto rhsMember = dyn_cast<MemberPointerType>(rhsType);
         if (!rhsMember)
             return false;
-        if (lhsMember->getClass() != rhsMember->getClass())
+        if (compat::getClass(lhsMember) != compat::getClass(rhsMember))
             return true;
         return areTypesEqual(lhsMember->getPointeeType(), 
rhsMember->getPointeeType());
     }

Reply via email to