diff options
Diffstat (limited to 'clang/lib/AST/ASTContext.cpp')
-rw-r--r-- | clang/lib/AST/ASTContext.cpp | 40 |
1 files changed, 22 insertions, 18 deletions
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index a8b41ba..e403b3e 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -563,8 +563,7 @@ comments::FullComment *ASTContext::getCommentForDecl( // does not have one of its own. QualType QT = TD->getUnderlyingType(); if (const auto *TT = QT->getAs<TagType>()) - if (comments::FullComment *FC = - getCommentForDecl(TT->getOriginalDecl(), PP)) + if (comments::FullComment *FC = getCommentForDecl(TT->getDecl(), PP)) return cloneFullComment(FC, D); } else if (const auto *IC = dyn_cast<ObjCInterfaceDecl>(D)) { @@ -2387,7 +2386,7 @@ TypeInfo ASTContext::getTypeInfoImpl(const Type *T) const { case Type::Record: case Type::Enum: { const auto *TT = cast<TagType>(T); - const TagDecl *TD = TT->getOriginalDecl()->getDefinitionOrSelf(); + const TagDecl *TD = TT->getDecl()->getDefinitionOrSelf(); if (TD->isInvalidDecl()) { Width = 8; @@ -2531,7 +2530,7 @@ unsigned ASTContext::getTypeUnadjustedAlign(const Type *T) const { unsigned UnadjustedAlign; if (const auto *RT = T->getAsCanonical<RecordType>()) { - const ASTRecordLayout &Layout = getASTRecordLayout(RT->getOriginalDecl()); + const ASTRecordLayout &Layout = getASTRecordLayout(RT->getDecl()); UnadjustedAlign = toBits(Layout.getUnadjustedAlignment()); } else if (const auto *ObjCI = T->getAsCanonical<ObjCInterfaceType>()) { const ASTRecordLayout &Layout = getASTObjCInterfaceLayout(ObjCI->getDecl()); @@ -3469,7 +3468,7 @@ static void encodeTypeForFunctionPointerAuth(const ASTContext &Ctx, llvm_unreachable("should never get here"); } case Type::Record: { - const RecordDecl *RD = T->castAsCanonical<RecordType>()->getOriginalDecl(); + const RecordDecl *RD = T->castAsCanonical<RecordType>()->getDecl(); const IdentifierInfo *II = RD->getIdentifier(); // In C++, an immediate typedef of an anonymous struct or union @@ -5377,7 +5376,7 @@ TagType *ASTContext::getTagTypeInternal(ElaboratedTypeKeyword Keyword, }(); assert(T->getKeyword() == Keyword); assert(T->getQualifier() == Qualifier); - assert(T->getOriginalDecl() == TD); + assert(T->getDecl() == TD); assert(T->isInjected() == IsInjected); assert(T->isTagOwned() == OwnsTag); assert((T->isCanonicalUnqualified() @@ -8271,7 +8270,7 @@ Qualifiers::ObjCLifetime ASTContext::getInnerObjCOwnership(QualType T) const { static const Type *getIntegerTypeForEnum(const EnumType *ET) { // Incomplete enum types are not treated as integer types. // FIXME: In C++, enum types are never integer types. - const EnumDecl *ED = ET->getOriginalDecl()->getDefinitionOrSelf(); + const EnumDecl *ED = ET->getDecl()->getDefinitionOrSelf(); if (ED->isComplete() && !ED->isScoped()) return ED->getIntegerType().getTypePtr(); return nullptr; @@ -9189,7 +9188,7 @@ static void EncodeBitField(const ASTContext *Ctx, std::string& S, S += llvm::utostr(Offset); if (const auto *ET = T->getAsCanonical<EnumType>()) - S += ObjCEncodingForEnumDecl(Ctx, ET->getOriginalDecl()); + S += ObjCEncodingForEnumDecl(Ctx, ET->getDecl()); else { const auto *BT = T->castAs<BuiltinType>(); S += getObjCEncodingForPrimitiveType(Ctx, BT); @@ -9246,7 +9245,7 @@ void ASTContext::getObjCEncodingForTypeImpl(QualType T, std::string &S, if (const auto *BT = dyn_cast<BuiltinType>(CT)) S += getObjCEncodingForPrimitiveType(this, BT); else - S += ObjCEncodingForEnumDecl(this, cast<EnumType>(CT)->getOriginalDecl()); + S += ObjCEncodingForEnumDecl(this, cast<EnumType>(CT)->getDecl()); return; case Type::Complex: @@ -9314,7 +9313,7 @@ void ASTContext::getObjCEncodingForTypeImpl(QualType T, std::string &S, return; } } else if (const auto *RTy = PointeeTy->getAsCanonical<RecordType>()) { - const IdentifierInfo *II = RTy->getOriginalDecl()->getIdentifier(); + const IdentifierInfo *II = RTy->getDecl()->getIdentifier(); // GCC binary compat: Need to convert "struct objc_class *" to "#". if (II == &Idents.get("objc_class")) { S += '#'; @@ -9386,7 +9385,7 @@ void ASTContext::getObjCEncodingForTypeImpl(QualType T, std::string &S, return; case Type::Record: { - RecordDecl *RDecl = cast<RecordType>(CT)->getOriginalDecl(); + RecordDecl *RDecl = cast<RecordType>(CT)->getDecl(); S += RDecl->isUnion() ? '(' : '{'; // Anonymous structures print as '?' if (const IdentifierInfo *II = RDecl->getIdentifier()) { @@ -11290,7 +11289,7 @@ QualType ASTContext::mergeTransparentUnionType(QualType T, QualType SubType, bool OfBlockPointer, bool Unqualified) { if (const RecordType *UT = T->getAsUnionType()) { - RecordDecl *UD = UT->getOriginalDecl()->getMostRecentDecl(); + RecordDecl *UD = UT->getDecl()->getMostRecentDecl(); if (UD->hasAttr<TransparentUnionAttr>()) { for (const auto *I : UD->fields()) { QualType ET = I->getType().getUnqualifiedType(); @@ -11560,7 +11559,7 @@ static QualType mergeEnumWithInteger(ASTContext &Context, const EnumType *ET, // Compatibility is based on the underlying type, not the promotion // type. QualType underlyingType = - ET->getOriginalDecl()->getDefinitionOrSelf()->getIntegerType(); + ET->getDecl()->getDefinitionOrSelf()->getIntegerType(); if (underlyingType.isNull()) return {}; if (Context.hasSameType(underlyingType, other)) @@ -11581,6 +11580,12 @@ QualType ASTContext::mergeTagDefinitions(QualType LHS, QualType RHS) { if (LangOpts.CPlusPlus || !LangOpts.C23) return {}; + // Nameless tags are comparable only within outer definitions. At the top + // level they are not comparable. + const TagDecl *LTagD = LHS->castAsTagDecl(), *RTagD = RHS->castAsTagDecl(); + if (!LTagD->getIdentifier() || !RTagD->getIdentifier()) + return {}; + // C23, on the other hand, requires the members to be "the same enough", so // we use a structural equivalence check. StructuralEquivalenceContext::NonEquivalentDeclSet NonEquivalentDecls; @@ -14154,11 +14159,10 @@ static QualType getCommonNonSugarTypeNode(const ASTContext &Ctx, const Type *X, case Type::Record: case Type::InjectedClassName: { const auto *TX = cast<TagType>(X), *TY = cast<TagType>(Y); - return Ctx.getTagType( - ::getCommonTypeKeyword(TX, TY, /*IsSame=*/false), - ::getCommonQualifier(Ctx, TX, TY, /*IsSame=*/false), - ::getCommonDeclChecked(TX->getOriginalDecl(), TY->getOriginalDecl()), - /*OwnedTag=*/false); + return Ctx.getTagType(::getCommonTypeKeyword(TX, TY, /*IsSame=*/false), + ::getCommonQualifier(Ctx, TX, TY, /*IsSame=*/false), + ::getCommonDeclChecked(TX->getDecl(), TY->getDecl()), + /*OwnedTag=*/false); } case Type::TemplateSpecialization: { const auto *TX = cast<TemplateSpecializationType>(X), |