diff options
Diffstat (limited to 'include/clang/Driver')
-rw-r--r-- | include/clang/Driver/Action.h | 209 | ||||
-rw-r--r-- | include/clang/Driver/Arg.h | 230 | ||||
-rw-r--r-- | include/clang/Driver/ArgList.h | 245 | ||||
-rw-r--r-- | include/clang/Driver/Compilation.h | 127 | ||||
-rw-r--r-- | include/clang/Driver/Driver.h | 271 | ||||
-rw-r--r-- | include/clang/Driver/DriverDiagnostic.h | 27 | ||||
-rw-r--r-- | include/clang/Driver/HostInfo.h | 84 | ||||
-rw-r--r-- | include/clang/Driver/Job.h | 138 | ||||
-rw-r--r-- | include/clang/Driver/Option.h | 308 | ||||
-rw-r--r-- | include/clang/Driver/Options.def | 624 | ||||
-rw-r--r-- | include/clang/Driver/Options.h | 90 | ||||
-rw-r--r-- | include/clang/Driver/Phases.h | 32 | ||||
-rw-r--r-- | include/clang/Driver/Tool.h | 69 | ||||
-rw-r--r-- | include/clang/Driver/ToolChain.h | 105 | ||||
-rw-r--r-- | include/clang/Driver/Types.def | 78 | ||||
-rw-r--r-- | include/clang/Driver/Types.h | 85 | ||||
-rw-r--r-- | include/clang/Driver/Util.h | 30 |
17 files changed, 2752 insertions, 0 deletions
diff --git a/include/clang/Driver/Action.h b/include/clang/Driver/Action.h new file mode 100644 index 0000000..b9bf671 --- /dev/null +++ b/include/clang/Driver/Action.h @@ -0,0 +1,209 @@ +//===--- Action.h - Abstract compilation steps ------------------*- 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_ACTION_H_ +#define CLANG_DRIVER_ACTION_H_ + +#include "llvm/ADT/SmallVector.h" + +#include "clang/Driver/Types.h" +#include "clang/Driver/Util.h" + +#include "llvm/Support/Casting.h" +using llvm::isa; +using llvm::cast; +using llvm::cast_or_null; +using llvm::dyn_cast; +using llvm::dyn_cast_or_null; + +namespace clang { +namespace driver { + class Arg; + +/// Action - Represent an abstract compilation step to perform. +/// +/// An action represents an edge in the compilation graph; typically +/// it is a job to transform an input using some tool. +/// +/// The current driver is hard wired to expect actions which produce a +/// single primary output, at least in terms of controlling the +/// compilation. Actions can produce auxiliary files, but can only +/// produce a single output to feed into subsequent actions. +class Action { +public: + typedef ActionList::size_type size_type; + typedef ActionList::iterator iterator; + typedef ActionList::const_iterator const_iterator; + + enum ActionClass { + InputClass = 0, + BindArchClass, + PreprocessJobClass, + PrecompileJobClass, + AnalyzeJobClass, + CompileJobClass, + AssembleJobClass, + LinkJobClass, + LipoJobClass, + + JobClassFirst=PreprocessJobClass, + JobClassLast=LipoJobClass + }; + + static const char *getClassName(ActionClass AC); + +private: + ActionClass Kind; + + /// The output type of this action. + types::ID Type; + + ActionList Inputs; + +protected: + Action(ActionClass _Kind, types::ID _Type) : Kind(_Kind), Type(_Type) {} + Action(ActionClass _Kind, Action *Input, types::ID _Type) + : Kind(_Kind), Type(_Type), Inputs(&Input, &Input + 1) {} + Action(ActionClass _Kind, const ActionList &_Inputs, types::ID _Type) + : Kind(_Kind), Type(_Type), Inputs(_Inputs) {} +public: + virtual ~Action(); + + ActionClass getKind() const { return Kind; } + types::ID getType() const { return Type; } + + ActionList &getInputs() { return Inputs; } + const ActionList &getInputs() const { return Inputs; } + + size_type size() const { return Inputs.size(); } + + iterator begin() { return Inputs.begin(); } + iterator end() { return Inputs.end(); } + const_iterator begin() const { return Inputs.begin(); } + const_iterator end() const { return Inputs.end(); } + + static bool classof(const Action *) { return true; } +}; + +class InputAction : public Action { + const Arg &Input; +public: + InputAction(const Arg &_Input, types::ID _Type); + + const Arg &getInputArg() const { return Input; } + + static bool classof(const Action *A) { + return A->getKind() == InputClass; + } + static bool classof(const InputAction *) { return true; } +}; + +class BindArchAction : public Action { + /// The architecture to bind, or 0 if the default architecture + /// should be bound. + const char *ArchName; + +public: + BindArchAction(Action *Input, const char *_ArchName); + + const char *getArchName() const { return ArchName; } + + static bool classof(const Action *A) { + return A->getKind() == BindArchClass; + } + static bool classof(const BindArchAction *) { return true; } +}; + +class JobAction : public Action { +protected: + JobAction(ActionClass Kind, Action *Input, types::ID Type); + JobAction(ActionClass Kind, const ActionList &Inputs, types::ID Type); + +public: + static bool classof(const Action *A) { + return (A->getKind() >= JobClassFirst && + A->getKind() <= JobClassLast); + } + static bool classof(const JobAction *) { return true; } +}; + +class PreprocessJobAction : public JobAction { +public: + PreprocessJobAction(Action *Input, types::ID OutputType); + + static bool classof(const Action *A) { + return A->getKind() == PreprocessJobClass; + } + static bool classof(const PreprocessJobAction *) { return true; } +}; + +class PrecompileJobAction : public JobAction { +public: + PrecompileJobAction(Action *Input, types::ID OutputType); + + static bool classof(const Action *A) { + return A->getKind() == PrecompileJobClass; + } + static bool classof(const PrecompileJobAction *) { return true; } +}; + +class AnalyzeJobAction : public JobAction { +public: + AnalyzeJobAction(Action *Input, types::ID OutputType); + + static bool classof(const Action *A) { + return A->getKind() == AnalyzeJobClass; + } + static bool classof(const AnalyzeJobAction *) { return true; } +}; + +class CompileJobAction : public JobAction { +public: + CompileJobAction(Action *Input, types::ID OutputType); + + static bool classof(const Action *A) { + return A->getKind() == CompileJobClass; + } + static bool classof(const CompileJobAction *) { return true; } +}; + +class AssembleJobAction : public JobAction { +public: + AssembleJobAction(Action *Input, types::ID OutputType); + + static bool classof(const Action *A) { + return A->getKind() == AssembleJobClass; + } + static bool classof(const AssembleJobAction *) { return true; } +}; + +class LinkJobAction : public JobAction { +public: + LinkJobAction(ActionList &Inputs, types::ID Type); + + static bool classof(const Action *A) { + return A->getKind() == LinkJobClass; + } + static bool classof(const LinkJobAction *) { return true; } +}; + +class LipoJobAction : public JobAction { +public: + LipoJobAction(ActionList &Inputs, types::ID Type); + + static bool classof(const Action *A) { + return A->getKind() == LipoJobClass; + } + static bool classof(const LipoJobAction *) { return true; } +}; + +} // end namespace driver +} // end namespace clang + +#endif diff --git a/include/clang/Driver/Arg.h b/include/clang/Driver/Arg.h new file mode 100644 index 0000000..6bed2b8 --- /dev/null +++ b/include/clang/Driver/Arg.h @@ -0,0 +1,230 @@ +//===--- 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. +// +//===----------------------------------------------------------------------===// + +#ifndef CLANG_DRIVER_ARG_H_ +#define CLANG_DRIVER_ARG_H_ + +#include "llvm/Support/Casting.h" +using llvm::isa; +using llvm::cast; +using llvm::cast_or_null; +using llvm::dyn_cast; +using llvm::dyn_cast_or_null; + +#include "Util.h" +#include <vector> +#include <string> + +namespace clang { +namespace driver { + class ArgList; + class Option; + + /// Arg - 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 { + public: + enum ArgClass { + FlagClass = 0, + PositionalClass, + JoinedClass, + SeparateClass, + CommaJoinedClass, + JoinedAndSeparateClass + }; + + private: + ArgClass Kind; + + /// The option this argument is an instance of. + const Option *Opt; + + /// The argument this argument was derived from (during tool chain + /// argument translation), if any. + const Arg *BaseArg; + + /// The index at which this argument appears in the containing + /// ArgList. + unsigned Index; + + /// Flag indicating whether this argument was used to effect + /// compilation; used for generating "argument unused" + /// diagnostics. + mutable bool Claimed; + + protected: + Arg(ArgClass Kind, const Option *Opt, unsigned Index, + const Arg *BaseArg = 0); + + public: + Arg(const Arg &); + virtual ~Arg(); + + ArgClass getKind() const { return Kind; } + const Option &getOption() const { return *Opt; } + unsigned getIndex() const { return Index; } + + /// getBaseArg - 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 isClaimed() const { return getBaseArg().Claimed; } + + /// claim - Set the Arg claimed bit. + + // FIXME: We need to deal with derived arguments and set the bit + // in the original argument; not the derived one. + void claim() const { getBaseArg().Claimed = true; } + + virtual unsigned getNumValues() const = 0; + virtual const char *getValue(const ArgList &Args, unsigned N=0) const = 0; + + /// render - Append the argument onto the given array as strings. + virtual void render(const ArgList &Args, ArgStringList &Output) const = 0; + + /// renderAsInput - 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; + + static bool classof(const Arg *) { return true; } + + void dump() const; + + /// getAsString - Return a formatted version of the argument and + /// its values, for debugging and diagnostics. + std::string getAsString(const ArgList &Args) const; + }; + + /// FlagArg - An argument with no value. + class FlagArg : public Arg { + public: + FlagArg(const Option *Opt, unsigned Index, const Arg *BaseArg = 0); + + virtual void render(const ArgList &Args, ArgStringList &Output) const; + + virtual unsigned getNumValues() const { return 0; } + virtual const char *getValue(const ArgList &Args, unsigned N=0) const; + + static bool classof(const Arg *A) { + return A->getKind() == Arg::FlagClass; + } + static bool classof(const FlagArg *) { return true; } + }; + + /// PositionalArg - A simple positional argument. + class PositionalArg : public Arg { + public: + PositionalArg(const Option *Opt, unsigned Index, const Arg *BaseArg = 0); + + virtual void render(const ArgList &Args, ArgStringList &Output) const; + + virtual unsigned getNumValues() const { return 1; } + virtual const char *getValue(const ArgList &Args, unsigned N=0) const; + + static bool classof(const Arg *A) { + return A->getKind() == Arg::PositionalClass; + } + static bool classof(const PositionalArg *) { return true; } + }; + + /// JoinedArg - A single value argument where the value is joined + /// (suffixed) to the option. + class JoinedArg : public Arg { + public: + JoinedArg(const Option *Opt, unsigned Index, const Arg *BaseArg = 0); + + virtual void render(const ArgList &Args, ArgStringList &Output) const; + + virtual unsigned getNumValues() const { return 1; } + virtual const char *getValue(const ArgList &Args, unsigned N=0) const; + + static bool classof(const Arg *A) { + return A->getKind() == Arg::JoinedClass; + } + static bool classof(const JoinedArg *) { return true; } + }; + + /// SeparateArg - An argument where one or more values follow the + /// option specifier immediately in the argument vector. + class SeparateArg : public Arg { + unsigned NumValues; + + public: + SeparateArg(const Option *Opt, unsigned Index, unsigned NumValues, + const Arg *BaseArg = 0); + + virtual void render(const ArgList &Args, ArgStringList &Output) const; + + virtual unsigned getNumValues() const { return NumValues; } + virtual const char *getValue(const ArgList &Args, unsigned N=0) const; + + static bool classof(const Arg *A) { + return A->getKind() == Arg::SeparateClass; + } + static bool classof(const SeparateArg *) { return true; } + }; + + /// CommaJoinedArg - An argument with multiple values joined by + /// commas and joined (suffixed) to the option specifier. + /// + /// The key point of this arg is that it renders its values into + /// separate arguments, which allows it to be used as a generic + /// mechanism for passing arguments through to tools. + class CommaJoinedArg : public Arg { + std::vector<std::string> Values; + + public: + CommaJoinedArg(const Option *Opt, unsigned Index, const char *Str, + const Arg *BaseArg = 0); + + virtual void render(const ArgList &Args, ArgStringList &Output) const; + + virtual unsigned getNumValues() const { return Values.size(); } + virtual const char *getValue(const ArgList &Args, unsigned N=0) const; + + static bool classof(const Arg *A) { + return A->getKind() == Arg::CommaJoinedClass; + } + static bool classof(const CommaJoinedArg *) { return true; } + }; + + /// JoinedAndSeparateArg - An argument with both joined and separate + /// values. + class JoinedAndSeparateArg : public Arg { + public: + JoinedAndSeparateArg(const Option *Opt, unsigned Index, + const Arg *BaseArg = 0); + + virtual void render(const ArgList &Args, ArgStringList &Output) const; + + virtual unsigned getNumValues() const { return 2; } + virtual const char *getValue(const ArgList &Args, unsigned N=0) const; + + static bool classof(const Arg *A) { + return A->getKind() == Arg::JoinedAndSeparateClass; + } + static bool classof(const JoinedAndSeparateArg *) { return true; } + }; +} // end namespace driver +} // end namespace clang + +#endif diff --git a/include/clang/Driver/ArgList.h b/include/clang/Driver/ArgList.h new file mode 100644 index 0000000..84e0329 --- /dev/null +++ b/include/clang/Driver/ArgList.h @@ -0,0 +1,245 @@ +//===--- 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/Driver/Options.h" + +#include "clang/Driver/Util.h" +#include "llvm/ADT/SmallVector.h" + +#include <list> + +namespace clang { +namespace driver { + class Arg; + + /// 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 { + public: + typedef llvm::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 full list of arguments. + arglist_type &Args; + + protected: + ArgList(arglist_type &Args); + + public: + virtual ~ArgList(); + + /// @name Arg Access + /// @{ + + /// append - Append \arg 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(); } + + 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(); } + + /// hasArg - Does the arg list contain any option matching \arg Id. + /// + /// \arg Claim Whether the argument should be claimed, if it exists. + bool hasArg(options::ID Id, bool Claim=true) const { + return getLastArg(Id, Claim) != 0; + } + bool hasArg(options::ID Id0, options::ID Id1, bool Claim=true) const { + return getLastArg(Id0, Id1, Claim) != 0; + } + + /// getLastArg - Return the last argument matching \arg Id, or null. + /// + /// \arg Claim Whether the argument should be claimed, if it exists. + Arg *getLastArg(options::ID Id, bool Claim=true) const; + Arg *getLastArg(options::ID Id0, options::ID Id1, bool Claim=true) const; + + /// getArgString - Return the input argument string at \arg Index. + virtual const char *getArgString(unsigned Index) const = 0; + /// @name Translation Utilities + /// @{ + + /// hasFlag - Given an option \arg Pos and its negative form \arg + /// Neg, return true if the option is present, false if the + /// negation is present, and \arg Default if neither option is + /// given. If both the option and its negation are present, the + /// last one wins. + bool hasFlag(options::ID Pos, options::ID Neg, bool Default=true) const; + + /// AddLastArg - Render only the last argument match \arg Id0, if + /// present. + void AddLastArg(ArgStringList &Output, options::ID Id0) const; + + /// AddAllArgs - Render all arguments matching the given ids. + void AddAllArgs(ArgStringList &Output, options::ID Id0) const; + void AddAllArgs(ArgStringList &Output, options::ID Id0, + options::ID Id1) const; + void AddAllArgs(ArgStringList &Output, options::ID Id0, options::ID Id1, + options::ID Id2) const; + + /// AddAllArgValues - Render the argument values of all arguments + /// matching the given ids. + void AddAllArgValues(ArgStringList &Output, options::ID Id0) const; + void AddAllArgValues(ArgStringList &Output, options::ID Id0, + options::ID Id1) 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, options::ID Id0, + const char *Translation, + bool Joined = false) const; + + /// ClaimAllArgs - Claim all arguments which match the given + /// option id. + void ClaimAllArgs(options::ID Id0) const; + + /// @} + /// @name Arg Synthesis + /// @{ + + /// MakeArgString - Construct a constant string pointer whose + /// lifetime will match that of the ArgList. + virtual const char *MakeArgString(const char *Str) const = 0; + + /// @} + }; + + class InputArgList : public ArgList { + private: + /// The internal list of arguments. + arglist_type ActualArgs; + + /// 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 **ArgBegin, const char **ArgEnd); + InputArgList(const ArgList &); + ~InputArgList(); + + virtual const char *getArgString(unsigned Index) const { + return ArgStrings[Index]; + } + + /// getNumInputArgStrings - Return the number of original input + /// argument strings. + unsigned getNumInputArgStrings() const { return NumInputArgStrings; } + + /// @name Arg Synthesis + /// @{ + + public: + /// MakeIndex - Get an index for the given string(s). + unsigned MakeIndex(const char *String0) const; + unsigned MakeIndex(const char *String0, const char *String1) const; + + virtual const char *MakeArgString(const char *Str) const; + + /// @} + }; + + /// DerivedArgList - An ordered collection of driver arguments, + /// whose storage may be in another argument list. + class DerivedArgList : public ArgList { + InputArgList &BaseArgs; + + /// The internal list of arguments. + arglist_type ActualArgs; + + /// The list of arguments we synthesized. + arglist_type SynthesizedArgs; + + /// Is this only a proxy for the base ArgList? + bool OnlyProxy; + + public: + /// Construct a new derived arg list from \arg BaseArgs. + /// + /// \param OnlyProxy - If true, this is only a proxy for the base + /// list (to adapt the type), and it's Args list is unused. + DerivedArgList(InputArgList &BaseArgs, bool OnlyProxy); + ~DerivedArgList(); + + virtual const char *getArgString(unsigned Index) const { + return BaseArgs.getArgString(Index); + } + + /// @name Arg Synthesis + /// @{ + + virtual const char *MakeArgString(const char *Str) const; + + /// MakeFlagArg - Construct a new FlagArg for the given option + /// \arg Id. + Arg *MakeFlagArg(const Arg *BaseArg, const Option *Opt) const; + + /// MakePositionalArg - Construct a new Positional arg for the + /// given option \arg Id, with the provided \arg Value. + Arg *MakePositionalArg(const Arg *BaseArg, const Option *Opt, + const char *Value) const; + + /// MakeSeparateArg - Construct a new Positional arg for the + /// given option \arg Id, with the provided \arg Value. + Arg *MakeSeparateArg(const Arg *BaseArg, const Option *Opt, + const char *Value) const; + + /// MakeJoinedArg - Construct a new Positional arg for the + /// given option \arg Id, with the provided \arg Value. + Arg *MakeJoinedArg(const Arg *BaseArg, const Option *Opt, + const char *Value) const; + + /// @} + }; + +} // end namespace driver +} // end namespace clang + +#endif diff --git a/include/clang/Driver/Compilation.h b/include/clang/Driver/Compilation.h new file mode 100644 index 0000000..4985f30 --- /dev/null +++ b/include/clang/Driver/Compilation.h @@ -0,0 +1,127 @@ +//===--- Compilation.h - Compilation Task Data Structure --------*- 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_COMPILATION_H_ +#define CLANG_DRIVER_COMPILATION_H_ + +#include "clang/Driver/Job.h" +#include "clang/Driver/Util.h" + +#include "llvm/ADT/DenseMap.h" +#include "llvm/ADT/SmallVector.h" + +namespace llvm { + class raw_ostream; +} + +namespace clang { +namespace driver { + class DerivedArgList; + class Driver; + class InputArgList; + class JobList; + class ToolChain; + +/// Compilation - A set of tasks to perform for a single driver +/// invocation. +class Compilation { + /// The driver we were created by. + Driver &TheDriver; + + /// The default tool chain. + ToolChain &DefaultToolChain; + + /// The original (untranslated) input argument list. + InputArgList *Args; + + /// The list of actions. + ActionList Actions; + + /// The root list of jobs. + JobList Jobs; + + /// Cache of translated arguments for a particular tool chain. + llvm::DenseMap<const ToolChain*, DerivedArgList*> TCArgs; + + /// Temporary files which should be removed on exit. + ArgStringList TempFiles; + + /// Result files which should be removed on failure. + ArgStringList ResultFiles; + +public: + Compilation(Driver &D, ToolChain &DefaultToolChain, InputArgList *Args); + ~Compilation(); + + const Driver &getDriver() const { return TheDriver; } + + const ToolChain &getDefaultToolChain() const { return DefaultToolChain; } + + const InputArgList &getArgs() const { return *Args; } + + ActionList &getActions() { return Actions; } + const ActionList &getActions() const { return Actions; } + + JobList &getJobs() { return Jobs; } + + /// getArgsForToolChain - Return the derived argument list for the + /// tool chain \arg TC (or the default tool chain, if TC is not + /// specified). + const DerivedArgList &getArgsForToolChain(const ToolChain *TC = 0); + + /// addTempFile - Add a file to remove on exit, and returns its + /// argument. + const char *addTempFile(const char *Name) { + TempFiles.push_back(Name); + return Name; + } + + /// addResultFile - Add a file to remove on failure, and returns its + /// argument. + const char *addResultFile(const char *Name) { + ResultFiles.push_back(Name); + return Name; + } + + /// Execute - Execute the compilation jobs and return an + /// appropriate exit code. + int Execute() const; + +private: + /// CleanupFileList - Remove the files in the given list. + /// + /// \param IssueErrors - Report failures as errors. + /// \return Whether all files were removed successfully. + bool CleanupFileList(const ArgStringList &Files, + bool IssueErrors=false) const; + + /// PrintJob - Print one job in -### format. + /// + /// OS - The stream to print on. + /// J - The job to print. + /// Terminator - A string to print at the end of the line. + /// Quote - Should separate arguments be quoted. + void PrintJob(llvm::raw_ostream &OS, const Job &J, + const char *Terminator, bool Quote) const; + + /// ExecuteCommand - Execute an actual command. + /// + /// \return The result code of the subprocess. + int ExecuteCommand(const Command &C) const; + + /// ExecuteJob - Execute a single job. + /// + /// \return The accumulated result code of the job. + int ExecuteJob(const Job &J) const; +}; + +} // end namespace driver +} // end namespace clang + +#endif diff --git a/include/clang/Driver/Driver.h b/include/clang/Driver/Driver.h new file mode 100644 index 0000000..66e3b97 --- /dev/null +++ b/include/clang/Driver/Driver.h @@ -0,0 +1,271 @@ +//===--- Driver.h - Clang GCC Compatible Driver -----------------*- 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_DRIVER_H_ +#define CLANG_DRIVER_DRIVER_H_ + +#include "clang/Basic/Diagnostic.h" + +#include "clang/Driver/Phases.h" +#include "clang/Driver/Util.h" + +#include "llvm/System/Path.h" // FIXME: Kill when CompilationInfo + // lands. +#include <list> +#include <set> +#include <string> + +namespace clang { +namespace driver { + class Action; + class ArgList; + class Compilation; + class HostInfo; + class InputArgList; + class InputInfo; + class JobAction; + class OptTable; + class PipedJob; + class ToolChain; + +/// Driver - Encapsulate logic for constructing compilation processes +/// from a set of gcc-driver-like command line arguments. +class Driver { + OptTable *Opts; + + Diagnostic &Diags; + +public: + // Diag - Forwarding function for diagnostics. + DiagnosticBuilder Diag(unsigned DiagID) const { + return Diags.Report(FullSourceLoc(), DiagID); + } + + // FIXME: Privatize once interface is stable. +public: + /// The name the driver was invoked as. + std::string Name; + + /// The path the driver executable was in, as invoked from the + /// command line. + std::string Dir; + + /// Default host triple. + std::string DefaultHostTriple; + + /// Default name for linked images (e.g., "a.out"). + std::string DefaultImageName; + + /// Host information for the platform the driver is running as. This + /// will generally be the actual host platform, but not always. + const HostInfo *Host; + + /// Information about the host which can be overriden by the user. + std::string HostBits, HostMachine, HostSystem, HostRelease; + + /// Whether the driver should follow g++ like behavior. + bool CCCIsCXX : 1; + + /// Echo commands while executing (in -v style). + bool CCCEcho : 1; + + /// Only print tool bindings, don't build any jobs. + bool CCCPrintBindings : 1; + + /// Name to use when calling the generic gcc. + std::string CCCGenericGCCName; + +private: + /// Use the clang compiler where possible. + bool CCCUseClang : 1; + + /// Use clang for handling C++ and Objective-C++ inputs. + bool CCCUseClangCXX : 1; + + /// Use clang as a preprocessor (clang's preprocessor will still be + /// used where an integrated CPP would). + bool CCCUseClangCPP : 1; + +public: + /// Use lazy precompiled headers for PCH support. + bool CCCUsePCH; + +private: + /// Only use clang for the given architectures (only used when + /// non-empty). + std::set<std::string> CCCClangArchs; + + /// Certain options suppress the 'no input files' warning. + bool SuppressMissingInputWarning : 1; + + std::list<std::string> TempFiles; + std::list<std::string> ResultFiles; + +public: + Driver(const char *_Name, const char *_Dir, + const char *_DefaultHostTriple, + const char *_DefaultImageName, + Diagnostic &_Diags); + ~Driver(); + + /// @name Accessors + /// @{ + + const OptTable &getOpts() const { return *Opts; } + + const Diagnostic &getDiags() const { return Diags; } + + /// @} + /// @name Primary Functionality + /// @{ + + /// BuildCompilation - Construct a compilation object for a command + /// line argument vector. + /// + /// \return A compilation, or 0 if none was built for the given + /// argument vector. A null return value does not necessarily + /// indicate an error condition, the diagnostics should be queried + /// to determine if an error occurred. + Compilation *BuildCompilation(int argc, const char **argv); + + /// @name Driver Steps + /// @{ + + /// ParseArgStrings - Parse the given list of strings into an + /// ArgList. + InputArgList *ParseArgStrings(const char **ArgBegin, const char **ArgEnd); + + /// BuildActions - Construct the list of actions to perform for the + /// given arguments, which are only done for a single architecture. + /// + /// \param Args - The input arguments. + /// \param Actions - The list to store the resulting actions onto. + void BuildActions(const ArgList &Args, ActionList &Actions) const; + + /// BuildUniversalActions - Construct the list of actions to perform + /// for the given arguments, which may require a universal build. + /// + /// \param Args - The input arguments. + /// \param Actions - The list to store the resulting actions onto. + void BuildUniversalActions(const ArgList &Args, ActionList &Actions) const; + + /// BuildJobs - Bind actions to concrete tools and translate + /// arguments to form the list of jobs to run. + /// + /// \arg C - The compilation that is being built. + void BuildJobs(Compilation &C) const; + + /// @} + /// @name Helper Methods + /// @{ + + /// PrintActions - Print the list of actions. + void PrintActions(const Compilation &C) const; + + /// PrintHelp - Print the help text. + /// + /// \param ShowHidden - Show hidden options. + void PrintHelp(bool ShowHidden) const; + + /// PrintOptions - Print the list of arguments. + void PrintOptions(const ArgList &Args) const; + + /// PrintVersion - Print the driver version. + void PrintVersion(const Compilation &C) const; + + /// GetFilePath - Lookup \arg Name in the list of file search paths. + /// + /// \arg TC - The tool chain for additional information on + /// directories to search. + // FIXME: This should be in CompilationInfo. + llvm::sys::Path GetFilePath(const char *Name, const ToolChain &TC) const; + + /// GetProgramPath - Lookup \arg Name in the list of program search + /// paths. + /// + /// \arg TC - The provided tool chain for additional information on + /// directories to search. + /// + /// \arg WantFile - False when searching for an executable file, otherwise + /// true. Defaults to false. + // FIXME: This should be in CompilationInfo. + llvm::sys::Path GetProgramPath(const char *Name, const ToolChain &TC, + bool WantFile = false) const; + + /// HandleImmediateArgs - Handle any arguments which should be + /// treated before building actions or binding tools. + /// + /// \return Whether any compilation should be built for this + /// invocation. + bool HandleImmediateArgs(const Compilation &C); + + /// ConstructAction - Construct the appropriate action to do for + /// \arg Phase on the \arg Input, taking in to account arguments + /// like -fsyntax-only or --analyze. + Action *ConstructPhaseAction(const ArgList &Args, phases::ID Phase, + Action *Input) const; + + + /// BuildJobsForAction - Construct the jobs to perform for the + /// action \arg A. + void BuildJobsForAction(Compilation &C, + const Action *A, + const ToolChain *TC, + bool CanAcceptPipe, + bool AtTopLevel, + const char *LinkingOutput, + InputInfo &Result) const; + + /// GetNamedOutputPath - Return the name to use for the output of + /// the action \arg JA. The result is appended to the compilation's + /// list of temporary or result files, as appropriate. + /// + /// \param C - The compilation. + /// \param JA - The action of interest. + /// \param BaseInput - The original input file that this action was + /// triggered by. + /// \param AtTopLevel - Whether this is a "top-level" action. + const char *GetNamedOutputPath(Compilation &C, + const JobAction &JA, + const char *BaseInput, + bool AtTopLevel) const; + + /// GetTemporaryPath - Return the pathname of a temporary file to + /// use as part of compilation; the file will have the given suffix. + /// + /// GCC goes to extra lengths here to be a bit more robust. + std::string GetTemporaryPath(const char *Suffix) const; + + /// GetHostInfo - Construct a new host info object for the given + /// host triple. + const HostInfo *GetHostInfo(const char *HostTriple) const; + + /// ShouldUseClangCompilar - Should the clang compiler be used to + /// handle this action. + bool ShouldUseClangCompiler(const Compilation &C, const JobAction &JA, + const std::string &ArchName) const; + + /// @} + + /// GetReleaseVersion - Parse (([0-9]+)(.([0-9]+)(.([0-9]+)?))?)? and + /// return the grouped values as integers. Numbers which are not + /// provided are set to 0. + /// + /// \return True if the entire string was parsed (9.2), or all + /// groups were parsed (10.3.5extrastuff). HadExtra is true if all + /// groups were parsed but extra characters remain at the end. + static bool GetReleaseVersion(const char *Str, unsigned &Major, + unsigned &Minor, unsigned &Micro, + bool &HadExtra); +}; + +} // end namespace driver +} // end namespace clang + +#endif diff --git a/include/clang/Driver/DriverDiagnostic.h b/include/clang/Driver/DriverDiagnostic.h new file mode 100644 index 0000000..2a4413c --- /dev/null +++ b/include/clang/Driver/DriverDiagnostic.h @@ -0,0 +1,27 @@ +//===--- DiagnosticDriver.h - Diagnostics for libdriver ---------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_CLANG_DRIVERDIAGNOSTIC_H +#define LLVM_CLANG_DRIVERDIAGNOSTIC_H + +#include "clang/Basic/Diagnostic.h" + +namespace clang { + namespace diag { + enum { +#define DIAG(ENUM,FLAGS,DEFAULT_MAPPING,DESC,GROUP) ENUM, +#define DRIVERSTART +#include "clang/Basic/DiagnosticDriverKinds.inc" +#undef DIAG + NUM_BUILTIN_DRIVER_DIAGNOSTICS + }; + } // end namespace diag +} // end namespace clang + +#endif diff --git a/include/clang/Driver/HostInfo.h b/include/clang/Driver/HostInfo.h new file mode 100644 index 0000000..020bb3a --- /dev/null +++ b/include/clang/Driver/HostInfo.h @@ -0,0 +1,84 @@ +//===--- HostInfo.h - Host specific information -----------------*- 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_HOSTINFO_H_ +#define CLANG_DRIVER_HOSTINFO_H_ + +#include "clang/Driver/Types.h" +#include "llvm/ADT/Triple.h" +#include <string> + +namespace clang { +namespace driver { + class ArgList; + class Driver; + class ToolChain; + +/// HostInfo - Config information about a particular host which may +/// interact with driver behavior. +/// +/// The host information is used for controlling the parts of the +/// driver which interact with the platform the driver is ostensibly +/// being run from. For testing purposes, the HostInfo used by the +/// driver may differ from the actual host. +class HostInfo { + const Driver &TheDriver; + const llvm::Triple Triple; + +protected: + HostInfo(const Driver &D, const llvm::Triple &_Triple); + +public: + virtual ~HostInfo(); + + const Driver &getDriver() const { return TheDriver; } + + const llvm::Triple& getTriple() const { return Triple; } + std::string getArchName() const { return Triple.getArchName(); } + std::string getPlatformName() const { return Triple.getVendorName(); } + std::string getOSName() const { return Triple.getOSName(); } + + /// useDriverDriver - Whether the driver should act as a driver + /// driver for this host and support -arch, -Xarch, etc. + virtual bool useDriverDriver() const = 0; + + /// lookupTypeForExtension - Return the default language type to use + /// for the given extension. + virtual types::ID lookupTypeForExtension(const char *Ext) const = 0; + + /// getToolChain - Construct the toolchain to use for this host. + /// + /// \param Args - The argument list, which may be used to alter the + /// default toolchain, for example in the presence of -m32 or -m64. + /// + /// \param ArchName - The architecture to return a toolchain for, or + /// 0 if unspecified. This will only ever be non-zero for hosts + /// which support a driver driver. + + // FIXME: Pin down exactly what the HostInfo is allowed to use Args + // for here. Currently this is for -m32 / -m64 defaulting. + virtual ToolChain *getToolChain(const ArgList &Args, + const char *ArchName=0) const = 0; +}; + +const HostInfo *createDarwinHostInfo(const Driver &D, + const llvm::Triple& Triple); +const HostInfo *createFreeBSDHostInfo(const Driver &D, + const llvm::Triple& Triple); +const HostInfo *createDragonFlyHostInfo(const Driver &D, + const llvm::Triple& Triple); +const HostInfo *createLinuxHostInfo(const Driver &D, + const llvm::Triple& Triple); +const HostInfo *createUnknownHostInfo(const Driver &D, + const llvm::Triple& Triple); + +} // end namespace driver +} // end namespace clang + +#endif diff --git a/include/clang/Driver/Job.h b/include/clang/Driver/Job.h new file mode 100644 index 0000000..f60f514 --- /dev/null +++ b/include/clang/Driver/Job.h @@ -0,0 +1,138 @@ +//===--- Job.h - Commands to Execute ----------------------------*- 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_JOB_H_ +#define CLANG_DRIVER_JOB_H_ + +#include "clang/Driver/Util.h" +#include "llvm/ADT/SmallVector.h" + +#include "llvm/Support/Casting.h" +using llvm::isa; +using llvm::cast; +using llvm::cast_or_null; +using llvm::dyn_cast; +using llvm::dyn_cast_or_null; + +namespace clang { +namespace driver { + class Command; + +class Job { +public: + enum JobClass { + CommandClass, + PipedJobClass, + JobListClass + }; + +private: + JobClass Kind; + +protected: + Job(JobClass _Kind) : Kind(_Kind) {} +public: + virtual ~Job(); + + JobClass getKind() const { return Kind; } + + /// addCommand - Append a command to the current job, which must be + /// either a piped job or a job list. + void addCommand(Command *C); + + static bool classof(const Job *) { return true; } +}; + + /// Command - An executable path/name and argument vector to + /// execute. +class Command : public Job { + /// The executable to run. + const char *Executable; + + /// The list of program arguments (not including the implicit first + /// argument, which will be the executable). + ArgStringList Arguments; + +public: + Command(const char *_Executable, const ArgStringList &_Arguments); + + const char *getExecutable() const { return Executable; } + const ArgStringList &getArguments() const { return Arguments; } + + static bool classof(const Job *J) { + return J->getKind() == CommandClass; + } + static bool classof(const Command *) { return true; } +}; + + /// PipedJob - A list of Commands which should be executed together + /// with their standard inputs and outputs connected. +class PipedJob : public Job { +public: + typedef llvm::SmallVector<Command*, 4> list_type; + typedef list_type::size_type size_type; + typedef list_type::iterator iterator; + typedef list_type::const_iterator const_iterator; + +private: + list_type Commands; + +public: + PipedJob(); + + void addCommand(Command *C) { Commands.push_back(C); } + + const list_type &getCommands() const { return Commands; } + + size_type size() const { return Commands.size(); } + iterator begin() { return Commands.begin(); } + const_iterator begin() const { return Commands.begin(); } + iterator end() { return Commands.end(); } + const_iterator end() const { return Commands.end(); } + + static bool classof(const Job *J) { + return J->getKind() == PipedJobClass; + } + static bool classof(const PipedJob *) { return true; } +}; + + /// JobList - A sequence of jobs to perform. +class JobList : public Job { +public: + typedef llvm::SmallVector<Job*, 4> list_type; + typedef list_type::size_type size_type; + typedef list_type::iterator iterator; + typedef list_type::const_iterator const_iterator; + +private: + list_type Jobs; + +public: + JobList(); + + void addJob(Job *J) { Jobs.push_back(J); } + + const list_type &getJobs() const { return Jobs; } + + size_type size() const { return Jobs.size(); } + iterator begin() { return Jobs.begin(); } + const_iterator begin() const { return Jobs.begin(); } + iterator end() { return Jobs.end(); } + const_iterator end() const { return Jobs.end(); } + + static bool classof(const Job *J) { + return J->getKind() == JobListClass; + } + static bool classof(const JobList *) { return true; } +}; + +} // end namespace driver +} // end namespace clang + +#endif diff --git a/include/clang/Driver/Option.h b/include/clang/Driver/Option.h new file mode 100644 index 0000000..c59faef --- /dev/null +++ b/include/clang/Driver/Option.h @@ -0,0 +1,308 @@ +//===--- 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 "Options.h" + +#include "llvm/Support/Casting.h" +using llvm::isa; +using llvm::cast; +using llvm::cast_or_null; +using llvm::dyn_cast; +using llvm::dyn_cast_or_null; + +namespace clang { +namespace driver { + class Arg; + class InputArgList; + class OptionGroup; + + /// 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 + }; + + private: + OptionClass Kind; + + options::ID ID; + + /// The option name. + const char *Name; + + /// Group this option is a member of, if any. + const OptionGroup *Group; + + /// Option that this is an alias for, if any. + const Option *Alias; + + /// Unsupported options will not be rejected. + bool Unsupported : 1; + + /// Treat this option like a linker input? + bool LinkerInput : 1; + + /// When rendering as an input, don't render the option. + + // FIXME: We should ditch the render/renderAsInput distinction. + bool NoOptAsInput : 1; + + /// Always render this option as separate form its value. + bool ForceSeparateRender : 1; + + /// Always render this option joined with its value. + bool ForceJoinedRender : 1; + + /// This option is only consumed by the driver. + bool DriverOption : 1; + + /// This option should not report argument unused errors. + bool NoArgumentUnused : 1; + + protected: + Option(OptionClass Kind, options::ID ID, const char *Name, + const OptionGroup *Group, const Option *Alias); + public: + virtual ~Option(); + + options::ID getId() const { return ID; } + OptionClass getKind() const { return Kind; } + const char *getName() const { return Name; } + const OptionGroup *getGroup() const { return Group; } + const Option *getAlias() const { return Alias; } + + bool isUnsupported() const { return Unsupported; } + void setUnsupported(bool Value) { Unsupported = Value; } + + bool isLinkerInput() const { return LinkerInput; } + void setLinkerInput(bool Value) { LinkerInput = Value; } + + bool hasNoOptAsInput() const { return NoOptAsInput; } + void setNoOptAsInput(bool Value) { NoOptAsInput = Value; } + + bool hasForceSeparateRender() const { return ForceSeparateRender; } + void setForceSeparateRender(bool Value) { ForceSeparateRender = Value; } + + bool hasForceJoinedRender() const { return ForceJoinedRender; } + void setForceJoinedRender(bool Value) { ForceJoinedRender = Value; } + + bool isDriverOption() const { return DriverOption; } + void setDriverOption(bool Value) { DriverOption = Value; } + + bool hasNoArgumentUnused() const { return NoArgumentUnused; } + void setNoArgumentUnused(bool Value) { NoArgumentUnused = Value; } + + bool hasForwardToGCC() const { return !DriverOption && !LinkerInput; } + + /// getUnaliasedOption - Return the final option this option + /// aliases (itself, if the option has no alias). + const Option *getUnaliasedOption() const { + if (Alias) return Alias->getUnaliasedOption(); + return this; + } + + /// getRenderName - Return the name to use when rendering this + /// option. + const char *getRenderName() const { + return getUnaliasedOption()->getName(); + } + + /// matches - Predicate for whether this option is part of the + /// given option (which may be a group). + bool matches(const Option *Opt) const; + bool matches(options::ID Id) const; + + /// 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). + virtual Arg *accept(const InputArgList &Args, unsigned &Index) const = 0; + + void dump() const; + + static bool classof(const Option *) { return true; } + }; + + /// OptionGroup - A set of options which are can be handled uniformly + /// by the driver. + class OptionGroup : public Option { + public: + OptionGroup(options::ID ID, const char *Name, const OptionGroup *Group); + + virtual Arg *accept(const InputArgList &Args, unsigned &Index) const; + + static bool classof(const Option *O) { + return O->getKind() == Option::GroupClass; + } + static bool classof(const OptionGroup *) { return true; } + }; + + // Dummy option classes. + + /// InputOption - Dummy option class for representing driver inputs. + class InputOption : public Option { + public: + InputOption(); + + virtual Arg *accept(const InputArgList &Args, unsigned &Index) const; + + static bool classof(const Option *O) { + return O->getKind() == Option::InputClass; + } + static bool classof(const InputOption *) { return true; } + }; + + /// UnknownOption - Dummy option class for represent unknown arguments. + class UnknownOption : public Option { + public: + UnknownOption(); + + virtual Arg *accept(const InputArgList &Args, unsigned &Index) const; + + static bool classof(const Option *O) { + return O->getKind() == Option::UnknownClass; + } + static bool classof(const UnknownOption *) { return true; } + }; + + // Normal options. + + class FlagOption : public Option { + public: + FlagOption(options::ID ID, const char *Name, const OptionGroup *Group, + const Option *Alias); + + virtual Arg *accept(const InputArgList &Args, unsigned &Index) const; + + static bool classof(const Option *O) { + return O->getKind() == Option::FlagClass; + } + static bool classof(const FlagOption *) { return true; } + }; + + class JoinedOption : public Option { + public: + JoinedOption(options::ID ID, const char *Name, const OptionGroup *Group, + const Option *Alias); + + virtual Arg *accept(const InputArgList &Args, unsigned &Index) const; + + static bool classof(const Option *O) { + return O->getKind() == Option::JoinedClass; + } + static bool classof(const JoinedOption *) { return true; } + }; + + class SeparateOption : public Option { + public: + SeparateOption(options::ID ID, const char *Name, const OptionGroup *Group, + const Option *Alias); + + virtual Arg *accept(const InputArgList &Args, unsigned &Index) const; + + static bool classof(const Option *O) { + return O->getKind() == Option::SeparateClass; + } + static bool classof(const SeparateOption *) { return true; } + }; + + class CommaJoinedOption : public Option { + public: + CommaJoinedOption(options::ID ID, const char *Name, + const OptionGroup *Group, const Option *Alias); + + virtual Arg *accept(const InputArgList &Args, unsigned &Index) const; + + static bool classof(const Option *O) { + return O->getKind() == Option::CommaJoinedClass; + } + static bool classof(const CommaJoinedOption *) { return true; } + }; + + // FIXME: Fold MultiArgOption into SeparateOption? + + /// MultiArgOption - An option which takes multiple arguments (these + /// are always separate arguments). + class MultiArgOption : public Option { + unsigned NumArgs; + + public: + MultiArgOption(options::ID ID, const char *Name, const OptionGroup *Group, + const Option *Alias, unsigned NumArgs); + + unsigned getNumArgs() const { return NumArgs; } + + virtual Arg *accept(const InputArgList &Args, unsigned &Index) const; + + static bool classof(const Option *O) { + return O->getKind() == Option::MultiArgClass; + } + static bool classof(const MultiArgOption *) { return true; } + }; + + /// JoinedOrSeparateOption - An option which either literally + /// prefixes its (non-empty) value, or is follwed by a value. + class JoinedOrSeparateOption : public Option { + public: + JoinedOrSeparateOption(options::ID ID, const char *Name, + const OptionGroup *Group, const Option *Alias); + + virtual Arg *accept(const InputArgList &Args, unsigned &Index) const; + + static bool classof(const Option *O) { + return O->getKind() == Option::JoinedOrSeparateClass; + } + static bool classof(const JoinedOrSeparateOption *) { return true; } + }; + + /// JoinedAndSeparateOption - An option which literally prefixes its + /// value and is followed by another value. + class JoinedAndSeparateOption : public Option { + public: + JoinedAndSeparateOption(options::ID ID, const char *Name, + const OptionGroup *Group, const Option *Alias); + + virtual Arg *accept(const InputArgList &Args, unsigned &Index) const; + + static bool classof(const Option *O) { + return O->getKind() == Option::JoinedAndSeparateClass; + } + static bool classof(const JoinedAndSeparateOption *) { return true; } + }; + +} // end namespace driver +} // end namespace clang + +#endif diff --git a/include/clang/Driver/Options.def b/include/clang/Driver/Options.def new file mode 100644 index 0000000..c2981b9 --- /dev/null +++ b/include/clang/Driver/Options.def @@ -0,0 +1,624 @@ +//===--- Options.def - Driver option info -----------------------*- C++ -*-===// +// +// 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 driver option information. Users of this file +// must define the OPTION macro to make use of this information. +// +//===----------------------------------------------------------------------===// + +#ifndef OPTION +#error "Define OPTION prior to including this file!" +#endif + +// OPTION(NAME, ID, KIND, GROUP, ALIAS, FLAGS, PARAM, +// HELPTEXT, METAVARNAME) + +// The NAME value is the option name as a string. + +// The ID is the internal option id, which must be a valid +// C++ identifier, and results in a clang::driver::options::OPT_XX +// enum constant for XX. +// +// We want to unambiguously be able to refer to options from the +// driver source code, for this reason the option name is mangled into +// an id. This mangling isn't guaranteed to have an inverse, but for +// practical purposes it does. +// +// The mangling scheme is to ignore the leading '-', and perform the +// following substitutions: +// _ => __ +// - => _ +// # => _HASH +// , => _COMMA +// = => _EQ +// C++ => CXX + +// The KIND value is the option type, one of Group, Flag, Joined, +// Separate, CommaJoined, JoinedOrSeparate, JoinedAndSeparate. + +// The GROUP value is the internal name of the option group, or +// INVALID if the option is not part of a group. + +// The ALIAS value is the internal name of an aliased option, or +// INVALID if the option is not an alias. + +// The PARAM value is a string containing option flags. Valid values: +// d: The option is a "driver" option, and should not be forwarded to +// gcc. +// +// i: The option should not render the name when rendered as an +// input (i.e., the option is rendered as values). +// +// l: The option is a linker input. +// +// q: 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. +// +// u: The option is unsupported, and the driver will reject command +// lines that use it. +// +// S: The option should be rendered separately, even if joined (only +// sensible on joined options). +// +// J: The option should be rendered joined, even if separate (only +// sensible on single value separate options). + +// The PARAM value is an arbitrary integer parameter; currently +// this is only used for specifying the number of arguments for +// Separate options. + +// The HELPTEXT value is the string to print for this option in +// --help, or 0 if undocumented. + +// The METAVAR value is the name to use for this values arguments (if +// any) in the help text. This must be defined if the help text is +// specified and this option takes extra arguments. + +// + +// For now (pre-TableGen, that is) Options must be in order. The +// ordering is *almost* lexicographic, with two exceptions. First, +// '\0' comes at the end of the alphabet instead of the beginning +// (thus options preceed any other options which prefix them). Second, +// for options with the same name, the less permissive version should +// come first; a Flag option should preceed a Joined option, for +// example. + +///////// +// Groups + +OPTION("<I group>", I_Group, Group, INVALID, INVALID, "", 0, 0, 0) +OPTION("<M group>", M_Group, Group, INVALID, INVALID, "", 0, 0, 0) +OPTION("<T group>", T_Group, Group, INVALID, INVALID, "", 0, 0, 0) +OPTION("<O group>", O_Group, Group, INVALID, INVALID, "", 0, 0, 0) +OPTION("<W group>", W_Group, Group, INVALID, INVALID, "", 0, 0, 0) +OPTION("<X group>", X_Group, Group, INVALID, INVALID, "", 0, 0, 0) +OPTION("<a group>", a_Group, Group, INVALID, INVALID, "", 0, 0, 0) +OPTION("<d group>", d_Group, Group, INVALID, INVALID, "", 0, 0, 0) +OPTION("<f group>", f_Group, Group, INVALID, INVALID, "", 0, 0, 0) +OPTION("<g group>", g_Group, Group, INVALID, INVALID, "", 0, 0, 0) +OPTION("<i group>", i_Group, Group, INVALID, INVALID, "", 0, 0, 0) +OPTION("<clang i group>", clang_i_Group, Group, i_Group, INVALID, "", 0, 0, 0) +OPTION("<m group>", m_Group, Group, INVALID, INVALID, "", 0, 0, 0) +OPTION("<m x86 features group>", m_x86_Features_Group, Group, INVALID, INVALID, "", 0, 0, 0) +OPTION("<u group>", u_Group, Group, INVALID, INVALID, "", 0, 0, 0) + +OPTION("<pedantic group>", pedantic_Group, Group, INVALID, INVALID, "", 0, 0, 0) + +// Temporary groups for clang options which we know we don't support, +// but don't want to verbosely warn the user about. +OPTION("<clang ignored f group>", clang_ignored_f_Group, Group, f_Group, + INVALID, "", 0, 0, 0) +OPTION("<clang ignored m group>", clang_ignored_m_Group, Group, m_Group, + INVALID, "", 0, 0, 0) + +////////// +// Options + +OPTION("-###", _HASH_HASH_HASH, Flag, INVALID, INVALID, "d", 0, + "Print the commands to run for this compilation", 0) +OPTION("--CLASSPATH=", _CLASSPATH_EQ, Joined, INVALID, fclasspath_EQ, "", 0, 0, 0) +OPTION("--CLASSPATH", _CLASSPATH, Separate, INVALID, fclasspath_EQ, "J", 0, 0, 0) +OPTION("--all-warnings", _all_warnings, Flag, INVALID, Wall, "", 0, 0, 0) +OPTION("--analyze-auto", _analyze_auto, Flag, INVALID, INVALID, "d", 0, 0, 0) +OPTION("--analyzer-no-default-checks", _analyzer_no_default_checks, Flag, INVALID, INVALID, "d", 0, 0, 0) +OPTION("--analyzer-output", _analyzer_output, JoinedOrSeparate, INVALID, INVALID, "d", 0, 0, 0) +OPTION("--analyze", _analyze, Flag, INVALID, INVALID, "d", 0, + "Run the static analyzer", 0) +OPTION("--ansi", _ansi, Flag, INVALID, ansi, "", 0, 0, 0) +OPTION("--assemble", _assemble, Flag, INVALID, S, "", 0, 0, 0) +OPTION("--assert=", _assert_EQ, Joined, INVALID, A, "S", 0, 0, 0) +OPTION("--assert", _assert, Separate, INVALID, A, "", 0, 0, 0) +OPTION("--bootclasspath=", _bootclasspath_EQ, Joined, INVALID, fbootclasspath_EQ, "", 0, 0, 0) +OPTION("--bootclasspath", _bootclasspath, Separate, INVALID, fbootclasspath_EQ, "J", 0, 0, 0) +OPTION("--classpath=", _classpath_EQ, Joined, INVALID, fclasspath_EQ, "", 0, 0, 0) +OPTION("--classpath", _classpath, Separate, INVALID, fclasspath_EQ, "J", 0, 0, 0) +OPTION("--combine", _combine, Flag, INVALID, combine, "u", 0, 0, 0) +OPTION("--comments-in-macros", _comments_in_macros, Flag, INVALID, CC, "", 0, 0, 0) +OPTION("--comments", _comments, Flag, INVALID, C, "", 0, 0, 0) +OPTION("--compile", _compile, Flag, INVALID, c, "", 0, 0, 0) +OPTION("--constant-cfstrings", _constant_cfstrings, Flag, INVALID, INVALID, "", 0, 0, 0) +OPTION("--coverage", _coverage, Flag, INVALID, coverage, "", 0, 0, 0) +OPTION("--debug=", _debug_EQ, Joined, INVALID, g_Flag, "u", 0, 0, 0) +OPTION("--debug", _debug, Flag, INVALID, g_Flag, "u", 0, 0, 0) +OPTION("--define-macro=", _define_macro_EQ, Joined, INVALID, D, "", 0, 0, 0) +OPTION("--define-macro", _define_macro, Separate, INVALID, D, "J", 0, 0, 0) +OPTION("--dependencies", _dependencies, Flag, INVALID, M, "", 0, 0, 0) +OPTION("--encoding=", _encoding_EQ, Joined, INVALID, fencoding_EQ, "", 0, 0, 0) +OPTION("--encoding", _encoding, Separate, INVALID, fencoding_EQ, "J", 0, 0, 0) +OPTION("--entry", _entry, Flag, INVALID, e, "", 0, 0, 0) +OPTION("--extdirs=", _extdirs_EQ, Joined, INVALID, fextdirs_EQ, "", 0, 0, 0) +OPTION("--extdirs", _extdirs, Separate, INVALID, fextdirs_EQ, "J", 0, 0, 0) +OPTION("--extra-warnings", _extra_warnings, Flag, INVALID, W_Joined, "", 0, 0, 0) +OPTION("--for-linker=", _for_linker_EQ, Joined, INVALID, Xlinker, "liS", 0, 0, 0) +OPTION("--for-linker", _for_linker, Separate, INVALID, Xlinker, "li", 0, 0, 0) +OPTION("--force-link=", _force_link_EQ, Joined, INVALID, u, "S", 0, 0, 0) +OPTION("--force-link", _force_link, Separate, INVALID, u, "", 0, 0, 0) +OPTION("--help-hidden", _help_hidden, Flag, INVALID, INVALID, "", 0, 0, 0) +OPTION("--help", _help, Flag, INVALID, INVALID, "", 0, + "Display available options", 0) +OPTION("--imacros=", _imacros_EQ, Joined, INVALID, imacros, "S", 0, 0, 0) +OPTION("--imacros", _imacros, Separate, INVALID, imacros, "", 0, 0, 0) +OPTION("--include-barrier", _include_barrier, Flag, INVALID, I_, "", 0, 0, 0) +OPTION("--include-directory-after=", _include_directory_after_EQ, Joined, INVALID, idirafter, "S", 0, 0, 0) +OPTION("--include-directory-after", _include_directory_after, Separate, INVALID, idirafter, "", 0, 0, 0) +OPTION("--include-directory=", _include_directory_EQ, Joined, INVALID, I, "", 0, 0, 0) +OPTION("--include-directory", _include_directory, Separate, INVALID, I, "J", 0, 0, 0) +OPTION("--include-prefix=", _include_prefix_EQ, Joined, INVALID, iprefix, "S", 0, 0, 0) +OPTION("--include-prefix", _include_prefix, Separate, INVALID, iprefix, "", 0, 0, 0) +OPTION("--include-with-prefix-after=", _include_with_prefix_after_EQ, Joined, INVALID, iwithprefix, "S", 0, 0, 0) +OPTION("--include-with-prefix-after", _include_with_prefix_after, Separate, INVALID, iwithprefix, "", 0, 0, 0) +OPTION("--include-with-prefix-before=", _include_with_prefix_before_EQ, Joined, INVALID, iwithprefixbefore, "S", 0, 0, 0) +OPTION("--include-with-prefix-before", _include_with_prefix_before, Separate, INVALID, iwithprefixbefore, "", 0, 0, 0) +OPTION("--include-with-prefix=", _include_with_prefix_EQ, Joined, INVALID, iwithprefix, "S", 0, 0, 0) +OPTION("--include-with-prefix", _include_with_prefix, Separate, INVALID, iwithprefix, "", 0, 0, 0) +OPTION("--include=", _include_EQ, Joined, INVALID, include, "S", 0, 0, 0) +OPTION("--include", _include, Separate, INVALID, include, "", 0, 0, 0) +OPTION("--language=", _language_EQ, Joined, INVALID, x, "S", 0, 0, 0) +OPTION("--language", _language, Separate, INVALID, x, "", 0, 0, 0) +OPTION("--library-directory=", _library_directory_EQ, Joined, INVALID, L, "S", 0, 0, 0) +OPTION("--library-directory", _library_directory, Separate, INVALID, L, "", 0, 0, 0) +OPTION("--machine-=", _machine__EQ, Joined, INVALID, m_Joined, "u", 0, 0, 0) +OPTION("--machine-", _machine_, Joined, INVALID, m_Joined, "u", 0, 0, 0) +OPTION("--machine=", _machine_EQ, Joined, INVALID, m_Joined, "", 0, 0, 0) +OPTION("--machine", _machine, Separate, INVALID, m_Joined, "J", 0, 0, 0) +OPTION("--no-integrated-cpp", _no_integrated_cpp, Flag, INVALID, no_integrated_cpp, "", 0, 0, 0) +OPTION("--no-line-commands", _no_line_commands, Flag, INVALID, P, "", 0, 0, 0) +OPTION("--no-standard-includes", _no_standard_includes, Flag, INVALID, nostdinc, "", 0, 0, 0) +OPTION("--no-standard-libraries", _no_standard_libraries, Flag, INVALID, nostdlib, "", 0, 0, 0) +OPTION("--no-warnings", _no_warnings, Flag, INVALID, w, "", 0, 0, 0) +OPTION("--optimize=", _optimize_EQ, Joined, INVALID, O, "u", 0, 0, 0) +OPTION("--optimize", _optimize, Flag, INVALID, O, "u", 0, 0, 0) +OPTION("--output-class-directory=", _output_class_directory_EQ, Joined, INVALID, foutput_class_dir_EQ, "", 0, 0, 0) +OPTION("--output-class-directory", _output_class_directory, Separate, INVALID, foutput_class_dir_EQ, "J", 0, 0, 0) +OPTION("--output=", _output_EQ, Joined, INVALID, o, "S", 0, 0, 0) +OPTION("--output", _output, Separate, INVALID, o, "", 0, 0, 0) +OPTION("--param=", _param_EQ, Joined, INVALID, _param, "S", 0, 0, 0) +OPTION("--param", _param, Separate, INVALID, INVALID, "", 0, 0, 0) +OPTION("--pass-exit-codes", _pass_exit_codes, Flag, INVALID, pass_exit_codes, "", 0, 0, 0) +OPTION("--pedantic-errors", _pedantic_errors, Flag, INVALID, pedantic_errors, "", 0, 0, 0) +OPTION("--pedantic", _pedantic, Flag, INVALID, pedantic, "", 0, 0, 0) +OPTION("--pipe", _pipe, Flag, INVALID, pipe, "d", 0, 0, 0) +OPTION("--prefix=", _prefix_EQ, Joined, INVALID, B, "S", 0, 0, 0) +OPTION("--prefix", _prefix, Separate, INVALID, B, "", 0, 0, 0) +OPTION("--preprocess", _preprocess, Flag, INVALID, E, "", 0, 0, 0) +OPTION("--print-file-name=", _print_file_name_EQ, Joined, INVALID, print_file_name_EQ, "", 0, 0, 0) +OPTION("--print-file-name", _print_file_name, Separate, INVALID, print_file_name_EQ, "", 0, 0, 0) +OPTION("--print-libgcc-file-name", _print_libgcc_file_name, Flag, INVALID, print_libgcc_file_name, "", 0, 0, 0) +OPTION("--print-missing-file-dependencies", _print_missing_file_dependencies, Flag, INVALID, MG, "", 0, 0, 0) +OPTION("--print-multi-directory", _print_multi_directory, Flag, INVALID, print_multi_directory, "", 0, 0, 0) +OPTION("--print-multi-lib", _print_multi_lib, Flag, INVALID, print_multi_lib, "", 0, 0, 0) +OPTION("--print-multi-os-directory", _print_multi_os_directory, Flag, INVALID, print_multi_os_directory, "", 0, 0, 0) +OPTION("--print-prog-name=", _print_prog_name_EQ, Joined, INVALID, print_prog_name_EQ, "", 0, 0, 0) +OPTION("--print-prog-name", _print_prog_name, Separate, INVALID, print_prog_name_EQ, "", 0, 0, 0) +OPTION("--print-search-dirs", _print_search_dirs, Flag, INVALID, print_search_dirs, "", 0, 0, 0) +OPTION("--profile-blocks", _profile_blocks, Flag, INVALID, a, "", 0, 0, 0) +OPTION("--profile", _profile, Flag, INVALID, p, "", 0, 0, 0) +OPTION("--resource=", _resource_EQ, Joined, INVALID, fcompile_resource_EQ, "", 0, 0, 0) +OPTION("--resource", _resource, Separate, INVALID, fcompile_resource_EQ, "J", 0, 0, 0) +OPTION("--save-temps", _save_temps, Flag, INVALID, save_temps, "", 0, 0, 0) +OPTION("--shared", _shared, Flag, INVALID, shared, "", 0, 0, 0) +OPTION("--specs=", _specs_EQ, Joined, INVALID, specs_EQ, "u", 0, 0, 0) +OPTION("--specs", _specs, Separate, INVALID, specs_EQ, "uJ", 0, 0, 0) +OPTION("--static", _static, Flag, INVALID, static, "", 0, 0, 0) +OPTION("--std=", _std_EQ, Joined, INVALID, std_EQ, "", 0, 0, 0) +OPTION("--std", _std, Separate, INVALID, std_EQ, "J", 0, 0, 0) +OPTION("--sysroot=", _sysroot_EQ, Joined, INVALID, INVALID, "", 0, 0, 0) +OPTION("--sysroot", _sysroot, Separate, INVALID, _sysroot_EQ, "J", 0, 0, 0) +OPTION("--target-help", _target_help, Flag, INVALID, INVALID, "", 0, 0, 0) +OPTION("--trace-includes", _trace_includes, Flag, INVALID, H, "", 0, 0, 0) +OPTION("--traditional-cpp", _traditional_cpp, Flag, INVALID, traditional_cpp, "", 0, 0, 0) +OPTION("--traditional", _traditional, Flag, INVALID, traditional, "", 0, 0, 0) +OPTION("--trigraphs", _trigraphs, Flag, INVALID, trigraphs, "", 0, 0, 0) +OPTION("--undefine-macro=", _undefine_macro_EQ, Joined, INVALID, U, "", 0, 0, 0) +OPTION("--undefine-macro", _undefine_macro, Separate, INVALID, U, "J", 0, 0, 0) +OPTION("--user-dependencies", _user_dependencies, Flag, INVALID, MM, "", 0, 0, 0) +OPTION("--verbose", _verbose, Flag, INVALID, v, "", 0, 0, 0) +OPTION("--version", _version, Flag, INVALID, INVALID, "", 0, 0, 0) +OPTION("--warn-=", _warn__EQ, Joined, INVALID, W_Joined, "u", 0, 0, 0) +OPTION("--warn-", _warn_, Joined, INVALID, W_Joined, "u", 0, 0, 0) +OPTION("--write-dependencies", _write_dependencies, Flag, INVALID, MD, "", 0, 0, 0) +OPTION("--write-user-dependencies", _write_user_dependencies, Flag, INVALID, MMD, "", 0, 0, 0) +OPTION("--", _, Joined, INVALID, f, "u", 0, 0, 0) +OPTION("-A", A, JoinedOrSeparate, INVALID, INVALID, "", 0, 0, 0) +OPTION("-B", B, JoinedOrSeparate, INVALID, INVALID, "u", 0, 0, 0) +OPTION("-CC", CC, Flag, INVALID, INVALID, "", 0, 0, 0) +OPTION("-C", C, Flag, INVALID, INVALID, "", 0, 0, 0) +OPTION("-D", D, JoinedOrSeparate, INVALID, INVALID, "", 0, 0, 0) +OPTION("-E", E, Flag, INVALID, INVALID, "d", 0, + "Only run the preprocessor", 0) +OPTION("-F", F, JoinedOrSeparate, INVALID, INVALID, "", 0, 0, 0) +OPTION("-H", H, Flag, INVALID, INVALID, "", 0, 0, 0) +OPTION("-I-", I_, Flag, I_Group, INVALID, "", 0, 0, 0) +OPTION("-I", I, JoinedOrSeparate, I_Group, INVALID, "", 0, 0, 0) +OPTION("-L", L, JoinedOrSeparate, INVALID, INVALID, "", 0, 0, 0) +OPTION("-MD", MD, Flag, M_Group, INVALID, "", 0, 0, 0) +OPTION("-MF", MF, JoinedOrSeparate, M_Group, INVALID, "", 0, 0, 0) +OPTION("-MG", MG, Flag, M_Group, INVALID, "", 0, 0, 0) +OPTION("-MMD", MMD, Flag, M_Group, INVALID, "", 0, 0, 0) +OPTION("-MM", MM, Flag, M_Group, INVALID, "", 0, 0, 0) +OPTION("-MP", MP, Flag, M_Group, INVALID, "", 0, 0, 0) +OPTION("-MQ", MQ, JoinedOrSeparate, M_Group, INVALID, "", 0, 0, 0) +OPTION("-MT", MT, JoinedOrSeparate, M_Group, INVALID, "", 0, 0, 0) +OPTION("-Mach", Mach, Flag, INVALID, INVALID, "", 0, 0, 0) +OPTION("-M", M, Flag, M_Group, INVALID, "", 0, 0, 0) +OPTION("-O4", O4, Joined, O_Group, INVALID, "", 0, 0, 0) +OPTION("-ObjC++", ObjCXX, Flag, INVALID, INVALID, "d", 0, + "Treat source input files as Objective-C++ inputs", 0) +OPTION("-ObjC", ObjC, Flag, INVALID, INVALID, "d", 0, + "Treat source input files as Objective-C inputs", 0) +OPTION("-O", O, Joined, O_Group, INVALID, "", 0, 0, 0) +OPTION("-P", P, Flag, INVALID, INVALID, "", 0, 0, 0) +OPTION("-Qn", Qn, Flag, INVALID, INVALID, "", 0, 0, 0) +OPTION("-Qunused-arguments", Qunused_arguments, Flag, INVALID, INVALID, "d", 0, + "Don't emit warning for unused driver arguments", 0) +OPTION("-Q", Q, Flag, INVALID, INVALID, "", 0, 0, 0) +OPTION("-R", R, Flag, INVALID, INVALID, "", 0, 0, 0) +OPTION("-S", S, Flag, INVALID, INVALID, "d", 0, + "Only run preprocess and compilation steps", 0) +OPTION("-Tbss", Tbss, JoinedOrSeparate, T_Group, INVALID, "", 0, 0, 0) +OPTION("-Tdata", Tdata, JoinedOrSeparate, T_Group, INVALID, "", 0, 0, 0) +OPTION("-Ttext", Ttext, JoinedOrSeparate, T_Group, INVALID, "", 0, 0, 0) +OPTION("-T", T, JoinedOrSeparate, T_Group, INVALID, "", 0, 0, 0) +OPTION("-U", U, JoinedOrSeparate, INVALID, INVALID, "", 0, 0, 0) +OPTION("-V", V, JoinedOrSeparate, INVALID, INVALID, "du", 0, 0, 0) +OPTION("-Wa,", Wa_COMMA, CommaJoined, INVALID, INVALID, "", 0, + "Pass the comma separated arguments in <arg> to the assembler", "<arg>") +OPTION("-Wall", Wall, Flag, W_Group, INVALID, "", 0, 0, 0) +OPTION("-Wextra", Wextra, Flag, W_Group, INVALID, "", 0, 0, 0) +OPTION("-Wl,", Wl_COMMA, CommaJoined, INVALID, INVALID, "li", 0, + "Pass the comma separated arguments in <arg> to the linker", "<arg>") +OPTION("-Wno-nonportable-cfstrings", Wno_nonportable_cfstrings, Joined, W_Group, INVALID, "", 0, 0, 0) +OPTION("-Wnonportable-cfstrings", Wnonportable_cfstrings, Joined, W_Group, INVALID, "", 0, 0, 0) +OPTION("-Wp,", Wp_COMMA, CommaJoined, INVALID, INVALID, "", 0, + "Pass the comma separated arguments in <arg> to the preprocessor", "<arg>") +OPTION("-W", W_Joined, Joined, W_Group, INVALID, "", 0, 0, 0) +OPTION("-Xanalyzer", Xanalyzer, Separate, INVALID, INVALID, "", 0, + "Pass <arg> to the static analyzer", "<arg>") +OPTION("-Xarch_", Xarch__, JoinedAndSeparate, INVALID, INVALID, "d", 0, 0, 0) +OPTION("-Xassembler", Xassembler, Separate, INVALID, INVALID, "", 0, + "Pass <arg> to the assembler", "<arg>") +OPTION("-Xclang", Xclang, Separate, INVALID, INVALID, "", 0, + "Pass <arg> to the clang compiler", "<arg>") +OPTION("-Xlinker", Xlinker, Separate, INVALID, INVALID, "li", 0, + "Pass <arg> to the linker", "<arg>") +OPTION("-Xpreprocessor", Xpreprocessor, Separate, INVALID, INVALID, "", 0, + "Pass <arg> to the preprocessor", "<arg>") +OPTION("-X", X_Flag, Flag, INVALID, INVALID, "", 0, 0, 0) +OPTION("-X", X_Joined, Joined, INVALID, INVALID, "", 0, 0, 0) +OPTION("-Z", Z_Flag, Flag, INVALID, INVALID, "", 0, 0, 0) +OPTION("-Z", Z_Joined, Joined, INVALID, INVALID, "", 0, 0, 0) +OPTION("-all_load", all__load, Flag, INVALID, INVALID, "", 0, 0, 0) +OPTION("-allowable_client", allowable__client, Separate, INVALID, INVALID, "", 0, 0, 0) +OPTION("-ansi", ansi, Flag, a_Group, INVALID, "", 0, 0, 0) +OPTION("-arch", arch, Separate, INVALID, INVALID, "d", 0, 0, 0) +OPTION("-a", a, Joined, a_Group, INVALID, "", 0, 0, 0) +OPTION("-bind_at_load", bind__at__load, Flag, INVALID, INVALID, "", 0, 0, 0) +OPTION("-bundle_loader", bundle__loader, Separate, INVALID, INVALID, "", 0, 0, 0) +OPTION("-bundle", bundle, Flag, INVALID, INVALID, "", 0, 0, 0) +OPTION("-b", b, JoinedOrSeparate, INVALID, INVALID, "u", 0, 0, 0) +OPTION("-client_name", client__name, JoinedOrSeparate, INVALID, INVALID, "", 0, 0, 0) +OPTION("-combine", combine, Flag, INVALID, INVALID, "du", 0, 0, 0) +OPTION("-compatibility_version", compatibility__version, JoinedOrSeparate, INVALID, INVALID, "", 0, 0, 0) +OPTION("-coverage", coverage, Flag, INVALID, INVALID, "", 0, 0, 0) +OPTION("-cpp-precomp", cpp_precomp, Flag, INVALID, INVALID, "", 0, 0, 0) +OPTION("-current_version", current__version, JoinedOrSeparate, INVALID, INVALID, "", 0, 0, 0) +OPTION("-c", c, Flag, INVALID, INVALID, "d", 0, + "Only run preprocess, compile, and assemble steps", 0) +OPTION("-dA", dA, Flag, d_Group, INVALID, "", 0, 0, 0) +OPTION("-dD", dD, Flag, d_Group, INVALID, "", 0, 0, 0) +OPTION("-dM", dM, Flag, d_Group, INVALID, "", 0, 0, 0) +OPTION("-dead_strip", dead__strip, Flag, INVALID, INVALID, "", 0, 0, 0) +OPTION("-dependency-file", dependency_file, Separate, INVALID, INVALID, "", 0, 0, 0) +OPTION("-dumpmachine", dumpmachine, Flag, INVALID, INVALID, "u", 0, 0, 0) +OPTION("-dumpspecs", dumpspecs, Flag, INVALID, INVALID, "u", 0, 0, 0) +OPTION("-dumpversion", dumpversion, Flag, INVALID, INVALID, "", 0, 0, 0) +OPTION("-dylib_file", dylib__file, Separate, INVALID, INVALID, "", 0, 0, 0) +OPTION("-dylinker_install_name", dylinker__install__name, JoinedOrSeparate, INVALID, INVALID, "", 0, 0, 0) +OPTION("-dylinker", dylinker, Flag, INVALID, INVALID, "", 0, 0, 0) +OPTION("-dynamiclib", dynamiclib, Flag, INVALID, INVALID, "", 0, 0, 0) +OPTION("-dynamic", dynamic, Flag, INVALID, INVALID, "q", 0, 0, 0) +OPTION("-d", d_Flag, Flag, d_Group, INVALID, "", 0, 0, 0) +OPTION("-d", d_Joined, Joined, d_Group, INVALID, "", 0, 0, 0) +OPTION("-emit-llvm", emit_llvm, Flag, INVALID, INVALID, "", 0, + "Use the LLVM representation for assembler and object files", 0) +OPTION("-exported_symbols_list", exported__symbols__list, Separate, INVALID, INVALID, "", 0, 0, 0) +OPTION("-e", e, JoinedOrSeparate, INVALID, INVALID, "", 0, 0, 0) +OPTION("-fPIC", fPIC, Flag, f_Group, INVALID, "", 0, 0, 0) +OPTION("-fPIE", fPIE, Flag, f_Group, INVALID, "", 0, 0, 0) +OPTION("-fapple-kext", fapple_kext, Flag, f_Group, INVALID, "", 0, 0, 0) +OPTION("-fasm-blocks", fasm_blocks, Flag, clang_ignored_f_Group, INVALID, "", 0, 0, 0) +OPTION("-fastcp", fastcp, Flag, f_Group, INVALID, "", 0, 0, 0) +OPTION("-fastf", fastf, Flag, f_Group, INVALID, "", 0, 0, 0) +OPTION("-fast", fast, Flag, f_Group, INVALID, "", 0, 0, 0) +OPTION("-fasynchronous-unwind-tables", fasynchronous_unwind_tables, Flag, f_Group, INVALID, "", 0, 0, 0) +OPTION("-fblocks", fblocks, Flag, f_Group, INVALID, "", 0, 0, 0) +OPTION("-fbootclasspath=", fbootclasspath_EQ, Joined, f_Group, INVALID, "", 0, 0, 0) +OPTION("-fbuiltin", fbuiltin, Flag, f_Group, INVALID, "", 0, 0, 0) +OPTION("-fclasspath=", fclasspath_EQ, Joined, f_Group, INVALID, "", 0, 0, 0) +OPTION("-fcommon", fcommon, Flag, f_Group, INVALID, "", 0, 0, 0) +OPTION("-fcompile-resource=", fcompile_resource_EQ, Joined, f_Group, INVALID, "", 0, 0, 0) +OPTION("-fconstant-cfstrings", fconstant_cfstrings, Flag, clang_ignored_f_Group, INVALID, "", 0, 0, 0) +OPTION("-fcreate-profile", fcreate_profile, Flag, f_Group, INVALID, "", 0, 0, 0) +OPTION("-fdebug-pass-arguments", fdebug_pass_arguments, Flag, f_Group, INVALID, "", 0, 0, 0) +OPTION("-fdebug-pass-structure", fdebug_pass_structure, Flag, f_Group, INVALID, "", 0, 0, 0) +OPTION("-fdiagnostics-fixit-info", fdiagnostics_fixit_info, Flag, f_Group, INVALID, "", 0, 0, 0) +OPTION("-fdiagnostics-print-source-range-info", fdiagnostics_print_source_range_info, Flag, f_Group, INVALID, "", 0, 0, 0) +OPTION("-fdiagnostics-show-option", fdiagnostics_show_option, Flag, f_Group, INVALID, "", 0, 0, 0) +OPTION("-fdollars-in-identifiers", fdollars_in_identifiers, Flag, f_Group, INVALID, "", 0, 0, 0) +OPTION("-feliminate-unused-debug-symbols", feliminate_unused_debug_symbols, Flag, f_Group, INVALID, "", 0, 0, 0) +OPTION("-femit-all-decls", femit_all_decls, Flag, f_Group, INVALID, "", 0, 0, 0) +OPTION("-fencoding=", fencoding_EQ, Joined, f_Group, INVALID, "", 0, 0, 0) +OPTION("-fexceptions", fexceptions, Flag, f_Group, INVALID, "", 0, 0, 0) +OPTION("-fextdirs=", fextdirs_EQ, Joined, f_Group, INVALID, "", 0, 0, 0) +OPTION("-ffreestanding", ffreestanding, Flag, f_Group, INVALID, "", 0, 0, 0) +OPTION("-fgnu-runtime", fgnu_runtime, Flag, f_Group, INVALID, "", 0, 0, 0) +OPTION("-fheinous-gnu-extensions", fheinous_gnu_extensions, Flag, INVALID, INVALID, "", 0, 0, 0) +OPTION("-filelist", filelist, Separate, INVALID, INVALID, "l", 0, 0, 0) +OPTION("-findirect-virtual-calls", findirect_virtual_calls, Flag, f_Group, INVALID, "", 0, 0, 0) +OPTION("-finline-functions", finline_functions, Flag, clang_ignored_f_Group, INVALID, "", 0, 0, 0) +OPTION("-finline", finline, Flag, clang_ignored_f_Group, INVALID, "", 0, 0, 0) +OPTION("-fkeep-inline-functions", fkeep_inline_functions, Flag, clang_ignored_f_Group, INVALID, "", 0, 0, 0) +OPTION("-flat_namespace", flat__namespace, Flag, INVALID, INVALID, "", 0, 0, 0) +OPTION("-flax-vector-conversions", flax_vector_conversions, Flag, f_Group, INVALID, "", 0, 0, 0) +OPTION("-flimited-precision=", flimited_precision_EQ, Joined, f_Group, INVALID, "", 0, 0, 0) +OPTION("-flto", flto, Flag, f_Group, INVALID, "", 0, 0, 0) +OPTION("-fmath-errno", fmath_errno, Flag, f_Group, INVALID, "", 0, 0, 0) +OPTION("-fmessage-length=", fmessage_length_EQ, Joined, f_Group, INVALID, "", 0, 0, 0) +OPTION("-fms-extensions", fms_extensions, Flag, f_Group, INVALID, "", 0, 0, 0) +OPTION("-fmudflapth", fmudflapth, Flag, f_Group, INVALID, "", 0, 0, 0) +OPTION("-fmudflap", fmudflap, Flag, f_Group, INVALID, "", 0, 0, 0) +OPTION("-fnested-functions", fnested_functions, Flag, f_Group, INVALID, "", 0, 0, 0) +OPTION("-fnext-runtime", fnext_runtime, Flag, f_Group, INVALID, "", 0, 0, 0) +OPTION("-fno-asynchronous-unwind-tables", fno_asynchronous_unwind_tables, Flag, f_Group, INVALID, "", 0, 0, 0) +OPTION("-fno-blocks", fno_blocks, Flag, f_Group, INVALID, "", 0, 0, 0) +OPTION("-fno-builtin", fno_builtin, Flag, f_Group, INVALID, "", 0, 0, 0) +OPTION("-fno-caret-diagnostics", fno_caret_diagnostics, Flag, f_Group, INVALID, "", 0, 0, 0) +OPTION("-fno-common", fno_common, Flag, f_Group, INVALID, "", 0, 0, 0) +OPTION("-fno-constant-cfstrings", fno_constant_cfstrings, Flag, f_Group, INVALID, "", 0, 0, 0) +OPTION("-fno-diagnostics-fixit-info", fno_diagnostics_fixit_info, Flag, f_Group, INVALID, "", 0, 0, 0) +OPTION("-fno-diagnostics-show-option", fno_diagnostics_show_option, Flag, f_Group, INVALID, "", 0, 0, 0) +OPTION("-fno-dollars-in-identifiers", fno_dollars_in_identifiers, Flag, f_Group, INVALID, "", 0, 0, 0) +OPTION("-fno-eliminate-unused-debug-symbols", fno_eliminate_unused_debug_symbols, Flag, f_Group, INVALID, "", 0, 0, 0) +OPTION("-fno-inline-functions", fno_inline_functions, Flag, clang_ignored_f_Group, INVALID, "", 0, 0, 0) +OPTION("-fno-inline", fno_inline, Flag, clang_ignored_f_Group, INVALID, "", 0, 0, 0) +OPTION("-fno-keep-inline-functions", fno_keep_inline_functions, Flag, clang_ignored_f_Group, INVALID, "", 0, 0, 0) +OPTION("-fno-math-errno", fno_math_errno, Flag, f_Group, INVALID, "", 0, 0, 0) +OPTION("-fno-pascal-strings", fno_pascal_strings, Flag, f_Group, INVALID, "", 0, 0, 0) +OPTION("-fno-show-column", fno_show_column, Flag, f_Group, INVALID, "", 0, 0, 0) +OPTION("-fno-stack-protector", fno_stack_protector, Flag, clang_ignored_f_Group, INVALID, "", 0, 0, 0) +OPTION("-fno-strict-aliasing", fno_strict_aliasing, Flag, clang_ignored_f_Group, INVALID, "", 0, 0, 0) +OPTION("-fno-unit-at-a-time", fno_unit_at_a_time, Flag, f_Group, INVALID, "", 0, 0, 0) +OPTION("-fno-unwind-tables", fno_unwind_tables, Flag, f_Group, INVALID, "", 0, 0, 0) +OPTION("-fno-working-directory", fno_working_directory, Flag, f_Group, INVALID, "", 0, 0, 0) +OPTION("-fno-zero-initialized-in-bss", fno_zero_initialized_in_bss, Flag, f_Group, INVALID, "", 0, 0, 0) +OPTION("-fobjc-atdefs", fobjc_atdefs, Flag, clang_ignored_f_Group, INVALID, "", 0, 0, 0) +OPTION("-fobjc-call-cxx-cdtors", fobjc_call_cxx_cdtors, Flag, clang_ignored_f_Group, INVALID, "", 0, 0, 0) +OPTION("-fobjc-gc-only", fobjc_gc_only, Flag, f_Group, INVALID, "", 0, 0, 0) +OPTION("-fobjc-gc", fobjc_gc, Flag, f_Group, INVALID, "", 0, 0, 0) +OPTION("-fobjc-new-property", fobjc_new_property, Flag, clang_ignored_f_Group, INVALID, "", 0, 0, 0) +OPTION("-fobjc-nonfragile-abi", fobjc_nonfragile_abi, Flag, f_Group, INVALID, "", 0, 0, 0) +OPTION("-fobjc-sender-dependent-dispatch", fobjc_sender_dependent_dispatch, Flag, f_Group, INVALID, "", 0, 0, 0) +OPTION("-fobjc-tight-layout", fobjc_tight_layout, Flag, f_Group, INVALID, "", 0, 0, 0) +OPTION("-fobjc", fobjc, Flag, f_Group, INVALID, "", 0, 0, 0) +OPTION("-fomit-frame-pointer", fomit_frame_pointer, Flag, f_Group, INVALID, "", 0, 0, 0) +OPTION("-fopenmp", fopenmp, Flag, f_Group, INVALID, "", 0, 0, 0) +OPTION("-force_cpusubtype_ALL", force__cpusubtype__ALL, Flag, INVALID, INVALID, "", 0, 0, 0) +OPTION("-force_flat_namespace", force__flat__namespace, Flag, INVALID, INVALID, "", 0, 0, 0) +OPTION("-foutput-class-dir=", foutput_class_dir_EQ, Joined, f_Group, INVALID, "", 0, 0, 0) +OPTION("-fpascal-strings", fpascal_strings, Flag, f_Group, INVALID, "", 0, 0, 0) +OPTION("-fpch-preprocess", fpch_preprocess, Flag, f_Group, INVALID, "", 0, 0, 0) +OPTION("-fpic", fpic, Flag, f_Group, INVALID, "", 0, 0, 0) +OPTION("-fpie", fpie, Flag, f_Group, INVALID, "", 0, 0, 0) +OPTION("-fprofile-arcs", fprofile_arcs, Flag, f_Group, INVALID, "", 0, 0, 0) +OPTION("-fprofile-generate", fprofile_generate, Flag, f_Group, INVALID, "", 0, 0, 0) +OPTION("-framework", framework, Separate, INVALID, INVALID, "l", 0, 0, 0) +OPTION("-fsigned-bitfields", fsigned_bitfields, Flag, f_Group, INVALID, "", 0, 0, 0) +OPTION("-fstack-protector", fstack_protector, Flag, clang_ignored_f_Group, INVALID, "", 0, 0, 0) +OPTION("-fstrict-aliasing", fstrict_aliasing, Flag, clang_ignored_f_Group, INVALID, "", 0, 0, 0) +OPTION("-fsyntax-only", fsyntax_only, Flag, INVALID, INVALID, "d", 0, 0, 0) +OPTION("-ftemplate-depth-", ftemplate_depth_, Joined, f_Group, INVALID, "", 0, 0, 0) +OPTION("-fterminated-vtables", fterminated_vtables, Flag, f_Group, INVALID, "", 0, 0, 0) +OPTION("-ftime-report", ftime_report, Flag, f_Group, INVALID, "", 0, 0, 0) +OPTION("-ftraditional", ftraditional, Flag, f_Group, INVALID, "", 0, 0, 0) +OPTION("-ftrapv", ftrapv, Flag, f_Group, INVALID, "", 0, 0, 0) +OPTION("-funit-at-a-time", funit_at_a_time, Flag, f_Group, INVALID, "", 0, 0, 0) +OPTION("-funsigned-bitfields", funsigned_bitfields, Flag, f_Group, INVALID, "", 0, 0, 0) +OPTION("-funwind-tables", funwind_tables, Flag, f_Group, INVALID, "", 0, 0, 0) +OPTION("-fverbose-asm", fverbose_asm, Flag, f_Group, INVALID, "", 0, 0, 0) +OPTION("-fvisibility=", fvisibility_EQ, Joined, f_Group, INVALID, "", 0, 0, 0) +OPTION("-fwritable-strings", fwritable_strings, Flag, f_Group, INVALID, "", 0, 0, 0) +OPTION("-fzero-initialized-in-bss", fzero_initialized_in_bss, Flag, f_Group, INVALID, "", 0, 0, 0) +OPTION("-f", f, Joined, f_Group, INVALID, "", 0, 0, 0) +OPTION("-g0", g0, Joined, g_Group, INVALID, "", 0, 0, 0) +OPTION("-g3", g3, Joined, g_Group, INVALID, "", 0, 0, 0) +OPTION("-gfull", gfull, Joined, g_Group, INVALID, "", 0, 0, 0) +OPTION("-gstabs", gstabs, Joined, g_Group, INVALID, "", 0, 0, 0) +OPTION("-gused", gused, Joined, g_Group, INVALID, "", 0, 0, 0) +OPTION("-g", g_Flag, Flag, g_Group, INVALID, "", 0, 0, 0) +OPTION("-g", g_Joined, Joined, g_Group, INVALID, "", 0, 0, 0) +OPTION("-headerpad_max_install_names", headerpad__max__install__names, Joined, INVALID, INVALID, "", 0, 0, 0) +OPTION("-idirafter", idirafter, JoinedOrSeparate, clang_i_Group, INVALID, "", 0, 0, 0) +OPTION("-iframework", iframework, JoinedOrSeparate, clang_i_Group, INVALID, "", 0, 0, 0) +OPTION("-imacros", imacros, JoinedOrSeparate, clang_i_Group, INVALID, "", 0, 0, 0) +OPTION("-image_base", image__base, Separate, INVALID, INVALID, "", 0, 0, 0) +OPTION("-include", include, JoinedOrSeparate, clang_i_Group, INVALID, "", 0, 0, 0) +OPTION("-init", init, Separate, INVALID, INVALID, "", 0, 0, 0) +OPTION("-install_name", install__name, Separate, INVALID, INVALID, "", 0, 0, 0) +OPTION("-iprefix", iprefix, JoinedOrSeparate, clang_i_Group, INVALID, "", 0, 0, 0) +OPTION("-iquote", iquote, JoinedOrSeparate, clang_i_Group, INVALID, "", 0, 0, 0) +OPTION("-isysroot", isysroot, JoinedOrSeparate, i_Group, INVALID, "", 0, 0, 0) +OPTION("-isystem", isystem, JoinedOrSeparate, clang_i_Group, INVALID, "", 0, 0, 0) +OPTION("-iwithprefixbefore", iwithprefixbefore, JoinedOrSeparate, clang_i_Group, INVALID, "", 0, 0, 0) +OPTION("-iwithprefix", iwithprefix, JoinedOrSeparate, clang_i_Group, INVALID, "", 0, 0, 0) +OPTION("-iwithsysroot", iwithsysroot, JoinedOrSeparate, i_Group, INVALID, "", 0, 0, 0) +OPTION("-i", i, Joined, i_Group, INVALID, "", 0, 0, 0) +OPTION("-keep_private_externs", keep__private__externs, Flag, INVALID, INVALID, "", 0, 0, 0) +OPTION("-l", l, JoinedOrSeparate, INVALID, INVALID, "l", 0, 0, 0) +OPTION("-m32", m32, Flag, m_Group, INVALID, "d", 0, 0, 0) +OPTION("-m3dnowa", m3dnowa, Flag, m_x86_Features_Group, INVALID, "", 0, 0, 0) +OPTION("-m3dnow", m3dnow, Flag, m_x86_Features_Group, INVALID, "", 0, 0, 0) +OPTION("-m64", m64, Flag, m_Group, INVALID, "d", 0, 0, 0) +OPTION("-march=", march_EQ, Joined, m_Group, INVALID, "d", 0, 0, 0) +OPTION("-mconstant-cfstrings", mconstant_cfstrings, Flag, clang_ignored_m_Group, INVALID, "", 0, 0, 0) +OPTION("-mdynamic-no-pic", mdynamic_no_pic, Joined, m_Group, INVALID, "q", 0, 0, 0) +OPTION("-mfix-and-continue", mfix_and_continue, Flag, clang_ignored_m_Group, INVALID, "", 0, 0, 0) +OPTION("-miphoneos-version-min=", miphoneos_version_min_EQ, Joined, m_Group, INVALID, "", 0, 0, 0) +OPTION("-mkernel", mkernel, Flag, m_Group, INVALID, "", 0, 0, 0) +OPTION("-mmacosx-version-min=", mmacosx_version_min_EQ, Joined, m_Group, INVALID, "", 0, 0, 0) +OPTION("-mmmx", mmmx, Flag, m_x86_Features_Group, INVALID, "", 0, 0, 0) +OPTION("-mno-3dnowa", mno_3dnowa, Flag, m_x86_Features_Group, INVALID, "", 0, 0, 0) +OPTION("-mno-3dnow", mno_3dnow, Flag, m_x86_Features_Group, INVALID, "", 0, 0, 0) +OPTION("-mno-constant-cfstrings", mno_constant_cfstrings, Flag, m_Group, INVALID, "", 0, 0, 0) +OPTION("-mno-mmx", mno_mmx, Flag, m_x86_Features_Group, INVALID, "", 0, 0, 0) +OPTION("-mno-pascal-strings", mno_pascal_strings, Flag, m_Group, INVALID, "", 0, 0, 0) +OPTION("-mno-red-zone", mno_red_zone, Flag, m_Group, INVALID, "", 0, 0, 0) +OPTION("-mno-soft-float", mno_soft_float, Flag, m_Group, INVALID, "", 0, 0, 0) +OPTION("-mno-sse2", mno_sse2, Flag, m_x86_Features_Group, INVALID, "", 0, 0, 0) +OPTION("-mno-sse3", mno_sse3, Flag, m_x86_Features_Group, INVALID, "", 0, 0, 0) +OPTION("-mno-sse4a", mno_sse4a, Flag, m_x86_Features_Group, INVALID, "", 0, 0, 0) +OPTION("-mno-sse4", mno_sse4, Flag, m_x86_Features_Group, INVALID, "", 0, 0, 0) +OPTION("-mno-sse", mno_sse, Flag, m_x86_Features_Group, INVALID, "", 0, 0, 0) +OPTION("-mno-ssse3", mno_ssse3, Flag, m_x86_Features_Group, INVALID, "", 0, 0, 0) +OPTION("-mno-warn-nonportable-cfstrings", mno_warn_nonportable_cfstrings, Flag, m_Group, INVALID, "", 0, 0, 0) +OPTION("-mpascal-strings", mpascal_strings, Flag, m_Group, INVALID, "", 0, 0, 0) +OPTION("-mred-zone", mred_zone, Flag, m_Group, INVALID, "", 0, 0, 0) +OPTION("-msoft-float", msoft_float, Flag, m_Group, INVALID, "", 0, 0, 0) +OPTION("-msse2", msse2, Flag, m_x86_Features_Group, INVALID, "", 0, 0, 0) +OPTION("-msse3", msse3, Flag, m_x86_Features_Group, INVALID, "", 0, 0, 0) +OPTION("-msse4a", msse4a, Flag, m_x86_Features_Group, INVALID, "", 0, 0, 0) +OPTION("-msse4", msse4, Flag, m_x86_Features_Group, INVALID, "", 0, 0, 0) +OPTION("-msse", msse, Flag, m_x86_Features_Group, INVALID, "", 0, 0, 0) +OPTION("-mssse3", mssse3, Flag, m_x86_Features_Group, INVALID, "", 0, 0, 0) +OPTION("-mtune=", mtune_EQ, Joined, m_Group, INVALID, "", 0, 0, 0) +OPTION("-multi_module", multi__module, Flag, INVALID, INVALID, "", 0, 0, 0) +OPTION("-multiply_defined_unused", multiply__defined__unused, Separate, INVALID, INVALID, "", 0, 0, 0) +OPTION("-multiply_defined", multiply__defined, Separate, INVALID, INVALID, "", 0, 0, 0) +OPTION("-mwarn-nonportable-cfstrings", mwarn_nonportable_cfstrings, Flag, m_Group, INVALID, "", 0, 0, 0) +OPTION("-m", m_Separate, Separate, m_Group, INVALID, "", 0, 0, 0) +OPTION("-m", m_Joined, Joined, m_Group, INVALID, "", 0, 0, 0) +OPTION("-no-cpp-precomp", no_cpp_precomp, Flag, INVALID, INVALID, "", 0, 0, 0) +OPTION("-no-integrated-cpp", no_integrated_cpp, Flag, INVALID, INVALID, "d", 0, 0, 0) +OPTION("-no_dead_strip_inits_and_terms", no__dead__strip__inits__and__terms, Flag, INVALID, INVALID, "", 0, 0, 0) +OPTION("-nodefaultlibs", nodefaultlibs, Flag, INVALID, INVALID, "", 0, 0, 0) +OPTION("-nofixprebinding", nofixprebinding, Flag, INVALID, INVALID, "", 0, 0, 0) +OPTION("-nolibc", nolibc, Flag, INVALID, INVALID, "", 0, 0, 0) +OPTION("-nomultidefs", nomultidefs, Flag, INVALID, INVALID, "", 0, 0, 0) +OPTION("-noprebind", noprebind, Flag, INVALID, INVALID, "", 0, 0, 0) +OPTION("-noseglinkedit", noseglinkedit, Flag, INVALID, INVALID, "", 0, 0, 0) +OPTION("-nostartfiles", nostartfiles, Flag, INVALID, INVALID, "", 0, 0, 0) +OPTION("-nostdinc", nostdinc, Flag, INVALID, INVALID, "", 0, 0, 0) +OPTION("-nostdlib", nostdlib, Flag, INVALID, INVALID, "", 0, 0, 0) +OPTION("-object", object, Flag, INVALID, INVALID, "", 0, 0, 0) +OPTION("-o", o, JoinedOrSeparate, INVALID, INVALID, "di", 0, + "Write output to <file>", "<file>") +OPTION("-pagezero_size", pagezero__size, JoinedOrSeparate, INVALID, INVALID, "", 0, 0, 0) +OPTION("-pass-exit-codes", pass_exit_codes, Flag, INVALID, INVALID, "u", 0, 0, 0) +OPTION("-pedantic-errors", pedantic_errors, Flag, pedantic_Group, INVALID, "", 0, 0, 0) +OPTION("-pedantic", pedantic, Flag, pedantic_Group, INVALID, "", 0, 0, 0) +OPTION("-pg", pg, Flag, INVALID, INVALID, "", 0, 0, 0) +OPTION("-pipe", pipe, Flag, INVALID, INVALID, "", 0, + "Use pipes between commands, when possible", 0) +OPTION("-prebind_all_twolevel_modules", prebind__all__twolevel__modules, Flag, INVALID, INVALID, "", 0, 0, 0) +OPTION("-prebind", prebind, Flag, INVALID, INVALID, "", 0, 0, 0) +OPTION("-preload", preload, Flag, INVALID, INVALID, "", 0, 0, 0) +OPTION("-print-file-name=", print_file_name_EQ, Joined, INVALID, INVALID, "", 0, + "Print the full library path of <file>", "<file>") +OPTION("-print-ivar-layout", print_ivar_layout, Flag, INVALID, INVALID, "", 0, 0, 0) +OPTION("-print-libgcc-file-name", print_libgcc_file_name, Flag, INVALID, INVALID, "", 0, + "Print the library path for \"libgcc.a\"", 0) +OPTION("-print-multi-directory", print_multi_directory, Flag, INVALID, INVALID, "u", 0, 0, 0) +OPTION("-print-multi-lib", print_multi_lib, Flag, INVALID, INVALID, "u", 0, 0, 0) +OPTION("-print-multi-os-directory", print_multi_os_directory, Flag, INVALID, INVALID, "u", 0, 0, 0) +OPTION("-print-prog-name=", print_prog_name_EQ, Joined, INVALID, INVALID, "", 0, + "Print the full program path of <name>", "<name>") +OPTION("-print-search-dirs", print_search_dirs, Flag, INVALID, INVALID, "", 0, + "Print the paths used for finding libraries and programs", 0) +OPTION("-private_bundle", private__bundle, Flag, INVALID, INVALID, "", 0, 0, 0) +OPTION("-pthreads", pthreads, Flag, INVALID, INVALID, "", 0, 0, 0) +OPTION("-pthread", pthread, Flag, INVALID, INVALID, "", 0, 0, 0) +OPTION("-p", p, Flag, INVALID, INVALID, "", 0, 0, 0) +OPTION("-read_only_relocs", read__only__relocs, Separate, INVALID, INVALID, "", 0, 0, 0) +OPTION("-remap", remap, Flag, INVALID, INVALID, "", 0, 0, 0) +OPTION("-r", r, Flag, INVALID, INVALID, "", 0, 0, 0) +OPTION("-save-temps", save_temps, Flag, INVALID, INVALID, "d", 0, + "Save intermediate compilation results", 0) +OPTION("-sectalign", sectalign, MultiArg, INVALID, INVALID, "", 3, 0, 0) +OPTION("-sectcreate", sectcreate, MultiArg, INVALID, INVALID, "", 3, 0, 0) +OPTION("-sectobjectsymbols", sectobjectsymbols, MultiArg, INVALID, INVALID, "", 2, 0, 0) +OPTION("-sectorder", sectorder, MultiArg, INVALID, INVALID, "", 3, 0, 0) +OPTION("-seg1addr", seg1addr, JoinedOrSeparate, INVALID, INVALID, "", 0, 0, 0) +OPTION("-seg_addr_table_filename", seg__addr__table__filename, Separate, INVALID, INVALID, "", 0, 0, 0) +OPTION("-seg_addr_table", seg__addr__table, Separate, INVALID, INVALID, "", 0, 0, 0) +OPTION("-segaddr", segaddr, MultiArg, INVALID, INVALID, "", 2, 0, 0) +OPTION("-segcreate", segcreate, MultiArg, INVALID, INVALID, "", 3, 0, 0) +OPTION("-seglinkedit", seglinkedit, Flag, INVALID, INVALID, "", 0, 0, 0) +OPTION("-segprot", segprot, MultiArg, INVALID, INVALID, "", 3, 0, 0) +OPTION("-segs_read_only_addr", segs__read__only__addr, Separate, INVALID, INVALID, "", 0, 0, 0) +OPTION("-segs_read_write_addr", segs__read__write__addr, Separate, INVALID, INVALID, "", 0, 0, 0) +OPTION("-segs_read_", segs__read__, Joined, INVALID, INVALID, "", 0, 0, 0) +OPTION("-shared-libgcc", shared_libgcc, Flag, INVALID, INVALID, "", 0, 0, 0) +OPTION("-shared", shared, Flag, INVALID, INVALID, "", 0, 0, 0) +OPTION("-single_module", single__module, Flag, INVALID, INVALID, "", 0, 0, 0) +OPTION("-specs=", specs_EQ, Joined, INVALID, INVALID, "", 0, 0, 0) +OPTION("-specs", specs, Separate, INVALID, INVALID, "u", 0, 0, 0) +OPTION("-static-libgcc", static_libgcc, Flag, INVALID, INVALID, "", 0, 0, 0) +OPTION("-static", static, Flag, INVALID, INVALID, "q", 0, 0, 0) +OPTION("-std-default=", std_default_EQ, Joined, INVALID, INVALID, "", 0, 0, 0) +OPTION("-std=", std_EQ, Joined, INVALID, INVALID, "", 0, 0, 0) +OPTION("-sub_library", sub__library, JoinedOrSeparate, INVALID, INVALID, "", 0, 0, 0) +OPTION("-sub_umbrella", sub__umbrella, JoinedOrSeparate, INVALID, INVALID, "", 0, 0, 0) +OPTION("-s", s, Flag, INVALID, INVALID, "", 0, 0, 0) +OPTION("-time", time, Flag, INVALID, INVALID, "", 0, + "Time individual commands", 0) +OPTION("-traditional-cpp", traditional_cpp, Flag, INVALID, INVALID, "", 0, 0, 0) +OPTION("-traditional", traditional, Flag, INVALID, INVALID, "", 0, 0, 0) +OPTION("-trigraphs", trigraphs, Flag, INVALID, INVALID, "", 0, 0, 0) +OPTION("-twolevel_namespace_hints", twolevel__namespace__hints, Flag, INVALID, INVALID, "", 0, 0, 0) +OPTION("-twolevel_namespace", twolevel__namespace, Flag, INVALID, INVALID, "", 0, 0, 0) +OPTION("-t", t, Flag, INVALID, INVALID, "", 0, 0, 0) +OPTION("-umbrella", umbrella, Separate, INVALID, INVALID, "", 0, 0, 0) +OPTION("-undefined", undefined, JoinedOrSeparate, u_Group, INVALID, "", 0, 0, 0) +OPTION("-undef", undef, Flag, u_Group, INVALID, "", 0, 0, 0) +OPTION("-unexported_symbols_list", unexported__symbols__list, Separate, INVALID, INVALID, "", 0, 0, 0) +OPTION("-u", u, JoinedOrSeparate, u_Group, INVALID, "", 0, 0, 0) +OPTION("-v", v, Flag, INVALID, INVALID, "", 0, + "Show commands to run and use verbose output", 0) +OPTION("-weak-l", weak_l, Joined, INVALID, INVALID, "l", 0, 0, 0) +OPTION("-weak_framework", weak__framework, Separate, INVALID, INVALID, "l", 0, 0, 0) +OPTION("-weak_library", weak__library, Separate, INVALID, INVALID, "l", 0, 0, 0) +OPTION("-weak_reference_mismatches", weak__reference__mismatches, Separate, INVALID, INVALID, "", 0, 0, 0) +OPTION("-whatsloaded", whatsloaded, Flag, INVALID, INVALID, "", 0, 0, 0) +OPTION("-whyload", whyload, Flag, INVALID, INVALID, "", 0, 0, 0) +OPTION("-w", w, Flag, INVALID, INVALID, "", 0, 0, 0) +OPTION("-x", x, JoinedOrSeparate, INVALID, INVALID, "d", 0, + "Treat subsequent input files as having type <language>", "<language>") +OPTION("-y", y, Joined, INVALID, INVALID, "", 0, 0, 0) diff --git a/include/clang/Driver/Options.h b/include/clang/Driver/Options.h new file mode 100644 index 0000000..8b959d3 --- /dev/null +++ b/include/clang/Driver/Options.h @@ -0,0 +1,90 @@ +//===--- Options.h - Option info & 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_OPTIONS_H_ +#define CLANG_DRIVER_OPTIONS_H_ + +namespace clang { +namespace driver { +namespace options { + enum ID { + OPT_INVALID = 0, // This is not an option ID. + OPT_INPUT, // Reserved ID for input option. + OPT_UNKNOWN, // Reserved ID for unknown option. +#define OPTION(NAME, ID, KIND, GROUP, ALIAS, FLAGS, PARAM, \ + HELPTEXT, METAVAR) OPT_##ID, +#include "clang/Driver/Options.def" + LastOption +#undef OPTION + }; +} + + class Arg; + class InputArgList; + class Option; + + /// OptTable - Provide access to the Option info table. + /// + /// The OptTable class provides a layer of indirection which allows + /// Option instance to be created lazily. In the common case, only a + /// few options will be needed at runtime; the OptTable class + /// maintains enough information to parse command lines without + /// instantiating Options, while letting other parts of the driver + /// still use Option instances where convient. + class OptTable { + /// The table of options which have been constructed, indexed by + /// option::ID - 1. + mutable Option **Options; + + /// 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 FirstSearchableOption; + + Option *constructOption(options::ID id) const; + + public: + OptTable(); + ~OptTable(); + + unsigned getNumOptions() const; + + const char *getOptionName(options::ID id) const; + + /// getOption - Get the given \arg id's Option instance, lazily + /// creating it if necessary. + const Option *getOption(options::ID id) const; + + /// getOptionKind - Get the kind of the given option. + unsigned getOptionKind(options::ID id) const; + + /// getOptionHelpText - Get the help text to use to describe this + /// option. + const char *getOptionHelpText(options::ID id) const; + + /// getOptionMetaVar - Get the meta-variable name to use when + /// describing this options values in the help text. + const char *getOptionMetaVar(options::ID id) const; + + /// parseOneArg - Parse a single argument; returning the new + /// argument and updating Index. + /// + /// \param [in] [out] Index - The current parsing position in the + /// argument string list; on return this will be the index of the + /// next argument string to parse. + /// + /// \return - The parsed argument, or 0 if the argument is missing + /// values (in which case Index still points at the conceptual + /// next argument string to parse). + Arg *ParseOneArg(const InputArgList &Args, unsigned &Index) const; + }; +} +} + +#endif diff --git a/include/clang/Driver/Phases.h b/include/clang/Driver/Phases.h new file mode 100644 index 0000000..a0c42ea --- /dev/null +++ b/include/clang/Driver/Phases.h @@ -0,0 +1,32 @@ +//===--- Phases.h - Transformations on Driver Types -------------*- 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_PHASES_H_ +#define CLANG_DRIVER_PHASES_H_ + +namespace clang { +namespace driver { +namespace phases { + /// ID - Ordered values for successive stages in the + /// compilation process which interact with user options. + enum ID { + Preprocess, + Precompile, + Compile, + Assemble, + Link + }; + + const char *getPhaseName(ID Id); + +} // end namespace phases +} // end namespace driver +} // end namespace clang + +#endif diff --git a/include/clang/Driver/Tool.h b/include/clang/Driver/Tool.h new file mode 100644 index 0000000..d8b37e9 --- /dev/null +++ b/include/clang/Driver/Tool.h @@ -0,0 +1,69 @@ +//===--- Tool.h - Compilation Tools -----------------------------*- 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_TOOL_H_ +#define CLANG_DRIVER_TOOL_H_ + +namespace llvm { + template<typename T, unsigned N> class SmallVector; +} + +namespace clang { +namespace driver { + class ArgList; + class Compilation; + class InputInfo; + class Job; + class JobAction; + class ToolChain; + + typedef llvm::SmallVector<InputInfo, 4> InputInfoList; + +/// Tool - Information on a specific compilation tool. +class Tool { + /// The tool name (for debugging). + const char *Name; + + /// The tool chain this tool is a part of. + const ToolChain &TheToolChain; + +public: + Tool(const char *Name, const ToolChain &TC); + +public: + virtual ~Tool(); + + const char *getName() const { return Name; } + + const ToolChain &getToolChain() const { return TheToolChain; } + + virtual bool acceptsPipedInput() const = 0; + virtual bool canPipeOutput() const = 0; + virtual bool hasIntegratedCPP() const = 0; + + /// ConstructJob - Construct jobs to perform the action \arg JA, + /// writing to \arg Output and with \arg Inputs. + /// + /// \param Dest - Where to put the resulting commands. + /// \param TCArgs - The argument list for this toolchain, with any + /// tool chain specific translations applied. + /// \param LinkingOutput - If this output will eventually feed the + /// linker, then this is the final output name of the linked image. + virtual void ConstructJob(Compilation &C, const JobAction &JA, + Job &Dest, + const InputInfo &Output, + const InputInfoList &Inputs, + const ArgList &TCArgs, + const char *LinkingOutput) const = 0; +}; + +} // end namespace driver +} // end namespace clang + +#endif diff --git a/include/clang/Driver/ToolChain.h b/include/clang/Driver/ToolChain.h new file mode 100644 index 0000000..6196c13 --- /dev/null +++ b/include/clang/Driver/ToolChain.h @@ -0,0 +1,105 @@ +//===--- ToolChain.h - Collections of tools for one platform ----*- 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_TOOLCHAIN_H_ +#define CLANG_DRIVER_TOOLCHAIN_H_ + +#include "llvm/ADT/SmallVector.h" +#include "llvm/ADT/Triple.h" +#include "llvm/System/Path.h" +#include <string> + +namespace clang { +namespace driver { + class Compilation; + class DerivedArgList; + class HostInfo; + class InputArgList; + class JobAction; + class Tool; + +/// ToolChain - Access to tools for a single platform. +class ToolChain { +public: + typedef llvm::SmallVector<std::string, 4> path_list; + +private: + const HostInfo &Host; + const llvm::Triple Triple; + + /// The list of toolchain specific path prefixes to search for + /// files. + path_list FilePaths; + + /// The list of toolchain specific path prefixes to search for + /// programs. + path_list ProgramPaths; + +protected: + ToolChain(const HostInfo &Host, const llvm::Triple &_Triple); + +public: + virtual ~ToolChain(); + + // Accessors + + const HostInfo &getHost() const { return Host; } + std::string getArchName() const { return Triple.getArchName(); } + std::string getPlatform() const { return Triple.getVendorName(); } + std::string getOS() const { return Triple.getOSName(); } + + std::string getTripleString() const { + return Triple.getTriple(); + } + + path_list &getFilePaths() { return FilePaths; } + const path_list &getFilePaths() const { return FilePaths; } + + path_list &getProgramPaths() { return ProgramPaths; } + const path_list &getProgramPaths() const { return ProgramPaths; } + + // Tool access. + + /// TranslateArgs - Create a new derived argument list for any + /// argument translations this ToolChain may wish to perform. + virtual DerivedArgList *TranslateArgs(InputArgList &Args) const = 0; + + /// SelectTool - Choose a tool to use to handle the action \arg JA. + virtual Tool &SelectTool(const Compilation &C, const JobAction &JA) const = 0; + + // Helper methods + + llvm::sys::Path GetFilePath(const Compilation &C, const char *Name) const; + llvm::sys::Path GetProgramPath(const Compilation &C, const char *Name, + bool WantFile = false) const; + + // Platform defaults information + + /// IsMathErrnoDefault - Does this tool chain set -fmath-errno by + /// default. + virtual bool IsMathErrnoDefault() const = 0; + + /// IsUnwindTablesDefault - Does this tool chain use -funwind-tables + /// by default. + virtual bool IsUnwindTablesDefault() const = 0; + + /// GetDefaultRelocationModel - Return the LLVM name of the default + /// relocation model for this tool chain. + virtual const char *GetDefaultRelocationModel() const = 0; + + /// GetForcedPicModel - Return the LLVM name of the forced PIC model + /// for this tool chain, or 0 if this tool chain does not force a + /// particular PIC mode. + virtual const char *GetForcedPicModel() const = 0; +}; + +} // end namespace driver +} // end namespace clang + +#endif diff --git a/include/clang/Driver/Types.def b/include/clang/Driver/Types.def new file mode 100644 index 0000000..8d24e50 --- /dev/null +++ b/include/clang/Driver/Types.def @@ -0,0 +1,78 @@ +//===--- Types.def - Driver Type info ---------------------------*- C++ -*-===// +// +// 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 driver type information. Users of this file +// must define the TYPE macro to make use of this information. +// +//===----------------------------------------------------------------------===// + +#ifndef TYPE +#error "Define TYPE prior to including this file!" +#endif + +// TYPE(NAME, ID, PP_TYPE, TEMP_SUFFIX, FLAGS) + +// The first value is the type name as a string; for types which can +// be user specified this should be the equivalent -x option. + +// The second value is the type id, which will result in a +// clang::driver::types::TY_XX enum constant. + +// The third value is that id of the type for preprocessed inputs of +// this type, or INVALID if this type is not preprocessed. + +// The fourth value is the suffix to use when creating temporary files +// of this type, or null if unspecified. + +// The fifth value is a string containt option flags. Valid values: +// a - The type should only be assembled. +// p - The type should only be precompiled. +// u - The type can be user specified (with -x). +// A - The type's temporary suffix should be appended when generating +// outputs of this type. + + +// C family source language (with and without preprocessing). +TYPE("cpp-output", PP_C, INVALID, "i", "u") +TYPE("c", C, PP_C, 0, "u") +TYPE("objective-c-cpp-output", PP_ObjC, INVALID, "mi", "u") +TYPE("objective-c", ObjC, PP_ObjC, 0, "u") +TYPE("c++-cpp-output", PP_CXX, INVALID, "ii", "u") +TYPE("c++", CXX, PP_CXX, 0, "u") +TYPE("objective-c++-cpp-output", PP_ObjCXX, INVALID, "mii", "u") +TYPE("objective-c++", ObjCXX, PP_ObjCXX, 0, "u") + +// C family input files to precompile. +TYPE("c-header-cpp-output", PP_CHeader, INVALID, "i", "p") +TYPE("c-header", CHeader, PP_CHeader, 0, "pu") +TYPE("objective-c-header-cpp-output", PP_ObjCHeader, INVALID, "mi", "p") +TYPE("objective-c-header", ObjCHeader, PP_ObjCHeader, 0, "pu") +TYPE("c++-header-cpp-output", PP_CXXHeader, INVALID, "ii", "p") +TYPE("c++-header", CXXHeader, PP_CXXHeader, 0, "pu") +TYPE("objective-c++-header-cpp-output", PP_ObjCXXHeader, INVALID, "mii", "p") +TYPE("objective-c++-header", ObjCXXHeader, PP_ObjCXXHeader, 0, "pu") + +// Other languages. +TYPE("ada", Ada, INVALID, 0, "u") +TYPE("assembler", PP_Asm, INVALID, "s", "au") +TYPE("assembler-with-cpp", Asm, PP_Asm, 0, "au") +TYPE("f95", PP_Fortran, INVALID, 0, "u") +TYPE("f95-cpp-input", Fortran, PP_Fortran, 0, "u") +TYPE("java", Java, INVALID, 0, "u") + +// Misc. +TYPE("llvm-asm", LLVMAsm, INVALID, "s", "") +TYPE("llvm-bc", LLVMBC, INVALID, "o", "") +TYPE("plist", Plist, INVALID, "plist", "") +TYPE("precompiled-header", PCH, INVALID, "gch", "A") +TYPE("object", Object, INVALID, "o", "") +TYPE("treelang", Treelang, INVALID, 0, "u") +TYPE("image", Image, INVALID, "out", "") +TYPE("dependencies", Dependencies, INVALID, "d", "") +TYPE("none", Nothing, INVALID, 0, "u") diff --git a/include/clang/Driver/Types.h b/include/clang/Driver/Types.h new file mode 100644 index 0000000..92520a7 --- /dev/null +++ b/include/clang/Driver/Types.h @@ -0,0 +1,85 @@ +//===--- Types.h - Input & Temporary Driver Types ---------------*- 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_TYPES_H_ +#define CLANG_DRIVER_TYPES_H_ + +#include "clang/Driver/Phases.h" + +namespace clang { +namespace driver { +namespace types { + enum ID { + TY_INVALID, +#define TYPE(NAME, ID, PP_TYPE, TEMP_SUFFIX, FLAGS) TY_##ID, +#include "clang/Driver/Types.def" +#undef TYPE + TY_LAST + }; + + /// getTypeName - Return the name of the type for \arg Id. + const char *getTypeName(ID Id); + + /// getPreprocessedType - Get the ID of the type for this input when + /// it has been preprocessed, or INVALID if this input is not + /// preprocessed. + ID getPreprocessedType(ID Id); + + /// getTypeTempSuffix - Return the suffix to use when creating a + /// temp file of this type, or null if unspecified. + const char *getTypeTempSuffix(ID Id); + + /// onlyAssembleType - Should this type only be assembled. + bool onlyAssembleType(ID Id); + + /// onlyPrecompileType - Should this type only be precompiled. + bool onlyPrecompileType(ID Id); + + /// canTypeBeUserSpecified - Can this type be specified on the + /// command line (by the type name); this is used when forwarding + /// commands to gcc. + bool canTypeBeUserSpecified(ID Id); + + /// appendSuffixForType - When generating outputs of this type, + /// should the suffix be appended (instead of replacing the existing + /// suffix). + bool appendSuffixForType(ID Id); + + /// canLipoType - Is this type acceptable as the output of a + /// universal build (currently, just the Nothing, Image, and Object + /// types). + bool canLipoType(ID Id); + + /// isAcceptedByClang - Can clang handle this input type. + bool isAcceptedByClang(ID Id); + + /// isCXX - Is this a "C++" input (C++ and Obj-C++ sources and headers). + bool isCXX(ID Id); + + /// lookupTypeForExtension - Lookup the type to use for the file + /// extension \arg Ext. + ID lookupTypeForExtension(const char *Ext); + + /// lookupTypeForTypSpecifier - Lookup the type to use for a user + /// specified type name. + ID lookupTypeForTypeSpecifier(const char *Name); + + /// getNumCompilationPhases - Return the complete number of phases + /// to be done for this type. + unsigned getNumCompilationPhases(ID Id); + + /// getCompilationPhase - Return the \args N th compilation phase to + /// be done for this type. + phases::ID getCompilationPhase(ID Id, unsigned N); + +} // end namespace types +} // end namespace driver +} // end namespace clang + +#endif diff --git a/include/clang/Driver/Util.h b/include/clang/Driver/Util.h new file mode 100644 index 0000000..52f268d --- /dev/null +++ b/include/clang/Driver/Util.h @@ -0,0 +1,30 @@ +//===--- Util.h - Common Driver Utilities -----------------------*- 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_UTIL_H_ +#define CLANG_DRIVER_UTIL_H_ + +namespace llvm { + template<typename T, unsigned N> class SmallVector; +} + +namespace clang { +namespace driver { + class Action; + + /// ArgStringList - Type used for constructing argv lists for subprocesses. + typedef llvm::SmallVector<const char*, 16> ArgStringList; + + /// ActionList - Type used for lists of actions. + typedef llvm::SmallVector<Action*, 3> ActionList; + +} // end namespace driver +} // end namespace clang + +#endif |