[llvm-branch-commits] [clang] [clang] Introduce scopes for arguments without destructors (PR #191019)

Paul Kirth via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Wed Apr 8 16:06:49 PDT 2026


================
@@ -6872,6 +6893,15 @@ RValue CodeGenFunction::EmitCall(QualType CalleeType,
   assert(CalleeType->isFunctionPointerType() &&
          "Call must have function pointer type!");
 
+  // For calls with trivial aggregate arguments, we want to tighten the
+  // lifetime of those aggregates to end immediately after the call returns,
+  // rather than at the end of the full-expression. We create a nested cleanup
+  // scope to intercept these lifetime markers. However, we only do this if the
+  // call is "safe".
----------------
ilovepi wrote:

> Thinking about it a bit more, I'm actually not sure. I was thinking just "doesn't have any arguments that trigger isSafeToTightenLifetime", but I'm not sure if it's sufficient to check the types of the arguments. Any argument to a call can contain arbitrary temporaries in C++.

Are you saying its unsound to scan the arguments and determine if we can use a narrower scope? That the `isSafeToTightenLifetime()` is incomplete? or that the current implementation is just overly conservative?

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


More information about the llvm-branch-commits mailing list