]> granicus.if.org Git - clang/commitdiff
Driver: Tweak option naming/def:
authorDaniel Dunbar <daniel@zuster.org>
Thu, 12 Mar 2009 03:42:54 +0000 (03:42 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Thu, 12 Mar 2009 03:42:54 +0000 (03:42 +0000)
 - Use OPT_ prefix for ids.

 - Reference groups and aliases by shortend id (on the theory that
   this is more readable).

 - Rename the special option ids to more protected names.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66767 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Driver/Options.def
include/clang/Driver/Options.h
lib/Driver/OptTable.cpp
lib/Driver/Option.cpp

index f50729f42ebfe8f02197aa9011098803b3991d7a..79a257f9e6932898422bd0860060b965de8e8c2f 100644 (file)
 // The third value is the option type, one of Group, Flag, Joined,
 // Separate, CommaJoined, JoinedOrSeparate, JoinedAndSeparate.
 
-// The fourth value is the internal name of the option group, or 0 if
-// the option is not part of a group.
+// The fourth value is the internal name of the option group, or
+// INVALID if the option is not part of a group.
 
-// The fifth value is the internal name of an aliased option, or 0 if
-// the option is not an alias.
+// The fifth value is the internal name of an aliased option, or
+// INVALID if the option is not an alias.
 
 // The sixth value is a string containing option flags. Valid values:
 //  l: The option is a linker input.
 //  U: The option is unsupported, and the driver will reject command
 //     lines that use it.
 
-/// The seventh value is an arbitrary integer parameter; currently
-/// this is only used for specifying the number of arguments for
-/// Separate options.
+// The seventh value is an arbitrary integer parameter; currently
+// this is only used for specifying the number of arguments for
+// Separate options.
 
-OPTION("-arch", ArchOpt, Separate, 0, 0, "", 0)
-OPTION("-pass-exit-codes", PassExitCodesFlag, Flag, 0, 0, "", 0)
-OPTION("-print-file-name=", PrintFileNameOpt, Joined, 0, 0, "", 0)
-OPTION("-Wp,", WpOpt, CommaJoined, 0, 0, "", 0)
+OPTION("-arch", ArchOpt, Separate, INVALID, INVALID, "", 0)
+OPTION("-pass-exit-codes", PassExitCodesFlag, Flag, INVALID, INVALID, "", 0)
+OPTION("-print-file-name=", PrintFileNameOpt, Joined, INVALID, INVALID, "", 0)
+OPTION("-Wp,", WpOpt, CommaJoined, INVALID, INVALID, "", 0)
index f5551e644abf06f4568766c239084cf784d6d00e..9690d3afb32e1939b6fad1ef0f3239514c24f81c 100644 (file)
@@ -14,10 +14,10 @@ namespace clang {
 namespace driver {
 namespace options {
   enum ID {
-    NotOption = 0, // This is not an option ID.
-    InputOpt,      // Reserved ID for input option.
-    UnknownOpt,    // Reserved ID for unknown option.
-#define OPTION(NAME, ID, KIND, GROUP, ALIAS, FLAGS, PARAM) ID,
+    OPT_INVALID = 0, // This is not an option ID.
+    OPT_INPUT,      // Reserved ID for input option.
+    OPT_UNKNOWN,    // Reserved ID for unknown option.
+#define OPTION(NAME, ID, KIND, GROUP, ALIAS, FLAGS, PARAM) OPT_##ID,
 #include "clang/Driver/Options.def"
     LastOption
 #undef OPTION
index db910e1a31407aca445453f8a89512fa949845b7..5caaace3ad02de895f6fa6ff9af5bd19e91ae649 100644 (file)
@@ -30,12 +30,12 @@ struct Info {
 
 static Info OptionInfos[] = {
   // The InputOption info
-  { "<input>", "", Option::InputClass, 0, 0, 0 },
+  { "<input>", "", Option::InputClass, OPT_INVALID, OPT_INVALID, 0 },
   // The UnknownOption info
-  { "<unknown>", "", Option::UnknownClass, 0, 0, 0 },
+  { "<unknown>", "", Option::UnknownClass, OPT_INVALID, OPT_INVALID, 0 },
   
-#define OPTION(NAME, ID, KIND, GROUP, ALIAS, FLAGS, PARAM) \
-  { NAME, FLAGS, Option::KIND##Class, GROUP, ALIAS, PARAM },
+#define OPTION(NAME, ID, KIND, GROUP, ALIAS, FLAGS, PARAM)              \
+  { NAME, FLAGS, Option::KIND##Class, OPT_##GROUP, OPT_##ALIAS, PARAM },
 #include "clang/Driver/Options.def"
 };
 static const unsigned numOptions = sizeof(OptionInfos) / sizeof(OptionInfos[0]);
@@ -63,7 +63,7 @@ const char *OptTable::getOptionName(options::ID id) const {
 }
 
 const Option *OptTable::getOption(options::ID id) const {
-  if (id == NotOption)
+  if (id == OPT_INVALID)
     return 0;
 
   assert((unsigned) (id - 1) < numOptions && "Invalid ID.");
@@ -125,9 +125,9 @@ Arg *OptTable::ParseOneArg(const ArgList &Args, unsigned &Index,
 
   // Anything that doesn't start with '-' is an input.
   if (Str[0] != '-')
-    return new PositionalArg(getOption(InputOpt), Index++);
+    return new PositionalArg(getOption(OPT_INPUT), Index++);
 
-  for (unsigned j = UnknownOpt + 1; j < LastOption; ++j) {
+  for (unsigned j = OPT_UNKNOWN + 1; j < LastOption; ++j) {
     const char *OptName = getOptionName((options::ID) j);
     
     // Arguments are only accepted by options which prefix them.
@@ -136,6 +136,6 @@ Arg *OptTable::ParseOneArg(const ArgList &Args, unsigned &Index,
         return A;
   }
 
-  return new PositionalArg(getOption(UnknownOpt), Index++);
+  return new PositionalArg(getOption(OPT_UNKNOWN), Index++);
 }
 
index 7a74d34a86b5e152e263faa80e34ae3dc939a524..7a5300945572be10f044fe62fa00dc4a7cccb345 100644 (file)
@@ -113,7 +113,7 @@ Arg *OptionGroup::accept(const ArgList &Args, unsigned &Index) const {
 }
 
 InputOption::InputOption()
-  : Option(Option::InputClass, options::InputOpt, "<input>", 0, 0) {
+  : Option(Option::InputClass, options::OPT_INPUT, "<input>", 0, 0) {
 }
 
 Arg *InputOption::accept(const ArgList &Args, unsigned &Index) const {
@@ -122,7 +122,7 @@ Arg *InputOption::accept(const ArgList &Args, unsigned &Index) const {
 }
 
 UnknownOption::UnknownOption()
-  : Option(Option::UnknownClass, options::UnknownOpt, "<unknown>", 0, 0) {
+  : Option(Option::UnknownClass, options::OPT_UNKNOWN, "<unknown>", 0, 0) {
 }
 
 Arg *UnknownOption::accept(const ArgList &Args, unsigned &Index) const {