@@ -2446,19 +2446,17 @@ bool Type::isIncompleteType(NamedDecl **Def) const {
24462446 // Member pointers in the MS ABI have special behavior in
24472447 // RequireCompleteType: they attach a MSInheritanceAttr to the CXXRecordDecl
24482448 // to indicate which inheritance model to use.
2449- auto *MPTy = cast<MemberPointerType>(CanonicalType);
2450- const Type *ClassTy = MPTy->getClass ();
2449+ // The inheritance attribute might only be present on the most recent
2450+ // CXXRecordDecl.
2451+ const CXXRecordDecl *RD =
2452+ cast<MemberPointerType>(CanonicalType)->getMostRecentCXXRecordDecl ();
24512453 // Member pointers with dependent class types don't get special treatment.
2452- if (ClassTy-> isDependentType () )
2454+ if (!RD )
24532455 return false ;
2454- const CXXRecordDecl *RD = ClassTy->getAsCXXRecordDecl ();
24552456 ASTContext &Context = RD->getASTContext ();
24562457 // Member pointers not in the MS ABI don't get special treatment.
24572458 if (!Context.getTargetInfo ().getCXXABI ().isMicrosoft ())
24582459 return false ;
2459- // The inheritance attribute might only be present on the most recent
2460- // CXXRecordDecl, use that one.
2461- RD = RD->getMostRecentNonInjectedDecl ();
24622460 // Nothing interesting to do if the inheritance attribute is already set.
24632461 if (RD->hasAttr <MSInheritanceAttr>())
24642462 return false ;
@@ -4713,7 +4711,8 @@ LinkageInfo LinkageComputer::computeTypeLinkageInfo(const Type *T) {
47134711 return computeTypeLinkageInfo (cast<ReferenceType>(T)->getPointeeType ());
47144712 case Type::MemberPointer: {
47154713 const auto *MPT = cast<MemberPointerType>(T);
4716- LinkageInfo LV = computeTypeLinkageInfo (MPT->getClass ());
4714+ LinkageInfo LV =
4715+ getDeclLinkageAndVisibility (MPT->getMostRecentCXXRecordDecl ());
47174716 LV.merge (computeTypeLinkageInfo (MPT->getPointeeType ()));
47184717 return LV;
47194718 }
@@ -5179,7 +5178,10 @@ QualType::DestructionKind QualType::isDestructedTypeImpl(QualType type) {
51795178}
51805179
51815180CXXRecordDecl *MemberPointerType::getMostRecentCXXRecordDecl () const {
5182- return getClass ()->getAsCXXRecordDecl ()->getMostRecentNonInjectedDecl ();
5181+ auto *RD = getClass ()->getAsCXXRecordDecl ();
5182+ if (!RD)
5183+ return nullptr ;
5184+ return RD->getMostRecentNonInjectedDecl ();
51835185}
51845186
51855187void clang::FixedPointValueToString (SmallVectorImpl<char > &Str,
0 commit comments