aboutsummaryrefslogtreecommitdiff
path: root/llvm/unittests/Support/CommandLineTest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/unittests/Support/CommandLineTest.cpp')
-rw-r--r--llvm/unittests/Support/CommandLineTest.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/llvm/unittests/Support/CommandLineTest.cpp b/llvm/unittests/Support/CommandLineTest.cpp
index a9d0790..99d99c7 100644
--- a/llvm/unittests/Support/CommandLineTest.cpp
+++ b/llvm/unittests/Support/CommandLineTest.cpp
@@ -2301,4 +2301,29 @@ TEST(CommandLineTest, SubCommandGroups) {
EXPECT_FALSE(SC3.OptionsMap.contains("opt12"));
}
+TEST(CommandLineTest, HelpWithEmptyCategory) {
+ cl::ResetCommandLineParser();
+
+ cl::OptionCategory Category1("First Category");
+ cl::OptionCategory Category2("Second Category");
+ StackOption<int> Opt1("opt1", cl::cat(Category1));
+ StackOption<int> Opt2("opt2", cl::cat(Category2));
+ cl::HideUnrelatedOptions(Category2);
+
+ const char *args[] = {"prog"};
+ EXPECT_TRUE(cl::ParseCommandLineOptions(std::size(args), args, StringRef(),
+ &llvm::nulls()));
+ auto Output = interceptStdout(
+ []() { cl::PrintHelpMessage(/*Hidden=*/false, /*Categorized=*/true); });
+ EXPECT_EQ(std::string::npos, Output.find("First Category"))
+ << "An empty category should not be printed";
+
+ Output = interceptStdout(
+ []() { cl::PrintHelpMessage(/*Hidden=*/true, /*Categorized=*/true); });
+ EXPECT_EQ(std::string::npos, Output.find("First Category"))
+ << "An empty category should not be printed";
+
+ cl::ResetCommandLineParser();
+}
+
} // anonymous namespace