aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/AST/ByteCode/Compiler.cpp
diff options
context:
space:
mode:
authorTimm Baeder <tbaeder@redhat.com>2025-08-19 10:27:26 +0200
committerGitHub <noreply@github.com>2025-08-19 10:27:26 +0200
commitda05208bfb6abde863882767e34d175aa170246b (patch)
treea4487cf05ef4b9c05310ddfb23c9d424dbffcf49 /clang/lib/AST/ByteCode/Compiler.cpp
parent5753ee2434de77394b4fe597dac77abac6d95add (diff)
downloadllvm-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.cpp14
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());