This is an archive of the discontinued LLVM Phabricator instance.

[Support][CommandLine] Add cl::getRegisteredSubcommands()
ClosedPublic

Authored by dberris on Sep 12 2016, 6:56 PM.

Details

Summary

This should allow users of the library to get a range to iterate through
all the subcommands that are registered to the global parser. This
allows users to define subcommands in libraries that self-register to
have dispatch done at a different stage (like main). It allows for
writing code like the following:

for (auto *S : cl::getRegisteredSubcommands()) {
  if (*S) {
    // Dispatch on S->getName().
  }
}

This change also contains tests that show this usage pattern.

Diff Detail

Repository
rL LLVM

Event Timeline

dberris updated this revision to Diff 71096.Sep 12 2016, 6:56 PM
dberris retitled this revision from to [Support][CommandLine] Add cl::getRegisteredSubcommands().
dberris updated this object.
dberris added reviewers: zturner, dblaikie, echristo.
dberris added a subscriber: llvm-commits.
dberris updated this revision to Diff 71098.Sep 12 2016, 6:59 PM
  • Style fixes
This revision was automatically updated to reflect the committed changes.
dberris reopened this revision.Sep 12 2016, 9:51 PM

This was reverted in rL281292. Trying will try again.

dberris updated this revision to Diff 71105.Sep 12 2016, 10:04 PM
  • Add options to subcommands
dberris updated this revision to Diff 71106.Sep 12 2016, 10:05 PM
  • Explicitly initialise the option
This revision was automatically updated to reflect the committed changes.