diff options
author | Timm Baeder <tbaeder@redhat.com> | 2025-07-08 06:00:52 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-07-08 06:00:52 +0200 |
commit | 4c98da2cadfb23f6d4070db9136d8dc0a379bcc1 (patch) | |
tree | 9b546d23d9e48c50a60e46a19880ca7ab17d3a65 /clang/lib/AST/ByteCode/Compiler.cpp | |
parent | 862c2fc26eb1611e1c06dccaaa650fc29f2546de (diff) | |
download | llvm-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.cpp | 15 |
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> |