[cfe-commits] r89232 - in /cfe/trunk: include/clang/Driver/Option.h lib/Driver/Option.cpp lib/Driver/ToolChains.cpp

Daniel Dunbar daniel at zuster.org
Wed Nov 18 12:19:19 PST 2009


Author: ddunbar
Date: Wed Nov 18 14:19:19 2009
New Revision: 89232

URL: http://llvm.org/viewvc/llvm-project?rev=89232&view=rev
Log:
Driver: Store Option ID field as unsigned to drop dependency on the options
type.

Modified:
    cfe/trunk/include/clang/Driver/Option.h
    cfe/trunk/lib/Driver/Option.cpp
    cfe/trunk/lib/Driver/ToolChains.cpp

Modified: cfe/trunk/include/clang/Driver/Option.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Option.h?rev=89232&r1=89231&r2=89232&view=diff

==============================================================================
--- cfe/trunk/include/clang/Driver/Option.h (original)
+++ cfe/trunk/include/clang/Driver/Option.h Wed Nov 18 14:19:19 2009
@@ -10,8 +10,6 @@
 #ifndef CLANG_DRIVER_OPTION_H_
 #define CLANG_DRIVER_OPTION_H_
 
-#include "Options.h"
-
 #include "llvm/Support/Casting.h"
 using llvm::isa;
 using llvm::cast;
@@ -54,7 +52,7 @@
   private:
     OptionClass Kind;
 
-    options::ID ID;
+    unsigned ID;
 
     /// The option name.
     const char *Name;
@@ -89,12 +87,12 @@
     bool NoArgumentUnused : 1;
 
   protected:
-    Option(OptionClass Kind, options::ID ID, const char *Name,
+    Option(OptionClass Kind, unsigned ID, const char *Name,
            const OptionGroup *Group, const Option *Alias);
   public:
     virtual ~Option();
 
-    options::ID getId() const { return ID; }
+    unsigned getId() const { return ID; }
     OptionClass getKind() const { return Kind; }
     const char *getName() const { return Name; }
     const OptionGroup *getGroup() const { return Group; }
@@ -139,7 +137,7 @@
     /// matches - Predicate for whether this option is part of the
     /// given option (which may be a group).
     bool matches(const Option *Opt) const;
-    bool matches(options::ID Id) const;
+    bool matches(unsigned Id) const;
 
     /// accept - Potentially accept the current argument, returning a
     /// new Arg instance, or 0 if the option does not accept this
@@ -159,7 +157,7 @@
   /// by the driver.
   class OptionGroup : public Option {
   public:
-    OptionGroup(options::ID ID, const char *Name, const OptionGroup *Group);
+    OptionGroup(unsigned ID, const char *Name, const OptionGroup *Group);
 
     virtual Arg *accept(const InputArgList &Args, unsigned &Index) const;
 
@@ -201,7 +199,7 @@
 
   class FlagOption : public Option {
   public:
-    FlagOption(options::ID ID, const char *Name, const OptionGroup *Group,
+    FlagOption(unsigned ID, const char *Name, const OptionGroup *Group,
                const Option *Alias);
 
     virtual Arg *accept(const InputArgList &Args, unsigned &Index) const;
@@ -214,7 +212,7 @@
 
   class JoinedOption : public Option {
   public:
-    JoinedOption(options::ID ID, const char *Name, const OptionGroup *Group,
+    JoinedOption(unsigned ID, const char *Name, const OptionGroup *Group,
                  const Option *Alias);
 
     virtual Arg *accept(const InputArgList &Args, unsigned &Index) const;
@@ -227,7 +225,7 @@
 
   class SeparateOption : public Option {
   public:
-    SeparateOption(options::ID ID, const char *Name, const OptionGroup *Group,
+    SeparateOption(unsigned ID, const char *Name, const OptionGroup *Group,
                    const Option *Alias);
 
     virtual Arg *accept(const InputArgList &Args, unsigned &Index) const;
@@ -240,7 +238,7 @@
 
   class CommaJoinedOption : public Option {
   public:
-    CommaJoinedOption(options::ID ID, const char *Name,
+    CommaJoinedOption(unsigned ID, const char *Name,
                       const OptionGroup *Group, const Option *Alias);
 
     virtual Arg *accept(const InputArgList &Args, unsigned &Index) const;
@@ -259,7 +257,7 @@
     unsigned NumArgs;
 
   public:
-    MultiArgOption(options::ID ID, const char *Name, const OptionGroup *Group,
+    MultiArgOption(unsigned ID, const char *Name, const OptionGroup *Group,
                    const Option *Alias, unsigned NumArgs);
 
     unsigned getNumArgs() const { return NumArgs; }
@@ -276,7 +274,7 @@
   /// prefixes its (non-empty) value, or is follwed by a value.
   class JoinedOrSeparateOption : public Option {
   public:
-    JoinedOrSeparateOption(options::ID ID, const char *Name,
+    JoinedOrSeparateOption(unsigned ID, const char *Name,
                            const OptionGroup *Group, const Option *Alias);
 
     virtual Arg *accept(const InputArgList &Args, unsigned &Index) const;
@@ -291,7 +289,7 @@
   /// value and is followed by another value.
   class JoinedAndSeparateOption : public Option {
   public:
-    JoinedAndSeparateOption(options::ID ID, const char *Name,
+    JoinedAndSeparateOption(unsigned ID, const char *Name,
                             const OptionGroup *Group, const Option *Alias);
 
     virtual Arg *accept(const InputArgList &Args, unsigned &Index) const;

Modified: cfe/trunk/lib/Driver/Option.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Option.cpp?rev=89232&r1=89231&r2=89232&view=diff

==============================================================================
--- cfe/trunk/lib/Driver/Option.cpp (original)
+++ cfe/trunk/lib/Driver/Option.cpp Wed Nov 18 14:19:19 2009
@@ -16,7 +16,7 @@
 #include <algorithm>
 using namespace clang::driver;
 
-Option::Option(OptionClass _Kind, options::ID _ID, const char *_Name,
+Option::Option(OptionClass _Kind, unsigned _ID, const char *_Name,
                const OptionGroup *_Group, const Option *_Alias)
   : Kind(_Kind), ID(_ID), Name(_Name), Group(_Group), Alias(_Alias),
     Unsupported(false), LinkerInput(false), NoOptAsInput(false),
@@ -85,7 +85,7 @@
   return false;
 }
 
-bool Option::matches(options::ID Id) const {
+bool Option::matches(unsigned Id) const {
   // FIXME: Decide what to do here; we should either pull out the
   // handling of alias on the option for Id from the other matches, or
   // find some other solution (which hopefully doesn't require using
@@ -101,7 +101,7 @@
   return false;
 }
 
-OptionGroup::OptionGroup(options::ID ID, const char *Name,
+OptionGroup::OptionGroup(unsigned ID, const char *Name,
                          const OptionGroup *Group)
   : Option(Option::GroupClass, ID, Name, Group, 0) {
 }
@@ -129,7 +129,7 @@
   return 0;
 }
 
-FlagOption::FlagOption(options::ID ID, const char *Name,
+FlagOption::FlagOption(unsigned ID, const char *Name,
                        const OptionGroup *Group, const Option *Alias)
   : Option(Option::FlagClass, ID, Name, Group, Alias) {
 }
@@ -143,7 +143,7 @@
   return new FlagArg(this, Index++);
 }
 
-JoinedOption::JoinedOption(options::ID ID, const char *Name,
+JoinedOption::JoinedOption(unsigned ID, const char *Name,
                            const OptionGroup *Group, const Option *Alias)
   : Option(Option::JoinedClass, ID, Name, Group, Alias) {
 }
@@ -153,7 +153,7 @@
   return new JoinedArg(this, Index++);
 }
 
-CommaJoinedOption::CommaJoinedOption(options::ID ID, const char *Name,
+CommaJoinedOption::CommaJoinedOption(unsigned ID, const char *Name,
                                      const OptionGroup *Group,
                                      const Option *Alias)
   : Option(Option::CommaJoinedClass, ID, Name, Group, Alias) {
@@ -170,7 +170,7 @@
   return new CommaJoinedArg(this, Index++, Suffix);
 }
 
-SeparateOption::SeparateOption(options::ID ID, const char *Name,
+SeparateOption::SeparateOption(unsigned ID, const char *Name,
                                const OptionGroup *Group, const Option *Alias)
   : Option(Option::SeparateClass, ID, Name, Group, Alias) {
 }
@@ -188,7 +188,7 @@
   return new SeparateArg(this, Index - 2, 1);
 }
 
-MultiArgOption::MultiArgOption(options::ID ID, const char *Name,
+MultiArgOption::MultiArgOption(unsigned ID, const char *Name,
                                const OptionGroup *Group, const Option *Alias,
                                unsigned _NumArgs)
   : Option(Option::MultiArgClass, ID, Name, Group, Alias), NumArgs(_NumArgs) {
@@ -208,7 +208,7 @@
   return new SeparateArg(this, Index - 1 - NumArgs, NumArgs);
 }
 
-JoinedOrSeparateOption::JoinedOrSeparateOption(options::ID ID, const char *Name,
+JoinedOrSeparateOption::JoinedOrSeparateOption(unsigned ID, const char *Name,
                                                const OptionGroup *Group,
                                                const Option *Alias)
   : Option(Option::JoinedOrSeparateClass, ID, Name, Group, Alias) {
@@ -229,7 +229,7 @@
   return new SeparateArg(this, Index - 2, 1);
 }
 
-JoinedAndSeparateOption::JoinedAndSeparateOption(options::ID ID,
+JoinedAndSeparateOption::JoinedAndSeparateOption(unsigned ID,
                                                  const char *Name,
                                                  const OptionGroup *Group,
                                                  const Option *Alias)

Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=89232&r1=89231&r2=89232&view=diff

==============================================================================
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Wed Nov 18 14:19:19 2009
@@ -365,8 +365,7 @@
     // Sob. These is strictly gcc compatible for the time being. Apple
     // gcc translates options twice, which means that self-expanding
     // options add duplicates.
-    options::ID id = A->getOption().getId();
-    switch (id) {
+    switch ((options::ID) A->getOption().getId()) {
     default:
       DAL->append(A);
       break;





More information about the cfe-commits mailing list