[clang] [Clang] Keep the immediate-invocation wrapper on a reused CXXTemporaryObjectExpr during instantiation (PR #221816)

Corentin Jabot via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 11 00:59:17 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());
----------------
cor3ntin wrote:

I think that we should try to preserve the ConstantExpr node in TransformConstantExpr, at least when the subexpression isn't modified by the transformation (but ideally in all cases).

`CheckForImmediateInvocation` is faily expensive and we should avoid doing that work multiple times if we can avoid it

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


More information about the cfe-commits mailing list