This is an archive of the discontinued LLVM Phabricator instance.

[NFC] Refactor and improve comments in CommandObjectTarget
ClosedPublic

Authored by amccarth on Nov 19 2019, 12:55 PM.

Details

Reviewers
labath
Summary

Made small improvements while debugging through CommandObjectTarget::AddModuleSymbols.

  1. Refactored error case for an early out, reducing the indentation of the rest of this long function.
  2. Clarified some comments by correcting spelling and punctuation.
  3. Reduced duplicate code at the end of the function.

Tested with ninja check-lldb

Diff Detail

Event Timeline

amccarth created this revision.Nov 19 2019, 12:55 PM
labath added inline comments.Nov 20 2019, 12:35 AM
lldb/source/Commands/CommandObjectTarget.cpp
4059

This does change behavior because previously the symbol file directory wasn't being copied. I think that was intentional because the comment on line 4112 says "match up the file by basename" (and it also makes sense because if you're adding symbols in an external file, then the main module file cannot be the exact same path as the symbol file).

amccarth marked 2 inline comments as done.Nov 20 2019, 11:44 AM
amccarth added inline comments.
lldb/source/Commands/CommandObjectTarget.cpp
4059

Oops. Thanks for catching that.

ModuleSpec seems weird: It exposes an internal members to be tweaked in arbitrary ways. I would have expected that it would have to react to certain kinds of changes to keep itself consistent. If it has no invariants to enforce, it could have been a plain struct with a bunch of public member variables.

amccarth updated this revision to Diff 230303.Nov 20 2019, 11:45 AM
amccarth marked an inline comment as done.

Reverted unintended change caught by reviewer.

labath accepted this revision.Nov 21 2019, 5:49 AM
labath added inline comments.
lldb/source/Commands/CommandObjectTarget.cpp
4059

This isn't really a matter of internal consistency. Both things make sense -- sometimes you want to match an actual full path, and sometimes only the basename.

That said, module spec does not have any internal consistency checks, and I don't think any are needed, so I think that replacing all the getters with public members would be a good idea.

This revision is now accepted and ready to land.Nov 21 2019, 5:49 AM
amccarth closed this revision.Dec 19 2019, 9:30 AM

This landed in 3b69f0c5550a229dd6d39e361182cdd7cecc36a4, but there was a typo in the patch description so the tools didn't automatically close this.