From cf60744cd73d284b40c14a73abeccde2711e4684 Mon Sep 17 00:00:00 2001 From: David Chisnall Date: Thu, 2 Sep 2010 18:01:51 +0000 Subject: Tidy up last commit, as per Devang's comments. llvm-svn: 112840 --- clang/lib/CodeGen/CGDebugInfo.cpp | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) (limited to 'clang/lib/CodeGen/CGDebugInfo.cpp') diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index d59faa16024..406db886eee 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/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(DC)) { + OS << OID->getName(); + } else if (const ObjCCategoryImplDecl *OCD = dyn_cast(DC)){ + OS << ((NamedDecl *)OCD)->getIdentifier()->getNameStart() << '(' << + OCD->getIdentifier()->getNameStart() << ')'; + } + OS << ' ' << OMD->getSelector().getAsString() << ']'; + + char *StrPtr = DebugInfoNames.Allocate(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(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(DC)) { - OS << OID->getName(); - } else if (const ObjCCategoryImplDecl *OCD = dyn_cast(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. -- cgit v1.2.3