@@ -654,9 +654,9 @@ comments::FullComment *ASTContext::getCommentForDecl(
654
654
// does not have one of its own.
655
655
QualType QT = TD->getUnderlyingType();
656
656
if (const auto *TT = QT->getAs<TagType>())
657
- if (const Decl *TD = TT->getOriginalDecl())
658
- if (comments::FullComment *FC = getCommentForDecl(TD , PP))
659
- return cloneFullComment(FC, D);
657
+ if (comments::FullComment *FC =
658
+ getCommentForDecl(TT->getOriginalDecl() , PP))
659
+ return cloneFullComment(FC, D);
660
660
}
661
661
else if (const auto *IC = dyn_cast<ObjCInterfaceDecl>(D)) {
662
662
while (IC->getSuperClass()) {
@@ -1933,12 +1933,9 @@ TypeInfoChars ASTContext::getTypeInfoDataSizeInChars(QualType T) const {
1933
1933
// of a base-class subobject. We decide whether that's possible
1934
1934
// during class layout, so here we can just trust the layout results.
1935
1935
if (getLangOpts().CPlusPlus) {
1936
- if (const auto *RT = T->getAs<RecordType>()) {
1937
- const auto *RD = RT->getOriginalDecl()->getDefinitionOrSelf();
1938
- if (!RD->isInvalidDecl()) {
1939
- const ASTRecordLayout &layout = getASTRecordLayout(RD);
1940
- Info.Width = layout.getDataSize();
1941
- }
1936
+ if (const auto *RD = T->getAsCXXRecordDecl(); RD && !RD->isInvalidDecl()) {
1937
+ const ASTRecordLayout &layout = getASTRecordLayout(RD);
1938
+ Info.Width = layout.getDataSize();
1942
1939
}
1943
1940
}
1944
1941
@@ -2694,9 +2691,7 @@ unsigned ASTContext::getPreferredTypeAlign(const Type *T) const {
2694
2691
if (!Target->allowsLargerPreferedTypeAlignment())
2695
2692
return ABIAlign;
2696
2693
2697
- if (const auto *RT = T->getAs<RecordType>()) {
2698
- const RecordDecl *RD = RT->getOriginalDecl()->getDefinitionOrSelf();
2699
-
2694
+ if (const auto *RD = T->getAsRecordDecl()) {
2700
2695
// When used as part of a typedef, or together with a 'packed' attribute,
2701
2696
// the 'aligned' attribute can be used to decrease alignment. Note that the
2702
2697
// 'packed' case is already taken into consideration when computing the
@@ -2887,12 +2882,10 @@ structHasUniqueObjectRepresentations(const ASTContext &Context,
2887
2882
static std::optional<int64_t>
2888
2883
getSubobjectSizeInBits(const FieldDecl *Field, const ASTContext &Context,
2889
2884
bool CheckIfTriviallyCopyable) {
2890
- if (Field->getType()->isRecordType()) {
2891
- const RecordDecl *RD = Field->getType()->getAsRecordDecl();
2892
- if (!RD->isUnion())
2893
- return structHasUniqueObjectRepresentations(Context, RD,
2894
- CheckIfTriviallyCopyable);
2895
- }
2885
+ if (const auto *RD = Field->getType()->getAsRecordDecl();
2886
+ RD && !RD->isUnion())
2887
+ return structHasUniqueObjectRepresentations(Context, RD,
2888
+ CheckIfTriviallyCopyable);
2896
2889
2897
2890
// A _BitInt type may not be unique if it has padding bits
2898
2891
// but if it is a bitfield the padding bits are not used.
@@ -3047,10 +3040,7 @@ bool ASTContext::hasUniqueObjectRepresentations(
3047
3040
if (const auto *MPT = Ty->getAs<MemberPointerType>())
3048
3041
return !ABI->getMemberPointerInfo(MPT).HasPadding;
3049
3042
3050
- if (Ty->isRecordType()) {
3051
- const RecordDecl *Record =
3052
- Ty->castAs<RecordType>()->getOriginalDecl()->getDefinitionOrSelf();
3053
-
3043
+ if (const auto *Record = Ty->getAsRecordDecl()) {
3054
3044
if (Record->isInvalidDecl())
3055
3045
return false;
3056
3046
0 commit comments