[llvm] r238468 - AsmPrinter: Stop exposing underlying DIE children list, NFC

Duncan P. N. Exon Smith dexonsmith at apple.com
Thu May 28 12:56:34 PDT 2015


Author: dexonsmith
Date: Thu May 28 14:56:34 2015
New Revision: 238468

URL: http://llvm.org/viewvc/llvm-project?rev=238468&view=rev
Log:
AsmPrinter: Stop exposing underlying DIE children list, NFC

Update `DIE` API to hide the implementation of `DIE::Children` so we can
swap it out.

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

Modified: llvm/trunk/include/llvm/CodeGen/DIE.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/DIE.h?rev=238468&r1=238467&r2=238468&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/DIE.h (original)
+++ llvm/trunk/include/llvm/CodeGen/DIE.h Thu May 28 14:56:34 2015
@@ -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;

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp?rev=238468&r1=238467&r2=238468&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp Thu May 28 14:56:34 2015
@@ -281,7 +281,7 @@ void AsmPrinter::emitDwarfDIE(const DIE
 
   // 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");

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DIEHash.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DIEHash.cpp?rev=238468&r1=238467&r2=238468&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DIEHash.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DIEHash.cpp Thu May 28 14:56:34 2015
@@ -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) {

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfFile.cpp?rev=238468&r1=238467&r2=238468&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfFile.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfFile.cpp Thu May 28 14:56:34 2015
@@ -105,15 +105,12 @@ unsigned DwarfFile::computeSizeAndOffset
     // 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.

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.h?rev=238468&r1=238467&r2=238468&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.h (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.h Thu May 28 14:56:34 2015
@@ -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.
   ///





More information about the llvm-commits mailing list