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 2f9d825
Showing 1 changed file with 14 additions and 17 deletions.
31 changes: 14 additions & 17 deletions llvm/lib/Support/CommandLine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2457,11 +2457,9 @@ class HelpPrinter {
sortSubCommands(GlobalParser->RegisteredSubCommands, Subs);

#ifdef SYCLomatic_CUSTOMIZATION
if (isDPCT) {
if (CtHelpCat == CtHelpCategory::HC_Examples) {
outs() << DPCTExamplesMsg;
return;
}
if (isDPCT && CtHelpCat == CtHelpCategory::HC_Examples) {
outs() << DPCTExamplesMsg;
return;
}
#endif // SYCLomatic_CUSTOMIZATION

Expand Down Expand Up @@ -2515,10 +2513,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 +2598,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 +2610,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 All @@ -2626,7 +2624,7 @@ class CategorizedHelpPrinter : public HelpPrinter {
if (CategoryOptions.empty())
continue;

// Print category information.
// Print category information.
#ifdef SYCLomatic_CUSTOMIZATION
// outs() << "\n";
// outs() << Category->getName() << ":\n";
Expand Down Expand Up @@ -2980,7 +2978,6 @@ void HelpPrinterWrapper::operator=(bool Value) {
#ifdef SYCLomatic_CUSTOMIZATION
void HelpPrinterWrapper::operator=(CtHelpCategory Value) {
CategorizedPrinter.setReqCtHelpCategory(Value);
cl::HideUnrelatedOptions(CategorizedPrinter.getReqCtHelpCategory(Value));

*this = true;
}
Expand Down

0 comments on commit 2f9d825

Please sign in to comment.