AsmPrinter: Stop exposing underlying DIE children list, NFC
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>
Thu, 28 May 2015 19:56:34 +0000 (19:56 +0000)
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>
Thu, 28 May 2015 19:56:34 +0000 (19:56 +0000)
Update `DIE` API to hide the implementation of `DIE::Children` so we can
swap it out.

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

include/llvm/CodeGen/DIE.h
lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp
lib/CodeGen/AsmPrinter/DIEHash.cpp
lib/CodeGen/AsmPrinter/DwarfFile.cpp
lib/CodeGen/AsmPrinter/DwarfUnit.h

index efc27b340f8c7bde475c7e9800fa96c4215402a5..464e0faa0ed3cb01399460e8e79b2dbf7aa6a9f6 100644 (file)
@@ -496,8 +496,12 @@ public:
   unsigned getOffset() const { return Offset; }
   unsigned getSize() const { return Size; }
   bool hasChildren() const { return !Children.empty(); }
-  const std::vector<std::unique_ptr<DIE>> &getChildren() const {
-    return Children;
+
+  typedef std::vector<std::unique_ptr<DIE>>::const_iterator child_iterator;
+  typedef iterator_range<child_iterator> child_range;
+
+  child_range children() const {
+    return llvm::make_range(Children.begin(), Children.end());
   }
 
   typedef SmallVectorImpl<DIEValue>::const_iterator value_iterator;
index 9a100e36f1b8f8e9d288d817f35096881517ee70..7dbfddf6069162b48d04ee5ff04f2b5e46a6a57f 100644 (file)
@@ -281,7 +281,7 @@ void AsmPrinter::emitDwarfDIE(const DIE &Die) const {
 
   // Emit the DIE children if any.
   if (Die.hasChildren()) {
-    for (auto &Child : Die.getChildren())
+    for (auto &Child : Die.children())
       emitDwarfDIE(*Child);
 
     OutStreamer->AddComment("End Of Children Mark");
index dcd9b3503b3cdf0f7e1e28fd0720b05d8e9346a1..1445254e6c284f0b4d0b5a2f8345ec1c61118ac2 100644 (file)
@@ -451,7 +451,7 @@ void DIEHash::computeHash(const DIE &Die) {
   addAttributes(Die);
 
   // Then hash each of the children of the DIE.
-  for (auto &C : Die.getChildren()) {
+  for (auto &C : Die.children()) {
     // 7.27 Step 7
     // If C is a nested type entry or a member function entry, ...
     if (isType(C->getTag()) || C->getTag() == dwarf::DW_TAG_subprogram) {
index 1060366a8ba313671e1e2cfba5c5af6b189c5ffb..5ef333c4cf4432c54cc6180840d47f042b3c091e 100644 (file)
@@ -105,15 +105,12 @@ unsigned DwarfFile::computeSizeAndOffset(DIE &Die, unsigned Offset) {
     // Size attribute value.
     Offset += V.SizeOf(Asm, V.getForm());
 
-  // Get the children.
-  const auto &Children = Die.getChildren();
-
   // Size the DIE children if any.
-  if (!Children.empty()) {
+  if (Die.hasChildren()) {
     (void)Abbrev;
     assert(Abbrev.hasChildren() && "Children flag not set");
 
-    for (auto &Child : Children)
+    for (auto &Child : Die.children())
       Offset = computeSizeAndOffset(*Child, Offset);
 
     // End of children marker.
index e7e8267e0ed14eb3ff29011dbbfe17a4310b305c..f56c9b4eb13e7239da058338a9b07f591e0f03f8 100644 (file)
@@ -143,7 +143,7 @@ public:
   void setDebugInfoOffset(unsigned DbgInfoOff) { DebugInfoOffset = DbgInfoOff; }
 
   /// \brief Return true if this compile unit has something to write out.
-  bool hasContent() const { return !UnitDie.getChildren().empty(); }
+  bool hasContent() const { return UnitDie.hasChildren(); }
 
   /// \brief Get string containing language specific context for a global name.
   ///