[clang] [clang] Implement lifetime analysis for lifetime_capture_by(X) (PR #115921)

Utkarsh Saxena via cfe-commits cfe-commits at lists.llvm.org
Fri Nov 15 02:31:56 PST 2024


================
@@ -1420,9 +1446,18 @@ static void checkExprLifetimeImpl(Sema &SemaRef,
              ? IndirectLocalPathEntry::LifetimeBoundCall
              : IndirectLocalPathEntry::GslPointerAssignment,
          Init});
+  } else if (LK == LK_LifetimeCapture) {
+    Path.push_back({IndirectLocalPathEntry::LifetimeCapture, Init});
+    if (isRecordWithAttr<PointerAttr>(Init->getType()))
----------------
usx95 wrote:

Added this tests separately as well.
I am in favour of updating the documentation. I do not think we should treat `view` and `view&&` differently. So yeah `capture2_1` should be treated same as `capture2_2`.
Updated the documentation. Let me know if this is something not what you wanted.



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


More information about the cfe-commits mailing list