@@ -3322,8 +3322,7 @@ static void encodeTypeForFunctionPointerAuth(const ASTContext &Ctx,
3322
3322
case Type::MemberPointer: {
3323
3323
OS << "M";
3324
3324
const auto *MPT = T->castAs<MemberPointerType>();
3325
- encodeTypeForFunctionPointerAuth(
3326
- Ctx, OS, QualType(MPT->getQualifier()->getAsType(), 0));
3325
+ encodeTypeForFunctionPointerAuth(Ctx, OS, QualType(MPT->getClass(), 0));
3327
3326
encodeTypeForFunctionPointerAuth(Ctx, OS, MPT->getPointeeType());
3328
3327
return;
3329
3328
}
@@ -3512,8 +3511,7 @@ uint16_t ASTContext::getPointerAuthTypeDiscriminator(QualType T) {
3512
3511
if (PointeeType->castAs<FunctionProtoType>()->getExceptionSpecType() !=
3513
3512
EST_None) {
3514
3513
QualType FT = getFunctionTypeWithExceptionSpec(PointeeType, EST_None);
3515
- T = getMemberPointerType(FT, MPT->getQualifier(),
3516
- MPT->getMostRecentCXXRecordDecl());
3514
+ T = getMemberPointerType(FT, MPT->getClass());
3517
3515
}
3518
3516
}
3519
3517
std::unique_ptr<MangleContext> MC(createMangleContext());
@@ -4027,50 +4025,32 @@ QualType ASTContext::getRValueReferenceType(QualType T) const {
4027
4025
return QualType(New, 0);
4028
4026
}
4029
4027
4030
- QualType ASTContext::getMemberPointerType(QualType T,
4031
- NestedNameSpecifier *Qualifier,
4032
- const CXXRecordDecl *Cls) const {
4033
- if (!Qualifier) {
4034
- assert(Cls && "At least one of Qualifier or Cls must be provided");
4035
- Qualifier = NestedNameSpecifier::Create(*this, /*Prefix=*/nullptr,
4036
- /*Template=*/false,
4037
- getTypeDeclType(Cls).getTypePtr());
4038
- } else if (!Cls) {
4039
- Cls = Qualifier->getAsRecordDecl();
4040
- }
4028
+ /// getMemberPointerType - Return the uniqued reference to the type for a
4029
+ /// member pointer to the specified type, in the specified class.
4030
+ QualType ASTContext::getMemberPointerType(QualType T, const Type *Cls) const {
4041
4031
// Unique pointers, to guarantee there is only one pointer of a particular
4042
4032
// structure.
4043
4033
llvm::FoldingSetNodeID ID;
4044
- MemberPointerType::Profile(ID, T, Qualifier, Cls);
4034
+ MemberPointerType::Profile(ID, T, Cls);
4045
4035
4046
4036
void *InsertPos = nullptr;
4047
4037
if (MemberPointerType *PT =
4048
4038
MemberPointerTypes.FindNodeOrInsertPos(ID, InsertPos))
4049
4039
return QualType(PT, 0);
4050
4040
4051
- NestedNameSpecifier *CanonicalQualifier = [&] {
4052
- if (!Cls)
4053
- return getCanonicalNestedNameSpecifier(Qualifier);
4054
- NestedNameSpecifier *R = NestedNameSpecifier::Create(
4055
- *this, /*Prefix=*/nullptr, /*Template=*/false,
4056
- Cls->getCanonicalDecl()->getTypeForDecl());
4057
- assert(R == getCanonicalNestedNameSpecifier(R));
4058
- return R;
4059
- }();
4060
4041
// If the pointee or class type isn't canonical, this won't be a canonical
4061
4042
// type either, so fill in the canonical type field.
4062
4043
QualType Canonical;
4063
- if (!T.isCanonical() || Qualifier != CanonicalQualifier) {
4064
- Canonical =
4065
- getMemberPointerType(getCanonicalType(T), CanonicalQualifier, Cls);
4066
- assert(!cast<MemberPointerType>(Canonical)->isSugared());
4044
+ if (!T.isCanonical() || !Cls->isCanonicalUnqualified()) {
4045
+ Canonical = getMemberPointerType(getCanonicalType(T),getCanonicalType(Cls));
4046
+
4067
4047
// Get the new insert position for the node we care about.
4068
- [[maybe_unused]] MemberPointerType *NewIP =
4069
- MemberPointerTypes.FindNodeOrInsertPos(ID, InsertPos);
4070
- assert(!NewIP && "Shouldn't be in the map!");
4048
+ MemberPointerType *NewIP =
4049
+ MemberPointerTypes.FindNodeOrInsertPos(ID, InsertPos);
4050
+ assert(!NewIP && "Shouldn't be in the map!"); (void)NewIP;
4071
4051
}
4072
4052
auto *New = new (*this, alignof(MemberPointerType))
4073
- MemberPointerType(T, Qualifier , Canonical);
4053
+ MemberPointerType(T, Cls , Canonical);
4074
4054
Types.push_back(New);
4075
4055
MemberPointerTypes.InsertNode(New, InsertPos);
4076
4056
return QualType(New, 0);
@@ -6832,16 +6812,11 @@ bool ASTContext::UnwrapSimilarTypes(QualType &T1, QualType &T2,
6832
6812
return true;
6833
6813
}
6834
6814
6835
- if (const auto *T1MPType = T1->getAs<MemberPointerType>(),
6836
- *T2MPType = T2->getAs<MemberPointerType>();
6837
- T1MPType && T2MPType) {
6838
- if (auto *RD1 = T1MPType->getMostRecentCXXRecordDecl(),
6839
- *RD2 = T2MPType->getMostRecentCXXRecordDecl();
6840
- RD1 != RD2 && RD1->getCanonicalDecl() != RD2->getCanonicalDecl())
6841
- return false;
6842
- if (getCanonicalNestedNameSpecifier(T1MPType->getQualifier()) !=
6843
- getCanonicalNestedNameSpecifier(T2MPType->getQualifier()))
6844
- return false;
6815
+ const auto *T1MPType = T1->getAs<MemberPointerType>();
6816
+ const auto *T2MPType = T2->getAs<MemberPointerType>();
6817
+ if (T1MPType && T2MPType &&
6818
+ hasSameUnqualifiedType(QualType(T1MPType->getClass(), 0),
6819
+ QualType(T2MPType->getClass(), 0))) {
6845
6820
T1 = T1MPType->getPointeeType();
6846
6821
T2 = T2MPType->getPointeeType();
6847
6822
return true;
@@ -13882,12 +13857,11 @@ static QualType getCommonNonSugarTypeNode(ASTContext &Ctx, const Type *X,
13882
13857
case Type::MemberPointer: {
13883
13858
const auto *PX = cast<MemberPointerType>(X),
13884
13859
*PY = cast<MemberPointerType>(Y);
13885
- assert(declaresSameEntity(PX->getMostRecentCXXRecordDecl(),
13886
- PY->getMostRecentCXXRecordDecl()));
13887
13860
return Ctx.getMemberPointerType(
13888
13861
getCommonPointeeType(Ctx, PX, PY),
13889
- getCommonQualifier(Ctx, PX, PY, /*IsSame=*/true),
13890
- PX->getMostRecentCXXRecordDecl());
13862
+ Ctx.getCommonSugaredType(QualType(PX->getClass(), 0),
13863
+ QualType(PY->getClass(), 0))
13864
+ .getTypePtr());
13891
13865
}
13892
13866
case Type::LValueReference: {
13893
13867
const auto *PX = cast<LValueReferenceType>(X),
0 commit comments