[llvm-commits] [llvm-gcc-4.2] r91441 - in /llvm-gcc-4.2/trunk/gcc: llvm-debug.cpp llvm-debug.h
Devang Patel
dpatel at apple.com
Tue Dec 15 11:17:30 PST 2009
Author: dpatel
Date: Tue Dec 15 13:17:30 2009
New Revision: 91441
URL: http://llvm.org/viewvc/llvm-project?rev=91441&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=91441&r1=91440&r2=91441&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp Tue Dec 15 13:17:30 2009
@@ -263,10 +263,20 @@
Virtuality = dwarf::DW_VIRTUALITY_virtual;
ContainingType = getOrCreateType(DECL_CONTEXT (FnDecl));
}
+ bool UseModuleContext = false;
+ // If this artificial function has abstract origin then put this function
+ // at module scope. The abstract copy will be placed in appropriate region.
+ if (DECL_ABSTRACT_ORIGIN (FnDecl) != FnDecl
+ && DECL_ARTIFICIAL(FnDecl))
+ UseModuleContext = true;
+
+ const char *FnName = lang_hooks.dwarf_name(FnDecl, 0);
DISubprogram SP =
- DebugFactory.CreateSubprogram(findRegion(DECL_CONTEXT(FnDecl)),
- lang_hooks.dwarf_name(FnDecl, 0),
- lang_hooks.dwarf_name(FnDecl, 0),
+ DebugFactory.CreateSubprogram((UseModuleContext ?
+ getOrCreateCompileUnit(main_input_filename) :
+ findRegion(DECL_CONTEXT(FnDecl))),
+ (UseModuleContext ? FnName : StringRef()),
+ (UseModuleContext ? FnName : StringRef()),
LinkageName,
getOrCreateCompileUnit(Loc.file), lineno,
FNType,
@@ -282,7 +292,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);
@@ -295,8 +321,14 @@
if (TYPE_P (Node)) {
DIType Ty = getOrCreateType(Node);
return DIDescriptor(Ty.getNode());
- } else if (DECL_P (Node))
+ } else if (DECL_P (Node)) {
+ if (TREE_CODE (Node) == NAMESPACE_DECL) {
+ DIDescriptor NSContext = findRegion(DECL_CONTEXT(Node));
+ DINameSpace NS = getOrCreateNameSpace(Node, NSContext);
+ return DIDescriptor(NS.getNode());
+ }
return findRegion (DECL_CONTEXT (Node));
+ }
// 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=91441&r1=91440&r2=91441&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-debug.h (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-debug.h Tue Dec 15 13:17:30 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