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

Igor Kudrin via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 5 20:23:46 PST 2023


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

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.

>From 236e9a4129833cd8c8d8e896c20c36a9496802a1 Mon Sep 17 00:00:00 2001
From: Igor Kudrin <ikudrin at accesssoftek.com>
Date: Tue, 5 Dec 2023 20:16:01 -0800
Subject: [PATCH] [Support] Show '[subcommand]' in the help for less than 3
 subcommands

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.
---
 llvm/lib/Support/CommandLine.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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 {



More information about the llvm-commits mailing list