@@ -164,10 +164,7 @@ class CommandLineParser {
164
164
// This collects the different subcommands that have been registered.
165
165
SmallPtrSet<SubCommand *, 4 > RegisteredSubCommands;
166
166
167
- CommandLineParser () {
168
- registerSubCommand (&SubCommand::getTopLevel ());
169
- registerSubCommand (&SubCommand::getAll ());
170
- }
167
+ CommandLineParser () { registerSubCommand (&SubCommand::getTopLevel ()); }
171
168
172
169
void ResetAllOptionOccurrences ();
173
170
@@ -348,15 +345,15 @@ class CommandLineParser {
348
345
349
346
// For all options that have been registered for all subcommands, add the
350
347
// option to this subcommand now.
351
- if (sub != &SubCommand::getAll ()) {
352
- for ( auto &E : SubCommand::getAll (). OptionsMap ) {
353
- Option *O = E. second ;
354
- if ((O-> isPositional () || O-> isSink () || O-> isConsumeAfter ()) ||
355
- O->hasArgStr ())
356
- addOption (O, sub);
357
- else
358
- addLiteralOption (*O, sub, E. first ());
359
- }
348
+ assert (sub != &SubCommand::getAll () &&
349
+ " SubCommand::getAll() should not be registered " );
350
+ for ( auto &E : SubCommand::getAll (). OptionsMap ) {
351
+ Option *O = E. second ;
352
+ if ((O-> isPositional () || O-> isSink () || O->isConsumeAfter ()) ||
353
+ O-> hasArgStr ())
354
+ addOption (O, sub);
355
+ else
356
+ addLiteralOption (*O, sub, E. first ());
360
357
}
361
358
}
362
359
@@ -384,7 +381,6 @@ class CommandLineParser {
384
381
SubCommand::getTopLevel ().reset ();
385
382
SubCommand::getAll ().reset ();
386
383
registerSubCommand (&SubCommand::getTopLevel ());
387
- registerSubCommand (&SubCommand::getAll ());
388
384
389
385
DefaultOptions.clear ();
390
386
}
@@ -532,8 +528,8 @@ SubCommand *CommandLineParser::LookupSubCommand(StringRef Name,
532
528
// Find a subcommand with the edit distance == 1.
533
529
SubCommand *NearestMatch = nullptr ;
534
530
for (auto *S : RegisteredSubCommands) {
535
- if (S == &SubCommand::getAll ())
536
- continue ;
531
+ assert (S != &SubCommand::getAll () &&
532
+ " SubCommand::getAll() is not expected in RegisteredSubCommands " ) ;
537
533
if (S->getName ().empty ())
538
534
continue ;
539
535
0 commit comments