зеркало из https://github.com/microsoft/clang-1.git
Don't build an aggregate constructor loop when the constructor is trivial.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102912 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
33d73fa9db
Коммит
e99bdb6969
|
@ -465,11 +465,13 @@ static void EmitNewInitializer(CodeGenFunction &CGF, const CXXNewExpr *E,
|
|||
llvm::Value *NewPtr,
|
||||
llvm::Value *NumElements) {
|
||||
if (E->isArray()) {
|
||||
if (CXXConstructorDecl *Ctor = E->getConstructor())
|
||||
CGF.EmitCXXAggrConstructorCall(Ctor, NumElements, NewPtr,
|
||||
E->constructor_arg_begin(),
|
||||
E->constructor_arg_end());
|
||||
return;
|
||||
if (CXXConstructorDecl *Ctor = E->getConstructor()) {
|
||||
if (!Ctor->getParent()->hasTrivialConstructor())
|
||||
CGF.EmitCXXAggrConstructorCall(Ctor, NumElements, NewPtr,
|
||||
E->constructor_arg_begin(),
|
||||
E->constructor_arg_end());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
QualType AllocType = E->getAllocatedType();
|
||||
|
|
|
@ -96,3 +96,13 @@ void t11() {
|
|||
// CHECK: call void @llvm.memset.p0i8.i64(
|
||||
B* b = new B();
|
||||
}
|
||||
|
||||
struct Empty { };
|
||||
|
||||
// We don't need to initialize an empty class.
|
||||
void t12() {
|
||||
// CHECK: define void @_Z3t12v
|
||||
// CHECK-NOT: br label
|
||||
// CHECK: ret void
|
||||
(void)new Empty[10];
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче