]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
genmatch: clean up showUsage
authorAlexander Monakov <amonakov@ispras.ru>
Fri, 5 May 2023 22:25:26 +0000 (01:25 +0300)
committerAlexander Monakov <amonakov@ispras.ru>
Tue, 9 May 2023 09:57:14 +0000 (12:57 +0300)
Display usage more consistently and get rid of camelCase.

gcc/ChangeLog:

* genmatch.cc (showUsage): Reimplement as ...
(usage): ...this.  Adjust all uses.
(main): Print usage when no arguments.  Add missing 'return 1'.

gcc/genmatch.cc

index d5e56e2d6813856daa9abcf8227e86497e0f98cb..baf93855a6456d85f466851f0f5b9b12588848e5 100644 (file)
@@ -5301,13 +5301,12 @@ round_alloc_size (size_t s)
 /* Construct and display the help menu.  */
 
 static void
-showUsage ()
+usage ()
 {
-  fprintf (stderr, "Usage: genmatch [--gimple] [--generic] "
-                  "[--header=<filename>] [--include=<filename>] [-v[v]] input "
-                  "[<outputfile>...]\n");
-  fprintf (stderr, "\nWhen more then one outputfile is specified --header "
-                  "is required.\n");
+  const char *usage = "Usage:\n"
+    " %s [--gimple|--generic] [-v[v]] <input>\n"
+    " %s [options] [--include=FILE] --header=FILE <input> <output>...\n";
+  fprintf (stderr, usage, progname, progname);
 }
 
 /* Write out the correct include to the match-head fle containing the helper
@@ -5332,9 +5331,6 @@ main (int argc, char **argv)
 
   progname = "genmatch";
 
-  if (argc < 2)
-    return 1;
-
   bool gimple = true;
   char *s_header_file = NULL;
   char *s_include_file = NULL;
@@ -5359,14 +5355,17 @@ main (int argc, char **argv)
        files.safe_push (argv[i]);
       else
        {
-         showUsage ();
+         usage ();
          return 1;
        }
     }
 
   /* Validate if the combinations are valid.  */
   if ((files.length () > 1 && !s_header_file) || files.is_empty ())
-    showUsage ();
+    {
+      usage ();
+      return 1;
+    }
 
   if (!s_include_file)
     s_include_file = s_header_file;