[llvm-commits] [llvm-gcc-4.2] r90806 - in /llvm-gcc-4.2/trunk/gcc: llvm-debug.cpp llvm-debug.h
Devang Patel
dpatel at apple.com
Mon Dec 7 13:49:53 PST 2009
Author: dpatel
Date: Mon Dec 7 15:49:53 2009
New Revision: 90806
URL: http://llvm.org/viewvc/llvm-project?rev=90806&view=rev
Log:
Emit debug info for C++ namespaces.
Modified:
llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp
llvm-gcc-4.2/trunk/gcc/llvm-debug.h
Modified: llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp?rev=90806&r1=90805&r2=90806&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp Mon Dec 7 15:49:53 2009
@@ -282,7 +282,23 @@
RegionMap[FnDecl] = WeakVH(SP.getNode());
}
- /// findRegion - Find tree_node N's region.
+/// getOrCreateNameSpace - Get name space descriptor for the tree node.
+DINameSpace DebugInfo::getOrCreateNameSpace(tree Node, DIDescriptor Context) {
+ std::map<tree_node *, WeakVH >::iterator I =
+ NameSpaceCache.find(Node);
+ if (I != NameSpaceCache.end())
+ return DINameSpace(cast<MDNode>(I->second));
+
+ expanded_location Loc = GetNodeLocation(Node, false);
+ DINameSpace DNS =
+ DebugFactory.CreateNameSpace(Context, GetNodeName(Node),
+ getOrCreateCompileUnit(Loc.file), Loc.line);
+
+ NameSpaceCache[Node] = WeakVH(DNS.getNode());
+ return DNS;
+}
+
+/// findRegion - Find tree_node N's region.
DIDescriptor DebugInfo::findRegion(tree Node) {
if (Node == NULL_TREE)
return getOrCreateCompileUnit(main_input_filename);
@@ -293,8 +309,9 @@
return DIDescriptor(R);
if (TYPE_P (Node)) {
- if (TYPE_CONTEXT (Node))
+ if (TYPE_CONTEXT (Node)) {
return findRegion (TYPE_CONTEXT(Node));
+ }
} else if (DECL_P (Node)) {
tree decl = Node;
tree context = NULL_TREE;
@@ -304,10 +321,19 @@
context = TYPE_MAIN_VARIANT
(TREE_TYPE (TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (decl)))));
- if (context != NULL_TREE)
- return findRegion(context);
+ if (context != NULL_TREE) {
+ if (TREE_CODE(Node) == NAMESPACE_DECL) {
+ DIDescriptor Context = findRegion(context);
+ return getOrCreateNameSpace(Node, Context);
+ } else
+ return findRegion(context);
+ }
}
-
+
+ if (TREE_CODE(Node) == NAMESPACE_DECL)
+ return getOrCreateNameSpace(Node,
+ getOrCreateCompileUnit(main_input_filename));
+
// Otherwise main compile unit covers everything.
return getOrCreateCompileUnit(main_input_filename);
}
Modified: llvm-gcc-4.2/trunk/gcc/llvm-debug.h
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-debug.h?rev=90806&r1=90805&r2=90806&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-debug.h (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-debug.h Mon Dec 7 15:49:53 2009
@@ -68,6 +68,9 @@
std::map<tree_node *, WeakVH > SPCache;
// Cache of previously constructed
// Subprograms.
+ std::map<tree_node *, WeakVH> NameSpaceCache;
+ // Cache of previously constructed name
+ // spaces.
SmallVector<WeakVH, 4> RegionStack;
// Stack to track declarative scopes.
@@ -136,6 +139,9 @@
/// findRegion - Find tree_node N's region.
DIDescriptor findRegion(tree_node *n);
+
+ /// getOrCreateNameSpace - Get name space descriptor for the tree node.
+ DINameSpace getOrCreateNameSpace(tree_node *Node, DIDescriptor Context);
};
} // end namespace llvm
More information about the llvm-commits
mailing list