]> granicus.if.org Git - llvm/commit
[Support][CommandLine] Add cl::getRegisteredSubcommands()
authorDean Michael Berris <dberris@google.com>
Wed, 5 Oct 2016 05:20:08 +0000 (05:20 +0000)
committerDean Michael Berris <dberris@google.com>
Wed, 5 Oct 2016 05:20:08 +0000 (05:20 +0000)
commitf6b865d41a4cb74d40a2728db2c20ea9e5f9adf9
tree98ffa3582c6b5ef5c627b7562e84c0fe7d5a9500
parent6f45c30387846d7a0f8c7e7c20d30d2ec1abb6ae
[Support][CommandLine] Add cl::getRegisteredSubcommands()

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.

Reviewers: zturner, dblaikie, echristo

Subscribers: llvm-commits, mehdi_amini

Differential Revision: https://reviews.llvm.org/D24489

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@283296 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/Support/CommandLine.h
lib/Support/CommandLine.cpp
unittests/Support/CommandLineTest.cpp