This is an archive of the discontinued LLVM Phabricator instance.

Reset all options in cl::ResetCommandLineParser()
ClosedPublic

Authored by csigg on May 29 2021, 12:26 AM.

Details

Summary

Reset cl::Positional, cl::Sink and cl::ConsumeAfter options as well in cl::ResetCommandLineParser().

Diff Detail

Event Timeline

csigg created this revision.May 29 2021, 12:26 AM
csigg requested review of this revision.May 29 2021, 12:26 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 29 2021, 12:26 AM
csigg edited the summary of this revision. (Show Details)
rriddle accepted this revision.Jun 8 2021, 11:29 PM

This looks right to me, but might be good to get another LGTM.

This revision is now accepted and ready to land.Jun 8 2021, 11:29 PM
csigg updated this revision to Diff 351079.Jun 9 2021, 11:56 PM

Rebase.

csigg added a comment.Aug 11 2021, 6:53 AM

Sam, does this change look reasonable to you?

sammccall accepted this revision.Aug 12 2021, 9:53 AM

Sorry for the delay. I'm not really familiar with the code, but this seems right (not sure if it's bulletproof, but surely not worse).

llvm/lib/Support/CommandLine.cpp
1332

As I understand these will typically be in OptionsMap too, unless ArgStr happens to be empty.
So we're possibly resetting the same options multiple times, and that's OK because it's cheap and idempotent.

This all seems fine but I'd leave a comment at the top like "Reset all options at least once, it's okay if some get reset multiple times".

(An alternative is to track which ones have been reset, or add a member containing this, but it doesn't seem worth it)

This revision was automatically updated to reflect the committed changes.