diff options
Diffstat (limited to 'include/clang/Driver/Driver.h')
-rw-r--r-- | include/clang/Driver/Driver.h | 77 |
1 files changed, 50 insertions, 27 deletions
diff --git a/include/clang/Driver/Driver.h b/include/clang/Driver/Driver.h index d9053d1..867444e 100644 --- a/include/clang/Driver/Driver.h +++ b/include/clang/Driver/Driver.h @@ -15,6 +15,7 @@ #include "clang/Driver/Phases.h" #include "clang/Driver/Types.h" #include "clang/Driver/Util.h" +#include "llvm/ADT/OwningPtr.h" #include "llvm/ADT/StringMap.h" #include "llvm/ADT/StringRef.h" #include "llvm/ADT/Triple.h" @@ -24,27 +25,41 @@ #include <set> #include <string> +namespace llvm { +namespace opt { + class Arg; + class ArgList; + class DerivedArgList; + class InputArgList; + class OptTable; +} +} + namespace clang { namespace driver { + class Action; - class Arg; - class ArgList; class Command; class Compilation; - class DerivedArgList; - class InputArgList; class InputInfo; class JobAction; - class OptTable; + class SanitizerArgs; class ToolChain; /// Driver - Encapsulate logic for constructing compilation processes /// from a set of gcc-driver-like command line arguments. class Driver { - OptTable *Opts; + llvm::opt::OptTable *Opts; DiagnosticsEngine &Diags; + enum DriverMode { + GCCMode, + GXXMode, + CPPMode, + CLMode + } Mode; + public: // Diag - Forwarding function for diagnostics. DiagnosticBuilder Diag(unsigned DiagID) const { @@ -79,6 +94,9 @@ public: /// sysroot, if present std::string SysRoot; + /// Dynamic loader prefix, if present + std::string DyldPrefix; + /// If the standard library is used bool UseStdLib; @@ -104,16 +122,17 @@ public: const char *CCLogDiagnosticsFilename; /// A list of inputs and their types for the given arguments. - typedef SmallVector<std::pair<types::ID, const Arg*>, 16> InputList; + typedef SmallVector<std::pair<types::ID, const llvm::opt::Arg *>, 16> + InputList; /// Whether the driver should follow g++ like behavior. - unsigned CCCIsCXX : 1; + bool CCCIsCXX() const { return Mode == GXXMode; } /// Whether the driver is just the preprocessor. - unsigned CCCIsCPP : 1; + bool CCCIsCPP() const { return Mode == CPPMode; } - /// Echo commands while executing (in -v style). - unsigned CCCEcho : 1; + /// Whether the driver should follow cl.exe like behavior. + bool IsCLMode() const { return Mode == CLMode; } /// Only print tool bindings, don't build any jobs. unsigned CCCPrintBindings : 1; @@ -163,12 +182,13 @@ private: private: /// TranslateInputArgs - Create a new derived argument list from the input /// arguments, after applying the standard argument translations. - DerivedArgList *TranslateInputArgs(const InputArgList &Args) const; + llvm::opt::DerivedArgList * + TranslateInputArgs(const llvm::opt::InputArgList &Args) const; // getFinalPhase - Determine which compilation mode we are in and record // which option we used to determine the final phase. - phases::ID getFinalPhase(const DerivedArgList &DAL, Arg **FinalPhaseArg = 0) - const; + phases::ID getFinalPhase(const llvm::opt::DerivedArgList &DAL, + llvm::opt::Arg **FinalPhaseArg = 0) const; public: Driver(StringRef _ClangExecutable, @@ -183,8 +203,7 @@ public: /// Name to use when invoking gcc/g++. const std::string &getCCCGenericGCCName() const { return CCCGenericGCCName; } - - const OptTable &getOpts() const { return *Opts; } + const llvm::opt::OptTable &getOpts() const { return *Opts; } const DiagnosticsEngine &getDiags() const { return Diags; } @@ -226,9 +245,12 @@ public: /// @name Driver Steps /// @{ + /// ParseDriverMode - Look for and handle the driver mode option in Args. + void ParseDriverMode(ArrayRef<const char *> Args); + /// ParseArgStrings - Parse the given list of strings into an /// ArgList. - InputArgList *ParseArgStrings(ArrayRef<const char *> Args); + llvm::opt::InputArgList *ParseArgStrings(ArrayRef<const char *> Args); /// BuildInputs - Construct the list of inputs and their types from /// the given arguments. @@ -237,7 +259,7 @@ public: /// \param Args - The input arguments. /// \param Inputs - The list to store the resulting compilation /// inputs onto. - void BuildInputs(const ToolChain &TC, const DerivedArgList &Args, + void BuildInputs(const ToolChain &TC, const llvm::opt::DerivedArgList &Args, InputList &Inputs) const; /// BuildActions - Construct the list of actions to perform for the @@ -246,7 +268,7 @@ public: /// \param TC - The default host tool chain. /// \param Args - The input arguments. /// \param Actions - The list to store the resulting actions onto. - void BuildActions(const ToolChain &TC, const DerivedArgList &Args, + void BuildActions(const ToolChain &TC, llvm::opt::DerivedArgList &Args, const InputList &Inputs, ActionList &Actions) const; /// BuildUniversalActions - Construct the list of actions to perform @@ -255,7 +277,8 @@ public: /// \param TC - The default host tool chain. /// \param Args - The input arguments. /// \param Actions - The list to store the resulting actions onto. - void BuildUniversalActions(const ToolChain &TC, const DerivedArgList &Args, + void BuildUniversalActions(const ToolChain &TC, + llvm::opt::DerivedArgList &Args, const InputList &BAInputs, ActionList &Actions) const; @@ -292,9 +315,6 @@ public: /// \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, raw_ostream &OS) const; @@ -324,10 +344,9 @@ public: /// ConstructAction - Construct the appropriate action to do for /// \p Phase on the \p Input, taking in to account arguments /// like -fsyntax-only or --analyze. - Action *ConstructPhaseAction(const ArgList &Args, phases::ID Phase, + Action *ConstructPhaseAction(const llvm::opt::ArgList &Args, phases::ID Phase, Action *Input) const; - /// BuildJobsForAction - Construct the jobs to perform for the /// action \p A. void BuildJobsForAction(Compilation &C, @@ -367,18 +386,22 @@ public: /// handle this action. bool ShouldUseClangCompiler(const JobAction &JA) const; - bool IsUsingLTO(const ArgList &Args) const; + bool IsUsingLTO(const llvm::opt::ArgList &Args) const; private: /// \brief Retrieves a ToolChain for a particular target triple. /// /// Will cache ToolChains for the life of the driver object, and create them /// on-demand. - const ToolChain &getToolChain(const ArgList &Args, + const ToolChain &getToolChain(const llvm::opt::ArgList &Args, StringRef DarwinArchName = "") const; /// @} + /// \brief Get bitmasks for which option flags to include and exclude based on + /// the driver mode. + std::pair<unsigned, unsigned> getIncludeExcludeOptionFlagMasks() const; + public: /// GetReleaseVersion - Parse (([0-9]+)(.([0-9]+)(.([0-9]+)?))?)? and /// return the grouped values as integers. Numbers which are not |