[llvm] r281292 - Revert "[Support][CommandLine] Add cl::getRegisteredSubcommands()"
Zachary Turner via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 12 21:11:58 PDT 2016
Author: zturner
Date: Mon Sep 12 23:11:57 2016
New Revision: 281292
URL: http://llvm.org/viewvc/llvm-project?rev=281292&view=rev
Log:
Revert "[Support][CommandLine] Add cl::getRegisteredSubcommands()"
This reverts r281290, as it breaks unit tests.
http://lab.llvm.org:8011/builders/clang-x86-windows-msvc2015/builds/303
Modified:
llvm/trunk/include/llvm/Support/CommandLine.h
llvm/trunk/lib/Support/CommandLine.cpp
llvm/trunk/unittests/Support/CommandLineTest.cpp
Modified: llvm/trunk/include/llvm/Support/CommandLine.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/CommandLine.h?rev=281292&r1=281291&r2=281292&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/CommandLine.h (original)
+++ llvm/trunk/include/llvm/Support/CommandLine.h Mon Sep 12 23:11:57 2016
@@ -1736,28 +1736,6 @@ void PrintHelpMessage(bool Hidden = fals
/// than just handing around a global list.
StringMap<Option *> &getRegisteredOptions(SubCommand &Sub = *TopLevelSubCommand);
-/// \brief Use this to get all registered SubCommands from the provided parser.
-///
-/// \return A range of all SubCommand pointers registered with the parser.
-///
-/// Typical usage:
-/// \code
-/// main(int argc, char* argv[]) {
-/// llvm::cl::ParseCommandLineOptions(argc, argv);
-/// for (auto* S : llvm::cl::getRegisteredSubcommands()) {
-/// if (*S) {
-/// std::cout << "Executing subcommand: " << S->getName() << std::endl;
-/// // Execute some function based on the name...
-/// }
-/// }
-/// }
-/// \endcode
-///
-/// This interface is useful for defining subcommands in libraries and
-/// the dispatch from a single point (like in the main function).
-iterator_range<typename SmallPtrSet<SubCommand *, 4>::iterator>
-getRegisteredSubcommands();
-
//===----------------------------------------------------------------------===//
// Standalone command line processing utilities.
//
Modified: llvm/trunk/lib/Support/CommandLine.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/CommandLine.cpp?rev=281292&r1=281291&r2=281292&view=diff
==============================================================================
--- llvm/trunk/lib/Support/CommandLine.cpp (original)
+++ llvm/trunk/lib/Support/CommandLine.cpp Mon Sep 12 23:11:57 2016
@@ -309,12 +309,6 @@ public:
RegisteredSubCommands.erase(sub);
}
- iterator_range<typename SmallPtrSet<SubCommand *, 4>::iterator>
- getRegisteredSubcommands() {
- return make_range(RegisteredSubCommands.begin(),
- RegisteredSubCommands.end());
- }
-
void reset() {
ActiveSubCommand = nullptr;
ProgramName.clear();
@@ -2111,11 +2105,6 @@ StringMap<Option *> &cl::getRegisteredOp
return Sub.OptionsMap;
}
-iterator_range<typename SmallPtrSet<SubCommand *, 4>::iterator>
-cl::getRegisteredSubcommands() {
- return GlobalParser->getRegisteredSubcommands();
-}
-
void cl::HideUnrelatedOptions(cl::OptionCategory &Category, SubCommand &Sub) {
for (auto &I : Sub.OptionsMap) {
if (I.second->Category != &Category &&
Modified: llvm/trunk/unittests/Support/CommandLineTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Support/CommandLineTest.cpp?rev=281292&r1=281291&r2=281292&view=diff
==============================================================================
--- llvm/trunk/unittests/Support/CommandLineTest.cpp (original)
+++ llvm/trunk/unittests/Support/CommandLineTest.cpp Mon Sep 12 23:11:57 2016
@@ -476,27 +476,4 @@ TEST(CommandLineTest, RemoveFromAllSubCo
EXPECT_FALSE(cl::ParseCommandLineOptions(3, args2, nullptr, true));
}
-TEST(CommandLineTest, GetRegisteredSubcommands) {
- cl::ResetCommandLineParser();
-
- StackSubCommand SC1("sc1", "First Subcommand");
- StackSubCommand SC2("sc2", "Second subcommand");
-
- const char *args0[] = {"prog", "sc1"};
- const char *args1[] = {"prog", "sc2"};
-
- EXPECT_TRUE(cl::ParseCommandLineOptions(2, args0, nullptr, true));
- for (auto *S : cl::getRegisteredSubcommands()) {
- if (*S)
- EXPECT_STREQ("sc1", S->getName());
- }
-
- cl::ResetAllOptionOccurrences();
- EXPECT_TRUE(cl::ParseCommandLineOptions(2, args1, nullptr, true));
- for (auto *S : cl::getRegisteredSubcommands()) {
- if (*S)
- EXPECT_STREQ("sc2", S->getName());
- }
-}
-
} // anonymous namespace
More information about the llvm-commits
mailing list