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

Gábor Horváth via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 1 05:33:17 PDT 2026


================
@@ -704,10 +704,10 @@ void FactsGenerator::handleFunctionCall(const Expr *Call,
         assert(!Args[I]->isGLValue() || ArgList->getLength() >= 2);
         ArgList = getRValueOrigins(Args[I], ArgList);
       }
-      if (isGslOwnerType(Args[I]->getType())) {
-        // The constructed gsl::Pointer borrows from the Owner's storage, not
-        // from what the Owner itself borrows, so only the outermost origin is
-        // needed.
+      if (isGslOwnerType(Args[I]->getType()) || IsArgLifetimeBound(I)) {
+        // The constructed gsl::Pointer is dependent on the argument itself, not
----------------
Xazax-hun wrote:

> Hmmm... they appear to be exactly the same. I also tried running the code with a debugger, but it seems like even in the new code in flow only 1 iteration happens. Well this is really weird.

The one iteration makes sense to me as we do not have loops here. Also, the CFG supposed to be the same, this PR does not change that. The difference is the flow facts that we generate that are different from the CFG itself.

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


More information about the cfe-commits mailing list