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.bergmann@allotropia.de>
This commit is contained in:
Stephan Bergmann
2025-03-23 22:06:42 +01:00
parent ea1404e420
commit b936f80d96
5 changed files with 15 additions and 5 deletions

View File

@ -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();

View File

@ -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)
{

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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());
}