[cfe-commits] r112840 - in /cfe/trunk/lib/CodeGen: CGDebugInfo.cpp CGDebugInfo.h

Fariborz Jahanian fjahanian at apple.com
Thu Sep 2 11:45:16 PDT 2010


Please  refactor MiscNameMangler::mangleObjCMethodName to use in both  
places. It is two risky to have both.

- Fariborz

On Sep 2, 2010, at 11:01 AM, David Chisnall wrote:

> Author: theraven
> Date: Thu Sep  2 13:01:51 2010
> New Revision: 112840
>
> URL: http://llvm.org/viewvc/llvm-project?rev=112840&view=rev
> Log:
> Tidy up last commit, as per Devang's comments.
>
>
> Modified:
>    cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
>    cfe/trunk/lib/CodeGen/CGDebugInfo.h
>
> Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=112840&r1=112839&r2=112840&view=diff
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> ======================================================================
> --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Thu Sep  2 13:01:51 2010
> @@ -95,6 +95,24 @@
>   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 @@
>     // 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.
>
> Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.h?rev=112840&r1=112839&r2=112840&view=diff
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> ======================================================================
> --- cfe/trunk/lib/CodeGen/CGDebugInfo.h (original)
> +++ cfe/trunk/lib/CodeGen/CGDebugInfo.h Thu Sep  2 13:01:51 2010
> @@ -232,6 +232,9 @@
>   /// 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);
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits




More information about the cfe-commits mailing list