From 2c7cce70cde14daffc6b056c468d138ba2116d12 Mon Sep 17 00:00:00 2001 From: "Duncan P. N. Exon Smith" Date: Thu, 28 May 2015 19:56:34 +0000 Subject: [PATCH] AsmPrinter: Stop exposing underlying DIE children list, NFC 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 | 8 ++++++-- lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp | 2 +- lib/CodeGen/AsmPrinter/DIEHash.cpp | 2 +- lib/CodeGen/AsmPrinter/DwarfFile.cpp | 7 ++----- lib/CodeGen/AsmPrinter/DwarfUnit.h | 2 +- 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/include/llvm/CodeGen/DIE.h b/include/llvm/CodeGen/DIE.h index efc27b340f8..464e0faa0ed 100644 --- a/include/llvm/CodeGen/DIE.h +++ b/include/llvm/CodeGen/DIE.h @@ -496,8 +496,12 @@ public: unsigned getOffset() const { return Offset; } unsigned getSize() const { return Size; } bool hasChildren() const { return !Children.empty(); } - const std::vector> &getChildren() const { - return Children; + + typedef std::vector>::const_iterator child_iterator; + typedef iterator_range child_range; + + child_range children() const { + return llvm::make_range(Children.begin(), Children.end()); } typedef SmallVectorImpl::const_iterator value_iterator; diff --git a/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp b/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp index 9a100e36f1b..7dbfddf6069 100644 --- a/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp +++ b/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp @@ -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"); diff --git a/lib/CodeGen/AsmPrinter/DIEHash.cpp b/lib/CodeGen/AsmPrinter/DIEHash.cpp index dcd9b3503b3..1445254e6c2 100644 --- a/lib/CodeGen/AsmPrinter/DIEHash.cpp +++ b/lib/CodeGen/AsmPrinter/DIEHash.cpp @@ -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) { diff --git a/lib/CodeGen/AsmPrinter/DwarfFile.cpp b/lib/CodeGen/AsmPrinter/DwarfFile.cpp index 1060366a8ba..5ef333c4cf4 100644 --- a/lib/CodeGen/AsmPrinter/DwarfFile.cpp +++ b/lib/CodeGen/AsmPrinter/DwarfFile.cpp @@ -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. diff --git a/lib/CodeGen/AsmPrinter/DwarfUnit.h b/lib/CodeGen/AsmPrinter/DwarfUnit.h index e7e8267e0ed..f56c9b4eb13 100644 --- a/lib/CodeGen/AsmPrinter/DwarfUnit.h +++ b/lib/CodeGen/AsmPrinter/DwarfUnit.h @@ -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. /// -- 2.34.1