[Options] Store the option ID in OptTable::Info.
authorMichael J. Spencer <bigcheesegs@gmail.com>
Tue, 25 Sep 2012 23:12:48 +0000 (23:12 +0000)
committerMichael J. Spencer <bigcheesegs@gmail.com>
Tue, 25 Sep 2012 23:12:48 +0000 (23:12 +0000)
llvm-svn: 164644

clang/include/clang/Driver/OptTable.h
clang/include/clang/Driver/Option.h
clang/lib/Driver/CC1AsOptions.cpp
clang/lib/Driver/DriverOptions.cpp
clang/lib/Driver/OptTable.cpp
clang/lib/Driver/Option.cpp

index 15a22fe..ea7e57b 100644 (file)
@@ -34,6 +34,7 @@ namespace driver {
       const char *Name;
       const char *HelpText;
       const char *MetaVar;
+      unsigned ID;
       unsigned char Kind;
       unsigned char Param;
       unsigned short Flags;
index a149f5b..2adba6b 100644 (file)
@@ -71,9 +71,6 @@ namespace options {
   private:
     const OptTable::Info *Info;
 
-    /// The option ID.
-    OptSpecifier ID;
-
     /// Group this option is a member of, if any.
     const Option *Group;
 
@@ -81,11 +78,11 @@ namespace options {
     const Option *Alias;
 
   public:
-    Option(const OptTable::Info *Info, OptSpecifier ID,
+    Option(const OptTable::Info *Info,
            const Option *Group, const Option *Alias);
     ~Option();
 
-    unsigned getID() const { return ID.getID(); }
+    unsigned getID() const { return Info->ID; }
     OptionClass getKind() const { return OptionClass(Info->Kind); }
     StringRef getName() const { return Info->Name; }
     const Option *getGroup() const { return Group; }
index ea80f5a..cc7c7a4 100644 (file)
@@ -18,7 +18,7 @@ using namespace clang::driver::cc1asoptions;
 static const OptTable::Info CC1AsInfoTable[] = {
 #define OPTION(NAME, ID, KIND, GROUP, ALIAS, FLAGS, PARAM, \
                HELPTEXT, METAVAR)   \
-  { NAME, HELPTEXT, METAVAR, Option::KIND##Class, PARAM, FLAGS, \
+  { NAME, HELPTEXT, METAVAR, OPT_##ID, Option::KIND##Class, PARAM, FLAGS, \
     OPT_##GROUP, OPT_##ALIAS },
 #include "clang/Driver/CC1AsOptions.inc"
 };
index 715819d..f9d36cf 100644 (file)
@@ -17,7 +17,7 @@ using namespace clang::driver::options;
 static const OptTable::Info InfoTable[] = {
 #define OPTION(NAME, ID, KIND, GROUP, ALIAS, FLAGS, PARAM, \
                HELPTEXT, METAVAR)   \
-  { NAME, HELPTEXT, METAVAR, Option::KIND##Class, PARAM, FLAGS, \
+  { NAME, HELPTEXT, METAVAR, OPT_##ID, Option::KIND##Class, PARAM, FLAGS, \
     OPT_##GROUP, OPT_##ALIAS },
 #include "clang/Driver/Options.inc"
 };
index 3ebc6d8..a6d3cb3 100644 (file)
@@ -138,7 +138,7 @@ Option *OptTable::CreateOption(unsigned id) const {
   const Option *Group = getOption(info.GroupID);
   const Option *Alias = getOption(info.AliasID);
 
-  Option *Opt = new Option(&info, id, Group, Alias);
+  Option *Opt = new Option(&info, Group, Alias);
 
   return Opt;
 }
index 57eaee2..3be141e 100644 (file)
@@ -17,9 +17,9 @@
 #include <algorithm>
 using namespace clang::driver;
 
-Option::Option(const OptTable::Info *info, OptSpecifier _ID,
+Option::Option(const OptTable::Info *info,
                const Option *_Group, const Option *_Alias)
-  : Info(info), ID(_ID.getID()), Group(_Group), Alias(_Alias) {
+  : Info(info), Group(_Group), Alias(_Alias) {
 
   // Multi-level aliases are not supported, and alias options cannot
   // have groups. This just simplifies option tracking, it is not an
@@ -72,7 +72,7 @@ bool Option::matches(OptSpecifier Opt) const {
     return Alias->matches(Opt);
 
   // Check exact match.
-  if (ID == Opt)
+  if (getID() == Opt.getID())
     return true;
 
   if (Group)