aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/AST/ByteCode/Compiler.cpp
diff options
context:
space:
mode:
authorTimm Baeder <tbaeder@redhat.com>2025-07-08 06:00:52 +0200
committerGitHub <noreply@github.com>2025-07-08 06:00:52 +0200
commit4c98da2cadfb23f6d4070db9136d8dc0a379bcc1 (patch)
tree9b546d23d9e48c50a60e46a19880ca7ab17d3a65 /clang/lib/AST/ByteCode/Compiler.cpp
parent862c2fc26eb1611e1c06dccaaa650fc29f2546de (diff)
downloadllvm-4c98da2cadfb23f6d4070db9136d8dc0a379bcc1.zip
llvm-4c98da2cadfb23f6d4070db9136d8dc0a379bcc1.tar.gz
llvm-4c98da2cadfb23f6d4070db9136d8dc0a379bcc1.tar.bz2
[clang][bytecode] Create a temporary for discarded CXXBindTemporaryExprs (#147303)
So we run the destructor.
Diffstat (limited to 'clang/lib/AST/ByteCode/Compiler.cpp')
-rw-r--r--clang/lib/AST/ByteCode/Compiler.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/clang/lib/AST/ByteCode/Compiler.cpp b/clang/lib/AST/ByteCode/Compiler.cpp
index d1c93e4..51c234d 100644
--- a/clang/lib/AST/ByteCode/Compiler.cpp
+++ b/clang/lib/AST/ByteCode/Compiler.cpp
@@ -2886,7 +2886,20 @@ bool Compiler<Emitter>::VisitMaterializeTemporaryExpr(
template <class Emitter>
bool Compiler<Emitter>::VisitCXXBindTemporaryExpr(
const CXXBindTemporaryExpr *E) {
- return this->delegate(E->getSubExpr());
+ const Expr *SubExpr = E->getSubExpr();
+
+ if (Initializing)
+ return this->delegate(SubExpr);
+
+ // Make sure we create a temporary even if we're discarding, since that will
+ // make sure we will also call the destructor.
+
+ if (!this->visit(SubExpr))
+ return false;
+
+ if (DiscardResult)
+ return this->emitPopPtr(E);
+ return true;
}
template <class Emitter>