[cfe-commits] r55250 - /cfe/trunk/lib/CodeGen/CGCXX.cpp
Anders Carlsson
andersca at mac.com
Sat Aug 23 12:42:54 PDT 2008
Author: andersca
Date: Sat Aug 23 14:42:54 2008
New Revision: 55250
URL: http://llvm.org/viewvc/llvm-project?rev=55250&view=rev
Log:
Handle static initializers in Objective-C++ methods.
Modified:
cfe/trunk/lib/CodeGen/CGCXX.cpp
Modified: cfe/trunk/lib/CodeGen/CGCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCXX.cpp?rev=55250&r1=55249&r2=55250&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCXX.cpp Sat Aug 23 14:42:54 2008
@@ -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 @@
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 @@
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!");
}
More information about the cfe-commits
mailing list