$ 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
llvm-svn: 94300
diff --git a/llvm-gcc-4.2/gcc/llvm-debug.cpp b/llvm-gcc-4.2/gcc/llvm-debug.cpp
index ae4d1ca..7fcff95 100644
--- a/llvm-gcc-4.2/gcc/llvm-debug.cpp
+++ b/llvm-gcc-4.2/gcc/llvm-debug.cpp
@@ -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;
diff --git a/llvm-gcc-4.2/gcc/llvm-debug.h b/llvm-gcc-4.2/gcc/llvm-debug.h
index ef5eea0..0e85a13 100644
--- a/llvm-gcc-4.2/gcc/llvm-debug.h
+++ b/llvm-gcc-4.2/gcc/llvm-debug.h
@@ -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