This is an archive of the discontinued LLVM Phabricator instance.

[lld-macho][nfc] Parse more options using getLastArg{Value}
ClosedPublic

Authored by int3 on Mar 2 2021, 1:04 PM.

Details

Reviewers
smeenai
Group Reviewers
Restricted Project
Commits
rG1168736c6688: [lld-macho][nfc] Parse more options using getLastArg{Value}
Summary

The option-iterating loop should be reserved for options whose command-line
order is important. I think LLD-ELF follows a similar design.

Diff Detail

Event Timeline

int3 created this revision.Mar 2 2021, 1:04 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 2 2021, 1:04 PM
int3 requested review of this revision.Mar 2 2021, 1:04 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 2 2021, 1:04 PM
smeenai accepted this revision.Mar 2 2021, 4:43 PM
smeenai added a subscriber: smeenai.

I suppose it's more efficient to have a single iteration of the argument list, but I also don't think argument parsing efficiency matters at all (or at least doesn't matter enough for this change to be a problem), so LGTM.

This revision is now accepted and ready to land.Mar 2 2021, 4:43 PM
This revision was landed with ongoing or failed builds.Mar 3 2021, 12:52 PM
This revision was automatically updated to reflect the committed changes.
thakis added a subscriber: thakis.Mar 4 2021, 8:45 AM
thakis added inline comments.
lld/MachO/Driver.cpp
594

nit: the handle prefix is somewhat common for option handling cf eg handleUndefined in the ELF linker

int3 added inline comments.Mar 4 2021, 9:10 AM
lld/MachO/Driver.cpp
594

hm but the handle functions in ELF seem to take the arg / arg value. Whereas functions that take the ArgList and do both arg lookup + handling seem to be prefixed with get, e.g. getReproduceOption.