diff options
author | Christian Sigg <csigg@google.com> | 2021-06-10 08:56:15 +0200 |
---|---|---|
committer | Christian Sigg <csigg@google.com> | 2021-08-16 09:56:22 +0200 |
commit | 93c55d5ea24b8f455b0621bac373f142e0008739 (patch) | |
tree | b51d51fd8c416e5604a550c0030bf0c72cec5c9e /llvm/lib/Support/CommandLine.cpp | |
parent | 7185007735cd08a1928765f08301c48382c6222e (diff) | |
download | llvm-93c55d5ea24b8f455b0621bac373f142e0008739.zip llvm-93c55d5ea24b8f455b0621bac373f142e0008739.tar.gz llvm-93c55d5ea24b8f455b0621bac373f142e0008739.tar.bz2 |
Reset all options in cl::ResetCommandLineParser()
Reset cl::Positional, cl::Sink and cl::ConsumeAfter options as well in cl::ResetCommandLineParser().
Reviewed By: rriddle, sammccall
Differential Revision: https://reviews.llvm.org/D103356
Diffstat (limited to 'llvm/lib/Support/CommandLine.cpp')
-rw-r--r-- | llvm/lib/Support/CommandLine.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/llvm/lib/Support/CommandLine.cpp b/llvm/lib/Support/CommandLine.cpp index 6c14086..e64934a 100644 --- a/llvm/lib/Support/CommandLine.cpp +++ b/llvm/lib/Support/CommandLine.cpp @@ -1321,12 +1321,20 @@ bool cl::ParseCommandLineOptions(int argc, const char *const *argv, Errs, LongOptionsUseDoubleDash); } +/// Reset all options at least once, so that we can parse different options. void CommandLineParser::ResetAllOptionOccurrences() { - // So that we can parse different command lines multiple times in succession - // we reset all option values to look like they have never been seen before. + // Reset all option values to look like they have never been seen before. + // Options might be reset twice (they can be reference in both OptionsMap + // and one of the other members), but that does not harm. for (auto *SC : RegisteredSubCommands) { for (auto &O : SC->OptionsMap) O.second->reset(); + for (Option *O : SC->PositionalOpts) + O->reset(); + for (Option *O : SC->SinkOpts) + O->reset(); + if (SC->ConsumeAfterOpt) + SC->ConsumeAfterOpt->reset(); } } |