[clang] [clang] Introduce [[clang::lifetime_capture_by(X)]] (PR #111499)
Gábor Horváth via cfe-commits
cfe-commits at lists.llvm.org
Thu Nov 7 08:32:06 PST 2024
================
@@ -1873,6 +1873,46 @@ def LifetimeBound : DeclOrTypeAttr {
let SimpleHandler = 1;
}
+def LifetimeCaptureBy : DeclOrTypeAttr {
+ let Spellings = [Clang<"lifetime_capture_by", 0>];
+ let Subjects = SubjectList<[ParmVar, ImplicitObjectParameter], ErrorDiag>;
+ let Args = [VariadicParamOrParamIdxArgument<"Params">];
+ let Documentation = [LifetimeBoundDocs];
+ let LangOpts = [CPlusPlus];
+
+ // let SimpleHandler = 1;
+ // let LateParsed = LateAttrParseStandard;
+ // let HasCustomParsing = 1;
+ // let ParseArgumentsAsUnevaluated = 1;
+
+ let AdditionalMembers = [{
+private:
+ SmallVector<IdentifierInfo*, 1> ArgIdents;
+ SmallVector<SourceLocation, 1> ArgLocs;
+
+public:
+ static constexpr int INVALID = -2;
+ static constexpr int UNKNOWN = -1;
+ static constexpr int GLOBAL = -1;
+ static constexpr int THIS = 0;
+
+ void setArgs(SmallVector<IdentifierInfo*, 1> Idents,
+ SmallVector<SourceLocation, 1> Locs) {
+ assert(Idents.size() == Locs.size());
+ assert(Idents.size() == params_Size);
+ ArgIdents = std::move(Idents);
+ ArgLocs = std::move(Locs);
+ }
+
+ const SmallVector<IdentifierInfo*, 1>& getArgIdents() const { return ArgIdents; }
----------------
Xazax-hun wrote:
I think it might be better to return an `ArrayRef` here (and in the next getter).
https://github.com/llvm/llvm-project/pull/111499
More information about the cfe-commits
mailing list