[cfe-commits] r66767 - in /cfe/trunk: include/clang/Driver/Options.def include/clang/Driver/Options.h lib/Driver/OptTable.cpp lib/Driver/Option.cpp
Daniel Dunbar
daniel at zuster.org
Wed Mar 11 20:42:55 PDT 2009
Author: ddunbar
Date: Wed Mar 11 22:42:54 2009
New Revision: 66767
URL: http://llvm.org/viewvc/llvm-project?rev=66767&view=rev
Log:
Driver: Tweak option naming/def:
- 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.
Modified:
cfe/trunk/include/clang/Driver/Options.def
cfe/trunk/include/clang/Driver/Options.h
cfe/trunk/lib/Driver/OptTable.cpp
cfe/trunk/lib/Driver/Option.cpp
Modified: cfe/trunk/include/clang/Driver/Options.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.def?rev=66767&r1=66766&r2=66767&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/Options.def (original)
+++ cfe/trunk/include/clang/Driver/Options.def Wed Mar 11 22:42:54 2009
@@ -27,11 +27,11 @@
// 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.
@@ -48,11 +48,11 @@
// 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)
Modified: cfe/trunk/include/clang/Driver/Options.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.h?rev=66767&r1=66766&r2=66767&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/Options.h (original)
+++ cfe/trunk/include/clang/Driver/Options.h Wed Mar 11 22:42:54 2009
@@ -14,10 +14,10 @@
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
Modified: cfe/trunk/lib/Driver/OptTable.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/OptTable.cpp?rev=66767&r1=66766&r2=66767&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/OptTable.cpp (original)
+++ cfe/trunk/lib/Driver/OptTable.cpp Wed Mar 11 22:42:54 2009
@@ -30,12 +30,12 @@
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 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 @@
// 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 @@
return A;
}
- return new PositionalArg(getOption(UnknownOpt), Index++);
+ return new PositionalArg(getOption(OPT_UNKNOWN), Index++);
}
Modified: cfe/trunk/lib/Driver/Option.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Option.cpp?rev=66767&r1=66766&r2=66767&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Option.cpp (original)
+++ cfe/trunk/lib/Driver/Option.cpp Wed Mar 11 22:42:54 2009
@@ -113,7 +113,7 @@
}
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 @@
}
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 {
More information about the cfe-commits
mailing list