Page MenuHomePhabricator

[lldb][NFC] Allow range-based for loops over DWARFDIE's children
Needs ReviewPublic

Authored by teemperor on Wed, May 26, 8:39 AM.

Details

Reviewers
shafik
Group Reviewers
Restricted Project
Summary

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.

Diff Detail

Event Timeline

teemperor created this revision.Wed, May 26, 8:39 AM
teemperor requested review of this revision.Wed, May 26, 8:39 AM
shafik added inline comments.Wed, May 26, 1:30 PM
lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.h
117

I think:

bool operator==(const DWARFBaseDIE &lhs, const DWARFBaseDIE &rhs) {
  return lhs.GetDIE() == rhs.GetDIE() && lhs.GetCU() == rhs.GetCU();
}

will do the same thing but maybe I am confused.

Maybe we should have a unit test?