aboutsummaryrefslogtreecommitdiff
path: root/llvm/unittests/Support/CommandLineTest.cpp
diff options
context:
space:
mode:
authorDon Hinton <hintonda@gmail.com>2019-05-16 16:25:13 +0000
committerDon Hinton <hintonda@gmail.com>2019-05-16 16:25:13 +0000
commit8249a8889dbe5ef41c3367cca2d1f541b9c47081 (patch)
tree9fe3d3afdc5832c486049286fe64e24b56e7acf6 /llvm/unittests/Support/CommandLineTest.cpp
parent600ec01b7e27e4c815e1968db4a600e63491ed19 (diff)
downloadllvm-8249a8889dbe5ef41c3367cca2d1f541b9c47081.zip
llvm-8249a8889dbe5ef41c3367cca2d1f541b9c47081.tar.gz
llvm-8249a8889dbe5ef41c3367cca2d1f541b9c47081.tar.bz2
[CommandLine] Don't allow duplicate categories.
Summary: This is a fix to D61574, r360179, that allowed duplicate OptionCategory's. This change adds a check to make sure a category can only be added once even if the user passes it twice. Reviewed By: MaskRay Tags: #llvm Differential Revision: https://reviews.llvm.org/D61972 llvm-svn: 360913
Diffstat (limited to 'llvm/unittests/Support/CommandLineTest.cpp')
-rw-r--r--llvm/unittests/Support/CommandLineTest.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/llvm/unittests/Support/CommandLineTest.cpp b/llvm/unittests/Support/CommandLineTest.cpp
index 4fb20b1..43c9452 100644
--- a/llvm/unittests/Support/CommandLineTest.cpp
+++ b/llvm/unittests/Support/CommandLineTest.cpp
@@ -170,8 +170,12 @@ TEST(CommandLineTest, UseOptionCategory) {
TEST(CommandLineTest, UseMultipleCategories) {
StackOption<int> TestOption2("test-option2", cl::cat(TestCategory),
+ cl::cat(cl::GeneralCategory),
cl::cat(cl::GeneralCategory));
+ // Make sure cl::GeneralCategory wasn't added twice.
+ ASSERT_EQ(TestOption2.Categories.size(), 2U);
+
ASSERT_NE(TestOption2.Categories.end(),
find_if(TestOption2.Categories,
[&](const llvm::cl::OptionCategory *Cat) {