Coverage Report

Created: 2019-07-24 05:18

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/tools/clang/lib/Driver/ToolChains/MSVC.h
Line
Count
Source (jump to first uncovered line)
1
//===--- MSVC.h - MSVC ToolChain Implementations ----------------*- C++ -*-===//
2
//
3
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
// See https://llvm.org/LICENSE.txt for license information.
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
//
7
//===----------------------------------------------------------------------===//
8
9
#ifndef LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_MSVC_H
10
#define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_MSVC_H
11
12
#include "Cuda.h"
13
#include "clang/Basic/DebugInfoOptions.h"
14
#include "clang/Driver/Compilation.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
347
             llvm::sys::WEM_UTF16) {}
29
30
347
  bool hasIntegratedCPP() const override { return false; }
31
0
  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
15
             llvm::sys::WEM_UTF16) {}
44
45
0
  bool hasIntegratedAssembler() const override { return true; }
46
0
  bool hasIntegratedCPP() const override { return true; }
47
0
  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
  /// Set CodeView as the default debug info format for non-MachO binary
82
  /// formats, and to DWARF otherwise. Users can use -gcodeview and -gdwarf to
83
  /// override the default.
84
4
  codegenoptions::DebugInfoFormat getDefaultDebugFormat() const override {
85
4
    return getTriple().isOSBinFormatMachO() ? 
codegenoptions::DIF_DWARF1
86
4
                                            : 
codegenoptions::DIF_CodeView3
;
87
4
  }
88
89
  /// Set the debugger tuning to "default", since we're definitely not tuning
90
  /// for GDB.
91
648
  llvm::DebuggerKind getDefaultDebuggerTuning() const override {
92
648
    return llvm::DebuggerKind::Default;
93
648
  }
94
95
  enum class SubDirectoryType {
96
    Bin,
97
    Include,
98
    Lib,
99
  };
100
  std::string getSubDirectoryPath(SubDirectoryType Type,
101
                                  llvm::Triple::ArchType TargetArch) const;
102
103
  // Convenience overload.
104
  // Uses the current target arch.
105
2.65k
  std::string getSubDirectoryPath(SubDirectoryType Type) const {
106
2.65k
    return getSubDirectoryPath(Type, getArch());
107
2.65k
  }
108
109
  enum class ToolsetLayout {
110
    OlderVS,
111
    VS2017OrNewer,
112
    DevDivInternal,
113
  };
114
0
  bool getIsVS2017OrNewer() const { return VSLayout == ToolsetLayout::VS2017OrNewer; }
115
116
  void
117
  AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
118
                            llvm::opt::ArgStringList &CC1Args) const override;
119
  void AddClangCXXStdlibIncludeArgs(
120
      const llvm::opt::ArgList &DriverArgs,
121
      llvm::opt::ArgStringList &CC1Args) const override;
122
123
  void AddCudaIncludeArgs(const llvm::opt::ArgList &DriverArgs,
124
                          llvm::opt::ArgStringList &CC1Args) const override;
125
126
  bool getWindowsSDKLibraryPath(std::string &path) const;
127
  /// Check if Universal CRT should be used if available
128
  bool getUniversalCRTLibraryPath(std::string &path) const;
129
  bool useUniversalCRT() const;
130
  VersionTuple
131
  computeMSVCVersion(const Driver *D,
132
                     const llvm::opt::ArgList &Args) const override;
133
134
  std::string ComputeEffectiveClangTriple(const llvm::opt::ArgList &Args,
135
                                          types::ID InputType) const override;
136
  SanitizerMask getSupportedSanitizers() const override;
137
138
  void printVerboseInfo(raw_ostream &OS) const override;
139
140
344
  bool FoundMSVCInstall() const { return !VCToolChainPath.empty(); }
141
142
protected:
143
  void AddSystemIncludeWithSubfolder(const llvm::opt::ArgList &DriverArgs,
144
                                     llvm::opt::ArgStringList &CC1Args,
145
                                     const std::string &folder,
146
                                     const Twine &subfolder1,
147
                                     const Twine &subfolder2 = "",
148
                                     const Twine &subfolder3 = "") const;
149
150
  Tool *buildLinker() const override;
151
  Tool *buildAssembler() const override;
152
private:
153
  std::string VCToolChainPath;
154
  ToolsetLayout VSLayout = ToolsetLayout::OlderVS;
155
  CudaInstallationDetector CudaInstallation;
156
};
157
158
} // end namespace toolchains
159
} // end namespace driver
160
} // end namespace clang
161
162
#endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_MSVC_H