[clang] [clang] Introduce [[clang::lifetime_capture_by(X)]] (PR #111499)

Haojian Wu via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 11 01:46:58 PST 2024


================
@@ -3967,6 +3967,69 @@ Attribute ``trivial_abi`` has no effect in the following cases:
   }];
 }
 
+
+def LifetimeCaptureByDocs : Documentation {
+  let Category = DocCatFunction;
+  let Content = [{
+    The ``lifetime_capture_by(X)`` attribute on a function parameter or implicit object
+parameter indicates that references to arguments passed to such parameters may be
----------------
hokein wrote:

I think we should be clear about semantic of "references to arguments passed to such parameters" in the doc.

Similar to lifetimebound, I think we have 3 major cases:

- a reference parameter, we consider its referenced object;
- a pointer parameter, we consider its pointee object;
- a pass-by-value struct parameter,  we assume this struct is pointer-like object, we consider objects that its  transitive subobjects refer to;

https://github.com/llvm/llvm-project/pull/111499


More information about the cfe-commits mailing list