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

Daniel Dunbar daniel at zuster.org
Wed Nov 18 20:25:06 PST 2009


Author: ddunbar
Date: Wed Nov 18 22:25:06 2009
New Revision: 89312

URL: http://llvm.org/viewvc/llvm-project?rev=89312&view=rev
Log:
Driver: Take option ID for {Input,Unknown}Option, to drop dependency on actual options.

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

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

==============================================================================
--- cfe/trunk/include/clang/Driver/Option.h (original)
+++ cfe/trunk/include/clang/Driver/Option.h Wed Nov 18 22:25:06 2009
@@ -177,7 +177,7 @@
   /// InputOption - Dummy option class for representing driver inputs.
   class InputOption : public Option {
   public:
-    InputOption();
+    InputOption(OptSpecifier ID);
 
     virtual Arg *accept(const InputArgList &Args, unsigned &Index) const;
 
@@ -190,7 +190,7 @@
   /// UnknownOption - Dummy option class for represent unknown arguments.
   class UnknownOption : public Option {
   public:
-    UnknownOption();
+    UnknownOption(OptSpecifier ID);
 
     virtual Arg *accept(const InputArgList &Args, unsigned &Index) const;
 

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

==============================================================================
--- cfe/trunk/lib/Driver/OptTable.cpp (original)
+++ cfe/trunk/lib/Driver/OptTable.cpp Wed Nov 18 22:25:06 2009
@@ -136,9 +136,9 @@
   Option *Opt = 0;
   switch (info.Kind) {
   case Option::InputClass:
-    Opt = new InputOption(); break;
+    Opt = new InputOption(id); break;
   case Option::UnknownClass:
-    Opt = new UnknownOption(); break;
+    Opt = new UnknownOption(id); break;
   case Option::GroupClass:
     Opt = new OptionGroup(id, info.Name, Group); break;
   case Option::FlagClass:
@@ -188,7 +188,7 @@
     return new PositionalArg(TheInputOption, Index++);
 
   const Info *Start = OptionInfos + FirstSearchableIndex;
-  const Info *End = OptionInfos + LastOption - 1;
+  const Info *End = OptionInfos + getNumOptions();
 
   // Search for the first next option which could be a prefix.
   Start = std::lower_bound(Start, End, Str);
@@ -210,8 +210,7 @@
       break;
 
     // See if this option matches.
-    options::ID id = (options::ID) (Start - OptionInfos + 1);
-    if (Arg *A = getOption(id)->accept(Args, Index))
+    if (Arg *A = getOption(Start - OptionInfos + 1)->accept(Args, Index))
       return A;
 
     // Otherwise, see if this argument was missing values.

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

==============================================================================
--- cfe/trunk/lib/Driver/Option.cpp (original)
+++ cfe/trunk/lib/Driver/Option.cpp Wed Nov 18 22:25:06 2009
@@ -94,8 +94,8 @@
   return 0;
 }
 
-InputOption::InputOption()
-  : Option(Option::InputClass, options::OPT_INPUT, "<input>", 0, 0) {
+InputOption::InputOption(OptSpecifier ID)
+  : Option(Option::InputClass, ID, "<input>", 0, 0) {
 }
 
 Arg *InputOption::accept(const InputArgList &Args, unsigned &Index) const {
@@ -103,8 +103,8 @@
   return 0;
 }
 
-UnknownOption::UnknownOption()
-  : Option(Option::UnknownClass, options::OPT_UNKNOWN, "<unknown>", 0, 0) {
+UnknownOption::UnknownOption(OptSpecifier ID)
+  : Option(Option::UnknownClass, ID, "<unknown>", 0, 0) {
 }
 
 Arg *UnknownOption::accept(const InputArgList &Args, unsigned &Index) const {





More information about the cfe-commits mailing list