================ @@ -1889,6 +1889,43 @@ 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 = [LifetimeCaptureByDocs]; + let AdditionalMembers = [{ +private: + MutableArrayRef<IdentifierInfo*> ArgIdents; + MutableArrayRef<SourceLocation> ArgLocs; + +public: + static constexpr int THIS = 0; + static constexpr int INVALID = -1; + static constexpr int UNKNOWN = -2; + static constexpr int GLOBAL = -3; + + void CreateArgs(ASTContext &Ctx) { + ArgIdents = + MutableArrayRef<IdentifierInfo *>(new (Ctx) IdentifierInfo *[params_Size], params_Size); + ArgLocs = + MutableArrayRef<SourceLocation>(new (Ctx) SourceLocation[params_Size], params_Size); + } + auto getArgIdents() const { ---------------- hokein wrote:
Returning a `MutableArrayRef` and allowing mutations in the caller seems to break the encapsulation from a getter. I’d prefer using an `ArrayRef` and adding a setter like `setArgIdents(ArrayRef<IdentifierInfo*> Args)`. While this means we’d allocate the array in the caller, I think it is fine. https://github.com/llvm/llvm-project/pull/115823 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits