aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Support/CommandLine.cpp
diff options
context:
space:
mode:
authorJameson Nash <vtjnash@gmail.com>2021-11-25 00:15:05 -0500
committerJameson Nash <vtjnash@gmail.com>2021-11-30 14:56:22 -0500
commit2e114e3fda4ff6492eaafab0d38033ea17fa99fc (patch)
tree4c4d788ccc3228decd78e9f91d82e22dd6cbed49 /llvm/lib/Support/CommandLine.cpp
parent155f5a6dac62a902a30f60e2717c4ba8fb828139 (diff)
downloadllvm-2e114e3fda4ff6492eaafab0d38033ea17fa99fc.zip
llvm-2e114e3fda4ff6492eaafab0d38033ea17fa99fc.tar.gz
llvm-2e114e3fda4ff6492eaafab0d38033ea17fa99fc.tar.bz2
fix inverted logic for HideUnrelatedOptions
It seems clearer to me that this would check for *any of* instead of *all of* these option categories, as it looks to me like that was the intent. But apparently this logic has always has been inverted, and possibly never fully used? Differential Revision: https://reviews.llvm.org/D114572
Diffstat (limited to 'llvm/lib/Support/CommandLine.cpp')
-rw-r--r--llvm/lib/Support/CommandLine.cpp16
1 files changed, 11 insertions, 5 deletions
diff --git a/llvm/lib/Support/CommandLine.cpp b/llvm/lib/Support/CommandLine.cpp
index e64934a..5b7004c 100644
--- a/llvm/lib/Support/CommandLine.cpp
+++ b/llvm/lib/Support/CommandLine.cpp
@@ -2656,10 +2656,13 @@ cl::getRegisteredSubcommands() {
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 @@ void cl::HideUnrelatedOptions(ArrayRef<const cl::OptionCategory *> Categories,
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);
}
}