[clang-tools-extra] 52cb972 - [CommandLine] --help: print "-o <xxx>" instead of "-o=<xxx>"

Fangrui Song via cfe-commits cfe-commits at lists.llvm.org
Thu Jul 14 01:28:36 PDT 2022


Author: Fangrui Song
Date: 2022-07-14T01:28:28-07:00
New Revision: 52cb972537dac7ac535b57ba9399d53549c027e8

URL: https://github.com/llvm/llvm-project/commit/52cb972537dac7ac535b57ba9399d53549c027e8
DIFF: https://github.com/llvm/llvm-project/commit/52cb972537dac7ac535b57ba9399d53549c027e8.diff

LOG: [CommandLine] --help: print "-o <xxx>" instead of "-o=<xxx>"

Accepting -o= is a quirk of CommandLine. For --help, we should print the
conventional "-o <xxx>".

Added: 
    

Modified: 
    clang-tools-extra/docs/clang-doc.rst
    clang-tools-extra/docs/clang-rename.rst
    clang-tools-extra/docs/clang-tidy/index.rst
    clang/docs/ClangOffloadPackager.rst
    clang/docs/ClangOffloadWrapper.rst
    clang/test/Driver/clang-offload-wrapper.c
    llvm/docs/CommandGuide/llvm-cov.rst
    llvm/lib/Support/CommandLine.cpp
    llvm/test/tools/llvm-dwarfdump/cmdline.test

Removed: 
    


################################################################################
diff  --git a/clang-tools-extra/docs/clang-doc.rst b/clang-tools-extra/docs/clang-doc.rst
index 2db3e914ac8a7..bd0a9cacaf011 100644
--- a/clang-tools-extra/docs/clang-doc.rst
+++ b/clang-tools-extra/docs/clang-doc.rst
@@ -90,7 +90,7 @@ Options
       =html                     -   Documentation in HTML format.
     --ignore-map-errors         - Continue if files are not mapped correctly.
     --output=<string>           - Directory for outputting generated files.
-    -p=<string>                 - Build path
+    -p <string>                 - Build path
     --project-name=<string>     - Name of project.
     --public                    - Document only public declarations.
     --repository=<string>       -

diff  --git a/clang-tools-extra/docs/clang-rename.rst b/clang-tools-extra/docs/clang-rename.rst
index e797c9bafe8a5..e13d8c3ad25f9 100644
--- a/clang-tools-extra/docs/clang-rename.rst
+++ b/clang-tools-extra/docs/clang-rename.rst
@@ -131,7 +131,7 @@ That way you can avoid spelling out all the names as command line arguments:
     -input=<string>            - YAML file to load oldname-newname pairs from.
     -new-name=<string>         - The new name to change the symbol to.
     -offset=<uint>             - Locates the symbol by offset as opposed to <line>:<column>.
-    -p=<string>                - Build path
+    -p <string>                - Build path
     -pl                        - Print the locations affected by renaming to stderr.
     -pn                        - Print the found symbol's name prior to renaming to stderr.
     -qualified-name=<string>   - The fully qualified name of the symbol.

diff  --git a/clang-tools-extra/docs/clang-tidy/index.rst b/clang-tools-extra/docs/clang-tidy/index.rst
index 05e369818f069..345b15495a9a9 100644
--- a/clang-tools-extra/docs/clang-tidy/index.rst
+++ b/clang-tools-extra/docs/clang-tidy/index.rst
@@ -226,7 +226,7 @@ An overview of all the command-line options:
                                      complete list of passes, use the
                                      :option:`--list-checks` and
                                      :option:`-load` options together.
-    -p=<string>                    - Build path
+    -p <string>                    - Build path
     --quiet                        -
                                      Run clang-tidy in quiet mode. This suppresses
                                      printing statistics about ignored warnings and

diff  --git a/clang/docs/ClangOffloadPackager.rst b/clang/docs/ClangOffloadPackager.rst
index 1664e415fe774..9b17b5d028d09 100644
--- a/clang/docs/ClangOffloadPackager.rst
+++ b/clang/docs/ClangOffloadPackager.rst
@@ -168,7 +168,7 @@ and ``arch`` arguments are considered mandatory to make a valid image.
   
     --image=<<key>=<value>,...> - List of key and value arguments. Required
                                   keywords are 'file' and 'triple'.
-    -o=<file>                   - Write output to <file>.
+    -o <file>                   - Write output to <file>.
 
 Example
 =======

diff  --git a/clang/docs/ClangOffloadWrapper.rst b/clang/docs/ClangOffloadWrapper.rst
index efd0425095479..9865bad8748aa 100644
--- a/clang/docs/ClangOffloadWrapper.rst
+++ b/clang/docs/ClangOffloadWrapper.rst
@@ -34,7 +34,7 @@ This tool can be used as follows:
     --help-list                        - Display list of available options (--help-list-hidden for more)
     --version                          - Display the version of this program
   clang-offload-wrapper options:
-    -o=<filename>                      - Output filename
+    -o <filename>                      - Output filename
     --target=<triple>                  - Target triple for the output module
 
 Example

diff  --git a/clang/test/Driver/clang-offload-wrapper.c b/clang/test/Driver/clang-offload-wrapper.c
index edc26e59781d3..14ff74d033d3f 100644
--- a/clang/test/Driver/clang-offload-wrapper.c
+++ b/clang/test/Driver/clang-offload-wrapper.c
@@ -8,7 +8,7 @@
 // CHECK-HELP: {{.*}}target binaries as input and produces bitcode file containing target binaries packaged
 // CHECK-HELP: {{.*}}as data and initialization code which registers target binaries in offload runtime.
 // CHECK-HELP: {{.*}}USAGE: clang-offload-wrapper [options] <input files>
-// CHECK-HELP: {{.*}}  -o=<filename>               - Output filename
+// CHECK-HELP: {{.*}}  -o <filename>               - Output filename
 // CHECK-HELP: {{.*}}  --target=<triple>           - Target triple for the output module
 
 //

diff  --git a/llvm/docs/CommandGuide/llvm-cov.rst b/llvm/docs/CommandGuide/llvm-cov.rst
index 4d3d4517397f7..61db8f641b043 100644
--- a/llvm/docs/CommandGuide/llvm-cov.rst
+++ b/llvm/docs/CommandGuide/llvm-cov.rst
@@ -128,7 +128,7 @@ OPTIONS
  Do not output any ``.gcov`` files. Summary information is still
  displayed.
 
-.. option:: -o=<DIR|FILE>, --object-directory=<DIR>, --object-file=<FILE>
+.. option:: -o <DIR|FILE>, --object-directory=<DIR>, --object-file=<FILE>
 
  Find objects in DIR or based on FILE's path. If you specify a particular
  object file, the coverage data files are expected to have the same base name
@@ -150,7 +150,7 @@ OPTIONS
  Only dump files with relative paths or absolute paths with the prefix specified
  by ``-s``.
 
-.. option:: -s=<string>
+.. option:: -s <string>
 
  Source prefix to elide.
 

diff  --git a/llvm/lib/Support/CommandLine.cpp b/llvm/lib/Support/CommandLine.cpp
index eb6c04d987b31..e3df172ef1133 100644
--- a/llvm/lib/Support/CommandLine.cpp
+++ b/llvm/lib/Support/CommandLine.cpp
@@ -1862,8 +1862,10 @@ void basic_parser_impl::printOptionInfo(const Option &O,
       outs() << " <" << getValueStr(O, ValName) << ">...";
     } else if (O.getValueExpectedFlag() == ValueOptional)
       outs() << "[=<" << getValueStr(O, ValName) << ">]";
-    else
-      outs() << "=<" << getValueStr(O, ValName) << '>';
+    else {
+      outs() << (O.ArgStr.size() == 1 ? " <" : "=<") << getValueStr(O, ValName)
+             << '>';
+    }
   }
 
   Option::printHelpStr(O.HelpStr, GlobalWidth, getOptionWidth(O));

diff  --git a/llvm/test/tools/llvm-dwarfdump/cmdline.test b/llvm/test/tools/llvm-dwarfdump/cmdline.test
index 1916ed73e04ba..246262ee2f024 100644
--- a/llvm/test/tools/llvm-dwarfdump/cmdline.test
+++ b/llvm/test/tools/llvm-dwarfdump/cmdline.test
@@ -50,7 +50,7 @@ HELP: --ignore-case
 HELP: --lookup=<address>
 HELP: -n
 HELP: --name=<pattern>
-HELP: -o=<filename>
+HELP: -o <filename>
 HELP: -p
 HELP: --parent-recurse-depth=<N>
 HELP: --quiet


        


More information about the cfe-commits mailing list