aboutsummaryrefslogtreecommitdiff
path: root/llvm/unittests/Support/CommandLineTest.cpp
diff options
context:
space:
mode:
authorDon Hinton <hintonda@gmail.com>2019-06-22 23:32:36 +0000
committerDon Hinton <hintonda@gmail.com>2019-06-22 23:32:36 +0000
commit64b0924531cc113029a3b738e9a3c2091e1740b3 (patch)
tree4cc7e5a45d46c7e4f5076d018796986552e46139 /llvm/unittests/Support/CommandLineTest.cpp
parent1fa07ebd929383f769994818c3f8c55919bf0a0e (diff)
downloadllvm-64b0924531cc113029a3b738e9a3c2091e1740b3.zip
llvm-64b0924531cc113029a3b738e9a3c2091e1740b3.tar.gz
llvm-64b0924531cc113029a3b738e9a3c2091e1740b3.tar.bz2
Revert [CommandLine] Remove OptionCategory and SubCommand caches from the Option class.
This reverts r364134 (git commit a5b83bc9e3b8e8945b55068c762bd6c73621a4b0) Caused errors in the asan bot, so the GeneralCategory global needs to be changed to ManagedStatic. Differential Revision: https://reviews.llvm.org/D62105 llvm-svn: 364141
Diffstat (limited to 'llvm/unittests/Support/CommandLineTest.cpp')
-rw-r--r--llvm/unittests/Support/CommandLineTest.cpp60
1 files changed, 17 insertions, 43 deletions
diff --git a/llvm/unittests/Support/CommandLineTest.cpp b/llvm/unittests/Support/CommandLineTest.cpp
index 42c578a..1a1c8a4 100644
--- a/llvm/unittests/Support/CommandLineTest.cpp
+++ b/llvm/unittests/Support/CommandLineTest.cpp
@@ -95,16 +95,16 @@ TEST(CommandLineTest, ModifyExisitingOption) {
cl::Option *Retrieved = Map["test-option"];
ASSERT_EQ(&TestOption, Retrieved) << "Retrieved wrong option.";
- ASSERT_NE(Retrieved->getCategories().end(),
- find_if(Retrieved->getCategories(),
+ ASSERT_NE(Retrieved->Categories.end(),
+ find_if(Retrieved->Categories,
[&](const llvm::cl::OptionCategory *Cat) {
return Cat == &cl::GeneralCategory;
}))
<< "Incorrect default option category.";
Retrieved->addCategory(TestCategory);
- ASSERT_NE(Retrieved->getCategories().end(),
- find_if(Retrieved->getCategories(),
+ ASSERT_NE(Retrieved->Categories.end(),
+ find_if(Retrieved->Categories,
[&](const llvm::cl::OptionCategory *Cat) {
return Cat == &TestCategory;
}))
@@ -160,8 +160,8 @@ TEST(CommandLineTest, ParseEnvironmentToLocalVar) {
TEST(CommandLineTest, UseOptionCategory) {
StackOption<int> TestOption2("test-option", cl::cat(TestCategory));
- ASSERT_NE(TestOption2.getCategories().end(),
- find_if(TestOption2.getCategories(),
+ ASSERT_NE(TestOption2.Categories.end(),
+ find_if(TestOption2.Categories,
[&](const llvm::cl::OptionCategory *Cat) {
return Cat == &TestCategory;
}))
@@ -172,19 +172,18 @@ TEST(CommandLineTest, UseMultipleCategories) {
StackOption<int> TestOption2("test-option2", cl::cat(TestCategory),
cl::cat(cl::GeneralCategory),
cl::cat(cl::GeneralCategory));
- auto TestOption2Categories = TestOption2.getCategories();
// Make sure cl::GeneralCategory wasn't added twice.
- ASSERT_EQ(TestOption2Categories.size(), 2U);
+ ASSERT_EQ(TestOption2.Categories.size(), 2U);
- ASSERT_NE(TestOption2Categories.end(),
- find_if(TestOption2Categories,
+ ASSERT_NE(TestOption2.Categories.end(),
+ find_if(TestOption2.Categories,
[&](const llvm::cl::OptionCategory *Cat) {
return Cat == &TestCategory;
}))
<< "Failed to assign Option Category.";
- ASSERT_NE(TestOption2Categories.end(),
- find_if(TestOption2Categories,
+ ASSERT_NE(TestOption2.Categories.end(),
+ find_if(TestOption2.Categories,
[&](const llvm::cl::OptionCategory *Cat) {
return Cat == &cl::GeneralCategory;
}))
@@ -193,21 +192,20 @@ TEST(CommandLineTest, UseMultipleCategories) {
cl::OptionCategory AnotherCategory("Additional test Options", "Description");
StackOption<int> TestOption("test-option", cl::cat(TestCategory),
cl::cat(AnotherCategory));
- auto TestOptionCategories = TestOption.getCategories();
- ASSERT_EQ(TestOptionCategories.end(),
- find_if(TestOptionCategories,
+ ASSERT_EQ(TestOption.Categories.end(),
+ find_if(TestOption.Categories,
[&](const llvm::cl::OptionCategory *Cat) {
return Cat == &cl::GeneralCategory;
}))
<< "Failed to remove General Category.";
- ASSERT_NE(TestOptionCategories.end(),
- find_if(TestOptionCategories,
+ ASSERT_NE(TestOption.Categories.end(),
+ find_if(TestOption.Categories,
[&](const llvm::cl::OptionCategory *Cat) {
return Cat == &TestCategory;
}))
<< "Failed to assign Option Category.";
- ASSERT_NE(TestOptionCategories.end(),
- find_if(TestOptionCategories,
+ ASSERT_NE(TestOption.Categories.end(),
+ find_if(TestOption.Categories,
[&](const llvm::cl::OptionCategory *Cat) {
return Cat == &AnotherCategory;
}))
@@ -380,30 +378,6 @@ TEST(CommandLineTest, AliasRequired) {
testAliasRequired(array_lengthof(opts2), opts2);
}
-TEST(CommandLineTest, AliasWithSubCommand) {
- StackSubCommand SC1("sc1", "Subcommand 1");
- StackOption<std::string> Option1("option", cl::value_desc("output file"),
- cl::init("-"), cl::desc("Option"),
- cl::sub(SC1));
- StackOption<std::string, cl::alias> Alias1("o", llvm::cl::aliasopt(Option1),
- cl::desc("Alias for --option"),
- cl::sub(SC1));
-}
-
-TEST(CommandLineTest, AliasWithMultipleSubCommandsWithSameOption) {
- StackSubCommand SC1("sc1", "Subcommand 1");
- StackOption<std::string> Option1("option", cl::value_desc("output file"),
- cl::init("-"), cl::desc("Option"),
- cl::sub(SC1));
- StackSubCommand SC2("sc2", "Subcommand 2");
- StackOption<std::string> Option2("option", cl::value_desc("output file"),
- cl::init("-"), cl::desc("Option"),
- cl::sub(SC2));
-
- StackOption<std::string, cl::alias> Alias1("o", llvm::cl::aliasopt(Option1),
- cl::desc("Alias for --option"));
-}
-
TEST(CommandLineTest, HideUnrelatedOptions) {
StackOption<int> TestOption1("hide-option-1");
StackOption<int> TestOption2("hide-option-2", cl::cat(TestCategory));