Skip to content

Commit

Permalink
Fixed --help bug
Browse files Browse the repository at this point in the history
  • Loading branch information
TejaX-Alaghari committed Jan 9, 2025
1 parent 7e8a364 commit e81ccd3
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions llvm/lib/Support/CommandLine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2515,10 +2515,10 @@ class HelpPrinter {
MaxArgLen = std::max(MaxArgLen, Opts[i].second->getOptionWidth());

#ifdef SYCLomatic_CUSTOMIZATION
OptionCategory &reqCtHelpCat(getReqCtHelpCategory(CtHelpCat));
OptionCategory &ReqCtHelpCat(getReqCtHelpCategory(CtHelpCat));

if (isDPCT && CtHelpCat != CtHelpCategory::HC_All)
outs() << "OPTIONS: " << reqCtHelpCat.getName() << "\n";
outs() << "OPTIONS: " << ReqCtHelpCat.getName() << "\n";
else
outs() << "OPTIONS:\n";
#else
Expand Down Expand Up @@ -2600,6 +2600,10 @@ class CategorizedHelpPrinter : public HelpPrinter {
array_pod_sort(SortedCategories.begin(), SortedCategories.end(),
OptionCategoryCompare);

#ifdef SYCLomatic_CUSTOMIZATION
OptionCategory &ReqCtHelpCat(getReqCtHelpCategory(CtHelpCat));
#endif // SYCLomatic_CUSTOMIZATION

// Walk through pre-sorted options and assign into categories.
// Because the options are already alphabetically sorted the
// options within categories will also be alphabetically sorted.
Expand All @@ -2608,16 +2612,12 @@ class CategorizedHelpPrinter : public HelpPrinter {
for (auto &Cat : Opt->Categories) {
assert(llvm::is_contained(SortedCategories, Cat) &&
"Option has an unregistered category");
CategorizedOptions[Cat].push_back(Opt);
}
}

#ifdef SYCLomatic_CUSTOMIZATION
if (CtHelpCat != CtHelpCategory::HC_All)
SortedCategories.erase(
std::find(SortedCategories.begin(), SortedCategories.end(),
&getReqCtHelpCategory(CtHelpCategory::HC_All)));
if (!isDPCT || Cat == &ReqCtHelpCat)
#endif // SYCLomatic_CUSTOMIZATION
CategorizedOptions[Cat].push_back(Opt);
}
}

// Now do printing.
for (OptionCategory *Category : SortedCategories) {
Expand Down Expand Up @@ -2980,7 +2980,7 @@ void HelpPrinterWrapper::operator=(bool Value) {
#ifdef SYCLomatic_CUSTOMIZATION
void HelpPrinterWrapper::operator=(CtHelpCategory Value) {
CategorizedPrinter.setReqCtHelpCategory(Value);
cl::HideUnrelatedOptions(CategorizedPrinter.getReqCtHelpCategory(Value));
// cl::HideUnrelatedOptions(CategorizedPrinter.getReqCtHelpCategory(Value));

*this = true;
}
Expand Down

0 comments on commit e81ccd3

Please sign in to comment.