forked from OSchip/llvm-project
Don't assert/crash on reference variables in lambdas bound to a
static local variable from the parent scope. PR14773. llvm-svn: 171433
This commit is contained in:
parent
3fdcc0bda3
commit
33accdf602
|
@ -905,10 +905,8 @@ public:
|
||||||
if (!VD->hasLocalStorage()) {
|
if (!VD->hasLocalStorage()) {
|
||||||
if (VD->isFileVarDecl() || VD->hasExternalStorage())
|
if (VD->isFileVarDecl() || VD->hasExternalStorage())
|
||||||
return CGM.GetAddrOfGlobalVar(VD);
|
return CGM.GetAddrOfGlobalVar(VD);
|
||||||
else if (VD->isLocalVarDecl()) {
|
else if (VD->isLocalVarDecl())
|
||||||
assert(CGF && "Can't access static local vars without CGF");
|
return CGM.getStaticLocalDeclAddress(VD);
|
||||||
return CGF->GetAddrOfStaticLocalVar(VD);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -1687,11 +1687,6 @@ public:
|
||||||
/// then reuse it.
|
/// then reuse it.
|
||||||
void StartBlock(const char *N);
|
void StartBlock(const char *N);
|
||||||
|
|
||||||
/// GetAddrOfStaticLocalVar - Return the address of a static local variable.
|
|
||||||
llvm::Constant *GetAddrOfStaticLocalVar(const VarDecl *BVD) {
|
|
||||||
return cast<llvm::Constant>(GetAddrOfLocalVar(BVD));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// GetAddrOfLocalVar - Return the address of a local variable.
|
/// GetAddrOfLocalVar - Return the address of a local variable.
|
||||||
llvm::Value *GetAddrOfLocalVar(const VarDecl *VD) {
|
llvm::Value *GetAddrOfLocalVar(const VarDecl *VD) {
|
||||||
llvm::Value *Res = LocalDeclMap[VD];
|
llvm::Value *Res = LocalDeclMap[VD];
|
||||||
|
|
|
@ -80,9 +80,20 @@ int g() {
|
||||||
return [] { return r; } ();
|
return [] { return r; } ();
|
||||||
};
|
};
|
||||||
|
|
||||||
// CHECK: define internal void @"_ZZ1hvEN3$_78__invokeEv"(%struct.A* noalias sret %agg.result)
|
// PR14773
|
||||||
|
// CHECK: [[ARRVAL:%[0-9a-zA-Z]*]] = load i32* getelementptr inbounds ([0 x i32]* bitcast (<{}>* @_ZZ14staticarrayrefvE5array to [0 x i32]*), i32 0, i64 0), align 4
|
||||||
|
// CHECK-NEXT: store i32 [[ARRVAL]]
|
||||||
|
void staticarrayref(){
|
||||||
|
static int array[] = {};
|
||||||
|
(void)[](){
|
||||||
|
int (&xxx)[0] = array;
|
||||||
|
int y = xxx[0];
|
||||||
|
}();
|
||||||
|
}
|
||||||
|
|
||||||
|
// CHECK: define internal void @"_ZZ1hvEN3$_88__invokeEv"(%struct.A* noalias sret %agg.result)
|
||||||
// CHECK-NOT: =
|
// CHECK-NOT: =
|
||||||
// CHECK: call void @"_ZZ1hvENK3$_7clEv"(%struct.A* sret %agg.result,
|
// CHECK: call void @"_ZZ1hvENK3$_8clEv"(%struct.A* sret %agg.result,
|
||||||
// CHECK-NEXT: ret void
|
// CHECK-NEXT: ret void
|
||||||
struct A { ~A(); };
|
struct A { ~A(); };
|
||||||
void h() {
|
void h() {
|
||||||
|
|
Loading…
Reference in New Issue