зеркало из https://github.com/microsoft/clang-1.git
Improve support for irgen of references.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72133 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
cd938172a4
Коммит
c8667a866b
|
@ -634,8 +634,10 @@ LValue CodeGenFunction::EmitDeclRefLValue(const DeclRefExpr *E) {
|
|||
LValue LV;
|
||||
bool GCable = VD->hasLocalStorage() && !VD->hasAttr<BlocksAttr>();
|
||||
if (VD->hasExternalStorage()) {
|
||||
LV = LValue::MakeAddr(CGM.GetAddrOfGlobalVar(VD),
|
||||
E->getType().getCVRQualifiers(),
|
||||
llvm::Value *V = CGM.GetAddrOfGlobalVar(VD);
|
||||
if (VD->getType()->isReferenceType())
|
||||
V = Builder.CreateLoad(V, "tmp");
|
||||
LV = LValue::MakeAddr(V, E->getType().getCVRQualifiers(),
|
||||
getContext().getObjCGCAttrKind(E->getType()));
|
||||
}
|
||||
else {
|
||||
|
@ -657,13 +659,17 @@ LValue CodeGenFunction::EmitDeclRefLValue(const DeclRefExpr *E) {
|
|||
V = Builder.CreateBitCast(V, PtrStructTy);
|
||||
V = Builder.CreateStructGEP(V, needsCopyDispose*2 + 4, "x");
|
||||
}
|
||||
if (VD->getType()->isReferenceType())
|
||||
V = Builder.CreateLoad(V, "tmp");
|
||||
LV = LValue::MakeAddr(V, E->getType().getCVRQualifiers(), attr);
|
||||
}
|
||||
LValue::SetObjCNonGC(LV, GCable);
|
||||
return LV;
|
||||
} else if (VD && VD->isFileVarDecl()) {
|
||||
LValue LV = LValue::MakeAddr(CGM.GetAddrOfGlobalVar(VD),
|
||||
E->getType().getCVRQualifiers(),
|
||||
llvm::Value *V = CGM.GetAddrOfGlobalVar(VD);
|
||||
if (VD->getType()->isReferenceType())
|
||||
V = Builder.CreateLoad(V, "tmp");
|
||||
LValue LV = LValue::MakeAddr(V, E->getType().getCVRQualifiers(),
|
||||
getContext().getObjCGCAttrKind(E->getType()));
|
||||
if (LV.isObjCStrong())
|
||||
LV.SetGlobalObjCRef(LV, true);
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
// RUN: clang-cc -verify -emit-llvm -o %t %s
|
||||
|
||||
void t1() {
|
||||
extern int& a;
|
||||
int b = a;
|
||||
}
|
||||
|
||||
void t2(int& a) {
|
||||
int b = a;
|
||||
}
|
||||
|
||||
int g;
|
||||
int& gr = g;
|
||||
void t3() {
|
||||
int b = gr;
|
||||
}
|
Загрузка…
Ссылка в новой задаче