[clang] [clang] Make lifetime annotations non type attributes (PR #196549)

Utkarsh Saxena via cfe-commits cfe-commits at lists.llvm.org
Fri May 8 08:11:10 PDT 2026


https://github.com/usx95 created https://github.com/llvm/llvm-project/pull/196549

None

>From 2f3909bc22d0a6fba27eb78e871a4492921d6022 Mon Sep 17 00:00:00 2001
From: Utkarsh Saxena <usx at google.com>
Date: Fri, 8 May 2026 15:09:10 +0000
Subject: [PATCH] [clang] Make lifetime annotations non type attributes

---
 clang/include/clang/Basic/Attr.td | 4 ++--
 clang/lib/AST/TypePrinter.cpp     | 2 --
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/clang/include/clang/Basic/Attr.td b/clang/include/clang/Basic/Attr.td
index 70b5773f95b08..84c610c181051 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -2126,14 +2126,14 @@ def ExplicitInit : InheritableAttr {
   let SimpleHandler = 1;
 }
 
-def LifetimeBound : DeclOrTypeAttr {
+def LifetimeBound : InheritableAttr {
   let Spellings = [Clang<"lifetimebound", 0>];
   let Subjects = SubjectList<[ParmVar, ImplicitObjectParameter], ErrorDiag>;
   let Documentation = [LifetimeBoundDocs];
   let SimpleHandler = 1;
 }
 
-def LifetimeCaptureBy : DeclOrTypeAttr {
+def LifetimeCaptureBy : InheritableAttr {
   let Spellings = [Clang<"lifetime_capture_by", 0>];
   let Subjects = SubjectList<[ParmVar, ImplicitObjectParameter], ErrorDiag>;
   let Args = [VariadicParamOrParamIdxArgument<"Params">];
diff --git a/clang/lib/AST/TypePrinter.cpp b/clang/lib/AST/TypePrinter.cpp
index 80f5b90ba35c4..a7f99a5fddfd8 100644
--- a/clang/lib/AST/TypePrinter.cpp
+++ b/clang/lib/AST/TypePrinter.cpp
@@ -2008,8 +2008,6 @@ void TypePrinter::printAttributedAfter(const AttributedType *T,
   case attr::CountedByOrNull:
   case attr::SizedBy:
   case attr::SizedByOrNull:
-  case attr::LifetimeBound:
-  case attr::LifetimeCaptureBy:
   case attr::TypeNonNull:
   case attr::TypeNullable:
   case attr::TypeNullableResult:



More information about the cfe-commits mailing list