diff options
Diffstat (limited to 'clang/lib/AST/Decl.cpp')
| -rw-r--r-- | clang/lib/AST/Decl.cpp | 34 |
1 files changed, 16 insertions, 18 deletions
diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp index 4507f415ce60..d8dffb7f5dc4 100644 --- a/clang/lib/AST/Decl.cpp +++ b/clang/lib/AST/Decl.cpp @@ -2861,9 +2861,8 @@ VarDecl::needsDestruction(const ASTContext &Ctx) const { bool VarDecl::hasFlexibleArrayInit(const ASTContext &Ctx) const { assert(hasInit() && "Expect initializer to check for flexible array init"); - auto *Ty = getType()->getAs<RecordType>(); - if (!Ty || - !Ty->getOriginalDecl()->getDefinitionOrSelf()->hasFlexibleArrayMember()) + auto *D = getType()->getAsRecordDecl(); + if (!D || !D->hasFlexibleArrayMember()) return false; auto *List = dyn_cast<InitListExpr>(getInit()->IgnoreParens()); if (!List) @@ -2877,11 +2876,8 @@ bool VarDecl::hasFlexibleArrayInit(const ASTContext &Ctx) const { CharUnits VarDecl::getFlexibleArrayInitChars(const ASTContext &Ctx) const { assert(hasInit() && "Expect initializer to check for flexible array init"); - auto *Ty = getType()->getAs<RecordType>(); - if (!Ty) - return CharUnits::Zero(); - const RecordDecl *RD = Ty->getOriginalDecl()->getDefinitionOrSelf(); - if (!Ty || !RD->hasFlexibleArrayMember()) + auto *RD = getType()->getAsRecordDecl(); + if (!RD || !RD->hasFlexibleArrayMember()) return CharUnits::Zero(); auto *List = dyn_cast<InitListExpr>(getInit()->IgnoreParens()); if (!List || List->getNumInits() == 0) @@ -2992,7 +2988,7 @@ bool ParmVarDecl::isDestroyedInCallee() const { // FIXME: isParamDestroyedInCallee() should probably imply // isDestructedType() - const auto *RT = getType()->getAs<RecordType>(); + const auto *RT = getType()->getAsCanonical<RecordType>(); if (RT && RT->getOriginalDecl() ->getDefinitionOrSelf() @@ -3507,7 +3503,7 @@ bool FunctionDecl::isUsableAsGlobalAllocationFunctionInConstantEvaluation( while (const auto *TD = T->getAs<TypedefType>()) T = TD->getDecl()->getUnderlyingType(); const IdentifierInfo *II = - T->castAs<EnumType>()->getOriginalDecl()->getIdentifier(); + T->castAsCanonical<EnumType>()->getOriginalDecl()->getIdentifier(); if (II && II->isStr("__hot_cold_t")) Consume(); } @@ -3604,6 +3600,10 @@ bool FunctionDecl::isNoReturn() const { return false; } +bool FunctionDecl::isAnalyzerNoReturn() const { + return hasAttr<AnalyzerNoReturnAttr>(); +} + bool FunctionDecl::isMemberLikeConstrainedFriend() const { // C++20 [temp.friend]p9: // A non-template friend declaration with a requires-clause [or] @@ -4657,7 +4657,7 @@ bool FieldDecl::isAnonymousStructOrUnion() const { if (!isImplicit() || getDeclName()) return false; - if (const auto *Record = getType()->getAs<RecordType>()) + if (const auto *Record = getType()->getAsCanonical<RecordType>()) return Record->getOriginalDecl()->isAnonymousStructOrUnion(); return false; @@ -4715,7 +4715,7 @@ bool FieldDecl::isZeroSize(const ASTContext &Ctx) const { return false; // -- is not of class type, or - const auto *RT = getType()->getAs<RecordType>(); + const auto *RT = getType()->getAsCanonical<RecordType>(); if (!RT) return false; const RecordDecl *RD = RT->getOriginalDecl()->getDefinition(); @@ -4738,7 +4738,7 @@ bool FieldDecl::isZeroSize(const ASTContext &Ctx) const { // MS ABI: has nonzero size if it is a class type with class type fields, // whether or not they have nonzero size return !llvm::any_of(CXXRD->fields(), [](const FieldDecl *Field) { - return Field->getType()->getAs<RecordType>(); + return Field->getType()->isRecordType(); }); } @@ -5142,7 +5142,7 @@ bool RecordDecl::isOrContainsUnion() const { if (const RecordDecl *Def = getDefinition()) { for (const FieldDecl *FD : Def->fields()) { - const RecordType *RT = FD->getType()->getAs<RecordType>(); + const RecordType *RT = FD->getType()->getAsCanonical<RecordType>(); if (RT && RT->getOriginalDecl()->isOrContainsUnion()) return true; } @@ -5274,10 +5274,8 @@ const FieldDecl *RecordDecl::findFirstNamedDataMember() const { if (I->getIdentifier()) return I; - if (const auto *RT = I->getType()->getAs<RecordType>()) - if (const FieldDecl *NamedDataMember = RT->getOriginalDecl() - ->getDefinitionOrSelf() - ->findFirstNamedDataMember()) + if (const auto *RD = I->getType()->getAsRecordDecl()) + if (const FieldDecl *NamedDataMember = RD->findFirstNamedDataMember()) return NamedDataMember; } |
