]> granicus.if.org Git - clang/commitdiff
[Driver] Refactor clang driver to use LLVM's Option library
authorReid Kleckner <reid@kleckner.net>
Fri, 14 Jun 2013 17:17:23 +0000 (17:17 +0000)
committerReid Kleckner <reid@kleckner.net>
Fri, 14 Jun 2013 17:17:23 +0000 (17:17 +0000)
The big changes are:
- Deleting Driver/(Arg|Opt)*
- Rewriting includes to llvm/Option/ and re-sorting
- 'using namespace llvm::opt' in clang::driver
- Fixing the autoconf build by adding option everywhere

As discussed in the review, this change includes using directives in
header files.  I'll make follow up changes to remove those in favor of
name specifiers.

Reviewers: espindola

Differential Revision: http://llvm-reviews.chandlerc.com/D975

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@183989 91177308-0d34-0410-b5e6-96231b3b80d8

62 files changed:
examples/clang-interpreter/Makefile
include/clang/Driver/Action.h
include/clang/Driver/Arg.h [deleted file]
include/clang/Driver/ArgList.h [deleted file]
include/clang/Driver/CC1AsOptions.h
include/clang/Driver/CC1AsOptions.td
include/clang/Driver/CMakeLists.txt
include/clang/Driver/Compilation.h
include/clang/Driver/Driver.h
include/clang/Driver/Job.h
include/clang/Driver/Makefile
include/clang/Driver/OptParser.td [deleted file]
include/clang/Driver/OptSpecifier.h [deleted file]
include/clang/Driver/OptTable.h [deleted file]
include/clang/Driver/Option.h [deleted file]
include/clang/Driver/Options.h
include/clang/Driver/Options.td
include/clang/Driver/Tool.h
include/clang/Driver/ToolChain.h
include/clang/Driver/Util.h
include/clang/Frontend/CompilerInvocation.h
include/clang/Frontend/Utils.h
lib/Driver/Action.cpp
lib/Driver/Arg.cpp [deleted file]
lib/Driver/ArgList.cpp [deleted file]
lib/Driver/CC1AsOptions.cpp
lib/Driver/CMakeLists.txt
lib/Driver/Compilation.cpp
lib/Driver/Driver.cpp
lib/Driver/DriverOptions.cpp
lib/Driver/InputInfo.h
lib/Driver/Job.cpp
lib/Driver/OptTable.cpp [deleted file]
lib/Driver/Option.cpp [deleted file]
lib/Driver/SanitizerArgs.h
lib/Driver/ToolChain.cpp
lib/Driver/ToolChains.cpp
lib/Driver/Tools.cpp
lib/Driver/Tools.h
lib/Driver/WindowsToolChain.cpp
lib/Frontend/CompilerInvocation.cpp
lib/Frontend/CreateInvocationFromCommandLine.cpp
lib/FrontendTool/ExecuteCompilerInvocation.cpp
lib/Tooling/Tooling.cpp
tools/arcmt-test/Makefile
tools/c-arcmt-test/Makefile
tools/c-index-test/Makefile
tools/clang-check/ClangCheck.cpp
tools/clang-check/Makefile
tools/clang-format/Makefile
tools/diagtool/Makefile
tools/driver/Makefile
tools/driver/cc1_main.cpp
tools/driver/cc1as_main.cpp
tools/driver/driver.cpp
tools/libclang/Makefile
unittests/AST/Makefile
unittests/ASTMatchers/Dynamic/Makefile
unittests/ASTMatchers/Makefile
unittests/Format/Makefile
unittests/Frontend/Makefile
unittests/Tooling/Makefile

index 0c4d35c8ebd2cc15c4319d21ad83a3af59b378df..8b73f5f856c0935a60053e6bbd659b29d0d6488e 100644 (file)
@@ -16,7 +16,7 @@ NO_INSTALL = 1
 TOOL_NO_EXPORTS = 1
 
 LINK_COMPONENTS := jit interpreter nativecodegen bitreader bitwriter ipo \
-       linker selectiondag asmparser instrumentation
+       linker selectiondag asmparser instrumentation option
 USEDLIBS = clangFrontend.a clangSerialization.a clangDriver.a clangCodeGen.a \
            clangParse.a clangSema.a clangStaticAnalyzerFrontend.a \
            clangStaticAnalyzerCheckers.a clangStaticAnalyzerCore.a \
index 4057e48f69a4aa6f34df4e80e430af81d40b756d..59e979c89d0476a8c915308c963762babeed2aa3 100644 (file)
 #include "clang/Driver/Util.h"
 #include "llvm/ADT/SmallVector.h"
 
+namespace llvm {
+namespace opt {
+  class Arg;
+}
+}
+
 namespace clang {
 namespace driver {
-  class Arg;
+  // FIXME: Remove this using directive and qualify class usage below.
+  using namespace llvm::opt;
+
 
 /// Action - Represent an abstract compilation step to perform.
 ///
diff --git a/include/clang/Driver/Arg.h b/include/clang/Driver/Arg.h
deleted file mode 100644 (file)
index 662a2e2..0000000
+++ /dev/null
@@ -1,133 +0,0 @@
-//===--- Arg.h - Parsed Argument Classes ------------------------*- C++ -*-===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-///
-/// \file
-/// \brief Defines the clang::driver::Arg class for parsed arguments.
-///
-//===----------------------------------------------------------------------===//
-
-#ifndef CLANG_DRIVER_ARG_H_
-#define CLANG_DRIVER_ARG_H_
-
-#include "Util.h"
-#include "clang/Driver/Option.h"
-#include "llvm/ADT/SmallVector.h"
-#include "llvm/ADT/StringRef.h"
-#include <string>
-
-namespace clang {
-namespace driver {
-  class ArgList;
-
-  /// \brief A concrete instance of a particular driver option.
-  ///
-  /// The Arg class encodes just enough information to be able to
-  /// derive the argument values efficiently. In addition, Arg
-  /// instances have an intrusive double linked list which is used by
-  /// ArgList to provide efficient iteration over all instances of a
-  /// particular option.
-  class Arg {
-    Arg(const Arg &) LLVM_DELETED_FUNCTION;
-    void operator=(const Arg &) LLVM_DELETED_FUNCTION;
-
-  private:
-    /// \brief The option this argument is an instance of.
-    const Option Opt;
-
-    /// \brief The argument this argument was derived from (during tool chain
-    /// argument translation), if any.
-    const Arg *BaseArg;
-
-    /// \brief How this instance of the option was spelled.
-    StringRef Spelling;
-
-    /// \brief The index at which this argument appears in the containing
-    /// ArgList.
-    unsigned Index;
-
-    /// \brief Was this argument used to affect compilation?
-    ///
-    /// This is used for generating "argument unused" diagnostics.
-    mutable unsigned Claimed : 1;
-
-    /// \brief Does this argument own its values?
-    mutable unsigned OwnsValues : 1;
-
-    /// \brief The argument values, as C strings.
-    SmallVector<const char *, 2> Values;
-
-  public:
-    Arg(const Option Opt, StringRef Spelling, unsigned Index,
-        const Arg *BaseArg = 0);
-    Arg(const Option Opt, StringRef Spelling, unsigned Index,
-        const char *Value0, const Arg *BaseArg = 0);
-    Arg(const Option Opt, StringRef Spelling, unsigned Index,
-        const char *Value0, const char *Value1, const Arg *BaseArg = 0);
-    ~Arg();
-
-    Option getOption() const { return Opt; }
-    StringRef getSpelling() const { return Spelling; }
-    unsigned getIndex() const { return Index; }
-
-    /// \brief Return the base argument which generated this arg.
-    ///
-    /// This is either the argument itself or the argument it was
-    /// derived from during tool chain specific argument translation.
-    const Arg &getBaseArg() const {
-      return BaseArg ? *BaseArg : *this;
-    }
-    void setBaseArg(const Arg *_BaseArg) {
-      BaseArg = _BaseArg;
-    }
-
-    bool getOwnsValues() const { return OwnsValues; }
-    void setOwnsValues(bool Value) const { OwnsValues = Value; }
-
-    bool isClaimed() const { return getBaseArg().Claimed; }
-
-    /// \brief Set the Arg claimed bit.
-    void claim() const { getBaseArg().Claimed = true; }
-
-    unsigned getNumValues() const { return Values.size(); }
-    const char *getValue(unsigned N = 0) const {
-      return Values[N];
-    }
-
-    SmallVectorImpl<const char*> &getValues() {
-      return Values;
-    }
-
-    bool containsValue(StringRef Value) const {
-      for (unsigned i = 0, e = getNumValues(); i != e; ++i)
-        if (Values[i] == Value)
-          return true;
-      return false;
-    }
-
-    /// \brief Append the argument onto the given array as strings.
-    void render(const ArgList &Args, ArgStringList &Output) const;
-
-    /// \brief Append the argument, render as an input, onto the given
-    /// array as strings.
-    ///
-    /// The distinction is that some options only render their values
-    /// when rendered as a input (e.g., Xlinker).
-    void renderAsInput(const ArgList &Args, ArgStringList &Output) const;
-
-    void dump() const;
-
-    /// \brief Return a formatted version of the argument and
-    /// its values, for debugging and diagnostics.
-    std::string getAsString(const ArgList &Args) const;
-  };
-
-} // end namespace driver
-} // end namespace clang
-
-#endif
diff --git a/include/clang/Driver/ArgList.h b/include/clang/Driver/ArgList.h
deleted file mode 100644 (file)
index 777d052..0000000
+++ /dev/null
@@ -1,442 +0,0 @@
-//===--- ArgList.h - Argument List Management ----------*- C++ -*-===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef CLANG_DRIVER_ARGLIST_H_
-#define CLANG_DRIVER_ARGLIST_H_
-
-#include "clang/Basic/LLVM.h"
-#include "clang/Driver/OptSpecifier.h"
-#include "clang/Driver/Option.h"
-#include "clang/Driver/Util.h"
-#include "llvm/ADT/SmallVector.h"
-#include "llvm/ADT/StringRef.h"
-#include <list>
-#include <string>
-#include <vector>
-
-namespace clang {
-  class DiagnosticsEngine;
-
-namespace driver {
-  class Arg;
-  class ArgList;
-  class Option;
-
-  /// arg_iterator - Iterates through arguments stored inside an ArgList.
-  class arg_iterator {
-    /// The current argument.
-    SmallVectorImpl<Arg*>::const_iterator Current;
-
-    /// The argument list we are iterating over.
-    const ArgList &Args;
-
-    /// Optional filters on the arguments which will be match. Most clients
-    /// should never want to iterate over arguments without filters, so we won't
-    /// bother to factor this into two separate iterator implementations.
-    //
-    // FIXME: Make efficient; the idea is to provide efficient iteration over
-    // all arguments which match a particular id and then just provide an
-    // iterator combinator which takes multiple iterators which can be
-    // efficiently compared and returns them in order.
-    OptSpecifier Id0, Id1, Id2;
-
-    void SkipToNextArg();
-
-  public:
-    typedef Arg * const *                 value_type;
-    typedef Arg * const &                 reference;
-    typedef Arg * const *                 pointer;
-    typedef std::forward_iterator_tag   iterator_category;
-    typedef std::ptrdiff_t              difference_type;
-
-    arg_iterator(SmallVectorImpl<Arg*>::const_iterator it,
-                 const ArgList &_Args, OptSpecifier _Id0 = 0U,
-                 OptSpecifier _Id1 = 0U, OptSpecifier _Id2 = 0U)
-      : Current(it), Args(_Args), Id0(_Id0), Id1(_Id1), Id2(_Id2) {
-      SkipToNextArg();
-    }
-
-    operator const Arg*() { return *Current; }
-    reference operator*() const { return *Current; }
-    pointer operator->() const { return Current; }
-
-    arg_iterator &operator++() {
-      ++Current;
-      SkipToNextArg();
-      return *this;
-    }
-
-    arg_iterator operator++(int) {
-      arg_iterator tmp(*this);
-      ++(*this);
-      return tmp;
-    }
-
-    friend bool operator==(arg_iterator LHS, arg_iterator RHS) {
-      return LHS.Current == RHS.Current;
-    }
-    friend bool operator!=(arg_iterator LHS, arg_iterator RHS) {
-      return !(LHS == RHS);
-    }
-  };
-
-  /// ArgList - Ordered collection of driver arguments.
-  ///
-  /// The ArgList class manages a list of Arg instances as well as
-  /// auxiliary data and convenience methods to allow Tools to quickly
-  /// check for the presence of Arg instances for a particular Option
-  /// and to iterate over groups of arguments.
-  class ArgList {
-  private:
-    ArgList(const ArgList &) LLVM_DELETED_FUNCTION;
-    void operator=(const ArgList &) LLVM_DELETED_FUNCTION;
-
-  public:
-    typedef SmallVector<Arg*, 16> arglist_type;
-    typedef arglist_type::iterator iterator;
-    typedef arglist_type::const_iterator const_iterator;
-    typedef arglist_type::reverse_iterator reverse_iterator;
-    typedef arglist_type::const_reverse_iterator const_reverse_iterator;
-
-  private:
-    /// The internal list of arguments.
-    arglist_type Args;
-
-  protected:
-    ArgList();
-
-  public:
-    virtual ~ArgList();
-
-    /// @name Arg Access
-    /// @{
-
-    /// append - Append \p A to the arg list.
-    void append(Arg *A);
-
-    arglist_type &getArgs() { return Args; }
-    const arglist_type &getArgs() const { return Args; }
-
-    unsigned size() const { return Args.size(); }
-
-    /// @}
-    /// @name Arg Iteration
-    /// @{
-
-    iterator begin() { return Args.begin(); }
-    iterator end() { return Args.end(); }
-
-    reverse_iterator rbegin() { return Args.rbegin(); }
-    reverse_iterator rend() { return Args.rend(); }
-
-    const_iterator begin() const { return Args.begin(); }
-    const_iterator end() const { return Args.end(); }
-
-    const_reverse_iterator rbegin() const { return Args.rbegin(); }
-    const_reverse_iterator rend() const { return Args.rend(); }
-
-    arg_iterator filtered_begin(OptSpecifier Id0 = 0U, OptSpecifier Id1 = 0U,
-                                OptSpecifier Id2 = 0U) const {
-      return arg_iterator(Args.begin(), *this, Id0, Id1, Id2);
-    }
-    arg_iterator filtered_end() const {
-      return arg_iterator(Args.end(), *this);
-    }
-
-    /// @}
-    /// @name Arg Removal
-    /// @{
-
-    /// eraseArg - Remove any option matching \p Id.
-    void eraseArg(OptSpecifier Id);
-
-    /// @}
-    /// @name Arg Access
-    /// @{
-
-    /// hasArg - Does the arg list contain any option matching \p Id.
-    ///
-    /// \p Claim Whether the argument should be claimed, if it exists.
-    bool hasArgNoClaim(OptSpecifier Id) const {
-      return getLastArgNoClaim(Id) != 0;
-    }
-    bool hasArg(OptSpecifier Id) const {
-      return getLastArg(Id) != 0;
-    }
-    bool hasArg(OptSpecifier Id0, OptSpecifier Id1) const {
-      return getLastArg(Id0, Id1) != 0;
-    }
-    bool hasArg(OptSpecifier Id0, OptSpecifier Id1, OptSpecifier Id2) const {
-      return getLastArg(Id0, Id1, Id2) != 0;
-    }
-
-    /// getLastArg - Return the last argument matching \p Id, or null.
-    ///
-    /// \p Claim Whether the argument should be claimed, if it exists.
-    Arg *getLastArgNoClaim(OptSpecifier Id) const;
-    Arg *getLastArg(OptSpecifier Id) const;
-    Arg *getLastArg(OptSpecifier Id0, OptSpecifier Id1) const;
-    Arg *getLastArg(OptSpecifier Id0, OptSpecifier Id1, OptSpecifier Id2) const;
-    Arg *getLastArg(OptSpecifier Id0, OptSpecifier Id1, OptSpecifier Id2,
-                    OptSpecifier Id3) const;
-    Arg *getLastArg(OptSpecifier Id0, OptSpecifier Id1, OptSpecifier Id2,
-                    OptSpecifier Id3, OptSpecifier Id4) const;
-    Arg *getLastArg(OptSpecifier Id0, OptSpecifier Id1, OptSpecifier Id2,
-                    OptSpecifier Id3, OptSpecifier Id4, OptSpecifier Id5) const;
-    Arg *getLastArg(OptSpecifier Id0, OptSpecifier Id1, OptSpecifier Id2,
-                    OptSpecifier Id3, OptSpecifier Id4, OptSpecifier Id5,
-                    OptSpecifier Id6) const;
-    Arg *getLastArg(OptSpecifier Id0, OptSpecifier Id1, OptSpecifier Id2,
-                    OptSpecifier Id3, OptSpecifier Id4, OptSpecifier Id5,
-                    OptSpecifier Id6, OptSpecifier Id7) const;
-
-    /// getArgString - Return the input argument string at \p Index.
-    virtual const char *getArgString(unsigned Index) const = 0;
-
-    /// getNumInputArgStrings - Return the number of original argument strings,
-    /// which are guaranteed to be the first strings in the argument string
-    /// list.
-    virtual unsigned getNumInputArgStrings() const = 0;
-
-    /// @}
-    /// @name Argument Lookup Utilities
-    /// @{
-
-    /// getLastArgValue - Return the value of the last argument, or a default.
-    StringRef getLastArgValue(OptSpecifier Id,
-                                    StringRef Default = "") const;
-
-    /// getLastArgValue - Return the value of the last argument as an integer,
-    /// or a default. If Diags is non-null, emits an error if the argument
-    /// is given, but non-integral.
-    int getLastArgIntValue(OptSpecifier Id, int Default,
-                           DiagnosticsEngine *Diags = 0) const;
-
-    /// getLastArgValue - Return the value of the last argument as an integer,
-    /// or a default. Emits an error if the argument is given, but non-integral.
-    int getLastArgIntValue(OptSpecifier Id, int Default,
-                           DiagnosticsEngine &Diags) const {
-      return getLastArgIntValue(Id, Default, &Diags);
-    }
-
-    /// getAllArgValues - Get the values of all instances of the given argument
-    /// as strings.
-    std::vector<std::string> getAllArgValues(OptSpecifier Id) const;
-
-    /// @}
-    /// @name Translation Utilities
-    /// @{
-
-    /// hasFlag - Given an option \p Pos and its negative form \p Neg, return
-    /// true if the option is present, false if the negation is present, and
-    /// \p Default if neither option is given. If both the option and its
-    /// negation are present, the last one wins.
-    bool hasFlag(OptSpecifier Pos, OptSpecifier Neg, bool Default = true) const;
-
-    /// hasFlag - Given an option \p Pos, an alias \p PosAlias and its negative
-    /// form \p Neg, return true if the option or its alias is present, false if
-    /// the negation is present, and \p Default if none of the options are
-    /// given. If multiple options are present, the last one wins.
-    bool hasFlag(OptSpecifier Pos, OptSpecifier PosAlias, OptSpecifier Neg,
-                 bool Default = true) const;
-
-    /// AddLastArg - Render only the last argument match \p Id0, if present.
-    void AddLastArg(ArgStringList &Output, OptSpecifier Id0) const;
-    void AddLastArg(ArgStringList &Output, OptSpecifier Id0,
-                    OptSpecifier Id1) const;
-
-    /// AddAllArgs - Render all arguments matching the given ids.
-    void AddAllArgs(ArgStringList &Output, OptSpecifier Id0,
-                    OptSpecifier Id1 = 0U, OptSpecifier Id2 = 0U) const;
-
-    /// AddAllArgValues - Render the argument values of all arguments
-    /// matching the given ids.
-    void AddAllArgValues(ArgStringList &Output, OptSpecifier Id0,
-                         OptSpecifier Id1 = 0U, OptSpecifier Id2 = 0U) const;
-
-    /// AddAllArgsTranslated - Render all the arguments matching the
-    /// given ids, but forced to separate args and using the provided
-    /// name instead of the first option value.
-    ///
-    /// \param Joined - If true, render the argument as joined with
-    /// the option specifier.
-    void AddAllArgsTranslated(ArgStringList &Output, OptSpecifier Id0,
-                              const char *Translation,
-                              bool Joined = false) const;
-
-    /// ClaimAllArgs - Claim all arguments which match the given
-    /// option id.
-    void ClaimAllArgs(OptSpecifier Id0) const;
-
-    /// ClaimAllArgs - Claim all arguments.
-    ///
-    void ClaimAllArgs() const;
-
-    /// @}
-    /// @name Arg Synthesis
-    /// @{
-
-    /// MakeArgString - Construct a constant string pointer whose
-    /// lifetime will match that of the ArgList.
-    virtual const char *MakeArgString(StringRef Str) const = 0;
-    const char *MakeArgString(const char *Str) const {
-      return MakeArgString(StringRef(Str));
-    }
-    const char *MakeArgString(std::string Str) const {
-      return MakeArgString(StringRef(Str));
-    }
-    const char *MakeArgString(const Twine &Str) const;
-
-    /// \brief Create an arg string for (\p LHS + \p RHS), reusing the
-    /// string at \p Index if possible.
-    const char *GetOrMakeJoinedArgString(unsigned Index, StringRef LHS,
-                                         StringRef RHS) const;
-
-    /// @}
-
-    void dump() const;
-  };
-
-  class InputArgList : public ArgList  {
-  private:
-    /// List of argument strings used by the contained Args.
-    ///
-    /// This is mutable since we treat the ArgList as being the list
-    /// of Args, and allow routines to add new strings (to have a
-    /// convenient place to store the memory) via MakeIndex.
-    mutable ArgStringList ArgStrings;
-
-    /// Strings for synthesized arguments.
-    ///
-    /// This is mutable since we treat the ArgList as being the list
-    /// of Args, and allow routines to add new strings (to have a
-    /// convenient place to store the memory) via MakeIndex.
-    mutable std::list<std::string> SynthesizedStrings;
-
-    /// The number of original input argument strings.
-    unsigned NumInputArgStrings;
-
-  public:
-    InputArgList(const char* const *ArgBegin, const char* const *ArgEnd);
-    ~InputArgList();
-
-    virtual const char *getArgString(unsigned Index) const {
-      return ArgStrings[Index];
-    }
-
-    virtual unsigned getNumInputArgStrings() const {
-      return NumInputArgStrings;
-    }
-
-    /// @name Arg Synthesis
-    /// @{
-
-  public:
-    /// MakeIndex - Get an index for the given string(s).
-    unsigned MakeIndex(StringRef String0) const;
-    unsigned MakeIndex(StringRef String0, StringRef String1) const;
-
-    virtual const char *MakeArgString(StringRef Str) const;
-
-    /// @}
-  };
-
-  /// DerivedArgList - An ordered collection of driver arguments,
-  /// whose storage may be in another argument list.
-  class DerivedArgList : public ArgList {
-    const InputArgList &BaseArgs;
-
-    /// The list of arguments we synthesized.
-    mutable arglist_type SynthesizedArgs;
-
-  public:
-    /// Construct a new derived arg list from \p BaseArgs.
-    DerivedArgList(const InputArgList &BaseArgs);
-    ~DerivedArgList();
-
-    virtual const char *getArgString(unsigned Index) const {
-      return BaseArgs.getArgString(Index);
-    }
-
-    virtual unsigned getNumInputArgStrings() const {
-      return BaseArgs.getNumInputArgStrings();
-    }
-
-    const InputArgList &getBaseArgs() const {
-      return BaseArgs;
-    }
-
-    /// @name Arg Synthesis
-    /// @{
-
-    /// AddSynthesizedArg - Add a argument to the list of synthesized arguments
-    /// (to be freed).
-    void AddSynthesizedArg(Arg *A) {
-      SynthesizedArgs.push_back(A);
-    }
-
-    virtual const char *MakeArgString(StringRef Str) const;
-
-    /// AddFlagArg - Construct a new FlagArg for the given option \p Id and
-    /// append it to the argument list.
-    void AddFlagArg(const Arg *BaseArg, const Option Opt) {
-      append(MakeFlagArg(BaseArg, Opt));
-    }
-
-    /// AddPositionalArg - Construct a new Positional arg for the given option
-    /// \p Id, with the provided \p Value and append it to the argument
-    /// list.
-    void AddPositionalArg(const Arg *BaseArg, const Option Opt,
-                          StringRef Value) {
-      append(MakePositionalArg(BaseArg, Opt, Value));
-    }
-
-
-    /// AddSeparateArg - Construct a new Positional arg for the given option
-    /// \p Id, with the provided \p Value and append it to the argument
-    /// list.
-    void AddSeparateArg(const Arg *BaseArg, const Option Opt,
-                        StringRef Value) {
-      append(MakeSeparateArg(BaseArg, Opt, Value));
-    }
-
-
-    /// AddJoinedArg - Construct a new Positional arg for the given option
-    /// \p Id, with the provided \p Value and append it to the argument list.
-    void AddJoinedArg(const Arg *BaseArg, const Option Opt,
-                      StringRef Value) {
-      append(MakeJoinedArg(BaseArg, Opt, Value));
-    }
-
-
-    /// MakeFlagArg - Construct a new FlagArg for the given option \p Id.
-    Arg *MakeFlagArg(const Arg *BaseArg, const Option Opt) const;
-
-    /// MakePositionalArg - Construct a new Positional arg for the
-    /// given option \p Id, with the provided \p Value.
-    Arg *MakePositionalArg(const Arg *BaseArg, const Option Opt,
-                           StringRef Value) const;
-
-    /// MakeSeparateArg - Construct a new Positional arg for the
-    /// given option \p Id, with the provided \p Value.
-    Arg *MakeSeparateArg(const Arg *BaseArg, const Option Opt,
-                         StringRef Value) const;
-
-    /// MakeJoinedArg - Construct a new Positional arg for the
-    /// given option \p Id, with the provided \p Value.
-    Arg *MakeJoinedArg(const Arg *BaseArg, const Option Opt,
-                       StringRef Value) const;
-
-    /// @}
-  };
-
-} // end namespace driver
-} // end namespace clang
-
-#endif
index 420a10138cbaafb42beee9cdac1daa649c7a477d..00e120c81d46c0beaf0b551d230b7e186b8fde89 100644 (file)
 #ifndef CLANG_DRIVER_CC1ASOPTIONS_H
 #define CLANG_DRIVER_CC1ASOPTIONS_H
 
+namespace llvm {
+namespace opt {
+  class OptTable;
+}
+}
+
 namespace clang {
 namespace driver {
-  class OptTable;
+  // FIXME: Remove this using directive and qualify class usage below.
+  using namespace llvm::opt;
+
 
 namespace cc1asoptions {
   enum ID {
index 2749bcd7779c3ee38be9021141919a37311181e7..a52babb91e547c8a05aeaa6ebd55be2bebff3106 100644 (file)
@@ -12,7 +12,7 @@
 //===----------------------------------------------------------------------===//
 
 // Include the common option parsing interfaces.
-include "OptParser.td"
+include "llvm/Option/OptParser.td"
 
 //===----------------------------------------------------------------------===//
 // Target Options
index 1277d51edb82c69d1b9e5d357346d383d0a01bc4..afcb8d3fbadb7541870023b944f2d2d1d49f972b 100644 (file)
@@ -1,7 +1,7 @@
-clang_tablegen(Options.inc -gen-opt-parser-defs
-  SOURCE Options.td
-  TARGET ClangDriverOptions)
+set(LLVM_TARGET_DEFINITIONS Options.td)
+tablegen(CLANG Options.inc -gen-opt-parser-defs)
+add_public_tablegen_target(ClangDriverOptions)
 
-clang_tablegen(CC1AsOptions.inc -gen-opt-parser-defs
-  SOURCE CC1AsOptions.td
-  TARGET ClangCC1AsOptions)
+set(LLVM_TARGET_DEFINITIONS CC1AsOptions.td)
+tablegen(CLANG CC1AsOptions.inc -gen-opt-parser-defs)
+add_public_tablegen_target(ClangCC1AsOptions)
index 3f9bb5aad7062465a42e8af23a293b48e19852d5..b488572f2440d3cf441aa198042b028157fb7a64 100644 (file)
 #include "llvm/Support/Path.h"
 #include "llvm/Support/PathV1.h"
 
+namespace llvm {
+namespace opt {
+  class DerivedArgList;
+  class InputArgList;
+}
+}
+
 namespace clang {
 namespace driver {
-  class DerivedArgList;
+  // FIXME: Remove this using directive and qualify class usage below.
+  using namespace llvm::opt;
+
   class Driver;
-  class InputArgList;
   class JobAction;
   class JobList;
   class ToolChain;
index 1b17578bbbe2f385b2e74f1bd81c66167a1011ad..f702548e1c41f794e5996eb48b9f22f1a7936c2a 100644 (file)
 #include <set>
 #include <string>
 
+namespace llvm {
+namespace opt {
+  class Arg;
+  class ArgList;
+  class DerivedArgList;
+  class InputArgList;
+  class OptTable;
+}
+}
+
 namespace clang {
 namespace driver {
+  // FIXME: Remove this using directive and qualify class usage below.
+  using namespace llvm::opt;
+
   class Action;
-  class Arg;
-  class ArgList;
   class Command;
   class Compilation;
-  class DerivedArgList;
-  class InputArgList;
   class InputInfo;
   class JobAction;
-  class OptTable;
   class ToolChain;
 
 /// Driver - Encapsulate logic for constructing compilation processes
index 045b5d89ded3c3f32194e2d21247445f9afcdf66..3f7b6094a4e95894a60661c1cc9a2fd3056906a7 100644 (file)
 #define CLANG_DRIVER_JOB_H_
 
 #include "clang/Basic/LLVM.h"
-#include "clang/Driver/Util.h"
 #include "llvm/ADT/SmallVector.h"
+#include "llvm/Option/Option.h"
 
 namespace clang {
 namespace driver {
+class Action;
 class Command;
 class Tool;
 
+using llvm::opt::ArgStringList;
+
 class Job {
 public:
   enum JobClass {
index 7d066c77b377deff5acefcae7e0b7d7e5e1dd831..375f6747c9934b1d7741dfb2e291c34ff3988b6d 100644 (file)
@@ -5,10 +5,10 @@ TABLEGEN_INC_FILES_COMMON = 1
 
 include $(CLANG_LEVEL)/Makefile
 
-$(ObjDir)/Options.inc.tmp : Options.td CC1Options.td OptParser.td $(CLANG_TBLGEN) $(ObjDir)/.dir
+$(ObjDir)/Options.inc.tmp : Options.td CC1Options.td $(LLVM_TBLGEN) $(ObjDir)/.dir
        $(Echo) "Building Clang Driver Option tables with tblgen"
-       $(Verb) $(ClangTableGen) -gen-opt-parser-defs -o $(call SYSPATH, $@) $<
+       $(Verb) $(LLVMTableGen) -gen-opt-parser-defs -o $(call SYSPATH, $@) $<
 
-$(ObjDir)/CC1AsOptions.inc.tmp : CC1AsOptions.td OptParser.td $(CLANG_TBLGEN) $(ObjDir)/.dir
+$(ObjDir)/CC1AsOptions.inc.tmp : CC1AsOptions.td $(LLVM_TBLGEN) $(ObjDir)/.dir
        $(Echo) "Building Clang CC1 Assembler Option tables with tblgen"
-       $(Verb) $(ClangTableGen) -gen-opt-parser-defs -o $(call SYSPATH, $@) $<
+       $(Verb) $(LLVMTableGen) -gen-opt-parser-defs -o $(call SYSPATH, $@) $<
diff --git a/include/clang/Driver/OptParser.td b/include/clang/Driver/OptParser.td
deleted file mode 100644 (file)
index d16a2a7..0000000
+++ /dev/null
@@ -1,152 +0,0 @@
-//===--- OptParser.td - Common Option Parsing Interfaces ------------------===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-//  This file defines the common interfaces used by the option parsing TableGen
-//  backend.
-//
-//===----------------------------------------------------------------------===//
-
-// Define the kinds of options.
-
-class OptionKind<string name, int predecence = 0, bit sentinel = 0> {
-  string Name = name;
-  // The kind precedence, kinds with lower precedence are matched first.
-  int Precedence = predecence;
-  // Indicate a sentinel option.
-  bit Sentinel = sentinel;
-}
-
-// An option group.
-def KIND_GROUP : OptionKind<"Group">;
-// The input option kind.
-def KIND_INPUT : OptionKind<"Input", 1, 1>;
-// The unknown option kind.
-def KIND_UNKNOWN : OptionKind<"Unknown", 2, 1>;
-// A flag with no values.
-def KIND_FLAG : OptionKind<"Flag">;
-// An option which prefixes its (single) value.
-def KIND_JOINED : OptionKind<"Joined", 1>;
-// An option which is followed by its value.
-def KIND_SEPARATE : OptionKind<"Separate">;
-// An option followed by its values, which are separated by commas.
-def KIND_COMMAJOINED : OptionKind<"CommaJoined">;
-// An option which is which takes multiple (separate) arguments.
-def KIND_MULTIARG : OptionKind<"MultiArg">;
-// An option which is either joined to its (non-empty) value, or followed by its
-// value.
-def KIND_JOINED_OR_SEPARATE : OptionKind<"JoinedOrSeparate">;
-// An option which is both joined to its (first) value, and followed by its
-// (second) value.
-def KIND_JOINED_AND_SEPARATE : OptionKind<"JoinedAndSeparate">;
-
-// Define the option flags.
-
-class OptionFlag {}
-
-// DriverOption - The option is a "driver" option, and should not be forwarded
-// to gcc.
-def DriverOption : OptionFlag;
-
-// LinkerInput - The option is a linker input.
-def LinkerInput : OptionFlag;
-
-// NoArgumentUnused - Don't report argument unused warnings for this option; this
-// is useful for options like -static or -dynamic which a user may always end up
-// passing, even if the platform defaults to (or only supports) that option.
-def NoArgumentUnused : OptionFlag;
-
-// RenderAsInput - The option should not render the name when rendered as an
-// input (i.e., the option is rendered as values).
-def RenderAsInput : OptionFlag;
-
-// RenderJoined - The option should be rendered joined, even if separate (only
-// sensible on single value separate options).
-def RenderJoined : OptionFlag;
-
-// RenderSeparate - The option should be rendered separately, even if joined
-// (only sensible on joined options).
-def RenderSeparate : OptionFlag;
-
-// Unsupported - The option is unsupported, and the driver will reject command
-// lines that use it.
-def Unsupported : OptionFlag;
-
-// HelpHidden - The option should not be displayed in --help, even if it has
-// help text. Clients *can* use this in conjunction with the OptTable::PrintHelp
-// arguments to implement hidden help groups.
-def HelpHidden : OptionFlag;
-
-// NoForward - The option should not be implicitly forwarded to other tools.
-def NoForward : OptionFlag;
-
-// CC1Option - This option should be accepted by clang -cc1.
-def CC1Option : OptionFlag;
-
-// NoDriverOption - This option should not be accepted by the driver.
-def NoDriverOption : OptionFlag;
-
-// Define the option group class.
-
-class OptionGroup<string name> {
-  string EnumName = ?; // Uses the def name if undefined.
-  string Name = name;
-  string HelpText = ?;
-  OptionGroup Group = ?;
-}
-
-// Define the option class.
-
-class Option<list<string> prefixes, string name, OptionKind kind> {
-  string EnumName = ?; // Uses the def name if undefined.
-  list<string> Prefixes = prefixes;
-  string Name = name;
-  OptionKind Kind = kind;
-  // Used by MultiArg option kind.
-  int NumArgs = 0;
-  string HelpText = ?;
-  string MetaVarName = ?;
-  list<OptionFlag> Flags = [];
-  OptionGroup Group = ?;
-  Option Alias = ?;
-}
-
-// Helpers for defining options.
-
-class Flag<list<string> prefixes, string name>
-  : Option<prefixes, name, KIND_FLAG>;
-class Joined<list<string> prefixes, string name>
-  : Option<prefixes, name, KIND_JOINED>;
-class Separate<list<string> prefixes, string name>
-  : Option<prefixes, name, KIND_SEPARATE>;
-class CommaJoined<list<string> prefixes, string name>
-  : Option<prefixes, name, KIND_COMMAJOINED>;
-class MultiArg<list<string> prefixes, string name, int numargs>
-  : Option<prefixes, name, KIND_MULTIARG> {
-  int NumArgs = numargs;
-}
-class JoinedOrSeparate<list<string> prefixes, string name>
-  : Option<prefixes, name, KIND_JOINED_OR_SEPARATE>;
-class JoinedAndSeparate<list<string> prefixes, string name>
-  : Option<prefixes, name, KIND_JOINED_AND_SEPARATE>;
-
-// Mix-ins for adding optional attributes.
-
-class Alias<Option alias> { Option Alias = alias; }
-class EnumName<string name> { string EnumName = name; }
-class Flags<list<OptionFlag> flags> { list<OptionFlag> Flags = flags; }
-class Group<OptionGroup group> { OptionGroup Group = group; }
-class HelpText<string text> { string HelpText = text; }
-class MetaVarName<string name> { string MetaVarName = name; }
-
-// Predefined options.
-
-// FIXME: Have generator validate that these appear in correct position (and
-// aren't duplicated).
-def INPUT : Option<[], "<input>", KIND_INPUT>, Flags<[DriverOption,CC1Option]>;
-def UNKNOWN : Option<[], "<unknown>", KIND_UNKNOWN>;
diff --git a/include/clang/Driver/OptSpecifier.h b/include/clang/Driver/OptSpecifier.h
deleted file mode 100644 (file)
index e683ef3..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-//===--- OptSpecifier.h - Option Specifiers ---------------------*- C++ -*-===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef CLANG_DRIVER_OPTSPECIFIER_H
-#define CLANG_DRIVER_OPTSPECIFIER_H
-
-#include "llvm/Support/Compiler.h"
-
-namespace clang {
-namespace driver {
-  class Option;
-
-  /// OptSpecifier - Wrapper class for abstracting references to option IDs.
-  class OptSpecifier {
-    unsigned ID;
-
-  private:
-    explicit OptSpecifier(bool) LLVM_DELETED_FUNCTION;
-
-  public:
-    OptSpecifier() : ID(0) {}
-    /*implicit*/ OptSpecifier(unsigned _ID) : ID(_ID) {}
-    /*implicit*/ OptSpecifier(const Option *Opt);
-
-    bool isValid() const { return ID != 0; }
-
-    unsigned getID() const { return ID; }
-
-    bool operator==(OptSpecifier Opt) const { return ID == Opt.getID(); }
-    bool operator!=(OptSpecifier Opt) const { return !(*this == Opt); }
-  };
-}
-}
-
-#endif
diff --git a/include/clang/Driver/OptTable.h b/include/clang/Driver/OptTable.h
deleted file mode 100644 (file)
index 53d83a0..0000000
+++ /dev/null
@@ -1,161 +0,0 @@
-//===--- OptTable.h - Option Table ------------------------------*- C++ -*-===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef CLANG_DRIVER_OPTTABLE_H
-#define CLANG_DRIVER_OPTTABLE_H
-
-#include "clang/Basic/LLVM.h"
-#include "clang/Driver/OptSpecifier.h"
-#include "llvm/ADT/StringSet.h"
-
-namespace clang {
-namespace driver {
-  class Arg;
-  class ArgList;
-  class InputArgList;
-  class Option;
-
-  /// \brief 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.
-  class OptTable {
-  public:
-    /// \brief Entry for a single option instance in the option data table.
-    struct Info {
-      /// A null terminated array of prefix strings to apply to name while
-      /// matching.
-      const char *const *Prefixes;
-      const char *Name;
-      const char *HelpText;
-      const char *MetaVar;
-      unsigned ID;
-      unsigned char Kind;
-      unsigned char Param;
-      unsigned short Flags;
-      unsigned short GroupID;
-      unsigned short AliasID;
-    };
-
-  private:
-    /// \brief The static option information table.
-    const Info *OptionInfos;
-    unsigned NumOptionInfos;
-
-    unsigned TheInputOptionID;
-    unsigned TheUnknownOptionID;
-
-    /// 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;
-
-    /// The union of all option prefixes. If an argument does not begin with
-    /// one of these, it is an input.
-    llvm::StringSet<> PrefixesUnion;
-    std::string PrefixChars;
-
-  private:
-    const Info &getInfo(OptSpecifier Opt) const {
-      unsigned id = Opt.getID();
-      assert(id > 0 && id - 1 < getNumOptions() && "Invalid Option ID.");
-      return OptionInfos[id - 1];
-    }
-
-  protected:
-    OptTable(const Info *_OptionInfos, unsigned _NumOptionInfos);
-  public:
-    ~OptTable();
-
-    /// \brief Return the total number of option classes.
-    unsigned getNumOptions() const { return NumOptionInfos; }
-
-    /// \brief Get the given Opt's Option instance, lazily creating it
-    /// if necessary.
-    ///
-    /// \return The option, or null for the INVALID option id.
-    const Option getOption(OptSpecifier Opt) const;
-
-    /// \brief Lookup the name of the given option.
-    const char *getOptionName(OptSpecifier id) const {
-      return getInfo(id).Name;
-    }
-
-    /// \brief Get the kind of the given option.
-    unsigned getOptionKind(OptSpecifier id) const {
-      return getInfo(id).Kind;
-    }
-
-    /// \brief Get the group id for the given option.
-    unsigned getOptionGroupID(OptSpecifier id) const {
-      return getInfo(id).GroupID;
-    }
-
-    /// \brief Get the help text to use to describe this option.
-    const char *getOptionHelpText(OptSpecifier id) const {
-      return getInfo(id).HelpText;
-    }
-
-    /// \brief Get the meta-variable name to use when describing
-    /// this options values in the help text.
-    const char *getOptionMetaVar(OptSpecifier id) const {
-      return getInfo(id).MetaVar;
-    }
-
-    /// \brief 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 ArgList &Args, unsigned &Index) const;
-
-    /// \brief Parse an list of arguments into an InputArgList.
-    ///
-    /// The resulting InputArgList will reference the strings in [\p ArgBegin,
-    /// \p ArgEnd), and their lifetime should extend past that of the returned
-    /// InputArgList.
-    ///
-    /// The only error that can occur in this routine is if an argument is
-    /// missing values; in this case \p MissingArgCount will be non-zero.
-    ///
-    /// \param ArgBegin - The beginning of the argument vector.
-    /// \param ArgEnd - The end of the argument vector.
-    /// \param MissingArgIndex - On error, the index of the option which could
-    /// not be parsed.
-    /// \param MissingArgCount - On error, the number of missing options.
-    /// \return An InputArgList; on error this will contain all the options
-    /// which could be parsed.
-    InputArgList *ParseArgs(const char* const *ArgBegin,
-                            const char* const *ArgEnd,
-                            unsigned &MissingArgIndex,
-                            unsigned &MissingArgCount) const;
-
-    /// \brief Render the help text for an option table.
-    ///
-    /// \param OS - The stream to write the help text to.
-    /// \param Name - The name to use in the usage line.
-    /// \param Title - The title to use in the usage line.
-    /// \param FlagsToInclude - If non-zero, only include options with any
-    ///                         of these flags set.
-    /// \param FlagsToExclude - Exclude options with any of these flags set.
-    void PrintHelp(raw_ostream &OS, const char *Name,
-                   const char *Title, unsigned short FlagsToInclude = 0,
-                   unsigned short FlagsToExclude = 0) const;
-  };
-}
-}
-
-#endif
diff --git a/include/clang/Driver/Option.h b/include/clang/Driver/Option.h
deleted file mode 100644 (file)
index 0536caa..0000000
+++ /dev/null
@@ -1,204 +0,0 @@
-//===--- Option.h - Abstract Driver Options ---------------------*- C++ -*-===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef CLANG_DRIVER_OPTION_H_
-#define CLANG_DRIVER_OPTION_H_
-
-#include "clang/Basic/LLVM.h"
-#include "clang/Driver/OptTable.h"
-#include "llvm/ADT/StringRef.h"
-#include "llvm/Support/ErrorHandling.h"
-
-namespace clang {
-namespace driver {
-  class Arg;
-  class ArgList;
-
-namespace options {
-  /// Base flags for all options. Custom flags may be added after.
-  enum DriverFlag {
-    HelpHidden       = (1 << 0),
-    RenderAsInput    = (1 << 1),
-    RenderJoined     = (1 << 2),
-    RenderSeparate   = (1 << 3)
-  };
-
-  /// Flags specifically for clang options.
-  enum ClangFlags {
-    DriverOption     = (1 << 4),
-    LinkerInput      = (1 << 5),
-    NoArgumentUnused = (1 << 6),
-    NoForward        = (1 << 7),
-    Unsupported      = (1 << 8),
-    CC1Option        = (1 << 9),
-    NoDriverOption   = (1 << 10)
-  };
-}
-
-  /// Option - Abstract representation for a single form of driver
-  /// argument.
-  ///
-  /// An Option class represents a form of option that the driver
-  /// takes, for example how many arguments the option has and how
-  /// they can be provided. Individual option instances store
-  /// additional information about what group the option is a member
-  /// of (if any), if the option is an alias, and a number of
-  /// flags. At runtime the driver parses the command line into
-  /// concrete Arg instances, each of which corresponds to a
-  /// particular Option instance.
-  class Option {
-  public:
-    enum OptionClass {
-      GroupClass = 0,
-      InputClass,
-      UnknownClass,
-      FlagClass,
-      JoinedClass,
-      SeparateClass,
-      CommaJoinedClass,
-      MultiArgClass,
-      JoinedOrSeparateClass,
-      JoinedAndSeparateClass
-    };
-
-    enum RenderStyleKind {
-      RenderCommaJoinedStyle,
-      RenderJoinedStyle,
-      RenderSeparateStyle,
-      RenderValuesStyle
-    };
-
-  protected:
-    const OptTable::Info *Info;
-    const OptTable *Owner;
-
-  public:
-    Option(const OptTable::Info *Info, const OptTable *Owner);
-    ~Option();
-
-    bool isValid() const {
-      return Info != 0;
-    }
-
-    unsigned getID() const {
-      assert(Info && "Must have a valid info!");
-      return Info->ID;
-    }
-
-    OptionClass getKind() const {
-      assert(Info && "Must have a valid info!");
-      return OptionClass(Info->Kind);
-    }
-
-    /// \brief Get the name of this option without any prefix.
-    StringRef getName() const {
-      assert(Info && "Must have a valid info!");
-      return Info->Name;
-    }
-
-    const Option getGroup() const {
-      assert(Info && "Must have a valid info!");
-      assert(Owner && "Must have a valid owner!");
-      return Owner->getOption(Info->GroupID);
-    }
-
-    const Option getAlias() const {
-      assert(Info && "Must have a valid info!");
-      assert(Owner && "Must have a valid owner!");
-      return Owner->getOption(Info->AliasID);
-    }
-
-    /// \brief Get the default prefix for this option.
-    StringRef getPrefix() const {
-      const char *Prefix = *Info->Prefixes;
-      return Prefix ? Prefix : StringRef();
-    }
-
-    /// \brief Get the name of this option with the default prefix.
-    std::string getPrefixedName() const {
-      std::string Ret = getPrefix();
-      Ret += getName();
-      return Ret;
-    }
-
-    unsigned getNumArgs() const { return Info->Param; }
-
-    bool hasNoOptAsInput() const { return Info->Flags & options::RenderAsInput;}
-
-    RenderStyleKind getRenderStyle() const {
-      if (Info->Flags & options::RenderJoined)
-        return RenderJoinedStyle;
-      if (Info->Flags & options::RenderSeparate)
-        return RenderSeparateStyle;
-      switch (getKind()) {
-      case GroupClass:
-      case InputClass:
-      case UnknownClass:
-        return RenderValuesStyle;
-      case JoinedClass:
-      case JoinedAndSeparateClass:
-        return RenderJoinedStyle;
-      case CommaJoinedClass:
-        return RenderCommaJoinedStyle;
-      case FlagClass:
-      case SeparateClass:
-      case MultiArgClass:
-      case JoinedOrSeparateClass:
-        return RenderSeparateStyle;
-      }
-      llvm_unreachable("Unexpected kind!");
-    }
-
-    /// Test if this option has the flag \a Val.
-    bool hasFlag(unsigned Val) const {
-      return Info->Flags & Val;
-    }
-
-    /// getUnaliasedOption - Return the final option this option
-    /// aliases (itself, if the option has no alias).
-    const Option getUnaliasedOption() const {
-      const Option Alias = getAlias();
-      if (Alias.isValid()) return Alias.getUnaliasedOption();
-      return *this;
-    }
-
-    /// getRenderName - Return the name to use when rendering this
-    /// option.
-    StringRef getRenderName() const {
-      return getUnaliasedOption().getName();
-    }
-
-    /// matches - Predicate for whether this option is part of the
-    /// given option (which may be a group).
-    ///
-    /// Note that matches against options which are an alias should never be
-    /// done -- aliases do not participate in matching and so such a query will
-    /// always be false.
-    bool matches(OptSpecifier ID) const;
-
-    /// accept - Potentially accept the current argument, returning a
-    /// new Arg instance, or 0 if the option does not accept this
-    /// argument (or the argument is missing values).
-    ///
-    /// If the option accepts the current argument, accept() sets
-    /// Index to the position where argument parsing should resume
-    /// (even if the argument is missing values).
-    ///
-    /// \param ArgSize The number of bytes taken up by the matched Option prefix
-    ///                and name. This is used to determine where joined values
-    ///                start.
-    Arg *accept(const ArgList &Args, unsigned &Index, unsigned ArgSize) const;
-
-    void dump() const;
-  };
-
-} // end namespace driver
-} // end namespace clang
-
-#endif
index 6c114e252d3ced701927377daf8adf3ba70067a9..650e8e75a6fd4e2c7c948f0872a10070ca7b142d 100644 (file)
 #ifndef CLANG_DRIVER_OPTIONS_H
 #define CLANG_DRIVER_OPTIONS_H
 
+namespace llvm {
+namespace opt {
+class OptTable;
+}
+}
+
 namespace clang {
 namespace driver {
-  class OptTable;
 
 namespace options {
-  enum ID {
+/// Flags specifically for clang options.  Must not overlap with
+/// llvm::opt::DriverFlag.
+enum ClangFlags {
+  DriverOption = (1 << 4),
+  LinkerInput = (1 << 5),
+  NoArgumentUnused = (1 << 6),
+  NoForward = (1 << 7),
+  Unsupported = (1 << 8),
+  CC1Option = (1 << 9),
+  NoDriverOption = (1 << 10)
+};
+
+enum ID {
     OPT_INVALID = 0, // This is not an option ID.
 #define PREFIX(NAME, VALUE)
 #define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, FLAGS, PARAM, \
@@ -27,7 +44,7 @@ namespace options {
   };
 }
 
-  OptTable *createDriverOptTable();
+llvm::opt::OptTable *createDriverOptTable();
 }
 }
 
index 4073d857a460511739c037b4e1e79c90b9e4f3a0..b74165a9ff4580ab2da27252aa709a02289946bf 100644 (file)
 //===----------------------------------------------------------------------===//
 
 // Include the common option parsing interfaces.
-include "OptParser.td"
+include "llvm/Option/OptParser.td"
+
+/////////
+// Flags
+
+// DriverOption - The option is a "driver" option, and should not be forwarded
+// to gcc.
+def DriverOption : OptionFlag;
+
+// LinkerInput - The option is a linker input.
+def LinkerInput : OptionFlag;
+
+// NoArgumentUnused - Don't report argument unused warnings for this option; this
+// is useful for options like -static or -dynamic which a user may always end up
+// passing, even if the platform defaults to (or only supports) that option.
+def NoArgumentUnused : OptionFlag;
+
+// Unsupported - The option is unsupported, and the driver will reject command
+// lines that use it.
+def Unsupported : OptionFlag;
+
+// NoForward - The option should not be implicitly forwarded to other tools.
+def NoForward : OptionFlag;
+
+// CC1Option - This option should be accepted by clang -cc1.
+def CC1Option : OptionFlag;
+
+// NoDriverOption - This option should not be accepted by the driver.
+def NoDriverOption : OptionFlag;
 
 /////////
 // Groups
index 4c05d0a743bcfe0f6efc4c3da1242a49ffcaca95..66168232a1ec89af2d76b4c9d5640d19515fda19 100644 (file)
 
 #include "clang/Basic/LLVM.h"
 
+namespace llvm {
+namespace opt {
+  class ArgList;
+}
+}
+
 namespace clang {
 namespace driver {
-  class ArgList;
+  // FIXME: Remove this using directive and qualify class usage below.
+  using namespace llvm::opt;
+
   class Compilation;
   class InputInfo;
   class Job;
index aae3d79936b68ac8324a8dc3c037f46c3bf1d405..7b123269803d0a561ff94d6521f7b55000f843a2 100644 (file)
 #include "llvm/Support/Path.h"
 #include <string>
 
+namespace llvm {
+namespace opt {
+  class ArgList;
+  class DerivedArgList;
+  class InputArgList;
+}
+}
+
 namespace clang {
   class ObjCRuntime;
 
 namespace driver {
-  class ArgList;
+  // FIXME: Remove this using directive and qualify class usage below.
+  using namespace llvm::opt;
+
   class Compilation;
-  class DerivedArgList;
   class Driver;
-  class InputArgList;
   class JobAction;
   class Tool;
 
index 06b82b977fe0f331a5882737c828c08b5603555c..b24b9904f2b56e5e78b5ff7d7bf20988f05543f1 100644 (file)
 #include "llvm/ADT/DenseMap.h"
 
 namespace clang {
+class DiagnosticsEngine;
+
 namespace driver {
   class Action;
   class JobAction;
 
-  /// ArgStringList - Type used for constructing argv lists for subprocesses.
-  typedef SmallVector<const char*, 16> ArgStringList;
-
   /// ArgStringMap - Type used to map a JobAction to its result file.
   typedef llvm::DenseMap<const JobAction*, const char*> ArgStringMap;
 
index fac05c55fbb149ff753b87a2cfdc6224a957e855..ef495ebd9a9932e94afd0933fa48ff3283a50d47 100644 (file)
 #include <string>
 #include <vector>
 
+namespace llvm {
+namespace opt {
+class ArgList;
+}
+}
+
 namespace clang {
 
 class CompilerInvocation;
 class DiagnosticsEngine;
 
 namespace driver {
-class ArgList;
+  // FIXME: Remove this using directive and qualify class usage below.
+  using namespace llvm::opt;
 }
 
 /// \brief Fill out Opts based on the options given in Args.
index 8830dced3cc2db7dca0457a78024675c2fcaa108..d6ab03783768ae3d65ef5352f3201b5e1f176987 100644 (file)
 #include "clang/Basic/Diagnostic.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Option/OptSpecifier.h"
 
 namespace llvm {
 class raw_fd_ostream;
 class Triple;
+
+namespace opt {
+class ArgList;
+}
 }
 
 namespace clang {
@@ -104,6 +109,18 @@ createInvocationFromCommandLine(ArrayRef<const char *> Args,
                             IntrusiveRefCntPtr<DiagnosticsEngine> Diags =
                                 IntrusiveRefCntPtr<DiagnosticsEngine>());
 
-}  // end namespace clang
+/// Return the value of the last argument as an integer, or a default. If Diags
+/// is non-null, emits an error if the argument is given, but non-integral.
+int getLastArgIntValue(const llvm::opt::ArgList &Args,
+                       llvm::opt::OptSpecifier Id, int Default,
+                       DiagnosticsEngine *Diags = 0);
+
+inline int getLastArgIntValue(const llvm::opt::ArgList &Args,
+                              llvm::opt::OptSpecifier Id, int Default,
+                              DiagnosticsEngine &Diags) {
+  return getLastArgIntValue(Args, Id, Default, &Diags);
+}
+
+} // end namespace clang
 
 #endif
index 2b5bbee3db2148f7d74a2dfbc49ca0890b71ae58..ddd2d599da06df03c6344f452bab082ead03e09d 100644 (file)
@@ -11,6 +11,7 @@
 #include "llvm/Support/ErrorHandling.h"
 #include <cassert>
 using namespace clang::driver;
+using namespace llvm::opt;
 
 Action::~Action() {
   if (OwnsInputs) {
diff --git a/lib/Driver/Arg.cpp b/lib/Driver/Arg.cpp
deleted file mode 100644 (file)
index 93d70a9..0000000
+++ /dev/null
@@ -1,123 +0,0 @@
-//===--- Arg.cpp - Argument Implementations -------------------------------===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "clang/Driver/Arg.h"
-#include "clang/Basic/LLVM.h"
-#include "clang/Driver/ArgList.h"
-#include "clang/Driver/Option.h"
-#include "llvm/ADT/SmallString.h"
-#include "llvm/ADT/Twine.h"
-#include "llvm/Support/raw_ostream.h"
-
-using namespace clang::driver;
-using clang::StringRef;
-
-Arg::Arg(const Option _Opt, StringRef S, unsigned _Index, const Arg *_BaseArg)
-  : Opt(_Opt), BaseArg(_BaseArg), Spelling(S), Index(_Index),
-    Claimed(false), OwnsValues(false) {
-}
-
-Arg::Arg(const Option _Opt, StringRef S, unsigned _Index,
-         const char *Value0, const Arg *_BaseArg)
-  : Opt(_Opt), BaseArg(_BaseArg), Spelling(S), Index(_Index),
-    Claimed(false), OwnsValues(false) {
-  Values.push_back(Value0);
-}
-
-Arg::Arg(const Option _Opt, StringRef S, unsigned _Index,
-         const char *Value0, const char *Value1, const Arg *_BaseArg)
-  : Opt(_Opt), BaseArg(_BaseArg), Spelling(S), Index(_Index),
-    Claimed(false), OwnsValues(false) {
-  Values.push_back(Value0);
-  Values.push_back(Value1);
-}
-
-Arg::~Arg() {
-  if (OwnsValues) {
-    for (unsigned i = 0, e = Values.size(); i != e; ++i)
-      delete[] Values[i];
-  }
-}
-
-void Arg::dump() const {
-  llvm::errs() << "<";
-
-  llvm::errs() << " Opt:";
-  Opt.dump();
-
-  llvm::errs() << " Index:" << Index;
-
-  llvm::errs() << " Values: [";
-  for (unsigned i = 0, e = Values.size(); i != e; ++i) {
-    if (i) llvm::errs() << ", ";
-    llvm::errs() << "'" << Values[i] << "'";
-  }
-
-  llvm::errs() << "]>\n";
-}
-
-std::string Arg::getAsString(const ArgList &Args) const {
-  SmallString<256> Res;
-  llvm::raw_svector_ostream OS(Res);
-
-  ArgStringList ASL;
-  render(Args, ASL);
-  for (ArgStringList::iterator
-         it = ASL.begin(), ie = ASL.end(); it != ie; ++it) {
-    if (it != ASL.begin())
-      OS << ' ';
-    OS << *it;
-  }
-
-  return OS.str();
-}
-
-void Arg::renderAsInput(const ArgList &Args, ArgStringList &Output) const {
-  if (!getOption().hasNoOptAsInput()) {
-    render(Args, Output);
-    return;
-  }
-
-  for (unsigned i = 0, e = getNumValues(); i != e; ++i)
-    Output.push_back(getValue(i));
-}
-
-void Arg::render(const ArgList &Args, ArgStringList &Output) const {
-  switch (getOption().getRenderStyle()) {
-  case Option::RenderValuesStyle:
-    for (unsigned i = 0, e = getNumValues(); i != e; ++i)
-      Output.push_back(getValue(i));
-    break;
-
-  case Option::RenderCommaJoinedStyle: {
-    SmallString<256> Res;
-    llvm::raw_svector_ostream OS(Res);
-    OS << getSpelling();
-    for (unsigned i = 0, e = getNumValues(); i != e; ++i) {
-      if (i) OS << ',';
-      OS << getValue(i);
-    }
-    Output.push_back(Args.MakeArgString(OS.str()));
-    break;
-  }
-
- case Option::RenderJoinedStyle:
-    Output.push_back(Args.GetOrMakeJoinedArgString(
-                       getIndex(), getSpelling(), getValue(0)));
-    for (unsigned i = 1, e = getNumValues(); i != e; ++i)
-      Output.push_back(getValue(i));
-    break;
-
-  case Option::RenderSeparateStyle:
-    Output.push_back(Args.MakeArgString(getSpelling()));
-    for (unsigned i = 0, e = getNumValues(); i != e; ++i)
-      Output.push_back(getValue(i));
-    break;
-  }
-}
diff --git a/lib/Driver/ArgList.cpp b/lib/Driver/ArgList.cpp
deleted file mode 100644 (file)
index 0033927..0000000
+++ /dev/null
@@ -1,422 +0,0 @@
-//===--- ArgList.cpp - Argument List Management ---------------------------===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "clang/Driver/ArgList.h"
-#include "clang/Driver/Arg.h"
-#include "clang/Driver/DriverDiagnostic.h"
-#include "clang/Driver/Option.h"
-#include "llvm/ADT/SmallString.h"
-#include "llvm/ADT/Twine.h"
-#include "llvm/Support/raw_ostream.h"
-
-using namespace clang;
-using namespace clang::driver;
-
-void arg_iterator::SkipToNextArg() {
-  for (; Current != Args.end(); ++Current) {
-    // Done if there are no filters.
-    if (!Id0.isValid())
-      break;
-
-    // Otherwise require a match.
-    const Option &O = (*Current)->getOption();
-    if (O.matches(Id0) ||
-        (Id1.isValid() && O.matches(Id1)) ||
-        (Id2.isValid() && O.matches(Id2)))
-      break;
-  }
-}
-
-//
-
-ArgList::ArgList() {
-}
-
-ArgList::~ArgList() {
-}
-
-void ArgList::append(Arg *A) {
-  Args.push_back(A);
-}
-
-void ArgList::eraseArg(OptSpecifier Id) {
-  for (iterator it = begin(), ie = end(); it != ie; ) {
-    if ((*it)->getOption().matches(Id)) {
-      it = Args.erase(it);
-      ie = end();
-    } else {
-      ++it;
-    }
-  }
-}
-
-Arg *ArgList::getLastArgNoClaim(OptSpecifier Id) const {
-  // FIXME: Make search efficient?
-  for (const_reverse_iterator it = rbegin(), ie = rend(); it != ie; ++it)
-    if ((*it)->getOption().matches(Id))
-      return *it;
-  return 0;
-}
-
-Arg *ArgList::getLastArg(OptSpecifier Id) const {
-  Arg *Res = 0;
-  for (const_iterator it = begin(), ie = end(); it != ie; ++it) {
-    if ((*it)->getOption().matches(Id)) {
-      Res = *it;
-      Res->claim();
-    }
-  }
-
-  return Res;
-}
-
-Arg *ArgList::getLastArg(OptSpecifier Id0, OptSpecifier Id1) const {
-  Arg *Res = 0;
-  for (const_iterator it = begin(), ie = end(); it != ie; ++it) {
-    if ((*it)->getOption().matches(Id0) ||
-        (*it)->getOption().matches(Id1)) {
-      Res = *it;
-      Res->claim();
-    }
-  }
-
-  return Res;
-}
-
-Arg *ArgList::getLastArg(OptSpecifier Id0, OptSpecifier Id1,
-                         OptSpecifier Id2) const {
-  Arg *Res = 0;
-  for (const_iterator it = begin(), ie = end(); it != ie; ++it) {
-    if ((*it)->getOption().matches(Id0) ||
-        (*it)->getOption().matches(Id1) ||
-        (*it)->getOption().matches(Id2)) {
-      Res = *it;
-      Res->claim();
-    }
-  }
-
-  return Res;
-}
-
-Arg *ArgList::getLastArg(OptSpecifier Id0, OptSpecifier Id1,
-                         OptSpecifier Id2, OptSpecifier Id3) const {
-  Arg *Res = 0;
-  for (const_iterator it = begin(), ie = end(); it != ie; ++it) {
-    if ((*it)->getOption().matches(Id0) ||
-        (*it)->getOption().matches(Id1) ||
-        (*it)->getOption().matches(Id2) ||
-        (*it)->getOption().matches(Id3)) {
-      Res = *it;
-      Res->claim();
-    }
-  }
-
-  return Res;
-}
-
-Arg *ArgList::getLastArg(OptSpecifier Id0, OptSpecifier Id1,
-                         OptSpecifier Id2, OptSpecifier Id3,
-                         OptSpecifier Id4) const {
-  Arg *Res = 0;
-  for (const_iterator it = begin(), ie = end(); it != ie; ++it) {
-    if ((*it)->getOption().matches(Id0) ||
-        (*it)->getOption().matches(Id1) ||
-        (*it)->getOption().matches(Id2) ||
-        (*it)->getOption().matches(Id3) ||
-        (*it)->getOption().matches(Id4)) {
-      Res = *it;
-      Res->claim();
-    }
-  }
-
-  return Res;
-}
-
-Arg *ArgList::getLastArg(OptSpecifier Id0, OptSpecifier Id1,
-                         OptSpecifier Id2, OptSpecifier Id3,
-                         OptSpecifier Id4, OptSpecifier Id5) const {
-  Arg *Res = 0;
-  for (const_iterator it = begin(), ie = end(); it != ie; ++it) {
-    if ((*it)->getOption().matches(Id0) ||
-        (*it)->getOption().matches(Id1) ||
-        (*it)->getOption().matches(Id2) ||
-        (*it)->getOption().matches(Id3) ||
-        (*it)->getOption().matches(Id4) ||
-        (*it)->getOption().matches(Id5)) {
-      Res = *it;
-      Res->claim();
-    }
-  }
-
-  return Res;
-}
-
-Arg *ArgList::getLastArg(OptSpecifier Id0, OptSpecifier Id1,
-                         OptSpecifier Id2, OptSpecifier Id3,
-                         OptSpecifier Id4, OptSpecifier Id5,
-                         OptSpecifier Id6) const {
-  Arg *Res = 0;
-  for (const_iterator it = begin(), ie = end(); it != ie; ++it) {
-    if ((*it)->getOption().matches(Id0) ||
-        (*it)->getOption().matches(Id1) ||
-        (*it)->getOption().matches(Id2) ||
-        (*it)->getOption().matches(Id3) ||
-        (*it)->getOption().matches(Id4) ||
-        (*it)->getOption().matches(Id5) ||
-        (*it)->getOption().matches(Id6)) {
-      Res = *it;
-      Res->claim();
-    }
-  }
-
-  return Res;
-}
-
-Arg *ArgList::getLastArg(OptSpecifier Id0, OptSpecifier Id1,
-                         OptSpecifier Id2, OptSpecifier Id3,
-                         OptSpecifier Id4, OptSpecifier Id5,
-                         OptSpecifier Id6, OptSpecifier Id7) const {
-  Arg *Res = 0;
-  for (const_iterator it = begin(), ie = end(); it != ie; ++it) {
-    if ((*it)->getOption().matches(Id0) ||
-        (*it)->getOption().matches(Id1) ||
-        (*it)->getOption().matches(Id2) ||
-        (*it)->getOption().matches(Id3) ||
-        (*it)->getOption().matches(Id4) ||
-        (*it)->getOption().matches(Id5) ||
-        (*it)->getOption().matches(Id6) ||
-        (*it)->getOption().matches(Id7)) {
-      Res = *it;
-      Res->claim();
-    }
-  }
-
-  return Res;
-}
-
-bool ArgList::hasFlag(OptSpecifier Pos, OptSpecifier Neg, bool Default) const {
-  if (Arg *A = getLastArg(Pos, Neg))
-    return A->getOption().matches(Pos);
-  return Default;
-}
-
-bool ArgList::hasFlag(OptSpecifier Pos, OptSpecifier PosAlias, OptSpecifier Neg,
-                      bool Default) const {
-  if (Arg *A = getLastArg(Pos, PosAlias, Neg))
-    return A->getOption().matches(Pos) || A->getOption().matches(PosAlias);
-  return Default;
-}
-
-StringRef ArgList::getLastArgValue(OptSpecifier Id,
-                                         StringRef Default) const {
-  if (Arg *A = getLastArg(Id))
-    return A->getValue();
-  return Default;
-}
-
-int ArgList::getLastArgIntValue(OptSpecifier Id, int Default,
-                                clang::DiagnosticsEngine *Diags) const {
-  int Res = Default;
-
-  if (Arg *A = getLastArg(Id)) {
-    if (StringRef(A->getValue()).getAsInteger(10, Res)) {
-      if (Diags)
-        Diags->Report(diag::err_drv_invalid_int_value)
-          << A->getAsString(*this) << A->getValue();
-    }
-  }
-
-  return Res;
-}
-
-std::vector<std::string> ArgList::getAllArgValues(OptSpecifier Id) const {
-  SmallVector<const char *, 16> Values;
-  AddAllArgValues(Values, Id);
-  return std::vector<std::string>(Values.begin(), Values.end());
-}
-
-void ArgList::AddLastArg(ArgStringList &Output, OptSpecifier Id) const {
-  if (Arg *A = getLastArg(Id)) {
-    A->claim();
-    A->render(*this, Output);
-  }
-}
-
-void ArgList::AddLastArg(ArgStringList &Output, OptSpecifier Id0,
-                         OptSpecifier Id1) const {
-  if (Arg *A = getLastArg(Id0, Id1)) {
-    A->claim();
-    A->render(*this, Output);
-  }
-}
-
-void ArgList::AddAllArgs(ArgStringList &Output, OptSpecifier Id0,
-                         OptSpecifier Id1, OptSpecifier Id2) const {
-  for (arg_iterator it = filtered_begin(Id0, Id1, Id2),
-         ie = filtered_end(); it != ie; ++it) {
-    (*it)->claim();
-    (*it)->render(*this, Output);
-  }
-}
-
-void ArgList::AddAllArgValues(ArgStringList &Output, OptSpecifier Id0,
-                              OptSpecifier Id1, OptSpecifier Id2) const {
-  for (arg_iterator it = filtered_begin(Id0, Id1, Id2),
-         ie = filtered_end(); it != ie; ++it) {
-    (*it)->claim();
-    for (unsigned i = 0, e = (*it)->getNumValues(); i != e; ++i)
-      Output.push_back((*it)->getValue(i));
-  }
-}
-
-void ArgList::AddAllArgsTranslated(ArgStringList &Output, OptSpecifier Id0,
-                                   const char *Translation,
-                                   bool Joined) const {
-  for (arg_iterator it = filtered_begin(Id0),
-         ie = filtered_end(); it != ie; ++it) {
-    (*it)->claim();
-
-    if (Joined) {
-      Output.push_back(MakeArgString(StringRef(Translation) +
-                                     (*it)->getValue(0)));
-    } else {
-      Output.push_back(Translation);
-      Output.push_back((*it)->getValue(0));
-    }
-  }
-}
-
-void ArgList::ClaimAllArgs(OptSpecifier Id0) const {
-  for (arg_iterator it = filtered_begin(Id0),
-         ie = filtered_end(); it != ie; ++it)
-    (*it)->claim();
-}
-
-void ArgList::ClaimAllArgs() const {
-  for (const_iterator it = begin(), ie = end(); it != ie; ++it)
-    if (!(*it)->isClaimed())
-      (*it)->claim();
-}
-
-const char *ArgList::MakeArgString(const Twine &T) const {
-  SmallString<256> Str;
-  T.toVector(Str);
-  return MakeArgString(Str.str());
-}
-
-const char *ArgList::GetOrMakeJoinedArgString(unsigned Index,
-                                              StringRef LHS,
-                                              StringRef RHS) const {
-  StringRef Cur = getArgString(Index);
-  if (Cur.size() == LHS.size() + RHS.size() &&
-      Cur.startswith(LHS) && Cur.endswith(RHS))
-    return Cur.data();
-
-  return MakeArgString(LHS + RHS);
-}
-
-void ArgList::dump() const {
-  llvm::errs() << "ArgList:";
-  for (const_iterator it = begin(), ie = end(); it != ie; ++it)
-    llvm::errs() << " " << (*it)->getSpelling();
-  llvm::errs() << "\n";
-}
-
-//
-
-InputArgList::InputArgList(const char* const *ArgBegin,
-                           const char* const *ArgEnd)
-  : NumInputArgStrings(ArgEnd - ArgBegin) {
-  ArgStrings.append(ArgBegin, ArgEnd);
-}
-
-InputArgList::~InputArgList() {
-  // An InputArgList always owns its arguments.
-  for (iterator it = begin(), ie = end(); it != ie; ++it)
-    delete *it;
-}
-
-unsigned InputArgList::MakeIndex(StringRef String0) const {
-  unsigned Index = ArgStrings.size();
-
-  // Tuck away so we have a reliable const char *.
-  SynthesizedStrings.push_back(String0);
-  ArgStrings.push_back(SynthesizedStrings.back().c_str());
-
-  return Index;
-}
-
-unsigned InputArgList::MakeIndex(StringRef String0,
-                                 StringRef String1) const {
-  unsigned Index0 = MakeIndex(String0);
-  unsigned Index1 = MakeIndex(String1);
-  assert(Index0 + 1 == Index1 && "Unexpected non-consecutive indices!");
-  (void) Index1;
-  return Index0;
-}
-
-const char *InputArgList::MakeArgString(StringRef Str) const {
-  return getArgString(MakeIndex(Str));
-}
-
-//
-
-DerivedArgList::DerivedArgList(const InputArgList &_BaseArgs)
-  : BaseArgs(_BaseArgs) {
-}
-
-DerivedArgList::~DerivedArgList() {
-  // We only own the arguments we explicitly synthesized.
-  for (iterator it = SynthesizedArgs.begin(), ie = SynthesizedArgs.end();
-       it != ie; ++it)
-    delete *it;
-}
-
-const char *DerivedArgList::MakeArgString(StringRef Str) const {
-  return BaseArgs.MakeArgString(Str);
-}
-
-Arg *DerivedArgList::MakeFlagArg(const Arg *BaseArg, const Option Opt) const {
-  Arg *A = new Arg(Opt, ArgList::MakeArgString(Twine(Opt.getPrefix()) +
-                                               Twine(Opt.getName())),
-                   BaseArgs.MakeIndex(Opt.getName()), BaseArg);
-  SynthesizedArgs.push_back(A);
-  return A;
-}
-
-Arg *DerivedArgList::MakePositionalArg(const Arg *BaseArg, const Option Opt,
-                                       StringRef Value) const {
-  unsigned Index = BaseArgs.MakeIndex(Value);
-  Arg *A = new Arg(Opt, ArgList::MakeArgString(Twine(Opt.getPrefix()) +
-                                               Twine(Opt.getName())),
-                   Index, BaseArgs.getArgString(Index), BaseArg);
-  SynthesizedArgs.push_back(A);
-  return A;
-}
-
-Arg *DerivedArgList::MakeSeparateArg(const Arg *BaseArg, const Option Opt,
-                                     StringRef Value) const {
-  unsigned Index = BaseArgs.MakeIndex(Opt.getName(), Value);
-  Arg *A = new Arg(Opt, ArgList::MakeArgString(Twine(Opt.getPrefix()) +
-                                               Twine(Opt.getName())),
-                   Index, BaseArgs.getArgString(Index + 1), BaseArg);
-  SynthesizedArgs.push_back(A);
-  return A;
-}
-
-Arg *DerivedArgList::MakeJoinedArg(const Arg *BaseArg, const Option Opt,
-                                   StringRef Value) const {
-  unsigned Index = BaseArgs.MakeIndex(Opt.getName().str() + Value.str());
-  Arg *A = new Arg(Opt, ArgList::MakeArgString(Twine(Opt.getPrefix()) +
-                                               Twine(Opt.getName())), Index,
-                   BaseArgs.getArgString(Index) + Opt.getName().size(),
-                   BaseArg);
-  SynthesizedArgs.push_back(A);
-  return A;
-}
index 904804383670e023c94faa8f2dc4e5b7955d7d52..b1e0deae3934d6c6995efe3ce18f015c6dd72a94 100644 (file)
@@ -8,11 +8,11 @@
 //===----------------------------------------------------------------------===//
 
 #include "clang/Driver/CC1AsOptions.h"
-#include "clang/Driver/OptTable.h"
-#include "clang/Driver/Option.h"
+#include "llvm/Option/OptTable.h"
+#include "llvm/Option/Option.h"
 using namespace clang;
 using namespace clang::driver;
-using namespace clang::driver::options;
+using namespace llvm::opt;
 using namespace clang::driver::cc1asoptions;
 
 #define PREFIX(NAME, VALUE) const char *const NAME[] = VALUE;
index 4ada7d92c3d12dc1d1291a6379742bc1c59456ac..f380e503889b8748711d08bfdb400936ec658c31 100644 (file)
@@ -1,14 +1,10 @@
 add_clang_library(clangDriver
   Action.cpp
-  Arg.cpp
-  ArgList.cpp
   CC1AsOptions.cpp
   Compilation.cpp
   Driver.cpp
   DriverOptions.cpp
   Job.cpp
-  Option.cpp
-  OptTable.cpp
   Phases.cpp
   Tool.cpp
   ToolChain.cpp
@@ -28,4 +24,5 @@ add_dependencies(clangDriver
 
 target_link_libraries(clangDriver
   clangBasic
+  LLVMOption
   )
index 1ab47f3bbf8dbea5ea3ccfffc2bea11e1f78bd70..50725fc678d98df6a34db0270286bb46e63d0dc0 100644 (file)
@@ -9,13 +9,13 @@
 
 #include "clang/Driver/Compilation.h"
 #include "clang/Driver/Action.h"
-#include "clang/Driver/ArgList.h"
 #include "clang/Driver/Driver.h"
 #include "clang/Driver/DriverDiagnostic.h"
 #include "clang/Driver/Options.h"
 #include "clang/Driver/ToolChain.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringSwitch.h"
+#include "llvm/Option/ArgList.h"
 #include "llvm/Support/Program.h"
 #include "llvm/Support/raw_ostream.h"
 #include <errno.h>
@@ -23,6 +23,7 @@
 
 using namespace clang::driver;
 using namespace clang;
+using namespace llvm::opt;
 
 Compilation::Compilation(const Driver &D, const ToolChain &_DefaultToolChain,
                          InputArgList *_Args, DerivedArgList *_TranslatedArgs)
index 937a676a3d5b80e5e467452d27dd56b3707d3630..e5d3ed4cab8697543829322f86fe9f7b3802f9d7 100644 (file)
 #include "ToolChains.h"
 #include "clang/Basic/Version.h"
 #include "clang/Driver/Action.h"
-#include "clang/Driver/Arg.h"
-#include "clang/Driver/ArgList.h"
 #include "clang/Driver/Compilation.h"
 #include "clang/Driver/DriverDiagnostic.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"
 #include "clang/Driver/ToolChain.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/OwningPtr.h"
 #include "llvm/ADT/StringSet.h"
+#include "llvm/Option/Arg.h"
+#include "llvm/Option/ArgList.h"
+#include "llvm/Option/OptTable.h"
+#include "llvm/Option/Option.h"
+#include "llvm/Option/OptSpecifier.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/FileSystem.h"
@@ -40,6 +41,7 @@
 
 using namespace clang::driver;
 using namespace clang;
+using namespace llvm::opt;
 
 Driver::Driver(StringRef ClangExecutable,
                StringRef DefaultTargetTriple,
@@ -579,10 +581,9 @@ void Driver::PrintOptions(const ArgList &Args) const {
 }
 
 void Driver::PrintHelp(bool ShowHidden) const {
-  getOpts().PrintHelp(llvm::outs(), Name.c_str(), DriverTitle.c_str(),
-                      /*Include*/0,
-                      /*Exclude*/options::NoDriverOption |
-                      (ShowHidden ? 0 : options::HelpHidden));
+  getOpts().PrintHelp(
+      llvm::outs(), Name.c_str(), DriverTitle.c_str(), /*Include*/ 0,
+      /*Exclude*/ options::NoDriverOption | (ShowHidden ? 0 : HelpHidden));
 }
 
 void Driver::PrintVersion(const Compilation &C, raw_ostream &OS) const {
index 3925b8aa35c5338b3a63652857394bbd42220b1d..0bf7303aca72664d4181b6f93222a34ff0577bcf 100644 (file)
@@ -8,11 +8,12 @@
 //===----------------------------------------------------------------------===//
 
 #include "clang/Driver/Options.h"
-#include "clang/Driver/OptTable.h"
-#include "clang/Driver/Option.h"
+#include "llvm/Option/OptTable.h"
+#include "llvm/Option/Option.h"
 
 using namespace clang::driver;
 using namespace clang::driver::options;
+using namespace llvm::opt;
 
 #define PREFIX(NAME, VALUE) const char *const NAME[] = VALUE;
 #define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, FLAGS, PARAM, \
index a243d322ee2104e13a2e970de57148849e182d9c..f42a94c986ecab024b0e4c651ad5a5b0612d2e95 100644 (file)
@@ -10,8 +10,8 @@
 #ifndef CLANG_LIB_DRIVER_INPUTINFO_H_
 #define CLANG_LIB_DRIVER_INPUTINFO_H_
 
-#include "clang/Driver/Arg.h"
 #include "clang/Driver/Types.h"
+#include "llvm/Option/Arg.h"
 #include <cassert>
 #include <string>
 
index 8c467050d563cbf132906721eb1099acc40cb695..61e7d983035ca62b61573d9b8ef0cdbe42bbfcd8 100644 (file)
@@ -17,11 +17,10 @@ Job::~Job() {}
 void Command::anchor() {}
 
 Command::Command(const Action &_Source, const Tool &_Creator,
-                 const char *_Executable, const ArgStringList &_Arguments)
-  : Job(CommandClass), Source(_Source), Creator(_Creator),
-    Executable(_Executable), Arguments(_Arguments)
-{
-}
+                 const char *_Executable,
+                 const llvm::opt::ArgStringList &_Arguments)
+    : Job(CommandClass), Source(_Source), Creator(_Creator),
+      Executable(_Executable), Arguments(_Arguments) {}
 
 JobList::JobList() : Job(JobListClass) {}
 
diff --git a/lib/Driver/OptTable.cpp b/lib/Driver/OptTable.cpp
deleted file mode 100644 (file)
index 20214a6..0000000
+++ /dev/null
@@ -1,388 +0,0 @@
-//===--- OptTable.cpp - Option Table Implementation -----------------------===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "clang/Driver/OptTable.h"
-#include "clang/Driver/Arg.h"
-#include "clang/Driver/ArgList.h"
-#include "clang/Driver/Option.h"
-#include "clang/Driver/Options.h"
-#include "llvm/Support/ErrorHandling.h"
-#include "llvm/Support/raw_ostream.h"
-#include <algorithm>
-#include <map>
-using namespace clang::driver;
-using namespace clang::driver::options;
-using namespace clang;
-
-// Ordering on Info. The ordering is *almost* lexicographic, with two
-// exceptions. First, '\0' comes at the end of the alphabet instead of
-// the beginning (thus options precede any other options which prefix
-// them). Second, for options with the same name, the less permissive
-// version should come first; a Flag option should precede a Joined
-// option, for example.
-
-static int StrCmpOptionName(const char *A, const char *B) {
-  char a = *A, b = *B;
-  while (a == b) {
-    if (a == '\0')
-      return 0;
-
-    a = *++A;
-    b = *++B;
-  }
-
-  if (a == '\0') // A is a prefix of B.
-    return 1;
-  if (b == '\0') // B is a prefix of A.
-    return -1;
-
-  // Otherwise lexicographic.
-  return (a < b) ? -1 : 1;
-}
-
-namespace clang {
-namespace driver {
-static inline bool operator<(const OptTable::Info &A, const OptTable::Info &B) {
-  if (&A == &B)
-    return false;
-
-  if (int N = StrCmpOptionName(A.Name, B.Name))
-    return N == -1;
-
-  for (const char * const *APre = A.Prefixes,
-                  * const *BPre = B.Prefixes;
-                          *APre != 0 && *BPre != 0; ++APre, ++BPre) {
-    if (int N = StrCmpOptionName(*APre, *BPre))
-      return N == -1;
-  }
-
-  // Names are the same, check that classes are in order; exactly one
-  // should be joined, and it should succeed the other.
-  assert(((A.Kind == Option::JoinedClass) ^ (B.Kind == Option::JoinedClass)) &&
-         "Unexpected classes for options with same name.");
-  return B.Kind == Option::JoinedClass;
-}
-
-// Support lower_bound between info and an option name.
-static inline bool operator<(const OptTable::Info &I, const char *Name) {
-  return StrCmpOptionName(I.Name, Name) == -1;
-}
-static inline bool operator<(const char *Name, const OptTable::Info &I) {
-  return StrCmpOptionName(Name, I.Name) == -1;
-}
-}
-}
-
-//
-
-OptSpecifier::OptSpecifier(const Option *Opt) : ID(Opt->getID()) {}
-
-//
-
-OptTable::OptTable(const Info *_OptionInfos, unsigned _NumOptionInfos)
-  : OptionInfos(_OptionInfos),
-    NumOptionInfos(_NumOptionInfos),
-    TheInputOptionID(0),
-    TheUnknownOptionID(0),
-    FirstSearchableIndex(0)
-{
-  // Explicitly zero initialize the error to work around a bug in array
-  // value-initialization on MinGW with gcc 4.3.5.
-
-  // Find start of normal options.
-  for (unsigned i = 0, e = getNumOptions(); i != e; ++i) {
-    unsigned Kind = getInfo(i + 1).Kind;
-    if (Kind == Option::InputClass) {
-      assert(!TheInputOptionID && "Cannot have multiple input options!");
-      TheInputOptionID = getInfo(i + 1).ID;
-    } else if (Kind == Option::UnknownClass) {
-      assert(!TheUnknownOptionID && "Cannot have multiple unknown options!");
-      TheUnknownOptionID = getInfo(i + 1).ID;
-    } else if (Kind != Option::GroupClass) {
-      FirstSearchableIndex = i;
-      break;
-    }
-  }
-  assert(FirstSearchableIndex != 0 && "No searchable options?");
-
-#ifndef NDEBUG
-  // Check that everything after the first searchable option is a
-  // regular option class.
-  for (unsigned i = FirstSearchableIndex, e = getNumOptions(); i != e; ++i) {
-    Option::OptionClass Kind = (Option::OptionClass) getInfo(i + 1).Kind;
-    assert((Kind != Option::InputClass && Kind != Option::UnknownClass &&
-            Kind != Option::GroupClass) &&
-           "Special options should be defined first!");
-  }
-
-  // Check that options are in order.
-  for (unsigned i = FirstSearchableIndex+1, e = getNumOptions(); i != e; ++i) {
-    if (!(getInfo(i) < getInfo(i + 1))) {
-      getOption(i).dump();
-      getOption(i + 1).dump();
-      llvm_unreachable("Options are not in order!");
-    }
-  }
-#endif
-
-  // Build prefixes.
-  for (unsigned i = FirstSearchableIndex+1, e = getNumOptions(); i != e; ++i) {
-    if (const char *const *P = getInfo(i).Prefixes) {
-      for (; *P != 0; ++P) {
-        PrefixesUnion.insert(*P);
-      }
-    }
-  }
-
-  // Build prefix chars.
-  for (llvm::StringSet<>::const_iterator I = PrefixesUnion.begin(),
-                                         E = PrefixesUnion.end(); I != E; ++I) {
-    StringRef Prefix = I->getKey();
-    for (StringRef::const_iterator C = Prefix.begin(), CE = Prefix.end();
-                                   C != CE; ++C)
-      if (std::find(PrefixChars.begin(), PrefixChars.end(), *C)
-            == PrefixChars.end())
-        PrefixChars.push_back(*C);
-  }
-}
-
-OptTable::~OptTable() {
-}
-
-const Option OptTable::getOption(OptSpecifier Opt) const {
-  unsigned id = Opt.getID();
-  if (id == 0)
-    return Option(0, 0);
-  assert((unsigned) (id - 1) < getNumOptions() && "Invalid ID.");
-  return Option(&getInfo(id), this);
-}
-
-static bool isInput(const llvm::StringSet<> &Prefixes, StringRef Arg) {
-  if (Arg == "-")
-    return true;
-  for (llvm::StringSet<>::const_iterator I = Prefixes.begin(),
-                                         E = Prefixes.end(); I != E; ++I)
-    if (Arg.startswith(I->getKey()))
-      return false;
-  return true;
-}
-
-/// \returns Matched size. 0 means no match.
-static unsigned matchOption(const OptTable::Info *I, StringRef Str) {
-  for (const char * const *Pre = I->Prefixes; *Pre != 0; ++Pre) {
-    StringRef Prefix(*Pre);
-    if (Str.startswith(Prefix) && Str.substr(Prefix.size()).startswith(I->Name))
-      return Prefix.size() + StringRef(I->Name).size();
-  }
-  return 0;
-}
-
-Arg *OptTable::ParseOneArg(const ArgList &Args, unsigned &Index) const {
-  unsigned Prev = Index;
-  const char *Str = Args.getArgString(Index);
-
-  // Anything that doesn't start with PrefixesUnion is an input, as is '-'
-  // itself.
-  if (isInput(PrefixesUnion, Str))
-    return new Arg(getOption(TheInputOptionID), Str, Index++, Str);
-
-  const Info *Start = OptionInfos + FirstSearchableIndex;
-  const Info *End = OptionInfos + getNumOptions();
-  StringRef Name = StringRef(Str).ltrim(PrefixChars);
-
-  // Search for the first next option which could be a prefix.
-  Start = std::lower_bound(Start, End, Name.data());
-
-  // Options are stored in sorted order, with '\0' at the end of the
-  // alphabet. Since the only options which can accept a string must
-  // prefix it, we iteratively search for the next option which could
-  // be a prefix.
-  //
-  // FIXME: This is searching much more than necessary, but I am
-  // blanking on the simplest way to make it fast. We can solve this
-  // problem when we move to TableGen.
-  for (; Start != End; ++Start) {
-    unsigned ArgSize = 0;
-    // Scan for first option which is a proper prefix.
-    for (; Start != End; ++Start)
-      if ((ArgSize = matchOption(Start, Str)))
-        break;
-    if (Start == End)
-      break;
-
-    // See if this option matches.
-    if (Arg *A = Option(Start, this).accept(Args, Index, ArgSize))
-      return A;
-
-    // Otherwise, see if this argument was missing values.
-    if (Prev != Index)
-      return 0;
-  }
-
-  return new Arg(getOption(TheUnknownOptionID), Str, Index++, Str);
-}
-
-InputArgList *OptTable::ParseArgs(const char* const *ArgBegin,
-                                  const char* const *ArgEnd,
-                                  unsigned &MissingArgIndex,
-                                  unsigned &MissingArgCount) const {
-  InputArgList *Args = new InputArgList(ArgBegin, ArgEnd);
-
-  // FIXME: Handle '@' args (or at least error on them).
-
-  MissingArgIndex = MissingArgCount = 0;
-  unsigned Index = 0, End = ArgEnd - ArgBegin;
-  while (Index < End) {
-    // Ignore empty arguments (other things may still take them as arguments).
-    if (Args->getArgString(Index)[0] == '\0') {
-      ++Index;
-      continue;
-    }
-
-    unsigned Prev = Index;
-    Arg *A = ParseOneArg(*Args, Index);
-    assert(Index > Prev && "Parser failed to consume argument.");
-
-    // Check for missing argument error.
-    if (!A) {
-      assert(Index >= End && "Unexpected parser error.");
-      assert(Index - Prev - 1 && "No missing arguments!");
-      MissingArgIndex = Prev;
-      MissingArgCount = Index - Prev - 1;
-      break;
-    }
-
-    Args->append(A);
-  }
-
-  return Args;
-}
-
-static std::string getOptionHelpName(const OptTable &Opts, OptSpecifier Id) {
-  const Option O = Opts.getOption(Id);
-  std::string Name = O.getPrefixedName();
-
-  // Add metavar, if used.
-  switch (O.getKind()) {
-  case Option::GroupClass: case Option::InputClass: case Option::UnknownClass:
-    llvm_unreachable("Invalid option with help text.");
-
-  case Option::MultiArgClass:
-    llvm_unreachable("Cannot print metavar for this kind of option.");
-
-  case Option::FlagClass:
-    break;
-
-  case Option::SeparateClass: case Option::JoinedOrSeparateClass:
-    Name += ' ';
-    // FALLTHROUGH
-  case Option::JoinedClass: case Option::CommaJoinedClass:
-  case Option::JoinedAndSeparateClass:
-    if (const char *MetaVarName = Opts.getOptionMetaVar(Id))
-      Name += MetaVarName;
-    else
-      Name += "<value>";
-    break;
-  }
-
-  return Name;
-}
-
-static void PrintHelpOptionList(raw_ostream &OS, StringRef Title,
-                                std::vector<std::pair<std::string,
-                                const char*> > &OptionHelp) {
-  OS << Title << ":\n";
-
-  // Find the maximum option length.
-  unsigned OptionFieldWidth = 0;
-  for (unsigned i = 0, e = OptionHelp.size(); i != e; ++i) {
-    // Skip titles.
-    if (!OptionHelp[i].second)
-      continue;
-
-    // Limit the amount of padding we are willing to give up for alignment.
-    unsigned Length = OptionHelp[i].first.size();
-    if (Length <= 23)
-      OptionFieldWidth = std::max(OptionFieldWidth, Length);
-  }
-
-  const unsigned InitialPad = 2;
-  for (unsigned i = 0, e = OptionHelp.size(); i != e; ++i) {
-    const std::string &Option = OptionHelp[i].first;
-    int Pad = OptionFieldWidth - int(Option.size());
-    OS.indent(InitialPad) << Option;
-
-    // Break on long option names.
-    if (Pad < 0) {
-      OS << "\n";
-      Pad = OptionFieldWidth + InitialPad;
-    }
-    OS.indent(Pad + 1) << OptionHelp[i].second << '\n';
-  }
-}
-
-static const char *getOptionHelpGroup(const OptTable &Opts, OptSpecifier Id) {
-  unsigned GroupID = Opts.getOptionGroupID(Id);
-
-  // If not in a group, return the default help group.
-  if (!GroupID)
-    return "OPTIONS";
-
-  // Abuse the help text of the option groups to store the "help group"
-  // name.
-  //
-  // FIXME: Split out option groups.
-  if (const char *GroupHelp = Opts.getOptionHelpText(GroupID))
-    return GroupHelp;
-
-  // Otherwise keep looking.
-  return getOptionHelpGroup(Opts, GroupID);
-}
-
-void OptTable::PrintHelp(raw_ostream &OS, const char *Name,
-                         const char *Title, unsigned short FlagsToInclude,
-                         unsigned short FlagsToExclude) const {
-  OS << "OVERVIEW: " << Title << "\n";
-  OS << '\n';
-  OS << "USAGE: " << Name << " [options] <inputs>\n";
-  OS << '\n';
-
-  // Render help text into a map of group-name to a list of (option, help)
-  // pairs.
-  typedef std::map<std::string,
-                 std::vector<std::pair<std::string, const char*> > > helpmap_ty;
-  helpmap_ty GroupedOptionHelp;
-
-  for (unsigned i = 0, e = getNumOptions(); i != e; ++i) {
-    unsigned Id = i + 1;
-
-    // FIXME: Split out option groups.
-    if (getOptionKind(Id) == Option::GroupClass)
-      continue;
-
-    if ((FlagsToInclude && !(getInfo(Id).Flags & FlagsToInclude)) ||
-        getInfo(Id).Flags & FlagsToExclude)
-      continue;
-
-    if (const char *Text = getOptionHelpText(Id)) {
-      const char *HelpGroup = getOptionHelpGroup(*this, Id);
-      const std::string &OptName = getOptionHelpName(*this, Id);
-      GroupedOptionHelp[HelpGroup].push_back(std::make_pair(OptName, Text));
-    }
-  }
-
-  for (helpmap_ty::iterator it = GroupedOptionHelp .begin(),
-         ie = GroupedOptionHelp.end(); it != ie; ++it) {
-    if (it != GroupedOptionHelp .begin())
-      OS << "\n";
-    PrintHelpOptionList(OS, it->first, it->second);
-  }
-
-  OS.flush();
-}
diff --git a/lib/Driver/Option.cpp b/lib/Driver/Option.cpp
deleted file mode 100644 (file)
index dbc61ea..0000000
+++ /dev/null
@@ -1,200 +0,0 @@
-//===--- Option.cpp - Abstract Driver Options -----------------------------===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "clang/Driver/Option.h"
-#include "clang/Driver/Arg.h"
-#include "clang/Driver/ArgList.h"
-#include "llvm/ADT/Twine.h"
-#include "llvm/Support/ErrorHandling.h"
-#include "llvm/Support/raw_ostream.h"
-#include <algorithm>
-#include <cassert>
-using namespace clang::driver;
-
-Option::Option(const OptTable::Info *info, const OptTable *owner)
-  : Info(info), Owner(owner) {
-
-  // Multi-level aliases are not supported, and alias options cannot
-  // have groups. This just simplifies option tracking, it is not an
-  // inherent limitation.
-  assert((!Info || !getAlias().isValid() || (!getAlias().getAlias().isValid() &&
-         !getGroup().isValid())) &&
-         "Multi-level aliases and aliases with groups are unsupported.");
-}
-
-Option::~Option() {
-}
-
-void Option::dump() const {
-  llvm::errs() << "<";
-  switch (getKind()) {
-#define P(N) case N: llvm::errs() << #N; break
-    P(GroupClass);
-    P(InputClass);
-    P(UnknownClass);
-    P(FlagClass);
-    P(JoinedClass);
-    P(SeparateClass);
-    P(CommaJoinedClass);
-    P(MultiArgClass);
-    P(JoinedOrSeparateClass);
-    P(JoinedAndSeparateClass);
-#undef P
-  }
-
-  llvm::errs() << " Prefixes:[";
-  for (const char * const *Pre = Info->Prefixes; *Pre != 0; ++Pre) {
-    llvm::errs() << '"' << *Pre << (*(Pre + 1) == 0 ? "\"" : "\", ");
-  }
-  llvm::errs() << ']';
-
-  llvm::errs() << " Name:\"" << getName() << '"';
-
-  const Option Group = getGroup();
-  if (Group.isValid()) {
-    llvm::errs() << " Group:";
-    Group.dump();
-  }
-
-  const Option Alias = getAlias();
-  if (Alias.isValid()) {
-    llvm::errs() << " Alias:";
-    Alias.dump();
-  }
-
-  if (getKind() == MultiArgClass)
-    llvm::errs() << " NumArgs:" << getNumArgs();
-
-  llvm::errs() << ">\n";
-}
-
-bool Option::matches(OptSpecifier Opt) const {
-  // Aliases are never considered in matching, look through them.
-  const Option Alias = getAlias();
-  if (Alias.isValid())
-    return Alias.matches(Opt);
-
-  // Check exact match.
-  if (getID() == Opt.getID())
-    return true;
-
-  const Option Group = getGroup();
-  if (Group.isValid())
-    return Group.matches(Opt);
-  return false;
-}
-
-Arg *Option::accept(const ArgList &Args,
-                    unsigned &Index,
-                    unsigned ArgSize) const {
-  const Option &UnaliasedOption = getUnaliasedOption();
-  StringRef Spelling;
-  // If the option was an alias, get the spelling from the unaliased one.
-  if (getID() == UnaliasedOption.getID()) {
-    Spelling = StringRef(Args.getArgString(Index), ArgSize);
-  } else {
-    Spelling = Args.MakeArgString(Twine(UnaliasedOption.getPrefix()) +
-                                  Twine(UnaliasedOption.getName()));
-  }
-
-  switch (getKind()) {
-  case FlagClass:
-    if (ArgSize != strlen(Args.getArgString(Index)))
-      return 0;
-
-    return new Arg(UnaliasedOption, Spelling, Index++);
-  case JoinedClass: {
-    const char *Value = Args.getArgString(Index) + ArgSize;
-    return new Arg(UnaliasedOption, Spelling, Index++, Value);
-  }
-  case CommaJoinedClass: {
-    // Always matches.
-    const char *Str = Args.getArgString(Index) + ArgSize;
-    Arg *A = new Arg(UnaliasedOption, Spelling, Index++);
-
-    // Parse out the comma separated values.
-    const char *Prev = Str;
-    for (;; ++Str) {
-      char c = *Str;
-
-      if (!c || c == ',') {
-        if (Prev != Str) {
-          char *Value = new char[Str - Prev + 1];
-          memcpy(Value, Prev, Str - Prev);
-          Value[Str - Prev] = '\0';
-          A->getValues().push_back(Value);
-        }
-
-        if (!c)
-          break;
-
-        Prev = Str + 1;
-      }
-    }
-    A->setOwnsValues(true);
-
-    return A;
-  }
-  case SeparateClass:
-    // Matches iff this is an exact match.
-    // FIXME: Avoid strlen.
-    if (ArgSize != strlen(Args.getArgString(Index)))
-      return 0;
-
-    Index += 2;
-    if (Index > Args.getNumInputArgStrings())
-      return 0;
-
-    return new Arg(UnaliasedOption, Spelling,
-                   Index - 2, Args.getArgString(Index - 1));
-  case MultiArgClass: {
-    // Matches iff this is an exact match.
-    // FIXME: Avoid strlen.
-    if (ArgSize != strlen(Args.getArgString(Index)))
-      return 0;
-
-    Index += 1 + getNumArgs();
-    if (Index > Args.getNumInputArgStrings())
-      return 0;
-
-    Arg *A = new Arg(UnaliasedOption, Spelling, Index - 1 - getNumArgs(),
-                      Args.getArgString(Index - getNumArgs()));
-    for (unsigned i = 1; i != getNumArgs(); ++i)
-      A->getValues().push_back(Args.getArgString(Index - getNumArgs() + i));
-    return A;
-  }
-  case JoinedOrSeparateClass: {
-    // If this is not an exact match, it is a joined arg.
-    // FIXME: Avoid strlen.
-    if (ArgSize != strlen(Args.getArgString(Index))) {
-      const char *Value = Args.getArgString(Index) + ArgSize;
-      return new Arg(*this, Spelling, Index++, Value);
-    }
-
-    // Otherwise it must be separate.
-    Index += 2;
-    if (Index > Args.getNumInputArgStrings())
-      return 0;
-
-    return new Arg(UnaliasedOption, Spelling,
-                   Index - 2, Args.getArgString(Index - 1));
-  }
-  case JoinedAndSeparateClass:
-    // Always matches.
-    Index += 2;
-    if (Index > Args.getNumInputArgStrings())
-      return 0;
-
-    return new Arg(UnaliasedOption, Spelling, Index - 2,
-                   Args.getArgString(Index - 2) + ArgSize,
-                   Args.getArgString(Index - 1));
-  default:
-    llvm_unreachable("Invalid option kind!");
-  }
-}
index fb5c8bdb9e37b8e388a954ea37a3e5431e7dc8a7..53a0a75fcb280f91c6c677a5b61ef546520ecdd9 100644 (file)
@@ -9,12 +9,12 @@
 #ifndef CLANG_LIB_DRIVER_SANITIZERARGS_H_
 #define CLANG_LIB_DRIVER_SANITIZERARGS_H_
 
-#include "clang/Driver/Arg.h"
-#include "clang/Driver/ArgList.h"
 #include "clang/Driver/Driver.h"
 #include "clang/Driver/DriverDiagnostic.h"
 #include "clang/Driver/Options.h"
 #include "llvm/ADT/StringSwitch.h"
+#include "llvm/Option/Arg.h"
+#include "llvm/Option/ArgList.h"
 #include "llvm/Support/Path.h"
 
 namespace clang {
index 824db2ae217a0792c324560a8de7a1675fc10095..5bc41f99cf676d99e53669aeba6481143870a896 100644 (file)
@@ -8,20 +8,21 @@
 //===----------------------------------------------------------------------===//
 
 #include "Tools.h"
-#include "clang/Driver/ToolChain.h"
 #include "clang/Basic/ObjCRuntime.h"
 #include "clang/Driver/Action.h"
-#include "clang/Driver/Arg.h"
-#include "clang/Driver/ArgList.h"
 #include "clang/Driver/Driver.h"
 #include "clang/Driver/DriverDiagnostic.h"
-#include "clang/Driver/Option.h"
 #include "clang/Driver/Options.h"
+#include "clang/Driver/ToolChain.h"
 #include "llvm/ADT/StringSwitch.h"
+#include "llvm/Option/Arg.h"
+#include "llvm/Option/ArgList.h"
+#include "llvm/Option/Option.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/FileSystem.h"
 using namespace clang::driver;
 using namespace clang;
+using namespace llvm::opt;
 
 ToolChain::ToolChain(const Driver &D, const llvm::Triple &T,
                      const ArgList &A)
index 71b010e185f2f82ea74e6cb1d0ccf44f0fb430d5..0853006b121e4264652ee8b5497eabd08477da19 100644 (file)
 #include "SanitizerArgs.h"
 #include "clang/Basic/ObjCRuntime.h"
 #include "clang/Basic/Version.h"
-#include "clang/Driver/Arg.h"
-#include "clang/Driver/ArgList.h"
 #include "clang/Driver/Compilation.h"
 #include "clang/Driver/Driver.h"
 #include "clang/Driver/DriverDiagnostic.h"
-#include "clang/Driver/OptTable.h"
-#include "clang/Driver/Option.h"
 #include "clang/Driver/Options.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringSwitch.h"
+#include "llvm/Option/Arg.h"
+#include "llvm/Option/ArgList.h"
+#include "llvm/Option/OptTable.h"
+#include "llvm/Option/Option.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/MemoryBuffer.h"
@@ -39,6 +39,7 @@
 using namespace clang::driver;
 using namespace clang::driver::toolchains;
 using namespace clang;
+using namespace llvm::opt;
 
 /// Darwin - Darwin tool chain for i386 and x86_64.
 
index ccd0558c090aa2a65e06eb148423d37141777c0b..c7053e84fa94ccd5ade3c2a4bd9d250c4de5bbce 100644 (file)
@@ -7,7 +7,6 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include <sys/stat.h>
 #include "Tools.h"
 #include "InputInfo.h"
 #include "SanitizerArgs.h"
 #include "clang/Basic/ObjCRuntime.h"
 #include "clang/Basic/Version.h"
 #include "clang/Driver/Action.h"
-#include "clang/Driver/Arg.h"
-#include "clang/Driver/ArgList.h"
 #include "clang/Driver/Compilation.h"
 #include "clang/Driver/Driver.h"
 #include "clang/Driver/DriverDiagnostic.h"
 #include "clang/Driver/Job.h"
-#include "clang/Driver/Option.h"
 #include "clang/Driver/Options.h"
 #include "clang/Driver/ToolChain.h"
 #include "clang/Driver/Util.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/ADT/Twine.h"
+#include "llvm/Option/Arg.h"
+#include "llvm/Option/ArgList.h"
+#include "llvm/Option/Option.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Format.h"
 #include "llvm/Support/Host.h"
 #include "llvm/Support/Process.h"
 #include "llvm/Support/raw_ostream.h"
+#include <sys/stat.h>
 
 using namespace clang::driver;
 using namespace clang::driver::tools;
 using namespace clang;
+using namespace llvm::opt;
 
 /// CheckPreprocessingOptions - Perform some validation of preprocessing
 /// arguments that is shared with gcc.
index d6471716e660989ab9165706fc95b94f7621996a..8250527202958d1b5e2c7459f976748dbebca2c3 100644 (file)
@@ -14,6 +14,7 @@
 #include "clang/Driver/Types.h"
 #include "clang/Driver/Util.h"
 #include "llvm/ADT/Triple.h"
+#include "llvm/Option/Option.h"
 #include "llvm/Support/Compiler.h"
 
 namespace clang {
@@ -27,6 +28,7 @@ namespace toolchains {
 }
 
 namespace tools {
+using llvm::opt::ArgStringList;
 
   /// \brief Clang compiler tool.
   class LLVM_LIBRARY_VISIBILITY Clang : public Tool {
index 622c49296de88872efcd22df2282e7d77de5b8ac..64625ed535b0cba7290d6bbd9b8328ccbee732c4 100644 (file)
 #include "ToolChains.h"
 #include "clang/Basic/CharInfo.h"
 #include "clang/Basic/Version.h"
-#include "clang/Driver/Arg.h"
-#include "clang/Driver/ArgList.h"
 #include "clang/Driver/Compilation.h"
 #include "clang/Driver/Driver.h"
 #include "clang/Driver/DriverDiagnostic.h"
 #include "clang/Driver/Options.h"
+#include "llvm/Option/Arg.h"
+#include "llvm/Option/ArgList.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/Path.h"
 
@@ -31,6 +31,7 @@
 using namespace clang::driver;
 using namespace clang::driver::toolchains;
 using namespace clang;
+using namespace llvm::opt;
 
 Windows::Windows(const Driver &D, const llvm::Triple& Triple,
                  const ArgList &Args)
index 3b757909387ca6cf9e5a949112ecd0eb5af49707..4e62fda4a3410d2bfcff62c391b5bd42efa758e0 100644 (file)
 #include "clang/Basic/Diagnostic.h"
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/Version.h"
-#include "clang/Driver/Arg.h"
-#include "clang/Driver/ArgList.h"
 #include "clang/Driver/DriverDiagnostic.h"
-#include "clang/Driver/OptTable.h"
-#include "clang/Driver/Option.h"
 #include "clang/Driver/Options.h"
+#include "clang/Driver/Util.h"
 #include "clang/Frontend/LangStandard.h"
+#include "clang/Frontend/Utils.h"
 #include "clang/Lex/HeaderSearchOptions.h"
 #include "clang/Serialization/ASTReader.h"
 #include "llvm/ADT/Hashing.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/ADT/Triple.h"
+#include "llvm/Option/Arg.h"
+#include "llvm/Option/ArgList.h"
+#include "llvm/Option/OptTable.h"
+#include "llvm/Option/Option.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/Host.h"
 #include "llvm/Support/Path.h"
@@ -58,6 +60,7 @@ CompilerInvocationBase::CompilerInvocationBase(const CompilerInvocationBase &X)
 
 using namespace clang::driver;
 using namespace clang::driver::options;
+using namespace llvm::opt;
 
 //
 
@@ -80,7 +83,7 @@ static unsigned getOptimizationLevel(ArgList &Args, InputKind IK,
     if (S == "s" || S == "z" || S.empty())
       return 2;
 
-    return Args.getLastArgIntValue(OPT_O, DefaultOpt, Diags);
+    return getLastArgIntValue(Args, OPT_O, DefaultOpt, Diags);
   }
 
   return DefaultOpt;
@@ -223,11 +226,12 @@ static bool ParseAnalyzerArgs(AnalyzerOptions &Opts, ArgList &Args,
   Opts.AnalyzeSpecificFunction = Args.getLastArgValue(OPT_analyze_function);
   Opts.UnoptimizedCFG = Args.hasArg(OPT_analysis_UnoptimizedCFG);
   Opts.TrimGraph = Args.hasArg(OPT_trim_egraph);
-  Opts.maxBlockVisitOnPath = Args.getLastArgIntValue(OPT_analyzer_max_loop, 4, Diags);
+  Opts.maxBlockVisitOnPath =
+      getLastArgIntValue(Args, OPT_analyzer_max_loop, 4, Diags);
   Opts.PrintStats = Args.hasArg(OPT_analyzer_stats);
   Opts.InlineMaxStackDepth =
-    Args.getLastArgIntValue(OPT_analyzer_inline_max_stack_depth,
-                            Opts.InlineMaxStackDepth, Diags);
+      getLastArgIntValue(Args, OPT_analyzer_inline_max_stack_depth,
+                         Opts.InlineMaxStackDepth, Diags);
 
   Opts.CheckersControlList.clear();
   for (arg_iterator it = Args.filtered_begin(OPT_analyzer_checker,
@@ -362,7 +366,7 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK,
                        Args.hasArg(OPT_cl_fast_relaxed_math));
   Opts.NoZeroInitializedInBSS = Args.hasArg(OPT_mno_zero_initialized_in_bss);
   Opts.BackendOptions = Args.getAllArgValues(OPT_backend_option);
-  Opts.NumRegisterParameters = Args.getLastArgIntValue(OPT_mregparm, 0, Diags);
+  Opts.NumRegisterParameters = getLastArgIntValue(Args, OPT_mregparm, 0, Diags);
   Opts.NoGlobalMerge = Args.hasArg(OPT_mno_global_merge);
   Opts.NoExecStack = Args.hasArg(OPT_mno_exec_stack);
   Opts.EnableSegmentedStacks = Args.hasArg(OPT_split_stacks);
@@ -421,7 +425,7 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK,
   Opts.SanitizeUndefinedTrapOnError =
     Args.hasArg(OPT_fsanitize_undefined_trap_on_error);
   Opts.SSPBufferSize =
-    Args.getLastArgIntValue(OPT_stack_protector_buffer_size, 8, Diags);
+      getLastArgIntValue(Args, OPT_stack_protector_buffer_size, 8, Diags);
   Opts.StackRealignment = Args.hasArg(OPT_mstackrealign);
   if (Arg *A = Args.getLastArg(OPT_mstack_alignment)) {
     StringRef Val = A->getValue();
@@ -570,19 +574,17 @@ bool clang::ParseDiagnosticArgs(DiagnosticOptions &Opts, ArgList &Args,
   Opts.VerifyDiagnostics = Args.hasArg(OPT_verify);
   Opts.ElideType = !Args.hasArg(OPT_fno_elide_type);
   Opts.ShowTemplateTree = Args.hasArg(OPT_fdiagnostics_show_template_tree);
-  Opts.ErrorLimit = Args.getLastArgIntValue(OPT_ferror_limit, 0, Diags);
-  Opts.MacroBacktraceLimit
-    = Args.getLastArgIntValue(OPT_fmacro_backtrace_limit,
+  Opts.ErrorLimit = getLastArgIntValue(Args, OPT_ferror_limit, 0, Diags);
+  Opts.MacroBacktraceLimit =
+      getLastArgIntValue(Args, OPT_fmacro_backtrace_limit,
                          DiagnosticOptions::DefaultMacroBacktraceLimit, Diags);
-  Opts.TemplateBacktraceLimit
-    = Args.getLastArgIntValue(OPT_ftemplate_backtrace_limit,
-                         DiagnosticOptions::DefaultTemplateBacktraceLimit,
-                         Diags);
-  Opts.ConstexprBacktraceLimit
-    = Args.getLastArgIntValue(OPT_fconstexpr_backtrace_limit,
-                         DiagnosticOptions::DefaultConstexprBacktraceLimit,
-                         Diags);
-  Opts.TabStop = Args.getLastArgIntValue(OPT_ftabstop,
+  Opts.TemplateBacktraceLimit = getLastArgIntValue(
+      Args, OPT_ftemplate_backtrace_limit,
+      DiagnosticOptions::DefaultTemplateBacktraceLimit, Diags);
+  Opts.ConstexprBacktraceLimit = getLastArgIntValue(
+      Args, OPT_fconstexpr_backtrace_limit,
+      DiagnosticOptions::DefaultConstexprBacktraceLimit, Diags);
+  Opts.TabStop = getLastArgIntValue(Args, OPT_ftabstop,
                                     DiagnosticOptions::DefaultTabStop, Diags);
   if (Opts.TabStop == 0 || Opts.TabStop > DiagnosticOptions::MaxTabStop) {
     Opts.TabStop = DiagnosticOptions::DefaultTabStop;
@@ -590,7 +592,7 @@ bool clang::ParseDiagnosticArgs(DiagnosticOptions &Opts, ArgList &Args,
       Diags->Report(diag::warn_ignoring_ftabstop_value)
       << Opts.TabStop << DiagnosticOptions::DefaultTabStop;
   }
-  Opts.MessageLength = Args.getLastArgIntValue(OPT_fmessage_length, 0, Diags);
+  Opts.MessageLength = getLastArgIntValue(Args, OPT_fmessage_length, 0, Diags);
   addWarningArgs(Args, Opts.Warnings);
 
   return Success;
@@ -845,12 +847,13 @@ static void ParseHeaderSearchArgs(HeaderSearchOptions &Opts, ArgList &Args) {
   Opts.ResourceDir = Args.getLastArgValue(OPT_resource_dir);
   Opts.ModuleCachePath = Args.getLastArgValue(OPT_fmodules_cache_path);
   Opts.DisableModuleHash = Args.hasArg(OPT_fdisable_module_hash);
-  Opts.ModuleCachePruneInterval
-    = Args.getLastArgIntValue(OPT_fmodules_prune_interval, 7*24*60*60);
-  Opts.ModuleCachePruneAfter
-    = Args.getLastArgIntValue(OPT_fmodules_prune_after, 31*24*60*60);
+  Opts.ModuleCachePruneInterval =
+      getLastArgIntValue(Args, OPT_fmodules_prune_interval, 7 * 24 * 60 * 60);
+  Opts.ModuleCachePruneAfter =
+      getLastArgIntValue(Args, OPT_fmodules_prune_after, 31 * 24 * 60 * 60);
   for (arg_iterator it = Args.filtered_begin(OPT_fmodules_ignore_macro),
-       ie = Args.filtered_end(); it != ie; ++it) {
+                    ie = Args.filtered_end();
+       it != ie; ++it) {
     StringRef MacroDef = (*it)->getValue();
     Opts.ModulesIgnoreMacros.insert(MacroDef.split('=').first);
   }
@@ -1219,7 +1222,7 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK,
     = Args.hasArg(OPT_fms_extensions) || Args.hasArg(OPT_fms_compatibility);
   Opts.MicrosoftMode = Args.hasArg(OPT_fms_compatibility);
   Opts.AsmBlocks = Args.hasArg(OPT_fasm_blocks) || Opts.MicrosoftExt;
-  Opts.MSCVersion = Args.getLastArgIntValue(OPT_fmsc_version, 0, Diags);
+  Opts.MSCVersion = getLastArgIntValue(Args, OPT_fmsc_version, 0, Diags);
   Opts.Borland = Args.hasArg(OPT_fborland_extensions);
   Opts.WritableStrings = Args.hasArg(OPT_fwritable_strings);
   Opts.ConstStrings = Args.hasFlag(OPT_fconst_strings, OPT_fno_const_strings,
@@ -1249,16 +1252,16 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK,
   Opts.AccessControl = !Args.hasArg(OPT_fno_access_control);
   Opts.ElideConstructors = !Args.hasArg(OPT_fno_elide_constructors);
   Opts.MathErrno = Args.hasArg(OPT_fmath_errno);
-  Opts.InstantiationDepth = Args.getLastArgIntValue(OPT_ftemplate_depth, 256,
-                                                    Diags);
-  Opts.ConstexprCallDepth = Args.getLastArgIntValue(OPT_fconstexpr_depth, 512,
-                                                    Diags);
-  Opts.ConstexprStepLimit = Args.getLastArgIntValue(OPT_fconstexpr_steps,
-                                                    1048576, Diags);
-  Opts.BracketDepth = Args.getLastArgIntValue(OPT_fbracket_depth, 256, Diags);
+  Opts.InstantiationDepth =
+      getLastArgIntValue(Args, OPT_ftemplate_depth, 256, Diags);
+  Opts.ConstexprCallDepth =
+      getLastArgIntValue(Args, OPT_fconstexpr_depth, 512, Diags);
+  Opts.ConstexprStepLimit =
+      getLastArgIntValue(Args, OPT_fconstexpr_steps, 1048576, Diags);
+  Opts.BracketDepth = getLastArgIntValue(Args, OPT_fbracket_depth, 256, Diags);
   Opts.DelayedTemplateParsing = Args.hasArg(OPT_fdelayed_template_parsing);
-  Opts.NumLargeByValueCopy = Args.getLastArgIntValue(OPT_Wlarge_by_value_copy_EQ,
-                                                    0, Diags);
+  Opts.NumLargeByValueCopy =
+      getLastArgIntValue(Args, OPT_Wlarge_by_value_copy_EQ, 0, Diags);
   Opts.MSBitfields = Args.hasArg(OPT_mms_bitfields);
   Opts.ObjCConstantStringClass =
     Args.getLastArgValue(OPT_fconstant_string_class);
@@ -1267,9 +1270,9 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK,
   Opts.EncodeExtendedBlockSig =
     Args.hasArg(OPT_fencode_extended_block_signature);
   Opts.EmitAllDecls = Args.hasArg(OPT_femit_all_decls);
-  Opts.PackStruct = Args.getLastArgIntValue(OPT_fpack_struct_EQ, 0, Diags);
-  Opts.PICLevel = Args.getLastArgIntValue(OPT_pic_level, 0, Diags);
-  Opts.PIELevel = Args.getLastArgIntValue(OPT_pie_level, 0, Diags);
+  Opts.PackStruct = getLastArgIntValue(Args, OPT_fpack_struct_EQ, 0, Diags);
+  Opts.PICLevel = getLastArgIntValue(Args, OPT_pic_level, 0, Diags);
+  Opts.PIELevel = getLastArgIntValue(Args, OPT_pie_level, 0, Diags);
   Opts.Static = Args.hasArg(OPT_static_define);
   Opts.DumpRecordLayoutsSimple = Args.hasArg(OPT_fdump_record_layouts_simple);
   Opts.DumpRecordLayouts = Opts.DumpRecordLayoutsSimple 
@@ -1314,7 +1317,7 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK,
   Opts.RetainCommentsFromSystemHeaders =
       Args.hasArg(OPT_fretain_comments_from_system_headers);
 
-  unsigned SSP = Args.getLastArgIntValue(OPT_stack_protector, 0, Diags);
+  unsigned SSP = getLastArgIntValue(Args, OPT_stack_protector, 0, Diags);
   switch (SSP) {
   default:
     Diags.Report(diag::err_drv_invalid_value)
@@ -1546,6 +1549,8 @@ bool CompilerInvocation::CreateFromArgs(CompilerInvocation &Res,
   // Issue errors on arguments that are not valid for CC1.
   for (ArgList::iterator I = Args->begin(), E = Args->end();
        I != E; ++I) {
+    if ((*I)->getOption().matches(options::OPT_INPUT))
+      continue;
     if (!(*I)->getOption().hasFlag(options::CC1Option)) {
       Diags.Report(diag::err_drv_unknown_argument) << (*I)->getAsString(*Args);
       Success = false;
@@ -1714,3 +1719,20 @@ std::string CompilerInvocation::getModuleHash() const {
 
   return llvm::APInt(64, code).toString(36, /*Signed=*/false);
 }
+
+namespace clang {
+
+// Declared in clang/Frontend/Utils.h.
+int getLastArgIntValue(const ArgList &Args, OptSpecifier Id, int Default,
+                       DiagnosticsEngine *Diags) {
+  int Res = Default;
+  if (Arg *A = Args.getLastArg(Id)) {
+    if (StringRef(A->getValue()).getAsInteger(10, Res)) {
+      if (Diags)
+        Diags->Report(diag::err_drv_invalid_int_value) << A->getAsString(Args)
+                                                       << A->getValue();
+    }
+  }
+  return Res;
+}
+}
index e25eb4322c55d7ca135e0869f8eefa8dc74d2bb9..acb93fa1b04bea094058c2d6273670f5c28b65ad 100644 (file)
 
 #include "clang/Frontend/Utils.h"
 #include "clang/Basic/DiagnosticOptions.h"
-#include "clang/Driver/ArgList.h"
 #include "clang/Driver/Compilation.h"
 #include "clang/Driver/Driver.h"
 #include "clang/Driver/Options.h"
 #include "clang/Driver/Tool.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/FrontendDiagnostic.h"
+#include "llvm/Option/ArgList.h"
 #include "llvm/Support/Host.h"
 using namespace clang;
+using namespace llvm::opt;
 
 /// createInvocationFromCommandLine - Construct a compiler invocation object for
 /// a command line argument vector.
@@ -76,7 +77,7 @@ clang::createInvocationFromCommandLine(ArrayRef<const char *> ArgList,
     return 0;
   }
 
-  const driver::ArgStringList &CCArgs = Cmd->getArguments();
+  const ArgStringList &CCArgs = Cmd->getArguments();
   OwningPtr<CompilerInvocation> CI(new CompilerInvocation());
   if (!CompilerInvocation::CreateFromArgs(*CI,
                                      const_cast<const char **>(CCArgs.data()),
index b0d76da33425ccd28892064595f723102ce8e385..0309d53f06e25afbc8efb325171d3c7a48fd6e44 100644 (file)
@@ -15,8 +15,6 @@
 #include "clang/FrontendTool/Utils.h"
 #include "clang/ARCMigrate/ARCMTActions.h"
 #include "clang/CodeGen/CodeGenAction.h"
-#include "clang/Driver/OptTable.h"
-#include "clang/Driver/Option.h"
 #include "clang/Driver/Options.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/CompilerInvocation.h"
 #include "clang/Frontend/FrontendPluginRegistry.h"
 #include "clang/Rewrite/Frontend/FrontendActions.h"
 #include "clang/StaticAnalyzer/Frontend/FrontendActions.h"
+#include "llvm/Option/OptTable.h"
+#include "llvm/Option/Option.h"
 #include "llvm/Support/DynamicLibrary.h"
 #include "llvm/Support/ErrorHandling.h"
 using namespace clang;
+using namespace llvm::opt;
 
 static FrontendAction *CreateFrontendBaseAction(CompilerInstance &CI) {
   using namespace clang::frontend;
@@ -177,11 +178,10 @@ static FrontendAction *CreateFrontendAction(CompilerInstance &CI) {
 bool clang::ExecuteCompilerInvocation(CompilerInstance *Clang) {
   // Honor -help.
   if (Clang->getFrontendOpts().ShowHelp) {
-    OwningPtr<driver::OptTable> Opts(driver::createDriverOptTable());
+    OwningPtr<OptTable> Opts(driver::createDriverOptTable());
     Opts->PrintHelp(llvm::outs(), "clang -cc1",
                     "LLVM 'Clang' Compiler: http://clang.llvm.org",
-                    /*Include=*/driver::options::CC1Option,
-                    /*Exclude=*/0);
+                    /*Include=*/ driver::options::CC1Option, /*Exclude=*/ 0);
     return 0;
   }
 
index a121cd0fd64363997260f493acd5476ec9c78250..e7bfba7e1269734093b8595671f6277602f7c024 100644 (file)
@@ -22,6 +22,7 @@
 #include "clang/Tooling/ArgumentsAdjusters.h"
 #include "clang/Tooling/CompilationDatabase.h"
 #include "llvm/ADT/STLExtras.h"
+#include "llvm/Option/Option.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Host.h"
@@ -57,7 +58,7 @@ static clang::driver::Driver *newDriver(clang::DiagnosticsEngine *Diagnostics,
 /// \brief Retrieves the clang CC1 specific flags out of the compilation's jobs.
 ///
 /// Returns NULL on error.
-static const clang::driver::ArgStringList *getCC1Arguments(
+static const llvm::opt::ArgStringList *getCC1Arguments(
     clang::DiagnosticsEngine *Diagnostics,
     clang::driver::Compilation *Compilation) {
   // We expect to get back exactly one Command job, if we didn't something
@@ -86,7 +87,7 @@ static const clang::driver::ArgStringList *getCC1Arguments(
 /// \brief Returns a clang build invocation initialized from the CC1 flags.
 static clang::CompilerInvocation *newInvocation(
     clang::DiagnosticsEngine *Diagnostics,
-    const clang::driver::ArgStringList &CC1Args) {
+    const llvm::opt::ArgStringList &CC1Args) {
   assert(!CC1Args.empty() && "Must at least contain the program name!");
   clang::CompilerInvocation *Invocation = new clang::CompilerInvocation;
   clang::CompilerInvocation::CreateFromArgs(
@@ -173,7 +174,7 @@ bool ToolInvocation::run() {
   Driver->setCheckInputsExist(false);
   const OwningPtr<clang::driver::Compilation> Compilation(
       Driver->BuildCompilation(llvm::makeArrayRef(Argv)));
-  const clang::driver::ArgStringList *const CC1Args = getCC1Arguments(
+  const llvm::opt::ArgStringList *const CC1Args = getCC1Arguments(
       &Diagnostics, Compilation.get());
   if (CC1Args == NULL) {
     return false;
index 52898ceab7e21f87298497b8fc3ae2c9051f085e..4b9b8db0a0b06464976cc342ffda4a8c4f2d2fdb 100644 (file)
@@ -17,7 +17,7 @@ TOOL_NO_EXPORTS = 1
 NO_INSTALL = 1
 
 include $(CLANG_LEVEL)/../../Makefile.config
-LINK_COMPONENTS := $(TARGETS_TO_BUILD) asmparser bitreader support mc
+LINK_COMPONENTS := $(TARGETS_TO_BUILD) asmparser bitreader support mc option
 USEDLIBS = clangARCMigrate.a clangRewriteCore.a \
                 clangFrontend.a clangDriver.a clangSerialization.a clangParse.a \
                 clangSema.a clangEdit.a clangAnalysis.a clangAST.a clangLex.a \
index 02b8ab7bd6870ca208f945e3660d9ba4703c849c..417d753e5055e7726d7b86eda1629144cd478483 100644 (file)
@@ -21,7 +21,7 @@ NO_INSTALL = 1
 # LINK_COMPONENTS before including Makefile.rules
 include $(CLANG_LEVEL)/../../Makefile.config
 
-LINK_COMPONENTS := $(TARGETS_TO_BUILD) asmparser bitreader support mc
+LINK_COMPONENTS := $(TARGETS_TO_BUILD) asmparser bitreader support mc option
 
 # Note that 'USEDLIBS' must include all of the core clang libraries
 # when -static is given to linker on cygming.
index 7723115263ee8b63c81e043b8806b6a5684bfe10..4df90e62abe89046baee89917d3ebaa3672f234c 100644 (file)
@@ -22,7 +22,7 @@ TOOL_NO_EXPORTS = 1
 # LINK_COMPONENTS before including Makefile.rules
 include $(CLANG_LEVEL)/../../Makefile.config
 
-LINK_COMPONENTS := $(TARGETS_TO_BUILD) asmparser bitreader support mc
+LINK_COMPONENTS := $(TARGETS_TO_BUILD) asmparser bitreader support mc option
 
 # Note that 'USEDLIBS' must include all of the core clang libraries
 # when -static is given to linker on cygming.
index bc01874bcf6efbbd649328923be6b622fe63e64c..701db52334c6ea980595cd571edaddd1795ee764 100644 (file)
@@ -17,7 +17,6 @@
 //===----------------------------------------------------------------------===//
 
 #include "clang/AST/ASTConsumer.h"
-#include "clang/Driver/OptTable.h"
 #include "clang/Driver/Options.h"
 #include "clang/Frontend/ASTConsumers.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Signals.h"
+#include "llvm/Option/OptTable.h"
 
 using namespace clang::driver;
 using namespace clang::tooling;
 using namespace llvm;
+using namespace llvm::opt;
 
 static cl::extrahelp CommonHelp(CommonOptionsParser::HelpMessage);
 static cl::extrahelp MoreHelp(
index a9ed1853a29f23e54556018fb1a3c49f2854f1ec..cf088d2689302f33300aff3816d1d590bd61ea79 100644 (file)
@@ -15,7 +15,7 @@ TOOLNAME = clang-check
 TOOL_NO_EXPORTS = 1
 
 include $(CLANG_LEVEL)/../../Makefile.config
-LINK_COMPONENTS := $(TARGETS_TO_BUILD) asmparser bitreader support mc
+LINK_COMPONENTS := $(TARGETS_TO_BUILD) asmparser bitreader support mc option
 USEDLIBS = clangFrontend.a clangSerialization.a clangDriver.a \
            clangTooling.a clangParse.a clangSema.a \
            clangStaticAnalyzerFrontend.a clangStaticAnalyzerCheckers.a \
index d869267a76f6bc1dc774b803e45ede807c0106dd..4902244f86579bb640ef11c5ecbe490d7b73f96a 100644 (file)
@@ -15,7 +15,7 @@ TOOLNAME = clang-format
 TOOL_NO_EXPORTS = 1
 
 include $(CLANG_LEVEL)/../../Makefile.config
-LINK_COMPONENTS := $(TARGETS_TO_BUILD) asmparser bitreader support mc
+LINK_COMPONENTS := $(TARGETS_TO_BUILD) asmparser bitreader support mc option
 USEDLIBS = clangFormat.a clangTooling.a clangFrontend.a clangSerialization.a \
           clangDriver.a clangParse.a clangSema.a clangAnalysis.a \
            clangRewriteFrontend.a clangRewriteCore.a clangEdit.a clangAST.a \
index 94f9c7663add67b6827b47e55c991522296e7609..d49e976e6428b32a6f66b2535a45e4ab8b0dee39 100644 (file)
@@ -17,7 +17,7 @@ TOOL_NO_EXPORTS := 1
 NO_INSTALL = 1
 
 include $(CLANG_LEVEL)/../../Makefile.config
-LINK_COMPONENTS := $(TARGETS_TO_BUILD) asmparser bitreader support mc
+LINK_COMPONENTS := $(TARGETS_TO_BUILD) asmparser bitreader support mc option
 USEDLIBS = clangFrontend.a clangDriver.a clangSerialization.a clangParse.a \
            clangSema.a clangAnalysis.a clangEdit.a clangAST.a clangLex.a \
            clangBasic.a
index cdf3b5248c312e51d2663fd75779deacca7f353f..f7a9f8f36e5e623c31e39467479ceeac232a0b35 100644 (file)
@@ -30,7 +30,7 @@ TOOL_INFO_PLIST := Info.plist
 include $(CLANG_LEVEL)/../../Makefile.config
 
 LINK_COMPONENTS := $(TARGETS_TO_BUILD) asmparser bitreader bitwriter codegen \
-                   instrumentation ipo irreader linker selectiondag
+                   instrumentation ipo irreader linker selectiondag option
 USEDLIBS = clangFrontendTool.a clangFrontend.a clangDriver.a \
            clangSerialization.a clangCodeGen.a clangParse.a clangSema.a
 
index 35cf5b8735107a8a19c35c18bdec96b55ce1e14c..5b3b5ad6500bca82c103ab5c201385a0cc1903f7 100644 (file)
 //
 //===----------------------------------------------------------------------===//
 
-#include "clang/Driver/Arg.h"
-#include "clang/Driver/ArgList.h"
+#include "llvm/Option/Arg.h"
 #include "clang/Driver/DriverDiagnostic.h"
-#include "clang/Driver/OptTable.h"
 #include "clang/Driver/Options.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/CompilerInvocation.h"
@@ -26,6 +24,8 @@
 #include "clang/FrontendTool/Utils.h"
 #include "llvm/ADT/Statistic.h"
 #include "llvm/LinkAllPasses.h"
+#include "llvm/Option/ArgList.h"
+#include "llvm/Option/OptTable.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/ManagedStatic.h"
 #include "llvm/Support/Signals.h"
@@ -34,6 +34,7 @@
 #include "llvm/Support/raw_ostream.h"
 #include <cstdio>
 using namespace clang;
+using namespace llvm::opt;
 
 //===----------------------------------------------------------------------===//
 // Main driver
index a8afff0fe20e7015f7f7de620d0a1fb5e02325c5..f189c5cf2acabdd1d30f6ed56a0a8832eae8b5d1 100644 (file)
 
 #include "clang/Basic/Diagnostic.h"
 #include "clang/Basic/DiagnosticOptions.h"
-#include "clang/Driver/Arg.h"
-#include "clang/Driver/ArgList.h"
 #include "clang/Driver/CC1AsOptions.h"
 #include "clang/Driver/DriverDiagnostic.h"
-#include "clang/Driver/OptTable.h"
 #include "clang/Driver/Options.h"
 #include "clang/Frontend/FrontendDiagnostic.h"
 #include "clang/Frontend/TextDiagnosticPrinter.h"
+#include "clang/Frontend/Utils.h"
 #include "llvm/ADT/OwningPtr.h"
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/ADT/Triple.h"
@@ -37,6 +35,9 @@
 #include "llvm/MC/MCStreamer.h"
 #include "llvm/MC/MCSubtargetInfo.h"
 #include "llvm/MC/MCTargetAsmParser.h"
+#include "llvm/Option/Arg.h"
+#include "llvm/Option/ArgList.h"
+#include "llvm/Option/OptTable.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/FormattedStream.h"
@@ -56,6 +57,7 @@
 using namespace clang;
 using namespace clang::driver;
 using namespace llvm;
+using namespace llvm::opt;
 
 namespace {
 
@@ -225,8 +227,8 @@ bool AssemblerInvocation::CreateFromArgs(AssemblerInvocation &Opts,
   Opts.ShowVersion = Args->hasArg(OPT_version);
 
   // Transliterate Options
-  Opts.OutputAsmVariant = Args->getLastArgIntValue(OPT_output_asm_variant,
-                                                   0, Diags);
+  Opts.OutputAsmVariant =
+      getLastArgIntValue(*Args.get(), OPT_output_asm_variant, 0, Diags);
   Opts.ShowEncoding = Args->hasArg(OPT_show_encoding);
   Opts.ShowInst = Args->hasArg(OPT_show_inst);
 
@@ -427,7 +429,7 @@ int cc1as_main(const char **ArgBegin, const char **ArgEnd,
 
   // Honor -help.
   if (Asm.ShowHelp) {
-    OwningPtr<driver::OptTable> Opts(driver::createCC1AsOptTable());
+    OwningPtr<OptTable> Opts(driver::createCC1AsOptTable());
     Opts->PrintHelp(llvm::outs(), "clang -cc1as", "Clang Integrated Assembler");
     return 0;
   }
index 7397667e08914c20cc09e7e88311c949fce068ed..f5a2dd041df59ea048e093cf6afb9e6c8eee0282 100644 (file)
 
 #include "clang/Basic/CharInfo.h"
 #include "clang/Basic/DiagnosticOptions.h"
-#include "clang/Driver/ArgList.h"
 #include "clang/Driver/Compilation.h"
 #include "clang/Driver/Driver.h"
 #include "clang/Driver/DriverDiagnostic.h"
-#include "clang/Driver/OptTable.h"
-#include "clang/Driver/Option.h"
 #include "clang/Driver/Options.h"
 #include "clang/Frontend/CompilerInvocation.h"
 #include "clang/Frontend/TextDiagnosticPrinter.h"
@@ -28,6 +25,9 @@
 #include "llvm/ADT/OwningPtr.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/SmallVector.h"
+#include "llvm/Option/ArgList.h"
+#include "llvm/Option/OptTable.h"
+#include "llvm/Option/Option.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Host.h"
@@ -45,6 +45,7 @@
 #include "llvm/Support/system_error.h"
 using namespace clang;
 using namespace clang::driver;
+using namespace llvm::opt;
 
 llvm::sys::Path GetExecutablePath(const char *Argv0, bool CanonicalPrefixes) {
   if (!CanonicalPrefixes)
index f33f345f94f7bbf44483cdefbc46d5426f12c224..0fee2c6cf9726f6ca79db992342919f81f51dadd 100644 (file)
@@ -16,7 +16,7 @@ LINK_LIBS_IN_SHARED = 1
 SHARED_LIBRARY = 1
 
 include $(CLANG_LEVEL)/../../Makefile.config
-LINK_COMPONENTS := $(TARGETS_TO_BUILD) asmparser bitreader support mc
+LINK_COMPONENTS := $(TARGETS_TO_BUILD) asmparser bitreader support mc option
 USEDLIBS = clangFrontend.a clangDriver.a \
           clangTooling.a \
           clangSerialization.a \
index 4fb2f5b2b55a716faed18c91acdc38438b11bdfe..0282d21fcf158c25c622ecdaadd19a77134554c3 100644 (file)
@@ -10,7 +10,7 @@
 CLANG_LEVEL = ../..
 TESTNAME = AST
 include $(CLANG_LEVEL)/../../Makefile.config
-LINK_COMPONENTS := $(TARGETS_TO_BUILD) asmparser bitreader support mc
+LINK_COMPONENTS := $(TARGETS_TO_BUILD) asmparser bitreader support mc option
 USEDLIBS = clangTooling.a clangFrontend.a clangSerialization.a clangDriver.a \
            clangRewriteCore.a clangRewriteFrontend.a \
            clangParse.a clangSema.a clangAnalysis.a \
index 52a02d0ec50f44dd0f7c05404ea28b04a06c7da6..66b183c0e484628df1cd71469a68f9ef00d56b8f 100644 (file)
@@ -11,7 +11,7 @@ CLANG_LEVEL = ../../..
 
 TESTNAME = DynamicASTMatchers
 include $(CLANG_LEVEL)/../../Makefile.config
-LINK_COMPONENTS := $(TARGETS_TO_BUILD) asmparser bitreader support mc
+LINK_COMPONENTS := $(TARGETS_TO_BUILD) asmparser bitreader support mc option
 USEDLIBS = clangTooling.a clangFrontend.a clangSerialization.a clangDriver.a \
            clangRewriteCore.a clangRewriteFrontend.a clangParse.a clangSema.a \
            clangAnalysis.a clangEdit.a clangAST.a clangASTMatchers.a \
index 7ff42f850ced7c3d08c2952d20f69bc89dbf75ae..dad300c04d32f433eaeadcba8c0c6d1fff6cf6b5 100644 (file)
@@ -13,7 +13,7 @@ PARALLEL_DIRS = Dynamic
 
 TESTNAME = ASTMatchers
 include $(CLANG_LEVEL)/../../Makefile.config
-LINK_COMPONENTS := $(TARGETS_TO_BUILD) asmparser bitreader support mc
+LINK_COMPONENTS := $(TARGETS_TO_BUILD) asmparser bitreader support mc option
 USEDLIBS = clangTooling.a clangFrontend.a clangSerialization.a clangDriver.a \
            clangRewriteCore.a clangRewriteFrontend.a \
            clangParse.a clangSema.a clangAnalysis.a \
index e9d0cbbbb4f608daf44f593387473930638f1f7f..7de127caafa2e2931ea4a274bdaf1c307c23c21c 100644 (file)
@@ -10,7 +10,7 @@
 CLANG_LEVEL = ../..
 TESTNAME = Format
 include $(CLANG_LEVEL)/../../Makefile.config
-LINK_COMPONENTS := $(TARGETS_TO_BUILD) asmparser bitreader support mc
+LINK_COMPONENTS := $(TARGETS_TO_BUILD) asmparser bitreader support mc option
 USEDLIBS = clangFormat.a clangTooling.a clangFrontend.a clangSerialization.a \
            clangDriver.a clangParse.a clangRewriteCore.a \
            clangRewriteFrontend.a clangSema.a clangAnalysis.a clangEdit.a \
index f61791bcc0a9924236a0e42ef5662f1521945079..7de9fb4778b434f0b6ccdd29d57e2b91708d543b 100644 (file)
@@ -10,7 +10,7 @@
 CLANG_LEVEL = ../..
 TESTNAME = Frontend
 include $(CLANG_LEVEL)/../../Makefile.config
-LINK_COMPONENTS := $(TARGETS_TO_BUILD) asmparser bitreader support mc
+LINK_COMPONENTS := $(TARGETS_TO_BUILD) asmparser bitreader support mc option
 USEDLIBS = clangFrontendTool.a clangFrontend.a clangDriver.a \
            clangSerialization.a clangCodeGen.a clangParse.a clangSema.a \
            clangStaticAnalyzerCheckers.a clangStaticAnalyzerCore.a \
index 06fdf88a2279f5d31e7621764b93f73d38506946..9d36f1fa3b4fa34aa8546d2e2fd483c6be631017 100644 (file)
@@ -10,7 +10,7 @@
 CLANG_LEVEL = ../..
 TESTNAME = Tooling
 include $(CLANG_LEVEL)/../../Makefile.config
-LINK_COMPONENTS := $(TARGETS_TO_BUILD) asmparser bitreader support mc
+LINK_COMPONENTS := $(TARGETS_TO_BUILD) asmparser bitreader support mc option
 USEDLIBS = clangTooling.a clangFrontend.a clangSerialization.a clangDriver.a \
            clangParse.a clangRewriteCore.a clangRewriteFrontend.a \
           clangSema.a clangAnalysis.a clangEdit.a \