@@ -1618,26 +1618,8 @@ void ASTContext::setRelocationInfoForCXXRecord(
16181618 RelocatableClasses.insert({D, Info});
16191619}
16201620
1621- // In future we may want to distinguish the presence or absence of address
1622- // discrimination, from the inability to determine the presence. For now we rely
1623- // on all source facing interfaces (type trait queries, etc) diagnosing and
1624- // reporting an error before reaching these paths.
1625- static bool canDeterminePointerAuthContent(QualType Type) {
1626- if (Type->isIncompleteType() || Type->isDependentType())
1627- return false;
1628- const TagDecl *Decl = Type->getAsTagDecl();
1629- return !Decl || !Decl->getDefinition()->isInvalidDecl();
1630- }
1631- static bool canDeterminePointerAuthContent(const ASTContext &Ctx,
1632- const TagDecl *Decl) {
1633- CanQualType DeclType = Ctx.getCanonicalTagType(Decl);
1634- return canDeterminePointerAuthContent(DeclType);
1635- }
1636-
16371621static bool primaryBaseHaseAddressDiscriminatedVTableAuthentication(
16381622 const ASTContext &Context, const CXXRecordDecl *Class) {
1639- if (!canDeterminePointerAuthContent(Context, Class))
1640- return false;
16411623 if (!Class->isPolymorphic())
16421624 return false;
16431625 const CXXRecordDecl *BaseType = Context.baseForVTableAuthentication(Class);
@@ -1657,7 +1639,7 @@ ASTContext::findPointerAuthContent(QualType T) const {
16571639 assert(isPointerAuthenticationAvailable());
16581640
16591641 T = T.getCanonicalType();
1660- if (!canDeterminePointerAuthContent(T ))
1642+ if (T->isDependentType( ))
16611643 return PointerAuthContent::None;
16621644
16631645 if (T.hasAddressDiscriminatedPointerAuth())
@@ -1666,6 +1648,9 @@ ASTContext::findPointerAuthContent(QualType T) const {
16661648 if (!RD)
16671649 return PointerAuthContent::None;
16681650
1651+ if (RD->isInvalidDecl())
1652+ return PointerAuthContent::None;
1653+
16691654 if (auto Existing = RecordContainsAddressDiscriminatedPointerAuth.find(RD);
16701655 Existing != RecordContainsAddressDiscriminatedPointerAuth.end())
16711656 return Existing->second;
@@ -3248,7 +3233,6 @@ QualType ASTContext::removeAddrSpaceQualType(QualType T) const {
32483233
32493234uint16_t
32503235ASTContext::getPointerAuthVTablePointerDiscriminator(const CXXRecordDecl *RD) {
3251- assert(canDeterminePointerAuthContent(*this, RD));
32523236 assert(RD->isPolymorphic() &&
32533237 "Attempted to get vtable pointer discriminator on a monomorphic type");
32543238 std::unique_ptr<MangleContext> MC(createMangleContext());
@@ -3536,9 +3520,6 @@ static void encodeTypeForFunctionPointerAuth(const ASTContext &Ctx,
35363520uint16_t ASTContext::getPointerAuthTypeDiscriminator(QualType T) {
35373521 assert(!T->isDependentType() &&
35383522 "cannot compute type discriminator of a dependent type");
3539- assert(canDeterminePointerAuthContent(T) &&
3540- "cannot compute type discriminator of an incomplete or otherwise "
3541- "invalid type");
35423523 SmallString<256> Str;
35433524 llvm::raw_svector_ostream Out(Str);
35443525
0 commit comments