[lldb][NFC] Allow range-based for loops over DWARFDIE's children
authorRaphael Isemann <teemperor@gmail.com>
Thu, 22 Jul 2021 12:18:57 +0000 (14:18 +0200)
committerRaphael Isemann <teemperor@gmail.com>
Thu, 22 Jul 2021 13:03:30 +0000 (15:03 +0200)
commit77440d644b3ba26443c1d14d04a4046fab07d731
treee53a98cf2eec6226c32b2b3726f14a9a2e057701
parent312b43da05002bbe4a06de925e34b216252bc412
[lldb][NFC] Allow range-based for loops over DWARFDIE's children

This patch adds the ability to get a DWARFDIE's children as an LLVM range.

This way we can use for range loops to iterate over them and we can use LLVM's
algorithms like `llvm::all_of` to query all children.

The implementation has to do some small shenanigans as the iterator needs to
store a DWARFDIE, but a DWARFDIE container is also a DWARFDIE so it can't return
the iterator by value. I just made the `children` getter a templated function to
avoid the cyclic dependency.

Reviewed By: #lldb, werat, JDevlieghere

Differential Revision: https://reviews.llvm.org/D103172
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.h
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/unittests/SymbolFile/DWARF/CMakeLists.txt
lldb/unittests/SymbolFile/DWARF/DWARFDIETest.cpp [new file with mode: 0644]