llvm/tools/obj2yaml
Greg Clayton beabb639c5 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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@291959 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-13 21:08:18 +00:00
..
CMakeLists.txt [obj2yaml] Refactor and abstract dwarf2yaml 2016-12-07 21:47:28 +00:00
coff2yaml.cpp
dwarf2yaml.cpp Cleanup how DWARFDie attributes are accessed and decoded. 2017-01-13 21:08:18 +00:00
elf2yaml.cpp [ELF] Convert ELF.h to Expected<T>. 2016-11-16 05:10:28 +00:00
Error.cpp
Error.h
macho2yaml.cpp [ObjectYAML] MachO support for endianness 2016-12-22 21:58:03 +00:00
obj2yaml.cpp
obj2yaml.h [ObjectYAML] Remove DWARF from class names 2016-12-08 17:46:57 +00:00