diff options
author | Timm Baeder <tbaeder@redhat.com> | 2025-08-19 10:27:26 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-08-19 10:27:26 +0200 |
commit | da05208bfb6abde863882767e34d175aa170246b (patch) | |
tree | a4487cf05ef4b9c05310ddfb23c9d424dbffcf49 /clang/lib/AST/ByteCode/Compiler.cpp | |
parent | 5753ee2434de77394b4fe597dac77abac6d95add (diff) | |
download | llvm-da05208bfb6abde863882767e34d175aa170246b.zip llvm-da05208bfb6abde863882767e34d175aa170246b.tar.gz llvm-da05208bfb6abde863882767e34d175aa170246b.tar.bz2 |
[clang][bytecode] Create temporary before discarding CXXConstructExpr (#154280)
Fixes #154110
Diffstat (limited to 'clang/lib/AST/ByteCode/Compiler.cpp')
-rw-r--r-- | clang/lib/AST/ByteCode/Compiler.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/clang/lib/AST/ByteCode/Compiler.cpp b/clang/lib/AST/ByteCode/Compiler.cpp index f2ce69a..f7947bd 100644 --- a/clang/lib/AST/ByteCode/Compiler.cpp +++ b/clang/lib/AST/ByteCode/Compiler.cpp @@ -3181,13 +3181,6 @@ bool Compiler<Emitter>::VisitCXXConstructExpr(const CXXConstructExpr *E) { if (T->isRecordType()) { const CXXConstructorDecl *Ctor = E->getConstructor(); - // Trivial copy/move constructor. Avoid copy. - if (Ctor->isDefaulted() && Ctor->isCopyOrMoveConstructor() && - Ctor->isTrivial() && - E->getArg(0)->isTemporaryObject(Ctx.getASTContext(), - T->getAsCXXRecordDecl())) - return this->visitInitializer(E->getArg(0)); - // If we're discarding a construct expression, we still need // to allocate a variable and call the constructor and destructor. if (DiscardResult) { @@ -3203,6 +3196,13 @@ bool Compiler<Emitter>::VisitCXXConstructExpr(const CXXConstructExpr *E) { return false; } + // Trivial copy/move constructor. Avoid copy. + if (Ctor->isDefaulted() && Ctor->isCopyOrMoveConstructor() && + Ctor->isTrivial() && + E->getArg(0)->isTemporaryObject(Ctx.getASTContext(), + T->getAsCXXRecordDecl())) + return this->visitInitializer(E->getArg(0)); + // Zero initialization. if (E->requiresZeroInitialization()) { const Record *R = getRecord(E->getType()); |