]> granicus.if.org Git - clang/commitdiff
Tidy up last commit, as per Devang's comments.
authorDavid Chisnall <csdavec@swan.ac.uk>
Thu, 2 Sep 2010 18:01:51 +0000 (18:01 +0000)
committerDavid Chisnall <csdavec@swan.ac.uk>
Thu, 2 Sep 2010 18:01:51 +0000 (18:01 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112840 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGDebugInfo.cpp
lib/CodeGen/CGDebugInfo.h

index d59faa160242de1728c2a10a598c86b1db479266..406db886eeed3156da986df58c4f10c0b332a3a9 100644 (file)
@@ -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.
index fce66b25af07296f693059ebc4c7d502ac446c1d..a1ad012353e5bef102fb97cf57ee7f6b60592c71 100644 (file)
@@ -232,6 +232,9 @@ private:
   /// name is constructred on demand (e.g. C++ destructor) then the name
   /// is stored on the side.
   llvm::StringRef getFunctionName(const FunctionDecl *FD);
+  /// getObjCMethodName - Returns the unmangled name of an Objective-C method.
+  /// This is the display name for the debugging info.  
+  llvm::StringRef getObjCMethodName(const ObjCMethodDecl *FD);
 
   /// getClassName - Get class name including template argument list.
   llvm::StringRef getClassName(RecordDecl *RD);