Add DwarfUnit::addGlobalType to match DwarfUnit::addGlobalName
authorDavid Blaikie <dblaikie@gmail.com>
Sun, 2 Nov 2014 06:06:14 +0000 (06:06 +0000)
committerDavid Blaikie <dblaikie@gmail.com>
Sun, 2 Nov 2014 06:06:14 +0000 (06:06 +0000)
(these will shortly become virtual, with a null implementation in
DwarfUnit (since type units don't have accelerator tables in the current
schema) and the current implementation down in DwarfCompileUnit, moving
the actual maps there too)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221082 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/AsmPrinter/DwarfUnit.cpp
lib/CodeGen/AsmPrinter/DwarfUnit.h

index c49edd8daca71201674e345a2f25ca2c6f765b2e..e523bb007bb1fc88c8c4d62684badeb14dd6fd88 100644 (file)
@@ -976,11 +976,9 @@ void DwarfUnit::updateAcceleratorTables(DIScope Context, DIType Ty,
     unsigned Flags = IsImplementation ? dwarf::DW_FLAG_type_implementation : 0;
     DD->addAccelType(Ty.getName(), TyDIE, Flags);
 
-    if ((!Context || Context.isCompileUnit() || Context.isFile() ||
-         Context.isNameSpace()) &&
-        getCUNode().getEmissionKind() != DIBuilder::LineTablesOnly)
-      GlobalTypes[getParentContextString(Context) + Ty.getName().str()] =
-          &TyDIE;
+    if (!Context || Context.isCompileUnit() || Context.isFile() ||
+        Context.isNameSpace())
+      addGlobalType(Ty, TyDIE, Context);
   }
 }
 
@@ -1013,6 +1011,14 @@ void DwarfUnit::addGlobalName(StringRef Name, DIE &Die, DIScope Context) {
   GlobalNames[FullName] = &Die;
 }
 
+/// Add a new global type to the unit.
+void DwarfUnit::addGlobalType(DIType Ty, const DIE &Die, DIScope Context) {
+  if (getCUNode().getEmissionKind() == DIBuilder::LineTablesOnly)
+    return;
+  std::string FullName = getParentContextString(Context) + Ty.getName().str();
+  GlobalTypes[FullName] = &Die;
+}
+
 /// getParentContextString - Walks the metadata parent chain in a language
 /// specific manner (using the compile unit language) and returns
 /// it as a string. This is done at the metadata level because DIEs may
index ce92b417536086d0ab79cd6aa487637a146dc373..fd3d6cb9ea683c9add37a496448c590ae9ef9d35 100644 (file)
@@ -174,10 +174,12 @@ public:
   /// context for a global name.
   std::string getParentContextString(DIScope Context) const;
 
-  /// addGlobalName - Add a new global entity to the compile unit.
-  ///
+  /// Add a new global name to the compile unit.
   void addGlobalName(StringRef Name, DIE &Die, DIScope Context);
 
+  /// Add a new global type to the compile unit.
+  void addGlobalType(DIType Ty, const DIE &Die, DIScope Context);
+
   /// addAccelNamespace - Add a new name to the namespace accelerator table.
   void addAccelNamespace(StringRef Name, const DIE &Die);