Coverage Report

Created: 2019-02-15 18:59

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/tools/clang/include/clang/Driver/Tool.h
Line
Count
Source (jump to first uncovered line)
1
//===--- Tool.h - Compilation Tools -----------------------------*- 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_DRIVER_TOOL_H
10
#define LLVM_CLANG_DRIVER_TOOL_H
11
12
#include "clang/Basic/LLVM.h"
13
#include "llvm/Support/Program.h"
14
15
namespace llvm {
16
namespace opt {
17
  class ArgList;
18
}
19
}
20
21
namespace clang {
22
namespace driver {
23
24
  class Compilation;
25
  class InputInfo;
26
  class Job;
27
  class JobAction;
28
  class ToolChain;
29
30
  typedef SmallVector<InputInfo, 4> InputInfoList;
31
32
/// Tool - Information on a specific compilation tool.
33
class Tool {
34
public:
35
  // Documents the level of support for response files in this tool.
36
  // Response files are necessary if the command line gets too large,
37
  // requiring the arguments to be transferred to a file.
38
  enum ResponseFileSupport {
39
    // Provides full support for response files, which means we can transfer
40
    // all tool input arguments to a file. E.g.: clang, gcc, binutils and MSVC
41
    // tools.
42
    RF_Full,
43
    // Input file names can live in a file, but flags can't. E.g.: ld64 (Mac
44
    // OS X linker).
45
    RF_FileList,
46
    // Does not support response files: all arguments must be passed via
47
    // command line.
48
    RF_None
49
  };
50
51
private:
52
  /// The tool name (for debugging).
53
  const char *Name;
54
55
  /// The human readable name for the tool, for use in diagnostics.
56
  const char *ShortName;
57
58
  /// The tool chain this tool is a part of.
59
  const ToolChain &TheToolChain;
60
61
  /// The level of support for response files seen in this tool
62
  const ResponseFileSupport ResponseSupport;
63
64
  /// The encoding to use when writing response files for this tool on Windows
65
  const llvm::sys::WindowsEncodingMethod ResponseEncoding;
66
67
  /// The flag used to pass a response file via command line to this tool
68
  const char *const ResponseFlag;
69
70
public:
71
  Tool(const char *Name, const char *ShortName, const ToolChain &TC,
72
       ResponseFileSupport ResponseSupport = RF_None,
73
       llvm::sys::WindowsEncodingMethod ResponseEncoding = llvm::sys::WEM_UTF8,
74
       const char *ResponseFlag = "@");
75
76
public:
77
  virtual ~Tool();
78
79
6.79k
  const char *getName() const { return Name; }
80
81
116
  const char *getShortName() const { return ShortName; }
82
83
312k
  const ToolChain &getToolChain() const { return TheToolChain; }
84
85
0
  virtual bool hasIntegratedAssembler() const { return false; }
86
7
  virtual bool canEmitIR() const { return false; }
87
  virtual bool hasIntegratedCPP() const = 0;
88
23
  virtual bool isLinkJob() const { return false; }
89
23
  virtual bool isDsymutilJob() const { return false; }
90
  /// Returns the level of support for response files of this tool,
91
  /// whether it accepts arguments to be passed via a file on disk.
92
17.8k
  ResponseFileSupport getResponseFilesSupport() const {
93
17.8k
    return ResponseSupport;
94
17.8k
  }
95
  /// Returns which encoding the response file should use. This is only
96
  /// relevant on Windows platforms where there are different encodings being
97
  /// accepted for different tools. On UNIX, UTF8 is universal.
98
  ///
99
  /// Windows use cases: - GCC and Binutils on mingw only accept ANSI response
100
  /// files encoded with the system current code page.
101
  /// - MSVC's CL.exe and LINK.exe accept UTF16 on Windows.
102
  /// - Clang accepts both UTF8 and UTF16.
103
  ///
104
  /// FIXME: When GNU tools learn how to parse UTF16 on Windows, we should
105
  /// always use UTF16 for Windows, which is the Windows official encoding for
106
  /// international characters.
107
1
  llvm::sys::WindowsEncodingMethod getResponseFileEncoding() const {
108
1
    return ResponseEncoding;
109
1
  }
110
  /// Returns which prefix to use when passing the name of a response
111
  /// file as a parameter to this tool.
112
1
  const char *getResponseFileFlag() const { return ResponseFlag; }
113
114
  /// Does this tool have "good" standardized diagnostics, or should the
115
  /// driver add an additional "command failed" diagnostic on failures.
116
12
  virtual bool hasGoodDiagnostics() const { return false; }
117
118
  /// ConstructJob - Construct jobs to perform the action \p JA,
119
  /// writing to \p Output and with \p Inputs, and add the jobs to
120
  /// \p C.
121
  ///
122
  /// \param TCArgs - The argument list for this toolchain, with any
123
  /// tool chain specific translations applied.
124
  /// \param LinkingOutput - If this output will eventually feed the
125
  /// linker, then this is the final output name of the linked image.
126
  virtual void ConstructJob(Compilation &C, const JobAction &JA,
127
                            const InputInfo &Output,
128
                            const InputInfoList &Inputs,
129
                            const llvm::opt::ArgList &TCArgs,
130
                            const char *LinkingOutput) const = 0;
131
  /// Construct jobs to perform the action \p JA, writing to the \p Outputs and
132
  /// with \p Inputs, and add the jobs to \p C. The default implementation
133
  /// assumes a single output and is expected to be overloaded for the tools
134
  /// that support multiple inputs.
135
  ///
136
  /// \param TCArgs The argument list for this toolchain, with any
137
  /// tool chain specific translations applied.
138
  /// \param LinkingOutput If this output will eventually feed the
139
  /// linker, then this is the final output name of the linked image.
140
  virtual void ConstructJobMultipleOutputs(Compilation &C, const JobAction &JA,
141
                                           const InputInfoList &Outputs,
142
                                           const InputInfoList &Inputs,
143
                                           const llvm::opt::ArgList &TCArgs,
144
                                           const char *LinkingOutput) const;
145
};
146
147
} // end namespace driver
148
} // end namespace clang
149
150
#endif