[Driver][cc1][cc1as] Call OptTable::PrintHelp with explicit " [options] file..."
authorFangrui Song <maskray@google.com>
Wed, 10 Oct 2018 00:15:33 +0000 (00:15 +0000)
committerFangrui Song <maskray@google.com>
Wed, 10 Oct 2018 00:15:33 +0000 (00:15 +0000)
Summary: This is to accommodate a change in llvm/lib/Option/OptTable.cpp D51009

Reviewers: rupprecht, alexshap, jhenderson

Reviewed By: rupprecht

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D51109

llvm-svn: 344098

clang/lib/Driver/Driver.cpp
clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
clang/tools/driver/cc1as_main.cpp

index ebf2ffc..203dcbe 100644 (file)
@@ -68,6 +68,7 @@
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/FileSystem.h"
+#include "llvm/Support/FormatVariadic.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/PrettyStackTrace.h"
 #include "llvm/Support/Process.h"
@@ -1433,7 +1434,8 @@ void Driver::PrintHelp(bool ShowHidden) const {
   if (!ShowHidden)
     ExcludedFlagsBitmask |= HelpHidden;
 
-  getOpts().PrintHelp(llvm::outs(), Name.c_str(), DriverTitle.c_str(),
+  std::string Usage = llvm::formatv("{0} [options] file...", Name).str();
+  getOpts().PrintHelp(llvm::outs(), Usage.c_str(), DriverTitle.c_str(),
                       IncludedFlagsBitmask, ExcludedFlagsBitmask,
                       /*ShowAllAliases=*/false);
 }
index 2d3a211..e63a973 100644 (file)
@@ -183,7 +183,7 @@ bool ExecuteCompilerInvocation(CompilerInstance *Clang) {
   // Honor -help.
   if (Clang->getFrontendOpts().ShowHelp) {
     std::unique_ptr<OptTable> Opts = driver::createDriverOptTable();
-    Opts->PrintHelp(llvm::outs(), "clang -cc1",
+    Opts->PrintHelp(llvm::outs(), "clang -cc1 [options] file...",
                     "LLVM 'Clang' Compiler: http://clang.llvm.org",
                     /*Include=*/driver::options::CC1Option,
                     /*Exclude=*/0, /*ShowAllAliases=*/false);
index 09db014..9e454cd 100644 (file)
@@ -534,7 +534,8 @@ int cc1as_main(ArrayRef<const char *> Argv, const char *Argv0, void *MainAddr) {
 
   if (Asm.ShowHelp) {
     std::unique_ptr<OptTable> Opts(driver::createDriverOptTable());
-    Opts->PrintHelp(llvm::outs(), "clang -cc1as", "Clang Integrated Assembler",
+    Opts->PrintHelp(llvm::outs(), "clang -cc1as [options] file...",
+                    "Clang Integrated Assembler",
                     /*Include=*/driver::options::CC1AsOption, /*Exclude=*/0,
                     /*ShowAllAliases=*/false);
     return 0;