diff options
author | David Chisnall <csdavec@swan.ac.uk> | 2010-09-02 18:01:51 +0000 |
---|---|---|
committer | David Chisnall <csdavec@swan.ac.uk> | 2010-09-02 18:01:51 +0000 |
commit | 52044a2cb6d33705cb69577e5f202e794123ce81 (patch) | |
tree | e1b00ff6e975b9d4e58b8ff51b5a7789e5acd698 /lib/CodeGen/CGDebugInfo.cpp | |
parent | 3f0ce9c3ab04d0edb8d28145a8feb4abaa8fb8e6 (diff) |
Tidy up last commit, as per Devang's comments.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112840 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGDebugInfo.cpp')
-rw-r--r-- | lib/CodeGen/CGDebugInfo.cpp | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp index d59faa1602..406db886ee 100644 --- a/lib/CodeGen/CGDebugInfo.cpp +++ b/lib/CodeGen/CGDebugInfo.cpp @@ -95,6 +95,24 @@ llvm::StringRef CGDebugInfo::getFunctionName(const FunctionDecl *FD) { return llvm::StringRef(StrPtr, NS.length()); } +llvm::StringRef CGDebugInfo::getObjCMethodName(const ObjCMethodDecl *OMD) { + llvm::SmallString<256> MethodName; + llvm::raw_svector_ostream OS(MethodName); + OS << (OMD->isInstanceMethod() ? '-' : '+') << '['; + const DeclContext *DC = OMD->getDeclContext(); + if (const ObjCImplementationDecl *OID = dyn_cast<const ObjCImplementationDecl>(DC)) { + OS << OID->getName(); + } else if (const ObjCCategoryImplDecl *OCD = dyn_cast<const ObjCCategoryImplDecl>(DC)){ + OS << ((NamedDecl *)OCD)->getIdentifier()->getNameStart() << '(' << + OCD->getIdentifier()->getNameStart() << ')'; + } + OS << ' ' << OMD->getSelector().getAsString() << ']'; + + char *StrPtr = DebugInfoNames.Allocate<char>(OS.tell()); + memcpy(StrPtr, MethodName.begin(), OS.tell()); + return llvm::StringRef(StrPtr, OS.tell()); +} + /// getClassName - Get class name including template argument list. llvm::StringRef CGDebugInfo::getClassName(RecordDecl *RD) { @@ -1472,18 +1490,7 @@ void CGDebugInfo::EmitFunctionStart(GlobalDecl GD, QualType FnType, // Use mangled name as linkage name for c/c++ functions. LinkageName = CGM.getMangledName(GD); } else if (const ObjCMethodDecl *OMD = dyn_cast<ObjCMethodDecl>(D)) { - llvm::SmallString<256> MethodName; - llvm::raw_svector_ostream OS(MethodName); - OS << (OMD->isInstanceMethod() ? '-' : '+') << '['; - const DeclContext *DC = OMD->getDeclContext(); - if (const ObjCImplementationDecl *OID = dyn_cast<const ObjCImplementationDecl>(DC)) { - OS << OID->getName(); - } else if (const ObjCCategoryImplDecl *OCD = dyn_cast<const ObjCCategoryImplDecl>(DC)){ - OS << ((NamedDecl *)OCD)->getIdentifier()->getNameStart() << '(' << - OCD->getIdentifier()->getNameStart() << ')'; - } - OS << ' ' << OMD->getSelector().getAsString() << ']'; - Name = MethodName; + Name = getObjCMethodName(OMD); LinkageName = Name; } else { // Use llvm function name as linkage name. |