compilerplugins/clang/check.cxx | 3 ++- compilerplugins/clang/compat.hxx | 8 ++++++++ compilerplugins/clang/cstylecast.cxx | 4 ++-- compilerplugins/clang/external.cxx | 4 ++-- compilerplugins/clang/typedefparam.cxx | 3 ++- 5 files changed, 16 insertions(+), 6 deletions(-)
New commits: commit c2d59f0ea74e52045dbe1276417d37fd1761dec9 Author: Stephan Bergmann <[email protected]> AuthorDate: Mon Jul 14 07:44:12 2025 +0200 Commit: Mohit Marathe <[email protected]> CommitDate: Tue Dec 16 14:25:35 2025 +0100 Adapt to Clang 21 trunk isInjectedClassName change <https://github.com/llvm/llvm-project/commit/c4cc3573d144831d2815433646ffcab62cc9ea40> "[Clang][AST][NFC] (`RecordDecl` -> `CXXRecordDecl`)`::isInjectedClassName` (#148195)" Change-Id: I2807a9ca402e856d55e1803997c86821f5a69bfc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/187839 Reviewed-by: Stephan Bergmann <[email protected]> Tested-by: Jenkins (cherry picked from commit d0a492c29655c8e86a9acdc807b9fdfc4882fbd7) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195702 Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-by: Michael Stahl <[email protected]> diff --git a/compilerplugins/clang/external.cxx b/compilerplugins/clang/external.cxx index f71c5947a3ed..4b147e79e764 100644 --- a/compilerplugins/clang/external.cxx +++ b/compilerplugins/clang/external.cxx @@ -344,7 +344,7 @@ private: } if (isa<TagDecl>(*d) || isa<ClassTemplateDecl>(*d)) { - if (auto const d1 = dyn_cast<RecordDecl>(*d)) + if (auto const d1 = dyn_cast<CXXRecordDecl>(*d)) { if (d1->isInjectedClassName()) { commit fab3881afa1207f4c46a56c91ffc6818a92b4874 Author: Stephan Bergmann <[email protected]> AuthorDate: Sun Mar 23 22:06:42 2025 +0100 Commit: Mohit Marathe <[email protected]> CommitDate: Tue Dec 16 14:25:22 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 <[email protected]> (cherry picked from commit b936f80d96b9a1f4646e0ba5371b67eccf302527) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195701 Reviewed-by: Michael Stahl <[email protected]> Tested-by: Jenkins CollaboraOffice <[email protected]> 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()); }
