[cfe-commits] r89283 - in /cfe/trunk: include/clang/Driver/ArgList.h include/clang/Driver/OptTable.h include/clang/Driver/Options.h lib/Driver/CMakeLists.txt lib/Driver/Driver.cpp lib/Driver/DriverOptions.cpp lib/Driver/OptTable.cpp lib/Driver/ToolChains.cpp

Daniel Dunbar daniel at zuster.org
Wed Nov 18 16:15:11 PST 2009


Author: ddunbar
Date: Wed Nov 18 18:15:11 2009
New Revision: 89283

URL: http://llvm.org/viewvc/llvm-project?rev=89283&view=rev
Log:
Driver: Split OptTable out into OptTable.{h,cpp}

Added:
    cfe/trunk/include/clang/Driver/OptTable.h
      - copied, changed from r89277, cfe/trunk/include/clang/Driver/Options.h
    cfe/trunk/lib/Driver/DriverOptions.cpp
Modified:
    cfe/trunk/include/clang/Driver/ArgList.h
    cfe/trunk/include/clang/Driver/Options.h
    cfe/trunk/lib/Driver/CMakeLists.txt
    cfe/trunk/lib/Driver/Driver.cpp
    cfe/trunk/lib/Driver/OptTable.cpp
    cfe/trunk/lib/Driver/ToolChains.cpp

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

==============================================================================
--- cfe/trunk/include/clang/Driver/ArgList.h (original)
+++ cfe/trunk/include/clang/Driver/ArgList.h Wed Nov 18 18:15:11 2009
@@ -26,6 +26,7 @@
 namespace clang {
 namespace driver {
   class Arg;
+  class Option;
 
   /// ArgList - Ordered collection of driver arguments.
   ///

Copied: cfe/trunk/include/clang/Driver/OptTable.h (from r89277, cfe/trunk/include/clang/Driver/Options.h)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/OptTable.h?p2=cfe/trunk/include/clang/Driver/OptTable.h&p1=cfe/trunk/include/clang/Driver/Options.h&r1=89277&r2=89283&rev=89283&view=diff

==============================================================================
--- cfe/trunk/include/clang/Driver/Options.h (original)
+++ cfe/trunk/include/clang/Driver/OptTable.h Wed Nov 18 18:15:11 2009
@@ -1,4 +1,4 @@
-//===--- Options.h - Option info & table ------------------------*- C++ -*-===//
+//===--- OptTable.h - Option Table ------------------------------*- C++ -*-===//
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -7,8 +7,8 @@
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef CLANG_DRIVER_OPTIONS_H_
-#define CLANG_DRIVER_OPTIONS_H_
+#ifndef CLANG_DRIVER_OPTTABLE_H
+#define CLANG_DRIVER_OPTTABLE_H
 
 #include <cassert>
 
@@ -136,21 +136,6 @@
     /// to parse).
     Arg *ParseOneArg(const InputArgList &Args, unsigned &Index) const;
   };
-
-namespace options {
-  enum 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, \
-               HELPTEXT, METAVAR) OPT_##ID,
-#include "clang/Driver/Options.def"
-    LastOption
-#undef OPTION
-  };
-}
-
-  OptTable *createDriverOptTable();
 }
 }
 

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

==============================================================================
--- cfe/trunk/include/clang/Driver/Options.h (original)
+++ cfe/trunk/include/clang/Driver/Options.h Wed Nov 18 18:15:11 2009
@@ -7,135 +7,12 @@
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef CLANG_DRIVER_OPTIONS_H_
-#define CLANG_DRIVER_OPTIONS_H_
-
-#include <cassert>
+#ifndef CLANG_DRIVER_OPTIONS_H
+#define CLANG_DRIVER_OPTIONS_H
 
 namespace clang {
 namespace driver {
-namespace options {
-  enum DriverFlag {
-    DriverOption     = (1 << 0),
-    LinkerInput      = (1 << 1),
-    NoArgumentUnused = (1 << 2),
-    RenderAsInput    = (1 << 3),
-    RenderJoined     = (1 << 4),
-    RenderSeparate   = (1 << 5),
-    Unsupported      = (1 << 6)
-  };
-}
-
-  class Arg;
-  class InputArgList;
-  class Option;
-
-  /// OptTable - Provide access to the Option info table.
-  ///
-  /// The OptTable class provides a layer of indirection which allows Option
-  /// instance to be created lazily. In the common case, only a few options will
-  /// be needed at runtime; the OptTable class maintains enough information to
-  /// parse command lines without instantiating Options, while letting other
-  /// parts of the driver still use Option instances where convenient.
-  //
-  // FIXME: Introduce an OptionSpecifier class to wrap the option ID
-  // variant?
-  class OptTable {
-  public:
-    /// Info - Entry for a single option instance in the option data table.
-    struct Info {
-      const char *Name;
-      const char *HelpText;
-      const char *MetaVar;
-      unsigned char Kind;
-      unsigned char Flags;
-      unsigned char Param;
-      unsigned short GroupID;
-      unsigned short AliasID;
-    };
-
-  private:
-    /// The static option information table.
-    const Info *OptionInfos;
-    unsigned NumOptionInfos;
-
-    /// The lazily constructed options table, indexed by option::ID - 1.
-    mutable Option **Options;
-
-    /// Prebound input option instance.
-    const Option *TheInputOption;
-
-    /// Prebound unknown option instance.
-    const Option *TheUnknownOption;
-
-    /// The index of the first option which can be parsed (i.e., is not a
-    /// special option like 'input' or 'unknown', and is not an option group).
-    unsigned FirstSearchableIndex;
-
-  private:
-    const Info &getInfo(unsigned id) const {
-      assert(id > 0 && id - 1 < getNumOptions() && "Invalid Option ID.");
-      return OptionInfos[id - 1];
-    }
-
-    Option *CreateOption(unsigned id) const;
-
-  protected:
-    OptTable(const Info *_OptionInfos, unsigned _NumOptionInfos);
-  public:
-    ~OptTable();
-
-    /// getNumOptions - Return the total number of option classes.
-    unsigned getNumOptions() const { return NumOptionInfos; }
-
-    /// getOption - Get the given \arg id's Option instance, lazily creating it
-    /// if necessary.
-    ///
-    /// \return The option, or null for the INVALID option id.
-    const Option *getOption(unsigned id) const {
-      if (id == 0)
-        return 0;
-
-      assert((unsigned) (id - 1) < getNumOptions() && "Invalid ID.");
-      Option *&Entry = Options[id - 1];
-      if (!Entry)
-        Entry = CreateOption(id);
-      return Entry;
-    }
-
-    /// getOptionName - Lookup the name of the given option.
-    const char *getOptionName(unsigned id) const {
-      return getInfo(id).Name;
-    }
-
-    /// getOptionKind - Get the kind of the given option.
-    unsigned getOptionKind(unsigned id) const {
-      return getInfo(id).Kind;
-    }
-
-    /// getOptionHelpText - Get the help text to use to describe this option.
-    const char *getOptionHelpText(unsigned id) const {
-      return getInfo(id).HelpText;
-    }
-
-    /// getOptionMetaVar - Get the meta-variable name to use when describing
-    /// this options values in the help text.
-    const char *getOptionMetaVar(unsigned id) const {
-      return getInfo(id).MetaVar;
-    }
-
-    /// parseOneArg - Parse a single argument; returning the new argument and
-    /// updating Index.
-    ///
-    /// \param [in] [out] Index - The current parsing position in the argument
-    /// string list; on return this will be the index of the next argument
-    /// string to parse.
-    ///
-    /// \return - The parsed argument, or 0 if the argument is missing values
-    /// (in which case Index still points at the conceptual next argument string
-    /// to parse).
-    Arg *ParseOneArg(const InputArgList &Args, unsigned &Index) const;
-  };
+  class OptTable;
 
 namespace options {
   enum ID {

Modified: cfe/trunk/lib/Driver/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/CMakeLists.txt?rev=89283&r1=89282&r2=89283&view=diff

==============================================================================
--- cfe/trunk/lib/Driver/CMakeLists.txt (original)
+++ cfe/trunk/lib/Driver/CMakeLists.txt Wed Nov 18 18:15:11 2009
@@ -6,6 +6,7 @@
   ArgList.cpp
   Compilation.cpp
   Driver.cpp
+  DriverOptions.cpp
   HostInfo.cpp
   Job.cpp
   OptTable.cpp

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

==============================================================================
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Wed Nov 18 18:15:11 2009
@@ -16,6 +16,7 @@
 #include "clang/Driver/DriverDiagnostic.h"
 #include "clang/Driver/HostInfo.h"
 #include "clang/Driver/Job.h"
+#include "clang/Driver/OptTable.h"
 #include "clang/Driver/Option.h"
 #include "clang/Driver/Options.h"
 #include "clang/Driver/Tool.h"

Added: cfe/trunk/lib/Driver/DriverOptions.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/DriverOptions.cpp?rev=89283&view=auto

==============================================================================
--- cfe/trunk/lib/Driver/DriverOptions.cpp (added)
+++ cfe/trunk/lib/Driver/DriverOptions.cpp Wed Nov 18 18:15:11 2009
@@ -0,0 +1,42 @@
+//===--- DriverOptions.cpp - Driver Options Table -----------------------*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "clang/Driver/Options.h"
+#include "clang/Driver/OptTable.h"
+#include "clang/Driver/Option.h"
+
+using namespace clang::driver;
+using namespace clang::driver::options;
+
+static OptTable::Info InfoTable[] = {
+  // The InputOption info
+  { "<input>", 0, 0, Option::InputClass, DriverOption, 0, OPT_INVALID, OPT_INVALID },
+  // The UnknownOption info
+  { "<unknown>", 0, 0, Option::UnknownClass, 0, 0, OPT_INVALID, OPT_INVALID },
+
+#define OPTION(NAME, ID, KIND, GROUP, ALIAS, FLAGS, PARAM, \
+               HELPTEXT, METAVAR)   \
+  { NAME, HELPTEXT, METAVAR, Option::KIND##Class, FLAGS, PARAM, \
+    OPT_##GROUP, OPT_##ALIAS },
+#include "clang/Driver/Options.def"
+};
+
+namespace {
+
+class DriverOptTable : public OptTable {
+public:
+  DriverOptTable()
+    : OptTable(InfoTable, sizeof(InfoTable) / sizeof(InfoTable[0])) {}
+};
+
+}
+
+OptTable *clang::driver::createDriverOptTable() {
+  return new DriverOptTable();
+}

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

==============================================================================
--- cfe/trunk/lib/Driver/OptTable.cpp (original)
+++ cfe/trunk/lib/Driver/OptTable.cpp Wed Nov 18 18:15:11 2009
@@ -1,4 +1,4 @@
-//===--- Options.cpp - Option info table --------------------------------*-===//
+//===--- OptTable.cpp - Option Table Implementation ---------------------*-===//
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -7,8 +7,7 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "clang/Driver/Options.h"
-
+#include "clang/Driver/OptTable.h"
 #include "clang/Driver/Arg.h"
 #include "clang/Driver/ArgList.h"
 #include "clang/Driver/Option.h"
@@ -218,32 +217,3 @@
 
   return new PositionalArg(TheUnknownOption, Index++);
 }
-
-//
-
-static OptTable::Info InfoTable[] = {
-  // The InputOption info
-  { "<input>", 0, 0, Option::InputClass, DriverOption, 0, OPT_INVALID, OPT_INVALID },
-  // The UnknownOption info
-  { "<unknown>", 0, 0, Option::UnknownClass, 0, 0, OPT_INVALID, OPT_INVALID },
-
-#define OPTION(NAME, ID, KIND, GROUP, ALIAS, FLAGS, PARAM, \
-               HELPTEXT, METAVAR)   \
-  { NAME, HELPTEXT, METAVAR, Option::KIND##Class, FLAGS, PARAM, \
-    OPT_##GROUP, OPT_##ALIAS },
-#include "clang/Driver/Options.def"
-};
-
-namespace {
-
-class DriverOptTable : public OptTable {
-public:
-  DriverOptTable()
-    : OptTable(InfoTable, sizeof(InfoTable) / sizeof(InfoTable[0])) {}
-};
-
-}
-
-OptTable *clang::driver::createDriverOptTable() {
-  return new DriverOptTable();
-}

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

==============================================================================
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Wed Nov 18 18:15:11 2009
@@ -14,6 +14,7 @@
 #include "clang/Driver/Driver.h"
 #include "clang/Driver/DriverDiagnostic.h"
 #include "clang/Driver/HostInfo.h"
+#include "clang/Driver/OptTable.h"
 #include "clang/Driver/Option.h"
 
 #include "llvm/ADT/StringExtras.h"





More information about the cfe-commits mailing list