[llvm-branch-commits] [llvm-gcc-branch] r94300 - in /llvm-gcc-4.2/branches/Apple/Zoidberg/gcc: llvm-debug.cpp llvm-debug.h

Bill Wendling isanbard at gmail.com
Fri Jan 22 23:49:22 PST 2010


Author: void
Date: Sat Jan 23 01:49:21 2010
New Revision: 94300

URL: http://llvm.org/viewvc/llvm-project?rev=94300&view=rev
Log:
$ svn merge -c 93972 https://llvm.org/svn/llvm-project/llvm-gcc-4.2/trunk
--- Merging r93972 into '.':
U    gcc/llvm-debug.cpp
U    gcc/llvm-debug.h


Modified:
    llvm-gcc-4.2/branches/Apple/Zoidberg/gcc/llvm-debug.cpp
    llvm-gcc-4.2/branches/Apple/Zoidberg/gcc/llvm-debug.h

Modified: llvm-gcc-4.2/branches/Apple/Zoidberg/gcc/llvm-debug.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/branches/Apple/Zoidberg/gcc/llvm-debug.cpp?rev=94300&r1=94299&r2=94300&view=diff

==============================================================================
--- llvm-gcc-4.2/branches/Apple/Zoidberg/gcc/llvm-debug.cpp (original)
+++ llvm-gcc-4.2/branches/Apple/Zoidberg/gcc/llvm-debug.cpp Sat Jan 23 01:49:21 2010
@@ -228,6 +228,25 @@
     return false;
 }
 
+/// getFunctionName - Get function name for the given FnDecl. If the
+/// name is constructred on demand (e.g. C++ destructor) then the name
+/// is stored on the side.
+StringRef DebugInfo::getFunctionName(tree FnDecl) {
+  StringRef FnNodeName = GetNodeName(FnDecl);
+  // Use dwarf_name to construct function names. In C++ this is used to
+  // create human readable destructor names.
+  StringRef FnName = lang_hooks.dwarf_name(FnDecl, 0);
+  if (FnNodeName.equals(FnName))
+    return FnNodeName;
+
+  // Use name returned by dwarf_name. It is in a temp. storage so make a 
+  // copy first.
+  char *StrPtr = FunctionNames.Allocate<char>(FnName.size() + 1);
+  strncpy(StrPtr, FnName.data(), FnName.size());
+  StrPtr[FnName.size()] = NULL;
+  return StringRef(StrPtr);
+}
+
 // Starting at the 'desired' BLOCK, recursively walk back to the
 // 'grand' context, and return pushing regions to make 'desired' the
 // current context.  Assumes 'grand' is a
@@ -308,7 +327,8 @@
       && DECL_ABSTRACT_ORIGIN (FnDecl) != FnDecl)
     ArtificialFnWithAbstractOrigin = true;
 
-  StringRef FnName = GetNodeName(FnDecl);
+  StringRef FnName = getFunctionName(FnDecl);
+
   DISubprogram SP = 
     DebugFactory.CreateSubprogram(ArtificialFnWithAbstractOrigin ?
                                   getOrCreateCompileUnit(main_input_filename) :
@@ -922,7 +942,7 @@
     else {
       // Get the location of the member.
       expanded_location MemLoc = GetNodeLocation(Member, false);
-      StringRef MemberName = GetNodeName(Member);        
+      StringRef MemberName = getFunctionName(Member);
       StringRef LinkageName = getLinkageName(Member);
       DIType SPTy = getOrCreateType(TREE_TYPE(Member));
       unsigned Virtuality = 0;

Modified: llvm-gcc-4.2/branches/Apple/Zoidberg/gcc/llvm-debug.h
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/branches/Apple/Zoidberg/gcc/llvm-debug.h?rev=94300&r1=94299&r2=94300&view=diff

==============================================================================
--- llvm-gcc-4.2/branches/Apple/Zoidberg/gcc/llvm-debug.h (original)
+++ llvm-gcc-4.2/branches/Apple/Zoidberg/gcc/llvm-debug.h Sat Jan 23 01:49:21 2010
@@ -32,6 +32,7 @@
 #include "llvm/Analysis/DebugInfo.h"
 #include "llvm/Support/Dwarf.h"
 #include "llvm/Support/ValueHandle.h"
+#include "llvm/Support/Allocator.h"
 
 extern "C" {
 #include "llvm.h"
@@ -72,6 +73,7 @@
   std::map<tree_node *, WeakVH> NameSpaceCache;
                                         // Cache of previously constructed name 
                                         // spaces.
+
   SmallVector<WeakVH, 4> RegionStack;
                                         // Stack to track declarative scopes.
   
@@ -79,7 +81,11 @@
 
   void push_regions(tree_node *desired, tree_node *grand);
 
-public:
+  /// FunctionNames - This is a storage for function names that are
+  /// constructed on demand. For example, C++ destructors, C++ operators etc..
+  llvm::BumpPtrAllocator FunctionNames;
+
+ public:
   DebugInfo(Module *m);
 
   /// Initialize - Initialize debug info by creating compile unit for
@@ -151,6 +157,11 @@
   
   /// getOrCreateNameSpace - Get name space descriptor for the tree node.
   DINameSpace getOrCreateNameSpace(tree_node *Node, DIDescriptor Context);
+
+  /// getFunctionName - Get function name for the given FnDecl. If the
+  /// name is constructred on demand (e.g. C++ destructor) then the name
+  /// is stored on the side.
+  StringRef getFunctionName(tree_node *FnDecl);
 };
 
 } // end namespace llvm





More information about the llvm-branch-commits mailing list