From: Anders Carlsson Date: Sat, 7 Nov 2009 22:53:10 +0000 (+0000) Subject: More cleanup, the code is much easier to follow now. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1e74c4f0333b4730f44197d5e4615ea2b06599f4;p=clang More cleanup, the code is much easier to follow now. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86412 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp index 1a3fcc180a..1a06226bb2 100644 --- a/lib/CodeGen/CGExpr.cpp +++ b/lib/CodeGen/CGExpr.cpp @@ -814,12 +814,13 @@ static void setObjCGCLValueClass(const ASTContext &Ctx, const Expr *E, } LValue CodeGenFunction::EmitDeclRefLValue(const DeclRefExpr *E) { - const VarDecl *VD = dyn_cast(E->getDecl()); + const NamedDecl *ND = E->getDecl(); - if (VD && (VD->isBlockVarDecl() || isa(VD) || - isa(VD))) { + if (const VarDecl *VD = dyn_cast(ND)) { LValue LV; - if (VD->hasExternalStorage()) { + + // Check if this is a global variable. + if (VD->hasExternalStorage() || VD->isFileVarDecl()) { llvm::Value *V = CGM.GetAddrOfGlobalVar(VD); if (VD->getType()->isReferenceType()) V = Builder.CreateLoad(V, "tmp"); @@ -852,16 +853,7 @@ LValue CodeGenFunction::EmitDeclRefLValue(const DeclRefExpr *E) { return LV; } - if (VD && VD->isFileVarDecl()) { - llvm::Value *V = CGM.GetAddrOfGlobalVar(VD); - if (VD->getType()->isReferenceType()) - V = Builder.CreateLoad(V, "tmp"); - LValue LV = LValue::MakeAddr(V, MakeQualifiers(E->getType())); - setObjCGCLValueClass(getContext(), E, LV); - return LV; - } - - if (const FunctionDecl *FD = dyn_cast(E->getDecl())) { + if (const FunctionDecl *FD = dyn_cast(ND)) { llvm::Value* V = CGM.GetAddrOfFunction(FD); if (!FD->hasPrototype()) { if (const FunctionProtoType *Proto = @@ -878,20 +870,15 @@ LValue CodeGenFunction::EmitDeclRefLValue(const DeclRefExpr *E) { return LValue::MakeAddr(V, MakeQualifiers(E->getType())); } - if (const ImplicitParamDecl *IPD = dyn_cast(E->getDecl())){ - llvm::Value *V = LocalDeclMap[IPD]; - assert(V && "BlockVarDecl not entered in LocalDeclMap?"); - return LValue::MakeAddr(V, MakeQualifiers(E->getType())); - } - if (E->getQualifier()) { // FIXME: the qualifier check does not seem sufficient here - return EmitPointerToDataMemberLValue(cast(E->getDecl())); + return EmitPointerToDataMemberLValue(cast(ND)); } - assert(0 && "Unimp declref"); - //an invalid LValue, but the assert will - //ensure that this point is never reached. + assert(false && "Unhandled DeclRefExpr"); + + // an invalid LValue, but the assert will + // ensure that this point is never reached. return LValue(); }