diff --git a/llvm/lib/Support/CommandLine.cpp b/llvm/lib/Support/CommandLine.cpp --- a/llvm/lib/Support/CommandLine.cpp +++ b/llvm/lib/Support/CommandLine.cpp @@ -2656,10 +2656,13 @@ void cl::HideUnrelatedOptions(cl::OptionCategory &Category, SubCommand &Sub) { initCommonOptions(); for (auto &I : Sub.OptionsMap) { + bool Unrelated = true; for (auto &Cat : I.second->Categories) { - if (Cat != &Category && Cat != &CommonOptions->GenericCategory) - I.second->setHiddenFlag(cl::ReallyHidden); + if (Cat == &Category || Cat == &CommonOptions->GenericCategory) + Unrelated = false; } + if (Unrelated) + I.second->setHiddenFlag(cl::ReallyHidden); } } @@ -2667,11 +2670,14 @@ SubCommand &Sub) { initCommonOptions(); for (auto &I : Sub.OptionsMap) { + bool Unrelated = true; for (auto &Cat : I.second->Categories) { - if (!is_contained(Categories, Cat) && - Cat != &CommonOptions->GenericCategory) - I.second->setHiddenFlag(cl::ReallyHidden); + if (is_contained(Categories, Cat) || + Cat == &CommonOptions->GenericCategory) + Unrelated = false; } + if (Unrelated) + I.second->setHiddenFlag(cl::ReallyHidden); } }