[clang] [Clang] Keep the immediate-invocation wrapper on a reused CXXTemporaryObjectExpr during instantiation (PR #221816)
Stanislav Bardyuk via cfe-commits
cfe-commits at lists.llvm.org
Fri Sep 11 04:42:46 PDT 2026
================
@@ -16183,7 +16183,12 @@ TreeTransform<Derived>::TransformCXXTemporaryObjectExpr(
!ArgumentChanged) {
// FIXME: Instantiation-specific
SemaRef.MarkFunctionReferenced(E->getBeginLoc(), Constructor);
- return SemaRef.MaybeBindToTemporary(E);
+ // The immediate-invocation wrapper was stripped by TransformConstantExpr;
+ // put it back before binding the temporary, as SemaInit does.
+ ExprResult Res = SemaRef.CheckForImmediateInvocation(E, Constructor);
+ if (Res.isInvalid())
+ return ExprError();
+ return SemaRef.MaybeBindToTemporary(Res.get());
----------------
kodlan wrote:
Done in the second commit. TransformConstantExpr now returns the original ConstantExpr, with its cached value when the subexpression comes back unchanged, so nothing is evaluated twice.
https://github.com/llvm/llvm-project/pull/221816
More information about the cfe-commits
mailing list