diff options
author | Anders Carlsson <andersca@mac.com> | 2008-08-23 19:42:54 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2008-08-23 19:42:54 +0000 |
commit | 86e9644199d91a33d0090395395bc718bd3a4981 (patch) | |
tree | 262173aa504953555acdd89e9c3c2381b16ae8f1 /lib/CodeGen/CGCXX.cpp | |
parent | 7267f7832e5f0c7f951765e201c5a2650eb1637b (diff) |
Handle static initializers in Objective-C++ methods.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55250 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGCXX.cpp')
-rw-r--r-- | lib/CodeGen/CGCXX.cpp | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/lib/CodeGen/CGCXX.cpp b/lib/CodeGen/CGCXX.cpp index 76e044bd9f..e12a68b4a7 100644 --- a/lib/CodeGen/CGCXX.cpp +++ b/lib/CodeGen/CGCXX.cpp @@ -17,6 +17,7 @@ #include "CodeGenModule.h" #include "clang/AST/ASTContext.h" #include "clang/AST/Decl.h" +#include "clang/AST/DeclObjC.h" #include "llvm/ADT/StringExtras.h" using namespace clang; @@ -29,10 +30,11 @@ using llvm::utostr; static void mangleDeclContextInternal(const DeclContext *D, std::string &S) { - assert(isa<TranslationUnitDecl>(D->getParent()) && + // FIXME: Should ObjcMethodDecl have the TranslationUnitDecl as its parent? + assert(!D->getParent() || isa<TranslationUnitDecl>(D->getParent()) && "Only one level of decl context mangling is currently supported!"); - if (FunctionDecl* FD = dyn_cast<FunctionDecl>(D)) { + if (const FunctionDecl* FD = dyn_cast<FunctionDecl>(D)) { S += utostr(FD->getIdentifier()->getLength()); S += FD->getIdentifier()->getName(); @@ -40,6 +42,18 @@ static void mangleDeclContextInternal(const DeclContext *D, std::string &S) S += 'v'; else assert(0 && "mangling of types not supported yet!"); + } else if (const ObjCMethodDecl* MD = dyn_cast<ObjCMethodDecl>(D)) { + + // FIXME: This should really use GetNameForMethod from CGObjCMac. + std::string Name; + Name += MD->isInstance() ? '-' : '+'; + Name += '['; + Name += MD->getClassInterface()->getName(); + Name += ' '; + Name += MD->getSelector().getName(); + Name += ']'; + S += utostr(Name.length()); + S += Name; } else assert(0 && "Unsupported decl type!"); } |