AsmPrinter: Stop exposing underlying DIEValue list, NFC
Change the `DIE` API to hide the implementation of the list of
`DIEValue`s.
llvm-svn: 238369
diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp
index 38ebedc..9a100e3 100644
--- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp
@@ -262,23 +262,21 @@
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 a899e34..fa8449e 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DIE.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DIE.cpp
@@ -136,13 +136,11 @@
}
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 2a65760..dcd9b35 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DIEHash.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DIEHash.cpp
@@ -31,14 +31,12 @@
/// \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 @@
// 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 @@
// 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 @@
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 f47cd53..1850e04 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DIEHash.h
+++ b/llvm/lib/CodeGen/AsmPrinter/DIEHash.h
@@ -128,7 +128,7 @@
/// \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 b59fb00..213e968 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
@@ -242,7 +242,7 @@
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::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 a9e9044..b166865 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfFile.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfFile.cpp
@@ -97,13 +97,10 @@
// 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();