diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2010-04-18 21:01:23 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2010-04-18 21:01:23 +0000 |
commit | 3fef72f0ba99f01b67fc75b8409bdb6d442bd1e6 (patch) | |
tree | 14fe33d2904703e25455ed0415181ff83c4e9698 /clang/lib | |
parent | 7b056bfed007a0e090eca4894988ec4eda4df5d0 (diff) | |
download | bcm5719-llvm-3fef72f0ba99f01b67fc75b8409bdb6d442bd1e6.tar.gz bcm5719-llvm-3fef72f0ba99f01b67fc75b8409bdb6d442bd1e6.zip |
Local static variables must be available module-wise
as they are accessible in static methods in a class
local to the same function. Fixes PR6769.
llvm-svn: 101756
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/CodeGen/CGDecl.cpp | 1 | ||||
-rw-r--r-- | clang/lib/CodeGen/CGExpr.cpp | 2 | ||||
-rw-r--r-- | clang/lib/CodeGen/CodeGenModule.h | 9 |
3 files changed, 12 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CGDecl.cpp b/clang/lib/CodeGen/CGDecl.cpp index 07d219f1fbf..58b90929f04 100644 --- a/clang/lib/CodeGen/CGDecl.cpp +++ b/clang/lib/CodeGen/CGDecl.cpp @@ -205,6 +205,7 @@ void CodeGenFunction::EmitStaticBlockVarDecl(const VarDecl &D, // Store into LocalDeclMap before generating initializer to handle // circular references. DMEntry = GV; + CGM.setStaticLocalDeclMap(&D, GV); // Make sure to evaluate VLA bounds now so that we have them for later. // diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp index 68f09e2d290..257f2fc4f2f 100644 --- a/clang/lib/CodeGen/CGExpr.cpp +++ b/clang/lib/CodeGen/CGExpr.cpp @@ -1106,6 +1106,8 @@ LValue CodeGenFunction::EmitDeclRefLValue(const DeclRefExpr *E) { bool NonGCable = VD->hasLocalStorage() && !VD->hasAttr<BlocksAttr>(); llvm::Value *V = LocalDeclMap[VD]; + if (!V && VD->isStaticLocal()) + V = CGM.getStaticLocalDeclMap(VD); assert(V && "DeclRefExpr not entered in LocalDeclMap?"); Qualifiers Quals = MakeQualifiers(E->getType()); diff --git a/clang/lib/CodeGen/CodeGenModule.h b/clang/lib/CodeGen/CodeGenModule.h index 8db5a588d07..022360bfc52 100644 --- a/clang/lib/CodeGen/CodeGenModule.h +++ b/clang/lib/CodeGen/CodeGenModule.h @@ -133,6 +133,7 @@ class CodeGenModule : public BlockModule { llvm::StringMap<llvm::Constant*> CFConstantStringMap; llvm::StringMap<llvm::Constant*> ConstantStringMap; + llvm::DenseMap<const Decl*, llvm::Value*> StaticLocalDeclMap; /// CXXGlobalInits - Global variables with initializers that need to run /// before main. @@ -170,6 +171,14 @@ public: /// been configured. bool hasObjCRuntime() { return !!Runtime; } + llvm::Value *getStaticLocalDeclMap(const VarDecl *VD) { + return StaticLocalDeclMap[VD]; + } + void setStaticLocalDeclMap(const VarDecl *D, + llvm::GlobalVariable *GV) { + StaticLocalDeclMap[D] = GV; + } + CGDebugInfo *getDebugInfo() { return DebugInfo; } ASTContext &getContext() const { return Context; } const CodeGenOptions &getCodeGenOpts() const { return CodeGenOpts; } |