This is an archive of the discontinued LLVM Phabricator instance.

[lldb] Remove FileSpec->CompileUnit inheritance
ClosedPublic

Authored by labath on Nov 28 2019, 7:34 AM.

Details

Summary

CompileUnit is a complicated class. Having it be implicitly convertible
to a FileSpec makes reasoning about it even harder.

This patch replaces the inheritance by a simple member and an accessor
function. This avoid the need for casting in places where one needed to
force a CompileUnit to be treated as a FileSpec, and does not add much
verbosity elsewhere.

It also fixes a bug where we were wrongly comparing CompileUnit& and a
CompileUnit*, which compiled due to a combination of this inheritance
and the FileSpec*->FileSpec implicit constructor.

Diff Detail

Event Timeline

labath created this revision.Nov 28 2019, 7:34 AM
Herald added a project: Restricted Project. · View Herald Transcript
labath marked 2 inline comments as done.Nov 28 2019, 7:39 AM
labath added inline comments.
lldb/source/Commands/CommandObjectThread.cpp
1196

The reason the is equivalent is a bit unobvious. CompileUnit::FindLineEntry will automatically pick the primary file (the support file at index zero) if this argument is null.

lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
607

This used to be a pointer comparison, until the type of comp_unit was changed to a reference in D56564, and the whole thing still miraculously compiled.

labath updated this revision to Diff 231438.Nov 28 2019, 7:47 AM
  • add doxygen for the new member
  • avoid using the magic pointer constructor in SearchFilter.cpp
teemperor accepted this revision.Nov 29 2019, 1:20 AM
This revision is now accepted and ready to land.Nov 29 2019, 1:20 AM
This revision was automatically updated to reflect the committed changes.

Awesome, thank you! This has been on my todo-list for awhile :-)