Sink DwarfDebug::constructLexicalScopeDIE into DwarfCompileUnit
[oota-llvm.git] / lib / CodeGen / AsmPrinter / DwarfCompileUnit.cpp
index 6a2561387d9e97307c0d527e3c1f7605dc40a651..225c2bf2847120f953f982bb2f4dd3c353eb3751 100644 (file)
@@ -376,7 +376,7 @@ void DwarfCompileUnit::constructScopeDIE(
                            std::make_move_iterator(Children.end()));
       return;
     }
-    ScopeDIE = DD->constructLexicalScopeDIE(*this, Scope);
+    ScopeDIE = constructLexicalScopeDIE(Scope);
     assert(ScopeDIE && "Scope DIE should not be null.");
   }
 
@@ -461,4 +461,20 @@ DwarfCompileUnit::constructInlinedScopeDIE(LexicalScope *Scope) {
   return ScopeDIE;
 }
 
+// Construct new DW_TAG_lexical_block for this scope and attach
+// DW_AT_low_pc/DW_AT_high_pc labels.
+std::unique_ptr<DIE>
+DwarfCompileUnit::constructLexicalScopeDIE(LexicalScope *Scope) {
+  if (DD->isLexicalScopeDIENull(Scope))
+    return nullptr;
+
+  auto ScopeDIE = make_unique<DIE>(dwarf::DW_TAG_lexical_block);
+  if (Scope->isAbstractScope())
+    return ScopeDIE;
+
+  attachRangesOrLowHighPC(*ScopeDIE, Scope->getRanges());
+
+  return ScopeDIE;
+}
+
 } // end llvm namespace