[llvm] 2e114e3 - fix inverted logic for HideUnrelatedOptions
Jameson Nash via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 30 11:59:23 PST 2021
Author: Jameson Nash
Date: 2021-11-30T14:56:22-05:00
New Revision: 2e114e3fda4ff6492eaafab0d38033ea17fa99fc
URL: https://github.com/llvm/llvm-project/commit/2e114e3fda4ff6492eaafab0d38033ea17fa99fc
DIFF: https://github.com/llvm/llvm-project/commit/2e114e3fda4ff6492eaafab0d38033ea17fa99fc.diff
LOG: 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
Added:
Modified:
llvm/lib/Support/CommandLine.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Support/CommandLine.cpp b/llvm/lib/Support/CommandLine.cpp
index e64934aa90cc8..5b7004c86f5a8 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);
}
}
More information about the llvm-commits
mailing list