[llvm] [llvm-support][llvm-profdata] Use cl::Subcommand to organize show options. And look up in top-level as a fallback if a special subcommand doesn't have an option. (PR #71328)

Mingming Liu via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 7 22:16:56 PST 2023


================
@@ -3051,7 +3084,7 @@ static int show_main(int argc, const char *argv[]) {
         DebugInfoFilename.ArgStr + "' is provided");
 
   if (Filename == OutputFilename) {
-    errs() << sys::path::filename(argv[0])
+    errs() << sys::path::filename(argv[0]) << " " << argv[1]
            << ": Input file name cannot be the same as the output file name!\n";
----------------
minglotus-6 wrote:

this is just an artifact that `show` options parses command lines differently with the other three subcommands (that are not updated).

When all subcommands are updated to be `cl::SubCommand`, or when we introduce the following code, this is going to look more formal.

```
// If we want to update one subcommand at a time
if  subcommand uses cl::SubCommand {
   // the new method in this PR
   handles argv list one way
}
else {
  // the existing method
  handles argv list the other way
}
```

https://github.com/llvm/llvm-project/pull/71328


More information about the llvm-commits mailing list