Skip to content

Commit eb4089a

Browse files
committed
Only trigger the initialize-an-array-via-elementwise-copy/move code
generation when we're dealing with an implicitly-defined copy or move constructor. And, actually set the implicitly-defined bit for implicitly-defined constructors and destructors. Should fix self-host. llvm-svn: 140334
1 parent 0e4fcb8 commit eb4089a

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

clang/lib/CodeGen/CGClass.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,8 @@ static void EmitMemberInitializer(CodeGenFunction &CGF,
573573
llvm::Value *ArrayIndexVar = 0;
574574
const ConstantArrayType *Array
575575
= CGF.getContext().getAsConstantArrayType(FieldType);
576-
if (Array && Constructor->isCopyOrMoveConstructor()) {
576+
if (Array && Constructor->isImplicitlyDefined() &&
577+
Constructor->isCopyOrMoveConstructor()) {
577578
llvm::Type *SizeTy
578579
= CGF.ConvertType(CGF.getContext().getSizeType());
579580

clang/lib/Sema/SemaDeclCXX.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6963,7 +6963,7 @@ void Sema::DefineImplicitDestructor(SourceLocation CurrentLocation,
69636963

69646964
SourceLocation Loc = Destructor->getLocation();
69656965
Destructor->setBody(new (Context) CompoundStmt(Context, 0, 0, Loc, Loc));
6966-
6966+
Destructor->setImplicitlyDefined(true);
69676967
Destructor->setUsed();
69686968
MarkVTableUsed(CurrentLocation, ClassDecl);
69696969

@@ -8301,10 +8301,10 @@ void Sema::DefineImplicitCopyConstructor(SourceLocation CurrentLocation,
83018301
MultiStmtArg(*this, 0, 0),
83028302
/*isStmtExpr=*/false)
83038303
.takeAs<Stmt>());
8304+
CopyConstructor->setImplicitlyDefined(true);
83048305
}
83058306

83068307
CopyConstructor->setUsed();
8307-
83088308
if (ASTMutationListener *L = getASTMutationListener()) {
83098309
L->CompletedImplicitDefinition(CopyConstructor);
83108310
}
@@ -8464,6 +8464,7 @@ void Sema::DefineImplicitMoveConstructor(SourceLocation CurrentLocation,
84648464
MultiStmtArg(*this, 0, 0),
84658465
/*isStmtExpr=*/false)
84668466
.takeAs<Stmt>());
8467+
MoveConstructor->setImplicitlyDefined(true);
84678468
}
84688469

84698470
MoveConstructor->setUsed();

0 commit comments

Comments
 (0)