Sink DwarfDebug::createAndAddScopeChildren down into DwarfCompileUnit.

llvm-svn: 219437
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
index 13bd12e..ec5c2ba 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
@@ -599,8 +599,7 @@
   // Collect lexical scope children first.
   // ObjectPointer might be a local (non-argument) local variable if it's a
   // block's synthetic this pointer.
-  if (DIE *BlockObjPtr =
-          DD->createAndAddScopeChildren(*this, Scope, ScopeDIE)) {
+  if (DIE *BlockObjPtr = createAndAddScopeChildren(Scope, ScopeDIE)) {
     assert(!ObjectPointer && "multiple object pointers can't be described");
     ObjectPointer = BlockObjPtr;
   }
@@ -609,4 +608,17 @@
     addDIEEntry(ScopeDIE, dwarf::DW_AT_object_pointer, *ObjectPointer);
 }
 
+DIE *DwarfCompileUnit::createAndAddScopeChildren(LexicalScope *Scope,
+                                                 DIE &ScopeDIE) {
+  // We create children when the scope DIE is not null.
+  SmallVector<std::unique_ptr<DIE>, 8> Children;
+  DIE *ObjectPointer = createScopeChildrenDIE(Scope, Children);
+
+  // Add children
+  for (auto &I : Children)
+    ScopeDIE.addChild(std::move(I));
+
+  return ObjectPointer;
+}
+
 } // end llvm namespace
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h
index fb6a867..9b97a51 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h
@@ -118,6 +118,8 @@
 
   /// \brief Construct a DIE for this subprogram scope.
   void constructSubprogramScopeDIE(LexicalScope *Scope);
+
+  DIE *createAndAddScopeChildren(LexicalScope *Scope, DIE &ScopeDIE);
 };
 
 } // end llvm namespace
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
index 49afdf2..86fe1a9 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -330,19 +330,6 @@
   return !getLabelAfterInsn(Ranges.front().second);
 }
 
-DIE *DwarfDebug::createAndAddScopeChildren(DwarfCompileUnit &TheCU,
-                                           LexicalScope *Scope, DIE &ScopeDIE) {
-  // We create children when the scope DIE is not null.
-  SmallVector<std::unique_ptr<DIE>, 8> Children;
-  DIE *ObjectPointer = TheCU.createScopeChildrenDIE(Scope, Children);
-
-  // Add children
-  for (auto &I : Children)
-    ScopeDIE.addChild(std::move(I));
-
-  return ObjectPointer;
-}
-
 void DwarfDebug::constructAbstractSubprogramScopeDIE(DwarfCompileUnit &TheCU,
                                                      LexicalScope *Scope) {
   assert(Scope && Scope->getScopeNode());
@@ -380,7 +367,7 @@
 
   if (TheCU.getCUNode().getEmissionKind() != DIBuilder::LineTablesOnly)
     SPCU.addUInt(*AbsDef, dwarf::DW_AT_inline, None, dwarf::DW_INL_inlined);
-  if (DIE *ObjectPointer = createAndAddScopeChildren(SPCU, Scope, *AbsDef))
+  if (DIE *ObjectPointer = SPCU.createAndAddScopeChildren(Scope, *AbsDef))
     SPCU.addDIEEntry(*AbsDef, dwarf::DW_AT_object_pointer, *ObjectPointer);
 }
 
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h
index 7d72602..7ee0bc7 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h
@@ -682,9 +682,6 @@
   SmallVector<DbgVariable *, 8> &getCurrentFnArguments() {
     return CurrentFnArguments;
   }
-
-  DIE *createAndAddScopeChildren(DwarfCompileUnit &TheCU, LexicalScope *Scope,
-                                 DIE &ScopeDIE);
 };
 } // End of namespace llvm