[llvm] [Support] Show '[subcommand]' in the help for less than 3 subcommands (PR #74557)

via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 5 20:24:07 PST 2023


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-support

Author: Igor Kudrin (igorkudrin)

<details>
<summary>Changes</summary>

When a tool defines only one or two subcommands, the `[subcommand]` part is not displayed in the `USAGE` help line. Note that a similar issue with printing the list of the subcommands has been fixed in https://reviews.llvm.org/D25463.

---
Full diff: https://github.com/llvm/llvm-project/pull/74557.diff


1 Files Affected:

- (modified) llvm/lib/Support/CommandLine.cpp (+1-1) 


``````````diff
diff --git a/llvm/lib/Support/CommandLine.cpp b/llvm/lib/Support/CommandLine.cpp
index a7e0cae8b855d..31f79972125da 100644
--- a/llvm/lib/Support/CommandLine.cpp
+++ b/llvm/lib/Support/CommandLine.cpp
@@ -2372,7 +2372,7 @@ class HelpPrinter {
 
     if (Sub == &SubCommand::getTopLevel()) {
       outs() << "USAGE: " << GlobalParser->ProgramName;
-      if (Subs.size() > 2)
+      if (!Subs.empty())
         outs() << " [subcommand]";
       outs() << " [options]";
     } else {

``````````

</details>


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


More information about the llvm-commits mailing list