summaryrefslogtreecommitdiffstats
path: root/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
diff options
context:
space:
mode:
authorGreg Clayton <gclayton@apple.com>2017-01-13 21:08:18 +0000
committerGreg Clayton <gclayton@apple.com>2017-01-13 21:08:18 +0000
commit97d22187d03848540559a1e32388c8d24987300b (patch)
tree5837a19551606a15806143e15dc237ed54890599 /llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
parent1ebfc59c894d4e22a8fd79aab14d6dfa2757a870 (diff)
downloadbcm5719-llvm-97d22187d03848540559a1e32388c8d24987300b.tar.gz
bcm5719-llvm-97d22187d03848540559a1e32388c8d24987300b.zip
Cleanup how DWARFDie attributes are accessed and decoded.
Removed all DWARFDie::getAttributeValueAs*() calls. Renamed: Optional<DWARFFormValue> DWARFDie::getAttributeValue(dwarf::Attribute); To: Optional<DWARFFormValue> DWARFDie::find(dwarf::Attribute); Added: Optional<DWARFFormValue> DWARFDie::findRecursively(dwarf::Attribute); All decoding of Optional<DWARFFormValue> values are now done using the dwarf::to*() functions from DWARFFormValue.h: Old code: auto DeclLine = DWARFDie.getAttributeValueAsSignedConstant(DW_AT_decl_line).getValueOr(0); New code: auto DeclLine = toUnsigned(DWARFDie.find(DW_AT_decl_line), 0); This composition helps us since we can now easily do: auto DeclLine = toUnsigned(DWARFDie.findRecursively(DW_AT_decl_line), 0); This allows us to easily find attribute values in the current DIE only (the first new code above) or in any DW_AT_abstract_origin or DW_AT_specification Dies using the line above. Note that the code line length is shorter and more concise. Differential Revision: https://reviews.llvm.org/D28581 llvm-svn: 291959
Diffstat (limited to 'llvm/lib/DebugInfo/DWARF/DWARFContext.cpp')
-rw-r--r--llvm/lib/DebugInfo/DWARF/DWARFContext.cpp5
1 files changed, 2 insertions, 3 deletions
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
index 77f6f65ee13..adc15b0481f 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
@@ -128,8 +128,7 @@ void DWARFContext::dump(raw_ostream &OS, DIDumpType DumpType, bool DumpEH,
auto CUDIE = CU->getUnitDIE();
if (!CUDIE)
continue;
- if (auto StmtOffset =
- CUDIE.getAttributeValueAsSectionOffset(DW_AT_stmt_list)) {
+ if (auto StmtOffset = toSectionOffset(CUDIE.find(DW_AT_stmt_list))) {
DataExtractor lineData(getLineSection().Data, isLittleEndian(),
savedAddressByteSize);
DWARFDebugLine::LineTable LineTable;
@@ -387,7 +386,7 @@ DWARFContext::getLineTableForUnit(DWARFUnit *U) {
if (!UnitDIE)
return nullptr;
- auto Offset = UnitDIE.getAttributeValueAsSectionOffset(DW_AT_stmt_list);
+ auto Offset = toSectionOffset(UnitDIE.find(DW_AT_stmt_list));
if (!Offset)
return nullptr; // No line table for this compile unit.
OpenPOWER on IntegriCloud