clang  6.0.0svn
MSVC.h
Go to the documentation of this file.
1 //===--- MSVC.h - MSVC ToolChain Implementations ----------------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #ifndef LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_MSVC_H
11 #define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_MSVC_H
12 
13 #include "Cuda.h"
15 #include "clang/Driver/Tool.h"
16 #include "clang/Driver/ToolChain.h"
17 
18 namespace clang {
19 namespace driver {
20 namespace tools {
21 
22 /// Visual studio tools.
23 namespace visualstudio {
24 class LLVM_LIBRARY_VISIBILITY Linker : public Tool {
25 public:
26  Linker(const ToolChain &TC)
27  : Tool("visualstudio::Linker", "linker", TC, RF_Full,
28  llvm::sys::WEM_UTF16) {}
29 
30  bool hasIntegratedCPP() const override { return false; }
31  bool isLinkJob() const override { return true; }
32 
33  void ConstructJob(Compilation &C, const JobAction &JA,
34  const InputInfo &Output, const InputInfoList &Inputs,
35  const llvm::opt::ArgList &TCArgs,
36  const char *LinkingOutput) const override;
37 };
38 
39 class LLVM_LIBRARY_VISIBILITY Compiler : public Tool {
40 public:
41  Compiler(const ToolChain &TC)
42  : Tool("visualstudio::Compiler", "compiler", TC, RF_Full,
43  llvm::sys::WEM_UTF16) {}
44 
45  bool hasIntegratedAssembler() const override { return true; }
46  bool hasIntegratedCPP() const override { return true; }
47  bool isLinkJob() const override { return false; }
48 
49  void ConstructJob(Compilation &C, const JobAction &JA,
50  const InputInfo &Output, const InputInfoList &Inputs,
51  const llvm::opt::ArgList &TCArgs,
52  const char *LinkingOutput) const override;
53 
54  std::unique_ptr<Command> GetCommand(Compilation &C, const JobAction &JA,
55  const InputInfo &Output,
56  const InputInfoList &Inputs,
57  const llvm::opt::ArgList &TCArgs,
58  const char *LinkingOutput) const;
59 };
60 } // end namespace visualstudio
61 
62 } // end namespace tools
63 
64 namespace toolchains {
65 
66 class LLVM_LIBRARY_VISIBILITY MSVCToolChain : public ToolChain {
67 public:
68  MSVCToolChain(const Driver &D, const llvm::Triple &Triple,
69  const llvm::opt::ArgList &Args);
70 
71  llvm::opt::DerivedArgList *
72  TranslateArgs(const llvm::opt::DerivedArgList &Args, StringRef BoundArch,
73  Action::OffloadKind DeviceOffloadKind) const override;
74 
75  bool IsIntegratedAssemblerDefault() const override;
76  bool IsUnwindTablesDefault(const llvm::opt::ArgList &Args) const override;
77  bool isPICDefault() const override;
78  bool isPIEDefault() const override;
79  bool isPICDefaultForced() const override;
80 
81  enum class SubDirectoryType {
82  Bin,
83  Include,
84  Lib,
85  };
86  std::string getSubDirectoryPath(SubDirectoryType Type,
87  llvm::Triple::ArchType TargetArch) const;
88 
89  // Convenience overload.
90  // Uses the current target arch.
91  std::string getSubDirectoryPath(SubDirectoryType Type) const {
92  return getSubDirectoryPath(Type, getArch());
93  }
94 
95  enum class ToolsetLayout {
96  OlderVS,
97  VS2017OrNewer,
98  DevDivInternal,
99  };
100  bool getIsVS2017OrNewer() const { return VSLayout == ToolsetLayout::VS2017OrNewer; }
101 
102  void
103  AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
104  llvm::opt::ArgStringList &CC1Args) const override;
105  void AddClangCXXStdlibIncludeArgs(
106  const llvm::opt::ArgList &DriverArgs,
107  llvm::opt::ArgStringList &CC1Args) const override;
108 
109  void AddCudaIncludeArgs(const llvm::opt::ArgList &DriverArgs,
110  llvm::opt::ArgStringList &CC1Args) const override;
111 
112  bool getWindowsSDKLibraryPath(std::string &path) const;
113  /// \brief Check if Universal CRT should be used if available
114  bool getUniversalCRTLibraryPath(std::string &path) const;
115  bool useUniversalCRT() const;
117  computeMSVCVersion(const Driver *D,
118  const llvm::opt::ArgList &Args) const override;
119 
120  std::string ComputeEffectiveClangTriple(const llvm::opt::ArgList &Args,
121  types::ID InputType) const override;
122  SanitizerMask getSupportedSanitizers() const override;
123 
124  void printVerboseInfo(raw_ostream &OS) const override;
125 
126 protected:
127  void AddSystemIncludeWithSubfolder(const llvm::opt::ArgList &DriverArgs,
128  llvm::opt::ArgStringList &CC1Args,
129  const std::string &folder,
130  const Twine &subfolder1,
131  const Twine &subfolder2 = "",
132  const Twine &subfolder3 = "") const;
133 
134  Tool *buildLinker() const override;
135  Tool *buildAssembler() const override;
136 private:
137  std::string VCToolChainPath;
138  ToolsetLayout VSLayout = ToolsetLayout::OlderVS;
139  CudaInstallationDetector CudaInstallation;
140 };
141 
142 } // end namespace toolchains
143 } // end namespace driver
144 } // end namespace clang
145 
146 #endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_MSVC_H
Represents a version number in the form major[.minor[.subminor[.build]]].
Definition: VersionTuple.h:26
DominatorTree GraphTraits specialization so the DominatorTree can be iterable by generic graph iterat...
Definition: Dominators.h:26
bool hasIntegratedAssembler() const override
Definition: MSVC.h:45
The base class of the type hierarchy.
Definition: Type.h:1353
bool isLinkJob() const override
Definition: MSVC.h:31
A class to find a viable CUDA installation.
Definition: Cuda.h:29
InputInfo - Wrapper for information about an input source.
Definition: InputInfo.h:23
Driver - Encapsulate logic for constructing compilation processes from a set of gcc-driver-like comma...
Definition: Driver.h:65
std::string getSubDirectoryPath(SubDirectoryType Type) const
Definition: MSVC.h:91
bool hasIntegratedCPP() const override
Definition: MSVC.h:30
Dataflow Directional Tag Classes.
uint64_t SanitizerMask
Definition: Sanitizers.h:24
Tool - Information on a specific compilation tool.
Definition: Tool.h:34
Compilation - A set of tasks to perform for a single driver invocation.
Definition: Compilation.h:34
bool isLinkJob() const override
Definition: MSVC.h:47
ToolChain - Access to tools for a single platform.
Definition: ToolChain.h:73
bool hasIntegratedCPP() const override
Definition: MSVC.h:46