summaryrefslogtreecommitdiff
path: root/include/clang/Driver/ToolChain.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/clang/Driver/ToolChain.h')
-rw-r--r--include/clang/Driver/ToolChain.h136
1 files changed, 75 insertions, 61 deletions
diff --git a/include/clang/Driver/ToolChain.h b/include/clang/Driver/ToolChain.h
index 13f54d3718b4c..addf7aa6a9c8d 100644
--- a/include/clang/Driver/ToolChain.h
+++ b/include/clang/Driver/ToolChain.h
@@ -1,4 +1,4 @@
-//===--- ToolChain.h - Collections of tools for one platform ----*- C++ -*-===//
+//===- ToolChain.h - Collections of tools for one platform ------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -10,69 +10,84 @@
#ifndef LLVM_CLANG_DRIVER_TOOLCHAIN_H
#define LLVM_CLANG_DRIVER_TOOLCHAIN_H
+#include "clang/Basic/LLVM.h"
#include "clang/Basic/Sanitizers.h"
-#include "clang/Basic/VersionTuple.h"
#include "clang/Driver/Action.h"
#include "clang/Driver/Multilib.h"
#include "clang/Driver/Types.h"
-#include "clang/Driver/Util.h"
+#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/Triple.h"
+#include "llvm/MC/MCTargetOptions.h"
+#include "llvm/Option/Option.h"
+#include "llvm/Support/VersionTuple.h"
#include "llvm/Target/TargetOptions.h"
+#include <cassert>
#include <memory>
#include <string>
+#include <utility>
namespace llvm {
namespace opt {
- class ArgList;
- class DerivedArgList;
- class InputArgList;
-}
-}
+
+class Arg;
+class ArgList;
+class DerivedArgList;
+
+} // namespace opt
+} // namespace llvm
namespace clang {
+
class ObjCRuntime;
+
namespace vfs {
+
class FileSystem;
-}
+
+} // namespace vfs
namespace driver {
- class Compilation;
- class CudaInstallationDetector;
- class Driver;
- class InputInfo;
- class JobAction;
- class RegisterEffectiveTriple;
- class SanitizerArgs;
- class Tool;
- class XRayArgs;
+
+class Driver;
+class InputInfo;
+class SanitizerArgs;
+class Tool;
+class XRayArgs;
/// Helper structure used to pass information extracted from clang executable
/// name such as `i686-linux-android-g++`.
-///
struct ParsedClangName {
/// Target part of the executable name, as `i686-linux-android`.
std::string TargetPrefix;
+
/// Driver mode part of the executable name, as `g++`.
std::string ModeSuffix;
+
/// Corresponding driver mode argument, as '--driver-mode=g++'
- const char *DriverMode;
+ const char *DriverMode = nullptr;
+
/// True if TargetPrefix is recognized as a registered target name.
- bool TargetIsValid;
+ bool TargetIsValid = false;
- ParsedClangName() : DriverMode(nullptr), TargetIsValid(false) {}
+ ParsedClangName() = default;
ParsedClangName(std::string Suffix, const char *Mode)
- : ModeSuffix(Suffix), DriverMode(Mode), TargetIsValid(false) {}
+ : ModeSuffix(Suffix), DriverMode(Mode) {}
ParsedClangName(std::string Target, std::string Suffix, const char *Mode,
bool IsRegistered)
: TargetPrefix(Target), ModeSuffix(Suffix), DriverMode(Mode),
TargetIsValid(IsRegistered) {}
+
+ bool isEmpty() const {
+ return TargetPrefix.empty() && ModeSuffix.empty() && DriverMode == nullptr;
+ }
};
/// ToolChain - Access to tools for a single platform.
class ToolChain {
public:
- typedef SmallVector<std::string, 16> path_list;
+ using path_list = SmallVector<std::string, 16>;
enum CXXStdlibType {
CST_Libcxx,
@@ -85,32 +100,33 @@ public:
};
enum RTTIMode {
- RM_EnabledExplicitly,
- RM_EnabledImplicitly,
- RM_DisabledExplicitly,
- RM_DisabledImplicitly
+ RM_Enabled,
+ RM_Disabled,
};
private:
+ friend class RegisterEffectiveTriple;
+
const Driver &D;
llvm::Triple Triple;
const llvm::opt::ArgList &Args;
+
// We need to initialize CachedRTTIArg before CachedRTTIMode
const llvm::opt::Arg *const CachedRTTIArg;
+
const RTTIMode CachedRTTIMode;
- /// The list of toolchain specific path prefixes to search for
- /// files.
+ /// 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.
+ /// The list of toolchain specific path prefixes to search for programs.
path_list ProgramPaths;
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;
@@ -128,8 +144,6 @@ private:
EffectiveTriple = std::move(ET);
}
- friend class RegisterEffectiveTriple;
-
protected:
MultilibSet Multilibs;
@@ -185,7 +199,7 @@ public:
StringRef getPlatform() const { return Triple.getVendorName(); }
StringRef getOS() const { return Triple.getOSName(); }
- /// \brief Provide the default architecture name (as expected by -arch) for
+ /// Provide the default architecture name (as expected by -arch) for
/// this toolchain.
StringRef getDefaultUniversalArchName() const;
@@ -217,7 +231,7 @@ public:
// Returns the RTTIMode for the toolchain with the current arguments.
RTTIMode getRTTIMode() const { return CachedRTTIMode; }
- /// \brief Return any implicit target and/or mode flag for an invocation of
+ /// Return any implicit target and/or mode flag for an invocation of
/// the compiler driver as `ProgName`.
///
/// For example, when called with i686-linux-android-g++, the first element
@@ -231,7 +245,6 @@ public:
/// e.g., argv[0]).
/// \return A structure of type ParsedClangName that contains the executable
/// name parts.
- ///
static ParsedClangName getTargetAndModeFromProgramName(StringRef ProgName);
// Tool access.
@@ -272,7 +285,7 @@ public:
/// the linker suffix or name.
std::string GetLinkerPath() const;
- /// \brief Dispatch to the specific toolchain for verbose printing.
+ /// Dispatch to the specific toolchain for verbose printing.
///
/// This is used when handling the verbose option to print detailed,
/// toolchain-specific information useful for understanding the behavior of
@@ -281,7 +294,7 @@ public:
// Platform defaults information
- /// \brief Returns true if the toolchain is targeting a non-native
+ /// Returns true if the toolchain is targeting a non-native
/// architecture.
virtual bool isCrossCompiling() const;
@@ -300,7 +313,7 @@ public:
/// by default.
virtual bool IsIntegratedAssemblerDefault() const { return false; }
- /// \brief Check if the toolchain should use the integrated assembler.
+ /// Check if the toolchain should use the integrated assembler.
virtual bool useIntegratedAs() const;
/// IsMathErrnoDefault - Does this tool chain use -fmath-errno by default.
@@ -318,7 +331,7 @@ public:
/// mixed dispatch method be used?
virtual bool UseObjCMixedDispatch() const { return false; }
- /// \brief Check whether to enable x86 relax relocations by default.
+ /// Check whether to enable x86 relax relocations by default.
virtual bool useRelaxRelocations() const;
/// GetDefaultStackProtectorLevel - Get the default stack protector level for
@@ -328,9 +341,7 @@ public:
}
/// GetDefaultLinker - Get the default linker to use.
- virtual const char *getDefaultLinker() const {
- return "ld";
- }
+ virtual const char *getDefaultLinker() const { return "ld"; }
/// GetDefaultRuntimeLibType - Get the default runtime library variant to use.
virtual RuntimeLibType GetDefaultRuntimeLibType() const {
@@ -355,6 +366,9 @@ public:
// as OpenMP) to find arch-specific libraries.
std::string getArchSpecificLibPath() const;
+ // Returns <OSname> part of above.
+ StringRef getOSLibName() const;
+
/// needsProfileRT - returns true if instrumentation profile is on.
static bool needsProfileRT(const llvm::opt::ArgList &Args);
@@ -362,13 +376,13 @@ public:
/// by default.
virtual bool IsUnwindTablesDefault(const llvm::opt::ArgList &Args) const;
- /// \brief Test whether this toolchain defaults to PIC.
+ /// Test whether this toolchain defaults to PIC.
virtual bool isPICDefault() const = 0;
- /// \brief Test whether this toolchain defaults to PIE.
+ /// Test whether this toolchain defaults to PIE.
virtual bool isPIEDefault() const = 0;
- /// \brief Tests whether this toolchain forces its default for PIC, PIE or
+ /// Tests whether this toolchain forces its default for PIC, PIE or
/// non-PIC. If this returns true, any PIC related flags should be ignored
/// and instead the results of \c isPICDefault() and \c isPIEDefault() are
/// used exclusively.
@@ -404,9 +418,7 @@ public:
GetExceptionModel(const llvm::opt::ArgList &Args) const;
/// SupportsEmbeddedBitcode - Does this tool chain support embedded bitcode.
- virtual bool SupportsEmbeddedBitcode() const {
- return false;
- }
+ virtual bool SupportsEmbeddedBitcode() const { return false; }
/// getThreadModel() - Which thread model does this target use?
virtual std::string getThreadModel() const { return "posix"; }
@@ -442,7 +454,7 @@ public:
/// FIXME: this really belongs on some sort of DeploymentTarget abstraction
virtual bool hasBlocksRuntime() const { return true; }
- /// \brief Add the clang cc1 arguments for system include paths.
+ /// Add the clang cc1 arguments for system include paths.
///
/// This routine is responsible for adding the necessary cc1 arguments to
/// include headers from standard system header directories.
@@ -450,12 +462,12 @@ public:
AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
llvm::opt::ArgStringList &CC1Args) const;
- /// \brief Add options that need to be passed to cc1 for this target.
+ /// Add options that need to be passed to cc1 for this target.
virtual void addClangTargetOptions(const llvm::opt::ArgList &DriverArgs,
llvm::opt::ArgStringList &CC1Args,
Action::OffloadKind DeviceOffloadKind) const;
- /// \brief Add warning options that need to be passed to cc1 for this target.
+ /// Add warning options that need to be passed to cc1 for this target.
virtual void addClangWarningOptions(llvm::opt::ArgStringList &CC1Args) const;
// GetRuntimeLibType - Determine the runtime library type to use with the
@@ -497,27 +509,28 @@ public:
/// This checks for presence of the -Ofast, -ffast-math or -funsafe-math flags.
virtual bool AddFastMathRuntimeIfAvailable(
const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs) const;
+
/// addProfileRTLibs - When -fprofile-instr-profile is specified, try to pass
/// a suitable profile runtime library to the linker.
virtual void addProfileRTLibs(const llvm::opt::ArgList &Args,
llvm::opt::ArgStringList &CmdArgs) const;
- /// \brief Add arguments to use system-specific CUDA includes.
+ /// Add arguments to use system-specific CUDA includes.
virtual void AddCudaIncludeArgs(const llvm::opt::ArgList &DriverArgs,
llvm::opt::ArgStringList &CC1Args) const;
- /// \brief Add arguments to use MCU GCC toolchain includes.
+ /// Add arguments to use MCU GCC toolchain includes.
virtual void AddIAMCUIncludeArgs(const llvm::opt::ArgList &DriverArgs,
llvm::opt::ArgStringList &CC1Args) const;
- /// \brief On Windows, returns the MSVC compatibility version.
+ /// 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.
+ /// Return sanitizers which are available in this toolchain.
virtual SanitizerMask getSupportedSanitizers() const;
- /// \brief Return sanitizers which are enabled by default.
+ /// Return sanitizers which are enabled by default.
virtual SanitizerMask getDefaultSanitizers() const { return 0; }
};
@@ -534,7 +547,8 @@ public:
~RegisterEffectiveTriple() { TC.setEffectiveTriple(llvm::Triple()); }
};
-} // end namespace driver
-} // end namespace clang
+} // namespace driver
+
+} // namespace clang
-#endif
+#endif // LLVM_CLANG_DRIVER_TOOLCHAIN_H