Include global types, that are referenced through local variables, in debug_pubtypes...
[oota-llvm.git] / lib / CodeGen / AsmPrinter / DwarfCompileUnit.cpp
index 9e4a61d52f65a97a7fe9cca96a8a75c61ef8f00f..5016c43aebea4f9ff27dbdb116f7a45a3a41535d 100644 (file)
@@ -605,8 +605,14 @@ void CompileUnit::addType(DIE *Entity, DIType Ty) {
   // Set up proxy.
   Entry = createDIEEntry(Buffer);
   insertDIEEntry(Ty, Entry);
-
   Entity->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, Entry);
+
+  // If this is a complete composite type then include it in the
+  // list of global types.
+  DIDescriptor Context = Ty.getContext();
+  if (Ty.isCompositeType() && !Ty.getName().empty() && !Ty.isForwardDecl() 
+      && (Context.isCompileUnit() || Context.isFile() || Context.isNameSpace()))
+    addGlobalType(Ty.getName(), Entry->getEntry());
 }
 
 /// addPubTypes - Add type for pubtypes section.