From 2b9d2ca4ce53fffbe8a77c7db2fe4df5ccfb9fd4 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Tue, 18 Dec 2007 08:16:44 +0000 Subject: local static vars are globals also. This fixes a testcase reported by Seo. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@45156 91177308-0d34-0410-b5e6-96231b3b80d8 --- CodeGen/CodeGenModule.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'CodeGen/CodeGenModule.cpp') diff --git a/CodeGen/CodeGenModule.cpp b/CodeGen/CodeGenModule.cpp index a09932e141..d6412a745e 100644 --- a/CodeGen/CodeGenModule.cpp +++ b/CodeGen/CodeGenModule.cpp @@ -113,8 +113,10 @@ llvm::Constant *CodeGenModule::GetAddrOfFunctionDecl(const FunctionDecl *D, return Entry = NewFn; } -llvm::Constant *CodeGenModule::GetAddrOfFileVarDecl(const FileVarDecl *D, - bool isDefinition) { +llvm::Constant *CodeGenModule::GetAddrOfGlobalVar(const VarDecl *D, + bool isDefinition) { + assert(D->hasGlobalStorage() && "Not a global variable"); + // See if it is already in the map. llvm::Constant *&Entry = GlobalDeclMap[D]; if (Entry) return Entry; @@ -433,8 +435,8 @@ static llvm::Constant *GenerateConstantExpr(const Expr *Expression, // The only thing that can have array type like this is a // DeclRefExpr(FileVarDecl)? const DeclRefExpr *DRE = cast(ICExpr->getSubExpr()); - const FileVarDecl *FVD = cast(DRE->getDecl()); - llvm::Constant *C = CGM.GetAddrOfFileVarDecl(FVD, false); + const VarDecl *VD = cast(DRE->getDecl()); + llvm::Constant *C = CGM.GetAddrOfGlobalVar(VD, false); assert(isa(C->getType()) && isa(cast(C->getType()) ->getElementType())); @@ -486,7 +488,7 @@ void CodeGenModule::EmitGlobalVar(const FileVarDecl *D) { // Get the global, forcing it to be a direct reference. llvm::GlobalVariable *GV = - cast(GetAddrOfFileVarDecl(D, true)); + cast(GetAddrOfGlobalVar(D, true)); // Convert the initializer, or use zero if appropriate. llvm::Constant *Init = 0; -- cgit v1.2.3-18-g5258