[clang] [LifetimeSafety] Flow origins from lifetimebound args in `gsl::Pointer` construction (PR #189907)

Utkarsh Saxena via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 6 08:19:01 PDT 2026


================
@@ -712,6 +712,12 @@ void FactsGenerator::handleFunctionCall(const Expr *Call,
             CallList->getOuterOriginID(), ArgList->getOuterOriginID(),
             KillSrc));
         KillSrc = false;
+      } else if (IsArgLifetimeBound(I)) {
+        // A lifetimebound argument may affect the result at every origin level,
+        // so we propagate the whole OriginList instead of only the outermost
+        // origin.
+        flow(CallList, ArgList, KillSrc);
----------------
usx95 wrote:

I am not sure we want to flow all the origins. The origin shape can differ and this can cause the analysis to crash atm.

Since `lifetimebound` is not expressive enough for inner lifetimes, I think it makes sense to only flow outer origins.

Let's also add a test where this crashes currently.
```cpp
class [[gsl::Pointer]] Pointer {
Pointer(int**x [[clang::lifetimebound]]);
}
```

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


More information about the cfe-commits mailing list