In D61502#1503247 @clayborg suggested that DWARFUnit *+dw_offset_t can be now replaced by DWARFDIE.
Details
- Reviewers
clayborg labath - Commits
- rZORG307ada67354c: Simplify `GetName`+`AppendTypeName` by `DWARFDIE`
rG307ada67354c: Simplify `GetName`+`AppendTypeName` by `DWARFDIE`
rG19a3c307310f: Simplify `GetName`+`AppendTypeName` by `DWARFDIE`
rL361463: Simplify `GetName`+`AppendTypeName` by `DWARFDIE`
rLLDB361463: Simplify `GetName`+`AppendTypeName` by `DWARFDIE`
Diff Detail
- Repository
- rLLDB LLDB
Event Timeline
lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp | ||
---|---|---|
1073 | This deep nesting is a general coding style in LLDB so I try to keep it. Yes, I would like to (and I use elsewhere) early returns to keep the nesting low. I will submit another patch for it when you say it is OK to clean it up. | |
lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h | ||
129 | There was already const dw_offset_t but OK, I will remove it as it is probably a LLVM rule. |
The whole goal of the DWARFDebugInfoEntry::GetName() and DWARFDebugInfoEntry::AppendTypeName() we might be needing to dump the name of a DIE in DWARF that was not parsed yet. Like if a DIE has a forward reference to a DIE and we are trying to dump a DWARFDebugInfoEntry when things go wrong. If this is not needed then just move these functions into DWARFDIE.
We really shouldn't have any DWARFDIE references inside DWARFDebugInfoEntry.h. I noticed there are a lot now which is wrong.
I take this back. Many uses are good inside of DWARFDebugInfoEntry as I ok'ed patches when I looked at them. Initially this file was intended to be the level below DWARFDIE, but that has changed, and for good reason: make sure we never use the wrong DWARFUnit with a DWARFDebugInfoEntry. But my initial comment about moving the GetName and AppendTypeName still stand. If we aren't using these for forward references when we don't have all of the DWARFDebugInfoEntry objects parsed already, then they should be moved to DWARFDIE and removed from here.
Isn't all of this dead code? These functions seem to be only called from DWARFDebugInfoEntry::Dump, and I can find no callers of the Dump method.
If that's the case, what I'd do is delete all of this stuff, and then if we ever need to dump debug info entries again, implement a llvm-style dump method on the DWARFDIE class. This will move us closer to aligning lldb and llvm versions of these two classes.
I think it is still possible (and desirable) to maintain (or restore) the "DWARFDIE >> DWARFDebugInfoEntry" invariant, while still making sure that users don't have to remember which entry goes with which compile unit. The way to achieve that is by making that nobody (outside the DWARFDIE class, and maybe some other low-level stuff) deals with DWARFDebugInfoEntries directly). That's pretty much what was done in the llvm's version of the parser where DWARFDebugInfoEntry is an extremely dumb class with just 5 simple accessor functions, and all of the interesting stuff happens in DWARFDie.
I have moved it to DWARFDIE.cpp. I agree that it is probably all irrelevant after moving to the LLVM DWARF/ part. I have also removed return type as (1) it was wrong in one case and (2) no existing caller used the return type. I also refactored the deep nesting noted by @JDevlieghere.
I can also remove all the dumping code instead upon request, @labath.
lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp | ||
---|---|---|
1073 | The deep nesting is definitely a bug and not a feature. We've been removing it where it makes sense. |
Since we pass by value we can remove the const?