summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>2015-05-27 22:44:06 +0000
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>2015-05-27 22:44:06 +0000
commit88a8fc544848278660de7cfa2d39c4762918267c (patch)
treeaefe7ad72fac82a5eb0e450915039db9ffa8d5eb /llvm
parent825a7681db958ffeae039a2a82f0cbe5f497efac (diff)
downloadbcm5719-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')
-rw-r--r--llvm/include/llvm/CodeGen/DIE.h11
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp12
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/DIE.cpp8
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/DIEHash.cpp30
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/DIEHash.h2
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp4
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/DwarfFile.cpp7
-rw-r--r--llvm/tools/dsymutil/DwarfLinker.cpp34
8 files changed, 53 insertions, 55 deletions
diff --git a/llvm/include/llvm/CodeGen/DIE.h b/llvm/include/llvm/CodeGen/DIE.h
index 270fa5c7c8d..5a8f4915f5e 100644
--- a/llvm/include/llvm/CodeGen/DIE.h
+++ b/llvm/include/llvm/CodeGen/DIE.h
@@ -499,7 +499,16 @@ public:
const std::vector<std::unique_ptr<DIE>> &getChildren() const {
return Children;
}
- const SmallVectorImpl<DIEValue> &getValues() const { return Values; }
+
+ typedef SmallVectorImpl<DIEValue>::const_iterator value_iterator;
+ typedef iterator_range<value_iterator> value_range;
+
+ value_iterator begin_values() const { return Values.begin(); }
+ value_iterator end_values() const { return Values.end(); }
+ value_range values() const {
+ return llvm::make_range(begin_values(), end_values());
+ }
+
void setValue(unsigned I, DIEValue New) {
assert(I < Values.size());
Values[I] = New;
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();
diff --git a/llvm/tools/dsymutil/DwarfLinker.cpp b/llvm/tools/dsymutil/DwarfLinker.cpp
index 4e5cb735122..62f177008f0 100644
--- a/llvm/tools/dsymutil/DwarfLinker.cpp
+++ b/llvm/tools/dsymutil/DwarfLinker.cpp
@@ -68,11 +68,13 @@ struct PatchLocation {
PatchLocation() : Die(nullptr), Index(0) {}
PatchLocation(DIE &Die, unsigned Index) : Die(&Die), Index(Index) {}
+ PatchLocation(DIE &Die)
+ : Die(&Die), Index(std::distance(Die.begin_values(), Die.end_values())) {}
void set(uint64_t New) const {
assert(Die);
- assert(Index < Die->getValues().size());
- const auto &Old = Die->getValues()[Index];
+ assert(Index < std::distance(Die->begin_values(), Die->end_values()));
+ const auto &Old = Die->begin_values()[Index];
assert(Old.getType() == DIEValue::isInteger);
Die->setValue(Index,
DIEValue(Old.getAttribute(), Old.getForm(), DIEInteger(New)));
@@ -80,9 +82,9 @@ struct PatchLocation {
uint64_t get() const {
assert(Die);
- assert(Index < Die->getValues().size());
- assert(Die->getValues()[Index].getType() == DIEValue::isInteger);
- return Die->getValues()[Index].getDIEInteger().getValue();
+ assert(Index < std::distance(Die->begin_values(), Die->end_values()));
+ assert(Die->begin_values()[Index].getType() == DIEValue::isInteger);
+ return Die->begin_values()[Index].getDIEInteger().getValue();
}
};
@@ -1839,8 +1841,7 @@ unsigned DwarfLinker::cloneDieReferenceAttribute(
} else {
// A forward reference. Note and fixup later.
Attr = 0xBADDEF;
- Unit.noteForwardReference(NewRefDie, RefUnit,
- PatchLocation(Die, Die.getValues().size()));
+ Unit.noteForwardReference(NewRefDie, RefUnit, PatchLocation(Die));
}
Die.addValue(dwarf::Attribute(AttrSpec.Attr), dwarf::DW_FORM_ref_addr,
DIEInteger(Attr));
@@ -1956,14 +1957,13 @@ unsigned DwarfLinker::cloneScalarAttribute(
}
DIEInteger Attr(Value);
if (AttrSpec.Attr == dwarf::DW_AT_ranges)
- Unit.noteRangeAttribute(Die, PatchLocation(Die, Die.getValues().size()));
+ Unit.noteRangeAttribute(Die, PatchLocation(Die));
// A more generic way to check for location attributes would be
// nice, but it's very unlikely that any other attribute needs a
// location list.
else if (AttrSpec.Attr == dwarf::DW_AT_location ||
AttrSpec.Attr == dwarf::DW_AT_frame_base)
- Unit.noteLocationAttribute(PatchLocation(Die, Die.getValues().size()),
- Info.PCOffset);
+ Unit.noteLocationAttribute(PatchLocation(Die), Info.PCOffset);
else if (AttrSpec.Attr == dwarf::DW_AT_declaration && Value)
Info.IsDeclaration = true;
@@ -2329,13 +2329,13 @@ void DwarfLinker::patchLineTableForUnit(CompileUnit &Unit,
// Update the cloned DW_AT_stmt_list with the correct debug_line offset.
if (auto *OutputDIE = Unit.getOutputUnitDIE()) {
- const auto &Values = OutputDIE->getValues();
- auto Stmt =
- std::find_if(Values.begin(), Values.end(), [](const DIEValue &Value) {
- return Value.getAttribute() == dwarf::DW_AT_stmt_list;
- });
- assert(Stmt < Values.end() && "Didn't find DW_AT_stmt_list in cloned DIE!");
- OutputDIE->setValue(Stmt - Values.begin(),
+ auto Stmt = std::find_if(OutputDIE->begin_values(), OutputDIE->end_values(),
+ [](const DIEValue &Value) {
+ return Value.getAttribute() == dwarf::DW_AT_stmt_list;
+ });
+ assert(Stmt != OutputDIE->end_values() &&
+ "Didn't find DW_AT_stmt_list in cloned DIE!");
+ OutputDIE->setValue(Stmt - OutputDIE->begin_values(),
DIEValue(Stmt->getAttribute(), Stmt->getForm(),
DIEInteger(Streamer->getLineSectionSize())));
}
OpenPOWER on IntegriCloud