forked from OSchip/llvm-project
Make heap-allocation of std::initializer_list 'work'.
llvm-svn: 150931
This commit is contained in:
parent
4e04dd1979
commit
d026dc499c
|
@ -456,7 +456,7 @@ static void EmitAggMemberInitializer(CodeGenFunction &CGF,
|
|||
|
||||
// Now, outside of the initializer cleanup scope, destroy the backing array
|
||||
// for a std::initializer_list member.
|
||||
CGF.MaybeEmitStdInitializerListCleanup(LV, Init);
|
||||
CGF.MaybeEmitStdInitializerListCleanup(LV.getAddress(), Init);
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -1093,7 +1093,7 @@ void CodeGenFunction::EmitExprAsInit(const Expr *init,
|
|||
AggValueSlot::IsDestructed,
|
||||
AggValueSlot::DoesNotNeedGCBarriers,
|
||||
AggValueSlot::IsNotAliased));
|
||||
MaybeEmitStdInitializerListCleanup(lvalue, init);
|
||||
MaybeEmitStdInitializerListCleanup(lvalue.getAddress(), init);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1263,19 +1263,17 @@ void CodeGenFunction::EmitAggregateCopy(llvm::Value *DestPtr,
|
|||
Alignment, isVolatile);
|
||||
}
|
||||
|
||||
void CodeGenFunction::MaybeEmitStdInitializerListCleanup(LValue lvalue,
|
||||
const Expr *init) {
|
||||
void CodeGenFunction::MaybeEmitStdInitializerListCleanup(llvm::Value *loc,
|
||||
const Expr *init) {
|
||||
const ExprWithCleanups *cleanups = dyn_cast<ExprWithCleanups>(init);
|
||||
if (!cleanups)
|
||||
return; // Nothing interesting here.
|
||||
init = cleanups->getSubExpr();
|
||||
if (cleanups)
|
||||
init = cleanups->getSubExpr();
|
||||
|
||||
if (isa<InitListExpr>(init) &&
|
||||
cast<InitListExpr>(init)->initializesStdInitializerList()) {
|
||||
// We initialized this std::initializer_list with an initializer list.
|
||||
// A backing array was created. Push a cleanup for it.
|
||||
EmitStdInitializerListCleanup(lvalue.getAddress(),
|
||||
cast<InitListExpr>(init));
|
||||
EmitStdInitializerListCleanup(loc, cast<InitListExpr>(init));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -762,6 +762,8 @@ static void StoreAnyExprIntoOneUnit(CodeGenFunction &CGF, const CXXNewExpr *E,
|
|||
AggValueSlot::DoesNotNeedGCBarriers,
|
||||
AggValueSlot::IsNotAliased);
|
||||
CGF.EmitAggExpr(Init, Slot);
|
||||
|
||||
CGF.MaybeEmitStdInitializerListCleanup(NewPtr, Init);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1811,7 +1811,7 @@ public:
|
|||
llvm::Value* EmitCXXTypeidExpr(const CXXTypeidExpr *E);
|
||||
llvm::Value *EmitDynamicCast(llvm::Value *V, const CXXDynamicCastExpr *DCE);
|
||||
|
||||
void MaybeEmitStdInitializerListCleanup(LValue lvalue, const Expr *init);
|
||||
void MaybeEmitStdInitializerListCleanup(llvm::Value *loc, const Expr *init);
|
||||
void EmitStdInitializerListCleanup(llvm::Value *loc,
|
||||
const InitListExpr *init);
|
||||
|
||||
|
|
|
@ -195,3 +195,23 @@ haslist2::haslist2()
|
|||
// CHECK: call void @_ZN10destroyme2D1Ev
|
||||
// CHECK: call void @_ZN10destroyme1D1Ev
|
||||
}
|
||||
|
||||
void fn10() {
|
||||
// CHECK: define void @_Z4fn10v
|
||||
// CHECK: alloca [3 x i32]
|
||||
// CHECK: call noalias i8* @_Znwm
|
||||
// CHECK: store i32 1
|
||||
// CHECK: store i32 2
|
||||
// CHECK: store i32 3
|
||||
// CHECK: store i32*
|
||||
// CHECK: store i{{32|64}} 3
|
||||
(void) new std::initializer_list<int> {1, 2, 3};
|
||||
}
|
||||
|
||||
void fn11() {
|
||||
// CHECK: define void @_Z4fn11v
|
||||
(void) new std::initializer_list<destroyme1> {destroyme1(), destroyme1()};
|
||||
// CHECK: call void @_ZN10destroyme1D1Ev
|
||||
destroyme2 dm2;
|
||||
// CHECK: call void @_ZN10destroyme2D1Ev
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue