1212
1313#include " clang/APINotes/APINotesReader.h"
1414#include " clang/AST/Decl.h"
15+ #include " clang/AST/DeclCXX.h"
1516#include " clang/AST/DeclObjC.h"
1617#include " clang/Basic/SourceLocation.h"
1718#include " clang/Lex/Lexer.h"
@@ -415,6 +416,13 @@ static void ProcessAPINotes(Sema &S, ParmVarDecl *D,
415416 return new (S.Context ) NoEscapeAttr (S.Context , getPlaceholderAttrInfo ());
416417 });
417418
419+ if (auto Lifetimebound = Info.isLifetimebound ())
420+ handleAPINotedAttribute<LifetimeBoundAttr>(
421+ S, D, *Lifetimebound, Metadata, [&] {
422+ return new (S.Context )
423+ LifetimeBoundAttr (S.Context , getPlaceholderAttrInfo ());
424+ });
425+
418426 // Retain count convention
419427 handleAPINotedRetainCountConvention (S, D, Metadata,
420428 Info.getRetainCountConvention ());
@@ -860,13 +868,12 @@ void Sema::ProcessAPINotes(Decl *D) {
860868 if (!D)
861869 return ;
862870
871+ auto *DC = D->getDeclContext ();
863872 // Globals.
864- if (D->getDeclContext ()->isFileContext () ||
865- D->getDeclContext ()->isNamespace () ||
866- D->getDeclContext ()->isExternCContext () ||
867- D->getDeclContext ()->isExternCXXContext ()) {
873+ if (DC->isFileContext () || DC->isNamespace () || DC->isExternCContext () ||
874+ DC->isExternCXXContext ()) {
868875 std::optional<api_notes::Context> APINotesContext =
869- UnwindNamespaceContext (D-> getDeclContext () , APINotes);
876+ UnwindNamespaceContext (DC , APINotes);
870877 // Global variables.
871878 if (auto VD = dyn_cast<VarDecl>(D)) {
872879 for (auto Reader : APINotes.findAPINotes (D->getLocation ())) {
@@ -967,8 +974,8 @@ void Sema::ProcessAPINotes(Decl *D) {
967974 }
968975
969976 // Enumerators.
970- if (D-> getDeclContext () ->getRedeclContext ()->isFileContext () ||
971- D-> getDeclContext () ->getRedeclContext ()->isExternCContext ()) {
977+ if (DC ->getRedeclContext ()->isFileContext () ||
978+ DC ->getRedeclContext ()->isExternCContext ()) {
972979 if (auto EnumConstant = dyn_cast<EnumConstantDecl>(D)) {
973980 for (auto Reader : APINotes.findAPINotes (D->getLocation ())) {
974981 auto Info = Reader->lookupEnumConstant (EnumConstant->getName ());
@@ -979,7 +986,7 @@ void Sema::ProcessAPINotes(Decl *D) {
979986 }
980987 }
981988
982- if (auto ObjCContainer = dyn_cast<ObjCContainerDecl>(D-> getDeclContext () )) {
989+ if (auto ObjCContainer = dyn_cast<ObjCContainerDecl>(DC )) {
983990 // Location function that looks up an Objective-C context.
984991 auto GetContext = [&](api_notes::APINotesReader *Reader)
985992 -> std::optional<api_notes::ContextID> {
@@ -1063,7 +1070,7 @@ void Sema::ProcessAPINotes(Decl *D) {
10631070 }
10641071 }
10651072
1066- if (auto TagContext = dyn_cast<TagDecl>(D-> getDeclContext () )) {
1073+ if (auto TagContext = dyn_cast<TagDecl>(DC )) {
10671074 if (auto CXXMethod = dyn_cast<CXXMethodDecl>(D)) {
10681075 if (!isa<CXXConstructorDecl>(CXXMethod) &&
10691076 !isa<CXXDestructorDecl>(CXXMethod) &&
0 commit comments