================
@@ -8244,11 +8229,33 @@ ExprResult Sema::IgnoredValueConversions(Expr *E) {
     //   If the expression is a prvalue after this optional conversion, the
     //   temporary materialization conversion is applied.
     //
-    // We skip this step: IR generation is able to synthesize the storage for
-    // itself in the aggregate case, and adding the extra node to the AST is
-    // just clutter.
-    // FIXME: We don't emit lifetime markers for the temporaries due to this.
-    // FIXME: Do any other AST consumers care about this?
+    // We do not materialize temporaries by default in order to avoid creating
+    // unnecessary temporary objects. If we skip this step, IR generation is
+    // able to synthesize the storage for itself in the aggregate case, and
+    // adding the extra node to the AST is just clutter.
+    if (ShouldMaterializePRValueInDiscardedExpression() &&
+        getLangOpts().CPlusPlus17 && E->isPRValue() &&
----------------
yronglin wrote:

AFAIK, https://en.cppreference.com/w/cpp/language/lifetime , since C++17, we 
should materialize temporary object when a prvalue appears as a 
[discarded-value 
expression](https://en.cppreference.com/w/cpp/language/expressions#Discarded-value_expressions),
 and the materialization of a temporary object is generally delayed as long as 
possible in order to avoid creating unnecessary temporary object, perviously, 
we ignored it, since this patch, we materialize temporary object once there 
requires to extending lifetime.

https://github.com/llvm/llvm-project/pull/76361
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to