clang  8.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"
16 #include "clang/Driver/Tool.h"
17 #include "clang/Driver/ToolChain.h"
18 
19 namespace clang {
20 namespace driver {
21 namespace tools {
22 
23 /// Visual studio tools.
24 namespace visualstudio {
25 class LLVM_LIBRARY_VISIBILITY Linker : public Tool {
26 public:
27  Linker(const ToolChain &TC)
28  : Tool("visualstudio::Linker", "linker", TC, RF_Full,
29  llvm::sys::WEM_UTF16) {}
30 
31  bool hasIntegratedCPP() const override { return false; }
32  bool isLinkJob() const override { return true; }
33 
34  void ConstructJob(Compilation &C, const JobAction &JA,
35  const InputInfo &Output, const InputInfoList &Inputs,
36  const llvm::opt::ArgList &TCArgs,
37  const char *LinkingOutput) const override;
38 };
39 
40 class LLVM_LIBRARY_VISIBILITY Compiler : public Tool {
41 public:
42  Compiler(const ToolChain &TC)
43  : Tool("visualstudio::Compiler", "compiler", TC, RF_Full,
44  llvm::sys::WEM_UTF16) {}
45 
46  bool hasIntegratedAssembler() const override { return true; }
47  bool hasIntegratedCPP() const override { return true; }
48  bool isLinkJob() const override { return false; }
49 
50  void ConstructJob(Compilation &C, const JobAction &JA,
51  const InputInfo &Output, const InputInfoList &Inputs,
52  const llvm::opt::ArgList &TCArgs,
53  const char *LinkingOutput) const override;
54 
55  std::unique_ptr<Command> GetCommand(Compilation &C, const JobAction &JA,
56  const InputInfo &Output,
57  const InputInfoList &Inputs,
58  const llvm::opt::ArgList &TCArgs,
59  const char *LinkingOutput) const;
60 };
61 } // end namespace visualstudio
62 
63 } // end namespace tools
64 
65 namespace toolchains {
66 
67 class LLVM_LIBRARY_VISIBILITY MSVCToolChain : public ToolChain {
68 public:
69  MSVCToolChain(const Driver &D, const llvm::Triple &Triple,
70  const llvm::opt::ArgList &Args);
71 
72  llvm::opt::DerivedArgList *
73  TranslateArgs(const llvm::opt::DerivedArgList &Args, StringRef BoundArch,
74  Action::OffloadKind DeviceOffloadKind) const override;
75 
76  bool IsIntegratedAssemblerDefault() const override;
77  bool IsUnwindTablesDefault(const llvm::opt::ArgList &Args) const override;
78  bool isPICDefault() const override;
79  bool isPIEDefault() const override;
80  bool isPICDefaultForced() const override;
81 
82  /// Set CodeView as the default debug info format. Users can use -gcodeview
83  /// and -gdwarf to override the default.
86  }
87 
88  /// Set the debugger tuning to "default", since we're definitely not tuning
89  /// for GDB.
90  llvm::DebuggerKind getDefaultDebuggerTuning() const override {
91  return llvm::DebuggerKind::Default;
92  }
93 
94  enum class SubDirectoryType {
95  Bin,
96  Include,
97  Lib,
98  };
99  std::string getSubDirectoryPath(SubDirectoryType Type,
100  llvm::Triple::ArchType TargetArch) const;
101 
102  // Convenience overload.
103  // Uses the current target arch.
104  std::string getSubDirectoryPath(SubDirectoryType Type) const {
105  return getSubDirectoryPath(Type, getArch());
106  }
107 
108  enum class ToolsetLayout {
109  OlderVS,
110  VS2017OrNewer,
111  DevDivInternal,
112  };
113  bool getIsVS2017OrNewer() const { return VSLayout == ToolsetLayout::VS2017OrNewer; }
114 
115  void
116  AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
117  llvm::opt::ArgStringList &CC1Args) const override;
118  void AddClangCXXStdlibIncludeArgs(
119  const llvm::opt::ArgList &DriverArgs,
120  llvm::opt::ArgStringList &CC1Args) const override;
121 
122  void AddCudaIncludeArgs(const llvm::opt::ArgList &DriverArgs,
123  llvm::opt::ArgStringList &CC1Args) const override;
124 
125  bool getWindowsSDKLibraryPath(std::string &path) const;
126  /// Check if Universal CRT should be used if available
127  bool getUniversalCRTLibraryPath(std::string &path) const;
128  bool useUniversalCRT() const;
129  VersionTuple
130  computeMSVCVersion(const Driver *D,
131  const llvm::opt::ArgList &Args) const override;
132 
133  std::string ComputeEffectiveClangTriple(const llvm::opt::ArgList &Args,
134  types::ID InputType) const override;
135  SanitizerMask getSupportedSanitizers() const override;
136 
137  void printVerboseInfo(raw_ostream &OS) const override;
138 
139  bool FoundMSVCInstall() const { return !VCToolChainPath.empty(); }
140 
141 protected:
142  void AddSystemIncludeWithSubfolder(const llvm::opt::ArgList &DriverArgs,
143  llvm::opt::ArgStringList &CC1Args,
144  const std::string &folder,
145  const Twine &subfolder1,
146  const Twine &subfolder2 = "",
147  const Twine &subfolder3 = "") const;
148 
149  Tool *buildLinker() const override;
150  Tool *buildAssembler() const override;
151 private:
152  std::string VCToolChainPath;
153  ToolsetLayout VSLayout = ToolsetLayout::OlderVS;
154  CudaInstallationDetector CudaInstallation;
155 };
156 
157 } // end namespace toolchains
158 } // end namespace driver
159 } // end namespace clang
160 
161 #endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_MSVC_H
DominatorTree GraphTraits specialization so the DominatorTree can be iterable by generic graph iterat...
Definition: Dominators.h:30
bool hasIntegratedAssembler() const override
Definition: MSVC.h:46
The base class of the type hierarchy.
Definition: Type.h:1415
bool isLinkJob() const override
Definition: MSVC.h:32
llvm::DebuggerKind getDefaultDebuggerTuning() const override
Set the debugger tuning to "default", since we&#39;re definitely not tuning for GDB.
Definition: MSVC.h:90
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:58
std::string getSubDirectoryPath(SubDirectoryType Type) const
Definition: MSVC.h:104
bool hasIntegratedCPP() const override
Definition: MSVC.h:31
Dataflow Directional Tag Classes.
Tool - Information on a specific compilation tool.
Definition: Tool.h:34
uint64_t SanitizerMask
Definition: Sanitizers.h:26
Compilation - A set of tasks to perform for a single driver invocation.
Definition: Compilation.h:46
codegenoptions::DebugInfoFormat getDefaultDebugFormat() const override
Set CodeView as the default debug info format.
Definition: MSVC.h:84
bool isLinkJob() const override
Definition: MSVC.h:48
ToolChain - Access to tools for a single platform.
Definition: ToolChain.h:88
bool hasIntegratedCPP() const override
Definition: MSVC.h:47