parent
2ff6395ddc
commit
ea4c30b39a
|
@ -813,21 +813,27 @@ static void setObjCGCLValueClass(const ASTContext &Ctx, const Expr *E,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static LValue EmitGlobalVarDeclLValue(CodeGenFunction &CGF,
|
||||||
|
const Expr *E, const VarDecl *VD) {
|
||||||
|
assert(VD->hasExternalStorage() || VD->isFileVarDecl() &&
|
||||||
|
"Var decl must have external storage or be a file var decl!");
|
||||||
|
|
||||||
|
llvm::Value *V = CGF.CGM.GetAddrOfGlobalVar(VD);
|
||||||
|
if (VD->getType()->isReferenceType())
|
||||||
|
V = CGF.Builder.CreateLoad(V, "tmp");
|
||||||
|
LValue LV = LValue::MakeAddr(V, CGF.MakeQualifiers(E->getType()));
|
||||||
|
setObjCGCLValueClass(CGF.getContext(), E, LV);
|
||||||
|
return LV;
|
||||||
|
}
|
||||||
|
|
||||||
LValue CodeGenFunction::EmitDeclRefLValue(const DeclRefExpr *E) {
|
LValue CodeGenFunction::EmitDeclRefLValue(const DeclRefExpr *E) {
|
||||||
const NamedDecl *ND = E->getDecl();
|
const NamedDecl *ND = E->getDecl();
|
||||||
|
|
||||||
if (const VarDecl *VD = dyn_cast<VarDecl>(ND)) {
|
if (const VarDecl *VD = dyn_cast<VarDecl>(ND)) {
|
||||||
LValue LV;
|
|
||||||
|
|
||||||
// Check if this is a global variable.
|
// Check if this is a global variable.
|
||||||
if (VD->hasExternalStorage() || VD->isFileVarDecl()) {
|
if (VD->hasExternalStorage() || VD->isFileVarDecl())
|
||||||
llvm::Value *V = CGM.GetAddrOfGlobalVar(VD);
|
return EmitGlobalVarDeclLValue(*this, E, VD);
|
||||||
if (VD->getType()->isReferenceType())
|
|
||||||
V = Builder.CreateLoad(V, "tmp");
|
|
||||||
LV = LValue::MakeAddr(V, MakeQualifiers(E->getType()));
|
|
||||||
setObjCGCLValueClass(getContext(), E, LV);
|
|
||||||
return LV;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool NonGCable = VD->hasLocalStorage() && !VD->hasAttr<BlocksAttr>();
|
bool NonGCable = VD->hasLocalStorage() && !VD->hasAttr<BlocksAttr>();
|
||||||
|
|
||||||
|
@ -847,7 +853,7 @@ LValue CodeGenFunction::EmitDeclRefLValue(const DeclRefExpr *E) {
|
||||||
}
|
}
|
||||||
if (VD->getType()->isReferenceType())
|
if (VD->getType()->isReferenceType())
|
||||||
V = Builder.CreateLoad(V, "tmp");
|
V = Builder.CreateLoad(V, "tmp");
|
||||||
LV = LValue::MakeAddr(V, Quals);
|
LValue LV = LValue::MakeAddr(V, Quals);
|
||||||
LValue::SetObjCNonGC(LV, NonGCable);
|
LValue::SetObjCNonGC(LV, NonGCable);
|
||||||
setObjCGCLValueClass(getContext(), E, LV);
|
setObjCGCLValueClass(getContext(), E, LV);
|
||||||
return LV;
|
return LV;
|
||||||
|
@ -1140,14 +1146,17 @@ LValue CodeGenFunction::EmitMemberExpr(const MemberExpr *E) {
|
||||||
BaseQuals = BaseTy.getQualifiers();
|
BaseQuals = BaseTy.getQualifiers();
|
||||||
}
|
}
|
||||||
|
|
||||||
FieldDecl *Field = dyn_cast<FieldDecl>(E->getMemberDecl());
|
NamedDecl *ND = E->getMemberDecl();
|
||||||
// FIXME: Handle non-field member expressions
|
if (FieldDecl *Field = dyn_cast<FieldDecl>(ND)) {
|
||||||
assert(Field && "No code generation for non-field member references");
|
LValue LV = EmitLValueForField(BaseValue, Field, isUnion,
|
||||||
LValue MemExpLV = EmitLValueForField(BaseValue, Field, isUnion,
|
|
||||||
BaseQuals.getCVRQualifiers());
|
BaseQuals.getCVRQualifiers());
|
||||||
LValue::SetObjCNonGC(MemExpLV, isNonGC);
|
LValue::SetObjCNonGC(LV, isNonGC);
|
||||||
setObjCGCLValueClass(getContext(), E, MemExpLV);
|
setObjCGCLValueClass(getContext(), E, LV);
|
||||||
return MemExpLV;
|
return LV;
|
||||||
|
}
|
||||||
|
|
||||||
|
assert(false && "Unhandled member declaration!");
|
||||||
|
return LValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
LValue CodeGenFunction::EmitLValueForBitfield(llvm::Value* BaseValue,
|
LValue CodeGenFunction::EmitLValueForBitfield(llvm::Value* BaseValue,
|
||||||
|
|
Loading…
Reference in New Issue