[PATCH] D154475: [clang][Interp] Fix ignoring MaterializeTemporaryExprs
Timm Bäder via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Aug 1 00:46:04 PDT 2023
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG97cddb78502e: [clang][Interp] Fix ignoring MaterializeTemporaryExprs (authored by tbaeder).
Changed prior to commit:
https://reviews.llvm.org/D154475?vs=537230&id=545946#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D154475/new/
https://reviews.llvm.org/D154475
Files:
clang/lib/AST/Interp/ByteCodeExprGen.cpp
clang/test/AST/Interp/literals.cpp
Index: clang/test/AST/Interp/literals.cpp
===================================================================
--- clang/test/AST/Interp/literals.cpp
+++ clang/test/AST/Interp/literals.cpp
@@ -890,7 +890,9 @@
1 ? 0 : 1; // expected-warning {{unused}} \
// ref-warning {{unused}}
-
+ /// Ignored MaterializeTemporaryExpr.
+ struct B{ const int &a; };
+ (void)B{12};
return 0;
}
Index: clang/lib/AST/Interp/ByteCodeExprGen.cpp
===================================================================
--- clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -865,6 +865,11 @@
const Expr *SubExpr = E->getSubExpr();
std::optional<PrimType> SubExprT = classify(SubExpr);
+ // If we don't end up using the materialized temporary anyway, don't
+ // bother creating it.
+ if (DiscardResult)
+ return this->discard(SubExpr);
+
if (E->getStorageDuration() == SD_Static) {
if (std::optional<unsigned> GlobalIndex = P.createGlobal(E)) {
const LifetimeExtendedTemporaryDecl *TempDecl =
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D154475.545946.patch
Type: text/x-patch
Size: 1060 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230801/86faea24/attachment.bin>
More information about the cfe-commits
mailing list