Handle global variable definitions which change the type of a definition, such as:
extern int x[];
void foo() { x[0] = 1; }
int x[10];
void bar() { x[0] = 1; }
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@44509 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/CodeGen/CGExpr.cpp b/CodeGen/CGExpr.cpp
index 93f3d71..e7bd712 100644
--- a/CodeGen/CGExpr.cpp
+++ b/CodeGen/CGExpr.cpp
@@ -268,8 +268,10 @@
llvm::Value *V = LocalDeclMap[D];
assert(V && "BlockVarDecl not entered in LocalDeclMap?");
return LValue::MakeAddr(V);
- } else if (isa<FunctionDecl>(D) || isa<FileVarDecl>(D)) {
- return LValue::MakeAddr(CGM.GetAddrOfGlobalDecl(D));
+ } else if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
+ return LValue::MakeAddr(CGM.GetAddrOfFunctionDecl(FD, false));
+ } else if (const FileVarDecl *FVD = dyn_cast<FileVarDecl>(D)) {
+ return LValue::MakeAddr(CGM.GetAddrOfFileVarDecl(FVD, false));
}
assert(0 && "Unimp declref");
//an invalid LValue, but the assert will