diff options
| author | Chris Lattner <sabre@nondot.org> | 2007-12-18 08:16:44 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2007-12-18 08:16:44 +0000 |
| commit | 37bd2ecb11f19a892bc4c7e59135106edca4341a (patch) | |
| tree | 059f925968aede841c8e31ad8c60ea4d716db1f8 /clang/CodeGen/CodeGenModule.cpp | |
| parent | d4fc27e9370c0f272e9800092e57936a67f22604 (diff) | |
| download | bcm5719-llvm-37bd2ecb11f19a892bc4c7e59135106edca4341a.tar.gz bcm5719-llvm-37bd2ecb11f19a892bc4c7e59135106edca4341a.zip | |
local static vars are globals also. This fixes a testcase
reported by Seo.
llvm-svn: 45156
Diffstat (limited to 'clang/CodeGen/CodeGenModule.cpp')
| -rw-r--r-- | clang/CodeGen/CodeGenModule.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/clang/CodeGen/CodeGenModule.cpp b/clang/CodeGen/CodeGenModule.cpp index a09932e141c..d6412a745ea 100644 --- a/clang/CodeGen/CodeGenModule.cpp +++ b/clang/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<DeclRefExpr>(ICExpr->getSubExpr()); - const FileVarDecl *FVD = cast<FileVarDecl>(DRE->getDecl()); - llvm::Constant *C = CGM.GetAddrOfFileVarDecl(FVD, false); + const VarDecl *VD = cast<VarDecl>(DRE->getDecl()); + llvm::Constant *C = CGM.GetAddrOfGlobalVar(VD, false); assert(isa<llvm::PointerType>(C->getType()) && isa<llvm::ArrayType>(cast<llvm::PointerType>(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<llvm::GlobalVariable>(GetAddrOfFileVarDecl(D, true)); + cast<llvm::GlobalVariable>(GetAddrOfGlobalVar(D, true)); // Convert the initializer, or use zero if appropriate. llvm::Constant *Init = 0; |

