From f6b865d41a4cb74d40a2728db2c20ea9e5f9adf9 Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Wed, 5 Oct 2016 05:20:08 +0000 Subject: [PATCH] [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 | 22 ++++++++++++++++++++ lib/Support/CommandLine.cpp | 11 ++++++++++ unittests/Support/CommandLineTest.cpp | 29 +++++++++++++++++++++++++++ 3 files changed, 62 insertions(+) diff --git a/include/llvm/Support/CommandLine.h b/include/llvm/Support/CommandLine.h index f2e8b281716..c46a99cb6bd 100644 --- a/include/llvm/Support/CommandLine.h +++ b/include/llvm/Support/CommandLine.h @@ -1736,6 +1736,28 @@ void PrintHelpMessage(bool Hidden = false, bool Categorized = false); /// than just handing around a global list. StringMap