]> granicus.if.org Git - clang/commitdiff
Handle static variables inside obj-c methods.
authorAnders Carlsson <andersca@mac.com>
Mon, 25 Aug 2008 01:38:19 +0000 (01:38 +0000)
committerAnders Carlsson <andersca@mac.com>
Mon, 25 Aug 2008 01:38:19 +0000 (01:38 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55297 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGDecl.cpp

index b60e20fda5ac334469d7b0c96f3389fa4e559292..c0ad1079bec7eaf1d415b4425729113e284b4e11 100644 (file)
@@ -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,