[llvm-branch-commits] [clang] [clang] Introduce scopes for arguments without destructors (PR #191019)
Eli Friedman via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Wed Apr 8 17:05:07 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".
----------------
efriedma-quic wrote:
Consider:
```
struct S { int x; };
const int* f(const int* p) { return p; }
int g() {
return *f(&((const S&)S{2}).x);
}
```
The lifetime should last to the end of the full-expression. Scanning the argument types clearly won't catch this. Scanning the arguments is probably possible, but maybe tricky to get right.
https://github.com/llvm/llvm-project/pull/191019
More information about the llvm-branch-commits
mailing list