aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@mac.com>2008-08-25 01:38:19 +0000
committerAnders Carlsson <andersca@mac.com>2008-08-25 01:38:19 +0000
commit19567ee4314ad1bb5144efbb23442f6bc54cd16c (patch)
tree1d038a1fe4cb975dac342223d8376b4e09ea04ce /lib/CodeGen
parent6c2dae7923f887b5f7746dd84c2d9535eb2112c0 (diff)
Handle static variables inside obj-c methods.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55297 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen')
-rw-r--r--lib/CodeGen/CGDecl.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/CodeGen/CGDecl.cpp b/lib/CodeGen/CGDecl.cpp
index b60e20fda5..c0ad1079be 100644
--- a/lib/CodeGen/CGDecl.cpp
+++ b/lib/CodeGen/CGDecl.cpp
@@ -16,6 +16,7 @@
#include "CodeGenModule.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/Decl.h"
+#include "clang/AST/DeclObjC.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Basic/TargetInfo.h"
#include "llvm/GlobalVariable.h"
@@ -98,10 +99,13 @@ CodeGenFunction::GenerateStaticBlockVarDecl(const VarDecl &D,
assert(Init && "Unable to create initialiser for static decl");
std::string ContextName;
- if (const FunctionDecl * FD = dyn_cast<FunctionDecl>(CurFuncDecl))
+ if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(CurFuncDecl))
ContextName = FD->getName();
+ else if (isa<ObjCMethodDecl>(CurFuncDecl))
+ ContextName = std::string(CurFn->getNameStart(),
+ CurFn->getNameStart() + CurFn->getNameLen());
else
- assert(0 && "Unknown context for block var decl"); // FIXME Handle objc.
+ assert(0 && "Unknown context for block var decl");
llvm::GlobalValue *GV =
new llvm::GlobalVariable(Init->getType(), false,