diff options
| author | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2015-05-27 22:44:06 +0000 |
|---|---|---|
| committer | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2015-05-27 22:44:06 +0000 |
| commit | 88a8fc544848278660de7cfa2d39c4762918267c (patch) | |
| tree | aefe7ad72fac82a5eb0e450915039db9ffa8d5eb /llvm/lib/CodeGen | |
| parent | 825a7681db958ffeae039a2a82f0cbe5f497efac (diff) | |
| download | bcm5719-llvm-88a8fc544848278660de7cfa2d39c4762918267c.tar.gz bcm5719-llvm-88a8fc544848278660de7cfa2d39c4762918267c.zip | |
AsmPrinter: Stop exposing underlying DIEValue list, NFC
Change the `DIE` API to hide the implementation of the list of
`DIEValue`s.
llvm-svn: 238369
Diffstat (limited to 'llvm/lib/CodeGen')
| -rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp | 12 | ||||
| -rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DIE.cpp | 8 | ||||
| -rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DIEHash.cpp | 30 | ||||
| -rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DIEHash.h | 2 | ||||
| -rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp | 4 | ||||
| -rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DwarfFile.cpp | 7 |
6 files changed, 26 insertions, 37 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp index 38ebedc9939..9a100e36f1b 100644 --- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp @@ -262,23 +262,21 @@ void AsmPrinter::emitDwarfDIE(const DIE &Die) const { dwarf::TagString(Die.getTag())); EmitULEB128(Die.getAbbrevNumber()); - const SmallVectorImpl<DIEValue> &Values = Die.getValues(); - // Emit the DIE attribute values. - for (unsigned i = 0, N = Values.size(); i < N; ++i) { - dwarf::Attribute Attr = Values[i].getAttribute(); - dwarf::Form Form = Values[i].getForm(); + for (const auto &V : Die.values()) { + dwarf::Attribute Attr = V.getAttribute(); + dwarf::Form Form = V.getForm(); assert(Form && "Too many attributes for DIE (check abbreviation)"); if (isVerbose()) { OutStreamer->AddComment(dwarf::AttributeString(Attr)); if (Attr == dwarf::DW_AT_accessibility) OutStreamer->AddComment( - dwarf::AccessibilityString(Values[i].getDIEInteger().getValue())); + dwarf::AccessibilityString(V.getDIEInteger().getValue())); } // Emit an attribute using the defined form. - Values[i].EmitValue(this, Form); + V.EmitValue(this, Form); } // Emit the DIE children if any. diff --git a/llvm/lib/CodeGen/AsmPrinter/DIE.cpp b/llvm/lib/CodeGen/AsmPrinter/DIE.cpp index a899e34c7ee..fa8449e94c9 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DIE.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DIE.cpp @@ -136,13 +136,11 @@ const DIE *DIE::getUnitOrNull() const { } DIEValue DIE::findAttribute(dwarf::Attribute Attribute) const { - const SmallVectorImpl<DIEValue> &Values = getValues(); - // Iterate through all the attributes until we find the one we're // looking for, if we can't find it return NULL. - for (size_t i = 0; i < Values.size(); ++i) - if (Values[i].getAttribute() == Attribute) - return Values[i]; + for (const auto &V : values()) + if (V.getAttribute() == Attribute) + return V; return DIEValue(); } diff --git a/llvm/lib/CodeGen/AsmPrinter/DIEHash.cpp b/llvm/lib/CodeGen/AsmPrinter/DIEHash.cpp index 2a65760ce22..dcd9b3503b3 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DIEHash.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DIEHash.cpp @@ -31,14 +31,12 @@ using namespace llvm; /// \brief Grabs the string in whichever attribute is passed in and returns /// a reference to it. static StringRef getDIEStringAttr(const DIE &Die, uint16_t Attr) { - const auto &Values = Die.getValues(); - // Iterate through all the attributes until we find the one we're // looking for, if we can't find it return an empty string. - for (size_t i = 0; i < Values.size(); ++i) { - if (Values[i].getAttribute() == Attr) - return Values[i].getDIEString().getString(); - } + for (const auto &V : Die.values()) + if (V.getAttribute() == Attr) + return V.getDIEString().getString(); + return StringRef(""); } @@ -118,18 +116,16 @@ void DIEHash::addParentContext(const DIE &Parent) { // Collect all of the attributes for a particular DIE in single structure. void DIEHash::collectAttributes(const DIE &Die, DIEAttrs &Attrs) { - const SmallVectorImpl<DIEValue> &Values = Die.getValues(); - #define COLLECT_ATTR(NAME) \ case dwarf::NAME: \ - Attrs.NAME = Values[i]; \ + Attrs.NAME = V; \ break - for (size_t i = 0, e = Values.size(); i != e; ++i) { + for (const auto &V : Die.values()) { DEBUG(dbgs() << "Attribute: " - << dwarf::AttributeString(Values[i].getAttribute()) + << dwarf::AttributeString(V.getAttribute()) << " added.\n"); - switch (Values[i].getAttribute()) { + switch (V.getAttribute()) { COLLECT_ATTR(DW_AT_name); COLLECT_ATTR(DW_AT_accessibility); COLLECT_ATTR(DW_AT_address_class); @@ -267,9 +263,9 @@ void DIEHash::hashDIEEntry(dwarf::Attribute Attribute, dwarf::Tag Tag, // Hash all of the values in a block like set of values. This assumes that // all of the data is going to be added as integers. -void DIEHash::hashBlockData(const SmallVectorImpl<DIEValue> &Values) { - for (auto I = Values.begin(), E = Values.end(); I != E; ++I) - Hash.update((uint64_t)I->getDIEInteger().getValue()); +void DIEHash::hashBlockData(const DIE::value_range &Values) { + for (const auto &V : Values) + Hash.update((uint64_t)V.getDIEInteger().getValue()); } // Hash the contents of a loclistptr class. @@ -342,10 +338,10 @@ void DIEHash::hashAttribute(DIEValue Value, dwarf::Tag Tag) { addULEB128(dwarf::DW_FORM_block); if (Value.getType() == DIEValue::isBlock) { addULEB128(Value.getDIEBlock().ComputeSize(AP)); - hashBlockData(Value.getDIEBlock().getValues()); + hashBlockData(Value.getDIEBlock().values()); } else if (Value.getType() == DIEValue::isLoc) { addULEB128(Value.getDIELoc().ComputeSize(AP)); - hashBlockData(Value.getDIELoc().getValues()); + hashBlockData(Value.getDIELoc().values()); } else { // We could add the block length, but that would take // a bit of work and not add a lot of uniqueness diff --git a/llvm/lib/CodeGen/AsmPrinter/DIEHash.h b/llvm/lib/CodeGen/AsmPrinter/DIEHash.h index f47cd53cb30..1850e042f92 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DIEHash.h +++ b/llvm/lib/CodeGen/AsmPrinter/DIEHash.h @@ -128,7 +128,7 @@ private: /// \brief Hashes the data in a block like DIEValue, e.g. DW_FORM_block or /// DW_FORM_exprloc. - void hashBlockData(const SmallVectorImpl<DIEValue> &Values); + void hashBlockData(const DIE::value_range &Values); /// \brief Hashes the contents pointed to in the .debug_loc section. void hashLocList(const DIELocList &LocList); diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp index b59fb002f72..213e968e00b 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp @@ -242,7 +242,7 @@ void DwarfCompileUnit::initStmtList() { MCSymbol *LineTableStartSym = Asm->OutStreamer->getDwarfLineTableSymbol(getUniqueID()); - stmtListIndex = UnitDie.getValues().size(); + stmtListIndex = std::distance(UnitDie.begin_values(), UnitDie.end_values()); // DW_AT_stmt_list is a offset of line number information for this // compile unit in debug_line section. For split dwarf this is @@ -255,7 +255,7 @@ void DwarfCompileUnit::initStmtList() { } void DwarfCompileUnit::applyStmtList(DIE &D) { - D.addValue(UnitDie.getValues()[stmtListIndex]); + D.addValue(UnitDie.begin_values()[stmtListIndex]); } void DwarfCompileUnit::attachLowHighPC(DIE &D, const MCSymbol *Begin, diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfFile.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfFile.cpp index a9e9044a4d6..b1668658815 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfFile.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfFile.cpp @@ -97,13 +97,10 @@ unsigned DwarfFile::computeSizeAndOffset(DIE &Die, unsigned Offset) { // Start the size with the size of abbreviation code. Offset += getULEB128Size(Die.getAbbrevNumber()); - const SmallVectorImpl<DIEValue> &Values = Die.getValues(); - const SmallVectorImpl<DIEAbbrevData> &AbbrevData = Abbrev.getData(); - // Size the DIE attribute values. - for (unsigned i = 0, N = Values.size(); i < N; ++i) + for (const auto &V : Die.values()) // Size attribute value. - Offset += Values[i].SizeOf(Asm, AbbrevData[i].getForm()); + Offset += V.SizeOf(Asm, V.getForm()); // Get the children. const auto &Children = Die.getChildren(); |

