diff options
Diffstat (limited to 'include/clang/Driver/ToolChain.h')
-rw-r--r-- | include/clang/Driver/ToolChain.h | 55 |
1 files changed, 46 insertions, 9 deletions
diff --git a/include/clang/Driver/ToolChain.h b/include/clang/Driver/ToolChain.h index 2a15d7ab061c..cca239c4be2a 100644 --- a/include/clang/Driver/ToolChain.h +++ b/include/clang/Driver/ToolChain.h @@ -18,7 +18,6 @@ #include "clang/Driver/Util.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/Triple.h" -#include "llvm/Support/Path.h" #include "llvm/Target/TargetOptions.h" #include <memory> #include <string> @@ -39,8 +38,10 @@ class FileSystem; namespace driver { class Compilation; + class CudaInstallationDetector; class Driver; class JobAction; + class RegisterEffectiveTriple; class SanitizerArgs; class Tool; @@ -85,16 +86,25 @@ private: mutable std::unique_ptr<Tool> Clang; mutable std::unique_ptr<Tool> Assemble; mutable std::unique_ptr<Tool> Link; + mutable std::unique_ptr<Tool> OffloadBundler; Tool *getClang() const; Tool *getAssemble() const; Tool *getLink() const; Tool *getClangAs() const; + Tool *getOffloadBundler() const; mutable std::unique_ptr<SanitizerArgs> SanitizerArguments; + /// The effective clang triple for the current Job. + mutable llvm::Triple EffectiveTriple; + + /// Set the toolchain's effective clang triple. + void setEffectiveTriple(llvm::Triple ET) const { EffectiveTriple = ET; } + + friend class RegisterEffectiveTriple; + protected: MultilibSet Multilibs; - const char *DefaultLinker = "ld"; ToolChain(const Driver &D, const llvm::Triple &T, const llvm::opt::ArgList &Args); @@ -142,6 +152,12 @@ public: return Triple.getTriple(); } + /// Get the toolchain's effective clang triple. + const llvm::Triple &getEffectiveTriple() const { + assert(!EffectiveTriple.getTriple().empty() && "No effective triple"); + return EffectiveTriple; + } + path_list &getFilePaths() { return FilePaths; } const path_list &getFilePaths() const { return FilePaths; } @@ -176,12 +192,15 @@ public: /// TranslateArgs - Create a new derived argument list for any argument /// translations this ToolChain may wish to perform, or 0 if no tool chain - /// specific translations are needed. + /// specific translations are needed. If \p DeviceOffloadKind is specified + /// the translation specific for that offload kind is performed. /// /// \param BoundArch - The bound architecture name, or 0. + /// \param DeviceOffloadKind - The device offload kind used for the + /// translation. virtual llvm::opt::DerivedArgList * - TranslateArgs(const llvm::opt::DerivedArgList &Args, - const char *BoundArch) const { + TranslateArgs(const llvm::opt::DerivedArgList &Args, StringRef BoundArch, + Action::OffloadKind DeviceOffloadKind) const { return nullptr; } @@ -219,7 +238,7 @@ public: /// LookupTypeForExtension - Return the default language type to use for the /// given extension. - virtual types::ID LookupTypeForExtension(const char *Ext) const; + virtual types::ID LookupTypeForExtension(StringRef Ext) const; /// IsBlocksDefault - Does this tool chain enable -fblocks by default. virtual bool IsBlocksDefault() const { return false; } @@ -252,6 +271,11 @@ public: return 0; } + /// GetDefaultLinker - Get the default linker to use. + virtual const char *getDefaultLinker() const { + return "ld"; + } + /// GetDefaultRuntimeLibType - Get the default runtime library variant to use. virtual RuntimeLibType GetDefaultRuntimeLibType() const { return ToolChain::RLT_Libgcc; @@ -422,15 +446,28 @@ public: virtual void AddIAMCUIncludeArgs(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const; + /// \brief On Windows, returns the MSVC compatibility version. + virtual VersionTuple computeMSVCVersion(const Driver *D, + const llvm::opt::ArgList &Args) const; + /// \brief Return sanitizers which are available in this toolchain. virtual SanitizerMask getSupportedSanitizers() const; /// \brief Return sanitizers which are enabled by default. virtual SanitizerMask getDefaultSanitizers() const { return 0; } +}; + +/// Set a ToolChain's effective triple. Reset it when the registration object +/// is destroyed. +class RegisterEffectiveTriple { + const ToolChain &TC; + +public: + RegisterEffectiveTriple(const ToolChain &TC, llvm::Triple T) : TC(TC) { + TC.setEffectiveTriple(T); + } - /// \brief On Windows, returns the version of cl.exe. On other platforms, - /// returns an empty VersionTuple. - virtual VersionTuple getMSVCVersionFromExe() const { return VersionTuple(); } + ~RegisterEffectiveTriple() { TC.setEffectiveTriple(llvm::Triple()); } }; } // end namespace driver |