[llvm] c913f6d - [llvm-rc] Lowercase the option definitions. NFC.

Martin Storsjö via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 15 23:34:52 PDT 2020


Author: Martin Storsjö
Date: 2020-09-16T09:34:26+03:00
New Revision: c913f6dce69513b430f705d5a1f4e745f5d0a27e

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

LOG: [llvm-rc] Lowercase the option definitions. NFC.

This matches how such options are most commonly defined in other tools.

This was pointed out in an earlier review a few months ago, that
the llvm-rc td entries felt shouty.

The INCLUDE option is renamed to includepath, to avoid clashing with
the tablegen include directive.

Added: 
    

Modified: 
    llvm/tools/llvm-rc/Opts.td
    llvm/tools/llvm-rc/llvm-rc.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/tools/llvm-rc/Opts.td b/llvm/tools/llvm-rc/Opts.td
index 873dd785b12b..613f0a0db31e 100644
--- a/llvm/tools/llvm-rc/Opts.td
+++ b/llvm/tools/llvm-rc/Opts.td
@@ -4,55 +4,55 @@ include "llvm/Option/OptParser.td"
 // These options seem to be important for the tool
 // and should be implemented.
 
-def FILEOUT : JoinedOrSeparate<[ "/", "-" ], "FO">,
+def fileout : JoinedOrSeparate<[ "/", "-" ], "FO">,
               HelpText<"Change the output file location.">;
 
-def DEFINE : Separate<[ "/", "-" ], "D">,
+def define : Separate<[ "/", "-" ], "D">,
              HelpText<"Define a symbol for the C preprocessor.">;
-def UNDEF : Separate<[ "/", "-" ], "U">,
+def undef : Separate<[ "/", "-" ], "U">,
             HelpText<"Undefine a symbol for the C preprocessor.">;
 
-def LANG_ID : JoinedOrSeparate<[ "/", "-" ], "L">,
+def lang_id : JoinedOrSeparate<[ "/", "-" ], "L">,
               HelpText<"Set the default language identifier.">;
-def LANG_NAME : Separate<[ "/", "-" ], "LN">,
+def lang_name : Separate<[ "/", "-" ], "LN">,
                 HelpText<"Set the default language name.">;
 
-def INCLUDE : Separate<[ "/", "-" ], "I">, HelpText<"Add an include path.">;
-def NOINCLUDE : Flag<[ "/", "-" ], "X">, HelpText<"Ignore 'include' variable.">;
+def includepath : Separate<[ "/", "-" ], "I">, HelpText<"Add an include path.">;
+def noinclude : Flag<[ "/", "-" ], "X">, HelpText<"Ignore 'include' variable.">;
 
-def ADD_NULL : Flag<[ "/", "-" ], "N">,
+def add_null : Flag<[ "/", "-" ], "N">,
                HelpText<"Null-terminate all strings in the string table.">;
 
-def DUPID_NOWARN : Flag<[ "/", "-" ], "Y">,
+def dupid_nowarn : Flag<[ "/", "-" ], "Y">,
                    HelpText<"Suppress warnings on duplicate resource IDs.">;
 
-def VERBOSE : Flag<[ "/", "-" ], "V">, HelpText<"Be verbose.">;
-def HELP : Flag<[ "/", "-" ], "?">, HelpText<"Display this help and exit.">;
-def H : Flag<[ "/", "-" ], "H">,
-        Alias<HELP>,
+def verbose : Flag<[ "/", "-" ], "V">, HelpText<"Be verbose.">;
+def help : Flag<[ "/", "-" ], "?">, HelpText<"Display this help and exit.">;
+def h : Flag<[ "/", "-" ], "H">,
+        Alias<help>,
         HelpText<"Display this help and exit.">;
 
-def DRY_RUN : Flag<[ "/", "-" ], "dry-run">,
+def dry_run : Flag<[ "/", "-" ], "dry-run">,
               HelpText<"Don't compile the input; only try to parse it.">;
 
-def CODEPAGE : JoinedOrSeparate<[ "/", "-" ], "C">,
+def codepage : JoinedOrSeparate<[ "/", "-" ], "C">,
                HelpText<"Set the codepage used for input strings.">;
 
 // Unused switches (at least for now). These will stay unimplemented
 // in an early stage of development and can be ignored. However, we need to
 // parse them in order to preserve the compatibility with the original tool.
 
-def NOLOGO : Flag<[ "/", "-" ], "NOLOGO">;
-def R : Flag<[ "/", "-" ], "R">;
-def SL : Flag<[ "/", "-" ], "SL">;
+def nologo : Flag<[ "/", "-" ], "NOLOGO">;
+def r : Flag<[ "/", "-" ], "R">;
+def sl : Flag<[ "/", "-" ], "SL">;
 
 // (Codepages support.)
-def W : Flag<[ "/", "-" ], "W">;
+def w : Flag<[ "/", "-" ], "W">;
 
 // (Support of MUI and similar.)
-def FM : Separate<[ "/", "-" ], "FM">;
-def Q : Separate<[ "/", "-" ], "Q">;
-def G : Flag<[ "/", "-" ], "G">;
-def GN : Flag<[ "/", "-" ], "GN">;
-def G1 : Flag<[ "/", "-" ], "G1">;
-def G2 : Flag<[ "/", "-" ], "G2">;
+def fm : Separate<[ "/", "-" ], "FM">;
+def q : Separate<[ "/", "-" ], "Q">;
+def g : Flag<[ "/", "-" ], "G">;
+def gn : Flag<[ "/", "-" ], "GN">;
+def g1 : Flag<[ "/", "-" ], "G1">;
+def g2 : Flag<[ "/", "-" ], "G2">;

diff  --git a/llvm/tools/llvm-rc/llvm-rc.cpp b/llvm/tools/llvm-rc/llvm-rc.cpp
index 71954804f255..e9027a21d46b 100644
--- a/llvm/tools/llvm-rc/llvm-rc.cpp
+++ b/llvm/tools/llvm-rc/llvm-rc.cpp
@@ -92,12 +92,12 @@ int main(int Argc, const char **Argv) {
   opt::InputArgList InputArgs = T.ParseArgs(ArgsArr, MAI, MAC);
 
   // The tool prints nothing when invoked with no command-line arguments.
-  if (InputArgs.hasArg(OPT_HELP)) {
+  if (InputArgs.hasArg(OPT_help)) {
     T.PrintHelp(outs(), "rc [options] file...", "Resource Converter", false);
     return 0;
   }
 
-  const bool BeVerbose = InputArgs.hasArg(OPT_VERBOSE);
+  const bool BeVerbose = InputArgs.hasArg(OPT_verbose);
 
   std::vector<std::string> InArgsInfo = InputArgs.getAllArgValues(OPT_INPUT);
   if (DashDash != Argv + Argc)
@@ -141,14 +141,14 @@ int main(int Argc, const char **Argv) {
   SmallString<128> InputFile(InArgsInfo[0]);
   llvm::sys::fs::make_absolute(InputFile);
   Params.InputFilePath = InputFile;
-  Params.Include = InputArgs.getAllArgValues(OPT_INCLUDE);
-  Params.NoInclude = InputArgs.getAllArgValues(OPT_NOINCLUDE);
+  Params.Include = InputArgs.getAllArgValues(OPT_includepath);
+  Params.NoInclude = InputArgs.getAllArgValues(OPT_noinclude);
 
-  if (InputArgs.hasArg(OPT_CODEPAGE)) {
-    if (InputArgs.getLastArgValue(OPT_CODEPAGE)
+  if (InputArgs.hasArg(OPT_codepage)) {
+    if (InputArgs.getLastArgValue(OPT_codepage)
             .getAsInteger(10, Params.CodePage))
       fatalError("Invalid code page: " +
-                 InputArgs.getLastArgValue(OPT_CODEPAGE));
+                 InputArgs.getLastArgValue(OPT_codepage));
     switch (Params.CodePage) {
     case CpAcp:
     case CpWin1252:
@@ -161,10 +161,10 @@ int main(int Argc, const char **Argv) {
   }
 
   std::unique_ptr<ResourceFileWriter> Visitor;
-  bool IsDryRun = InputArgs.hasArg(OPT_DRY_RUN);
+  bool IsDryRun = InputArgs.hasArg(OPT_dry_run);
 
   if (!IsDryRun) {
-    auto OutArgsInfo = InputArgs.getAllArgValues(OPT_FILEOUT);
+    auto OutArgsInfo = InputArgs.getAllArgValues(OPT_fileout);
     if (OutArgsInfo.empty()) {
       SmallString<128> OutputFile = InputFile;
       llvm::sys::path::replace_extension(OutputFile, "res");
@@ -182,17 +182,17 @@ int main(int Argc, const char **Argv) {
       fatalError("Error opening output file '" + OutArgsInfo[0] +
                  "': " + EC.message());
     Visitor = std::make_unique<ResourceFileWriter>(Params, std::move(FOut));
-    Visitor->AppendNull = InputArgs.hasArg(OPT_ADD_NULL);
+    Visitor->AppendNull = InputArgs.hasArg(OPT_add_null);
 
     ExitOnErr(NullResource().visit(Visitor.get()));
 
     // Set the default language; choose en-US arbitrarily.
     unsigned PrimaryLangId = 0x09, SubLangId = 0x01;
-    if (InputArgs.hasArg(OPT_LANG_ID)) {
+    if (InputArgs.hasArg(OPT_lang_id)) {
       unsigned LangId;
-      if (InputArgs.getLastArgValue(OPT_LANG_ID).getAsInteger(16, LangId))
+      if (InputArgs.getLastArgValue(OPT_lang_id).getAsInteger(16, LangId))
         fatalError("Invalid language id: " +
-                   InputArgs.getLastArgValue(OPT_LANG_ID));
+                   InputArgs.getLastArgValue(OPT_lang_id));
       PrimaryLangId = LangId & 0x3ff;
       SubLangId = LangId >> 10;
     }


        


More information about the llvm-commits mailing list