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

Boaz Brickner via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 17 01:24:21 PDT 2024


================
@@ -18,29 +18,42 @@
 
 namespace clang::sema {
 
-/// Describes an entity that is being assigned.
-struct AssignedEntity {
-  // The left-hand side expression of the assignment.
-  Expr *LHS = nullptr;
+struct CapturingEntity {
+  // The expression of the entity which captures another entity.
+  // For example:
+  //  1. In an assignment, this would be the left-hand side expression.
+  //    std::string_view sv;
+  //    sv = std::string(); // Here 'sv' is the 'Entity'.
+  //
+  //  2. In an function call involving a lifetime capture, this would be the
+  //  argument capturing the lifetime of another argument.
+  //    void addToSet(std::string_view s [[clang::lifetime_capture_by(sv)]],
----------------
bricknerb wrote:

Is sv here referring to sv in (1) or a typo?

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


More information about the cfe-commits mailing list