@@ -3433,8 +3433,7 @@ static void encodeTypeForFunctionPointerAuth(const ASTContext &Ctx,
3433
3433
case Type::MemberPointer: {
3434
3434
OS << "M";
3435
3435
const auto *MPT = T->castAs<MemberPointerType>();
3436
- encodeTypeForFunctionPointerAuth(
3437
- Ctx, OS, QualType(MPT->getQualifier()->getAsType(), 0));
3436
+ encodeTypeForFunctionPointerAuth(Ctx, OS, QualType(MPT->getClass(), 0));
3438
3437
encodeTypeForFunctionPointerAuth(Ctx, OS, MPT->getPointeeType());
3439
3438
return;
3440
3439
}
@@ -3622,8 +3621,7 @@ uint16_t ASTContext::getPointerAuthTypeDiscriminator(QualType T) {
3622
3621
if (PointeeType->castAs<FunctionProtoType>()->getExceptionSpecType() !=
3623
3622
EST_None) {
3624
3623
QualType FT = getFunctionTypeWithExceptionSpec(PointeeType, EST_None);
3625
- T = getMemberPointerType(FT, MPT->getQualifier(),
3626
- MPT->getMostRecentCXXRecordDecl());
3624
+ T = getMemberPointerType(FT, MPT->getClass());
3627
3625
}
3628
3626
}
3629
3627
std::unique_ptr<MangleContext> MC(createMangleContext());
@@ -4624,50 +4622,32 @@ QualType ASTContext::getRValueReferenceType(QualType T) const {
4624
4622
return QualType(New, 0);
4625
4623
}
4626
4624
4627
- QualType ASTContext::getMemberPointerType(QualType T,
4628
- NestedNameSpecifier *Qualifier,
4629
- const CXXRecordDecl *Cls) const {
4630
- if (!Qualifier) {
4631
- assert(Cls && "At least one of Qualifier or Cls must be provided");
4632
- Qualifier = NestedNameSpecifier::Create(*this, /*Prefix=*/nullptr,
4633
- /*Template=*/false,
4634
- getTypeDeclType(Cls).getTypePtr());
4635
- } else if (!Cls) {
4636
- Cls = Qualifier->getAsRecordDecl();
4637
- }
4625
+ /// getMemberPointerType - Return the uniqued reference to the type for a
4626
+ /// member pointer to the specified type, in the specified class.
4627
+ QualType ASTContext::getMemberPointerType(QualType T, const Type *Cls) const {
4638
4628
// Unique pointers, to guarantee there is only one pointer of a particular
4639
4629
// structure.
4640
4630
llvm::FoldingSetNodeID ID;
4641
- MemberPointerType::Profile(ID, T, Qualifier, Cls);
4631
+ MemberPointerType::Profile(ID, T, Cls);
4642
4632
4643
4633
void *InsertPos = nullptr;
4644
4634
if (MemberPointerType *PT =
4645
4635
MemberPointerTypes.FindNodeOrInsertPos(ID, InsertPos))
4646
4636
return QualType(PT, 0);
4647
4637
4648
- NestedNameSpecifier *CanonicalQualifier = [&] {
4649
- if (!Cls)
4650
- return getCanonicalNestedNameSpecifier(Qualifier);
4651
- NestedNameSpecifier *R = NestedNameSpecifier::Create(
4652
- *this, /*Prefix=*/nullptr, /*Template=*/false,
4653
- Cls->getCanonicalDecl()->getTypeForDecl());
4654
- assert(R == getCanonicalNestedNameSpecifier(R));
4655
- return R;
4656
- }();
4657
4638
// If the pointee or class type isn't canonical, this won't be a canonical
4658
4639
// type either, so fill in the canonical type field.
4659
4640
QualType Canonical;
4660
- if (!T.isCanonical() || Qualifier != CanonicalQualifier) {
4661
- Canonical =
4662
- getMemberPointerType(getCanonicalType(T), CanonicalQualifier, Cls);
4663
- assert(!cast<MemberPointerType>(Canonical)->isSugared());
4641
+ if (!T.isCanonical() || !Cls->isCanonicalUnqualified()) {
4642
+ Canonical = getMemberPointerType(getCanonicalType(T),getCanonicalType(Cls));
4643
+
4664
4644
// Get the new insert position for the node we care about.
4665
- [[maybe_unused]] MemberPointerType *NewIP =
4666
- MemberPointerTypes.FindNodeOrInsertPos(ID, InsertPos);
4667
- assert(!NewIP && "Shouldn't be in the map!");
4645
+ MemberPointerType *NewIP =
4646
+ MemberPointerTypes.FindNodeOrInsertPos(ID, InsertPos);
4647
+ assert(!NewIP && "Shouldn't be in the map!"); (void)NewIP;
4668
4648
}
4669
4649
auto *New = new (*this, alignof(MemberPointerType))
4670
- MemberPointerType(T, Qualifier , Canonical);
4650
+ MemberPointerType(T, Cls , Canonical);
4671
4651
Types.push_back(New);
4672
4652
MemberPointerTypes.InsertNode(New, InsertPos);
4673
4653
return QualType(New, 0);
@@ -7427,16 +7407,11 @@ bool ASTContext::UnwrapSimilarTypes(QualType &T1, QualType &T2,
7427
7407
return true;
7428
7408
}
7429
7409
7430
- if (const auto *T1MPType = T1->getAs<MemberPointerType>(),
7431
- *T2MPType = T2->getAs<MemberPointerType>();
7432
- T1MPType && T2MPType) {
7433
- if (auto *RD1 = T1MPType->getMostRecentCXXRecordDecl(),
7434
- *RD2 = T2MPType->getMostRecentCXXRecordDecl();
7435
- RD1 != RD2 && RD1->getCanonicalDecl() != RD2->getCanonicalDecl())
7436
- return false;
7437
- if (getCanonicalNestedNameSpecifier(T1MPType->getQualifier()) !=
7438
- getCanonicalNestedNameSpecifier(T2MPType->getQualifier()))
7439
- return false;
7410
+ const auto *T1MPType = T1->getAs<MemberPointerType>();
7411
+ const auto *T2MPType = T2->getAs<MemberPointerType>();
7412
+ if (T1MPType && T2MPType &&
7413
+ hasSameUnqualifiedType(QualType(T1MPType->getClass(), 0),
7414
+ QualType(T2MPType->getClass(), 0))) {
7440
7415
T1 = T1MPType->getPointeeType();
7441
7416
T2 = T2MPType->getPointeeType();
7442
7417
return true;
@@ -14690,12 +14665,11 @@ static QualType getCommonNonSugarTypeNode(ASTContext &Ctx, const Type *X,
14690
14665
case Type::MemberPointer: {
14691
14666
const auto *PX = cast<MemberPointerType>(X),
14692
14667
*PY = cast<MemberPointerType>(Y);
14693
- assert(declaresSameEntity(PX->getMostRecentCXXRecordDecl(),
14694
- PY->getMostRecentCXXRecordDecl()));
14695
14668
return Ctx.getMemberPointerType(
14696
14669
getCommonPointeeType(Ctx, PX, PY),
14697
- getCommonQualifier(Ctx, PX, PY, /*IsSame=*/true),
14698
- PX->getMostRecentCXXRecordDecl());
14670
+ Ctx.getCommonSugaredType(QualType(PX->getClass(), 0),
14671
+ QualType(PY->getClass(), 0))
14672
+ .getTypePtr());
14699
14673
}
14700
14674
case Type::LValueReference: {
14701
14675
const auto *PX = cast<LValueReferenceType>(X),
0 commit comments