Coverage Report

Created: 2022-01-15 10:30

/Users/buildslave/jenkins/workspace/coverage/llvm-project/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 "AMDGPU.h"
13
#include "Cuda.h"
14
#include "clang/Basic/DebugInfoOptions.h"
15
#include "clang/Driver/Compilation.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
377
  Linker(const ToolChain &TC) : Tool("visualstudio::Linker", "linker", TC) {}
28
29
376
  bool hasIntegratedCPP() const override { return false; }
30
0
  bool isLinkJob() const override { return true; }
31
32
  void ConstructJob(Compilation &C, const JobAction &JA,
33
                    const InputInfo &Output, const InputInfoList &Inputs,
34
                    const llvm::opt::ArgList &TCArgs,
35
                    const char *LinkingOutput) const override;
36
};
37
} // end namespace visualstudio
38
39
} // end namespace tools
40
41
namespace toolchains {
42
43
class LLVM_LIBRARY_VISIBILITY MSVCToolChain : public ToolChain {
44
public:
45
  MSVCToolChain(const Driver &D, const llvm::Triple &Triple,
46
                const llvm::opt::ArgList &Args);
47
48
  llvm::opt::DerivedArgList *
49
  TranslateArgs(const llvm::opt::DerivedArgList &Args, StringRef BoundArch,
50
                Action::OffloadKind DeviceOffloadKind) const override;
51
52
  bool IsIntegratedAssemblerDefault() const override;
53
  bool IsUnwindTablesDefault(const llvm::opt::ArgList &Args) const override;
54
  bool isPICDefault() const override;
55
  bool isPIEDefault(const llvm::opt::ArgList &Args) const override;
56
  bool isPICDefaultForced() const override;
57
58
  /// Set CodeView as the default debug info format for non-MachO binary
59
  /// formats, and to DWARF otherwise. Users can use -gcodeview and -gdwarf to
60
  /// override the default.
61
7
  codegenoptions::DebugInfoFormat getDefaultDebugFormat() const override {
62
7
    return getTriple().isOSBinFormatMachO() ? 
codegenoptions::DIF_DWARF1
63
7
                                            : 
codegenoptions::DIF_CodeView6
;
64
7
  }
65
66
  /// Set the debugger tuning to "default", since we're definitely not tuning
67
  /// for GDB.
68
8.22k
  llvm::DebuggerKind getDefaultDebuggerTuning() const override {
69
8.22k
    return llvm::DebuggerKind::Default;
70
8.22k
  }
71
72
  enum class SubDirectoryType {
73
    Bin,
74
    Include,
75
    Lib,
76
  };
77
  std::string getSubDirectoryPath(SubDirectoryType Type,
78
                                  llvm::StringRef SubdirParent,
79
                                  llvm::Triple::ArchType TargetArch) const;
80
81
  // Convenience overload.
82
  // Uses the current target arch.
83
  std::string getSubDirectoryPath(SubDirectoryType Type,
84
18.3k
                                  llvm::StringRef SubdirParent = "") const {
85
18.3k
    return getSubDirectoryPath(Type, SubdirParent, getArch());
86
18.3k
  }
87
88
  enum class ToolsetLayout {
89
    OlderVS,
90
    VS2017OrNewer,
91
    DevDivInternal,
92
  };
93
0
  bool getIsVS2017OrNewer() const { return VSLayout == ToolsetLayout::VS2017OrNewer; }
94
95
  void
96
  AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
97
                            llvm::opt::ArgStringList &CC1Args) const override;
98
  void AddClangCXXStdlibIncludeArgs(
99
      const llvm::opt::ArgList &DriverArgs,
100
      llvm::opt::ArgStringList &CC1Args) const override;
101
102
  void AddCudaIncludeArgs(const llvm::opt::ArgList &DriverArgs,
103
                          llvm::opt::ArgStringList &CC1Args) const override;
104
105
  void AddHIPIncludeArgs(const llvm::opt::ArgList &DriverArgs,
106
                         llvm::opt::ArgStringList &CC1Args) const override;
107
108
  bool getWindowsSDKLibraryPath(
109
      const llvm::opt::ArgList &Args, std::string &path) const;
110
  bool getUniversalCRTLibraryPath(const llvm::opt::ArgList &Args,
111
                                  std::string &path) const;
112
  bool useUniversalCRT() const;
113
  VersionTuple
114
  computeMSVCVersion(const Driver *D,
115
                     const llvm::opt::ArgList &Args) const override;
116
117
  std::string ComputeEffectiveClangTriple(const llvm::opt::ArgList &Args,
118
                                          types::ID InputType) const override;
119
  SanitizerMask getSupportedSanitizers() const override;
120
121
  void printVerboseInfo(raw_ostream &OS) const override;
122
123
374
  bool FoundMSVCInstall() const { return !VCToolChainPath.empty(); }
124
125
  void
126
  addClangTargetOptions(const llvm::opt::ArgList &DriverArgs,
127
                        llvm::opt::ArgStringList &CC1Args,
128
                        Action::OffloadKind DeviceOffloadKind) const override;
129
130
protected:
131
  void AddSystemIncludeWithSubfolder(const llvm::opt::ArgList &DriverArgs,
132
                                     llvm::opt::ArgStringList &CC1Args,
133
                                     const std::string &folder,
134
                                     const Twine &subfolder1,
135
                                     const Twine &subfolder2 = "",
136
                                     const Twine &subfolder3 = "") const;
137
138
  Tool *buildLinker() const override;
139
  Tool *buildAssembler() const override;
140
private:
141
  std::string VCToolChainPath;
142
  ToolsetLayout VSLayout = ToolsetLayout::OlderVS;
143
  CudaInstallationDetector CudaInstallation;
144
  RocmInstallationDetector RocmInstallation;
145
};
146
147
} // end namespace toolchains
148
} // end namespace driver
149
} // end namespace clang
150
151
#endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_MSVC_H