In order for LLDB to be able to use the LLVM DWARF parser, it needs to be able to iterate across all attributes in a DWARFDie. This change adds a DWARFDie::attributes() function that allows easy iteration:
for (auto &AttrValue : CUDie.attributes()) { switch (AttrValue.Attr) { case DW_AT_name: if (auto Name = AttrValue.Value.getAsCString()) ... break; case DW_AT_declaration: if (auto Declaration = AttrValue.Value.getAsUnsignedConstant()) ... break; case DW_AT_low_pc: if (auto LowPC = AttrValue.Value.getAsAddress()) ... break; default: break; } }
Assert that the index is valid, rather than conditionalizing? Or is this an error case (Optional<Attribute> or ErrorOr<Attribute> might be more suitable then) that callers are expecting to handle/look for?