Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[nfc][llvm-profdata] Use cl::Subcommand to organize subcommand and options in llvm-profdata #71328

Merged
merged 8 commits into from
Nov 14, 2023
7 changes: 7 additions & 0 deletions llvm/lib/Support/CommandLine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1667,6 +1667,13 @@ bool CommandLineParser::ParseCommandLineOptions(int argc,
Handler = LookupLongOption(*ChosenSubCommand, ArgName, Value,
LongOptionsUseDoubleDash, HaveDoubleDash);

// If Handler is not found in a specialized subcommand, look up handler
// in the top-level subcommand.
// cl::opt without cl::sub belongs to top-level subcommand.
if (!Handler && ChosenSubCommand != &SubCommand::getTopLevel())
snehasish marked this conversation as resolved.
Show resolved Hide resolved
Handler = LookupLongOption(SubCommand::getTopLevel(), ArgName, Value,
LongOptionsUseDoubleDash, HaveDoubleDash);

// Check to see if this "option" is really a prefixed or grouped argument.
if (!Handler && !(LongOptionsUseDoubleDash && HaveDoubleDash))
Handler = HandlePrefixedOrGroupedOption(ArgName, Value, ErrorParsing,
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/tools/llvm-profdata/errors.test
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ RUN: not llvm-profdata show file -o file 2>&1 | FileCheck %s --check-prefix SHOW
SHOW-OUT: Input file name cannot be the same as the output file name!

RUN: not llvm-profdata 2>&1 | FileCheck %s --check-prefix EMPTY
EMPTY: No command specified!
EMPTY: No subcommand specified!
1 change: 0 additions & 1 deletion llvm/test/tools/llvm-profdata/version.test
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# RUN: llvm-profdata --version | FileCheck %s

# CHECK: llvm-profdata
# CHECK: LLVM version {{.*}}
Loading