Coverage Report

Created: 2022-07-16 07:03

/Users/buildslave/jenkins/workspace/coverage/llvm-project/clang/include/clang/Driver/Compilation.h
Line
Count
Source (jump to first uncovered line)
1
//===- Compilation.h - Compilation Task Data Structure ----------*- 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_COMPILATION_H
10
#define LLVM_CLANG_DRIVER_COMPILATION_H
11
12
#include "clang/Basic/LLVM.h"
13
#include "clang/Driver/Action.h"
14
#include "clang/Driver/Job.h"
15
#include "clang/Driver/Util.h"
16
#include "llvm/ADT/ArrayRef.h"
17
#include "llvm/ADT/DenseMap.h"
18
#include "llvm/ADT/Optional.h"
19
#include "llvm/ADT/StringRef.h"
20
#include "llvm/Option/Option.h"
21
#include <cassert>
22
#include <iterator>
23
#include <map>
24
#include <memory>
25
#include <utility>
26
#include <vector>
27
28
namespace llvm {
29
namespace opt {
30
31
class DerivedArgList;
32
class InputArgList;
33
34
} // namespace opt
35
} // namespace llvm
36
37
namespace clang {
38
namespace driver {
39
40
class Driver;
41
class ToolChain;
42
43
/// Compilation - A set of tasks to perform for a single driver
44
/// invocation.
45
class Compilation {
46
  /// The driver we were created by.
47
  const Driver &TheDriver;
48
49
  /// The default tool chain.
50
  const ToolChain &DefaultToolChain;
51
52
  /// A mask of all the programming models the host has to support in the
53
  /// current compilation.
54
  unsigned ActiveOffloadMask = 0;
55
56
  /// Array with the toolchains of offloading host and devices in the order they
57
  /// were requested by the user. We are preserving that order in case the code
58
  /// generation needs to derive a programming-model-specific semantic out of
59
  /// it.
60
  std::multimap<Action::OffloadKind, const ToolChain *>
61
      OrderedOffloadingToolchains;
62
63
  /// The original (untranslated) input argument list.
64
  llvm::opt::InputArgList *Args;
65
66
  /// The driver translated arguments. Note that toolchains may perform their
67
  /// own argument translation.
68
  llvm::opt::DerivedArgList *TranslatedArgs;
69
70
  /// The list of actions we've created via MakeAction.  This is not accessible
71
  /// to consumers; it's here just to manage ownership.
72
  std::vector<std::unique_ptr<Action>> AllActions;
73
74
  /// The list of actions.  This is maintained and modified by consumers, via
75
  /// getActions().
76
  ActionList Actions;
77
78
  /// The root list of jobs.
79
  JobList Jobs;
80
81
  /// Cache of translated arguments for a particular tool chain, bound
82
  /// architecture, and device offload kind.
83
  struct TCArgsKey final {
84
    const ToolChain *TC = nullptr;
85
    StringRef BoundArch;
86
    Action::OffloadKind DeviceOffloadKind = Action::OFK_None;
87
88
    TCArgsKey(const ToolChain *TC, StringRef BoundArch,
89
              Action::OffloadKind DeviceOffloadKind)
90
110k
        : TC(TC), BoundArch(BoundArch), DeviceOffloadKind(DeviceOffloadKind) {}
91
92
128k
    bool operator<(const TCArgsKey &K) const {
93
128k
      if (TC < K.TC)
94
1.96k
        return true;
95
126k
      else if (TC == K.TC && 
BoundArch < K.BoundArch125k
)
96
1.70k
        return true;
97
124k
      else if (TC == K.TC && 
BoundArch == K.BoundArch123k
&&
98
124k
               
DeviceOffloadKind < K.DeviceOffloadKind122k
)
99
546
        return true;
100
124k
      return false;
101
128k
    }
102
  };
103
  std::map<TCArgsKey, llvm::opt::DerivedArgList *> TCArgs;
104
105
  /// Temporary files which should be removed on exit.
106
  llvm::opt::ArgStringList TempFiles;
107
108
  /// Result files which should be removed on failure.
109
  ArgStringMap ResultFiles;
110
111
  /// Result files which are generated correctly on failure, and which should
112
  /// only be removed if we crash.
113
  ArgStringMap FailureResultFiles;
114
115
  /// Optional redirection for stdin, stdout, stderr.
116
  std::vector<Optional<StringRef>> Redirects;
117
118
  /// Callback called after compilation job has been finished.
119
  /// Arguments of the callback are the compilation job as an instance of
120
  /// class Command and the exit status of the corresponding child process.
121
  std::function<void(const Command &, int)> PostCallback;
122
123
  /// Whether we're compiling for diagnostic purposes.
124
  bool ForDiagnostics = false;
125
126
  /// Whether an error during the parsing of the input args.
127
  bool ContainsError;
128
129
  /// Whether to keep temporary files regardless of -save-temps.
130
  bool ForceKeepTempFiles = false;
131
132
public:
133
  Compilation(const Driver &D, const ToolChain &DefaultToolChain,
134
              llvm::opt::InputArgList *Args,
135
              llvm::opt::DerivedArgList *TranslatedArgs, bool ContainsError);
136
  ~Compilation();
137
138
365k
  const Driver &getDriver() const { return TheDriver; }
139
140
282k
  const ToolChain &getDefaultToolChain() const { return DefaultToolChain; }
141
142
48.7k
  unsigned isOffloadingHostKind(Action::OffloadKind Kind) const {
143
48.7k
    return ActiveOffloadMask & Kind;
144
48.7k
  }
145
146
45.6k
  unsigned getActiveOffloadKinds() const { return ActiveOffloadMask; }
147
148
  /// Iterator that visits device toolchains of a given kind.
149
  using const_offload_toolchains_iterator =
150
      const std::multimap<Action::OffloadKind,
151
                          const ToolChain *>::const_iterator;
152
  using const_offload_toolchains_range =
153
      std::pair<const_offload_toolchains_iterator,
154
                const_offload_toolchains_iterator>;
155
156
  template <Action::OffloadKind Kind>
157
52.1k
  const_offload_toolchains_range getOffloadToolChains() const {
158
52.1k
    return OrderedOffloadingToolchains.equal_range(Kind);
159
52.1k
  }
std::__1::pair<std::__1::__map_const_iterator<std::__1::__tree_const_iterator<std::__1::__value_type<clang::driver::Action::OffloadKind, clang::driver::ToolChain const*>, std::__1::__tree_node<std::__1::__value_type<clang::driver::Action::OffloadKind, clang::driver::ToolChain const*>, void*>*, long> > const, std::__1::__map_const_iterator<std::__1::__tree_const_iterator<std::__1::__value_type<clang::driver::Action::OffloadKind, clang::driver::ToolChain const*>, std::__1::__tree_node<std::__1::__value_type<clang::driver::Action::OffloadKind, clang::driver::ToolChain const*>, void*>*, long> > const> clang::driver::Compilation::getOffloadToolChains<(clang::driver::Action::OffloadKind)1>() const
Line
Count
Source
157
2.22k
  const_offload_toolchains_range getOffloadToolChains() const {
158
2.22k
    return OrderedOffloadingToolchains.equal_range(Kind);
159
2.22k
  }
std::__1::pair<std::__1::__map_const_iterator<std::__1::__tree_const_iterator<std::__1::__value_type<clang::driver::Action::OffloadKind, clang::driver::ToolChain const*>, std::__1::__tree_node<std::__1::__value_type<clang::driver::Action::OffloadKind, clang::driver::ToolChain const*>, void*>*, long> > const, std::__1::__map_const_iterator<std::__1::__tree_const_iterator<std::__1::__value_type<clang::driver::Action::OffloadKind, clang::driver::ToolChain const*>, std::__1::__tree_node<std::__1::__value_type<clang::driver::Action::OffloadKind, clang::driver::ToolChain const*>, void*>*, long> > const> clang::driver::Compilation::getOffloadToolChains<(clang::driver::Action::OffloadKind)8>() const
Line
Count
Source
157
907
  const_offload_toolchains_range getOffloadToolChains() const {
158
907
    return OrderedOffloadingToolchains.equal_range(Kind);
159
907
  }
std::__1::pair<std::__1::__map_const_iterator<std::__1::__tree_const_iterator<std::__1::__value_type<clang::driver::Action::OffloadKind, clang::driver::ToolChain const*>, std::__1::__tree_node<std::__1::__value_type<clang::driver::Action::OffloadKind, clang::driver::ToolChain const*>, void*>*, long> > const, std::__1::__map_const_iterator<std::__1::__tree_const_iterator<std::__1::__value_type<clang::driver::Action::OffloadKind, clang::driver::ToolChain const*>, std::__1::__tree_node<std::__1::__value_type<clang::driver::Action::OffloadKind, clang::driver::ToolChain const*>, void*>*, long> > const> clang::driver::Compilation::getOffloadToolChains<(clang::driver::Action::OffloadKind)4>() const
Line
Count
Source
157
48.7k
  const_offload_toolchains_range getOffloadToolChains() const {
158
48.7k
    return OrderedOffloadingToolchains.equal_range(Kind);
159
48.7k
  }
std::__1::pair<std::__1::__map_const_iterator<std::__1::__tree_const_iterator<std::__1::__value_type<clang::driver::Action::OffloadKind, clang::driver::ToolChain const*>, std::__1::__tree_node<std::__1::__value_type<clang::driver::Action::OffloadKind, clang::driver::ToolChain const*>, void*>*, long> > const, std::__1::__map_const_iterator<std::__1::__tree_const_iterator<std::__1::__value_type<clang::driver::Action::OffloadKind, clang::driver::ToolChain const*>, std::__1::__tree_node<std::__1::__value_type<clang::driver::Action::OffloadKind, clang::driver::ToolChain const*>, void*>*, long> > const> clang::driver::Compilation::getOffloadToolChains<(clang::driver::Action::OffloadKind)2>() const
Line
Count
Source
157
278
  const_offload_toolchains_range getOffloadToolChains() const {
158
278
    return OrderedOffloadingToolchains.equal_range(Kind);
159
278
  }
160
161
  const_offload_toolchains_range
162
37
  getOffloadToolChains(Action::OffloadKind Kind) const {
163
37
    return OrderedOffloadingToolchains.equal_range(Kind);
164
37
  }
165
166
  /// Return true if an offloading tool chain of a given kind exists.
167
97.4k
  template <Action::OffloadKind Kind> bool hasOffloadToolChain() const {
168
97.4k
    return OrderedOffloadingToolchains.find(Kind) !=
169
97.4k
           OrderedOffloadingToolchains.end();
170
97.4k
  }
bool clang::driver::Compilation::hasOffloadToolChain<(clang::driver::Action::OffloadKind)2>() const
Line
Count
Source
167
48.7k
  template <Action::OffloadKind Kind> bool hasOffloadToolChain() const {
168
48.7k
    return OrderedOffloadingToolchains.find(Kind) !=
169
48.7k
           OrderedOffloadingToolchains.end();
170
48.7k
  }
bool clang::driver::Compilation::hasOffloadToolChain<(clang::driver::Action::OffloadKind)8>() const
Line
Count
Source
167
48.7k
  template <Action::OffloadKind Kind> bool hasOffloadToolChain() const {
168
48.7k
    return OrderedOffloadingToolchains.find(Kind) !=
169
48.7k
           OrderedOffloadingToolchains.end();
170
48.7k
  }
171
172
  /// Return an offload toolchain of the provided kind. Only one is expected to
173
  /// exist.
174
  template <Action::OffloadKind Kind>
175
3.40k
  const ToolChain *getSingleOffloadToolChain() const {
176
3.40k
    auto TCs = getOffloadToolChains<Kind>();
177
178
3.40k
    assert(TCs.first != TCs.second &&
179
3.40k
           "No tool chains of the selected kind exist!");
180
0
    assert(std::next(TCs.first) == TCs.second &&
181
3.40k
           "More than one tool chain of the this kind exist.");
182
0
    return TCs.first->second;
183
3.40k
  }
clang::driver::ToolChain const* clang::driver::Compilation::getSingleOffloadToolChain<(clang::driver::Action::OffloadKind)1>() const
Line
Count
Source
175
2.22k
  const ToolChain *getSingleOffloadToolChain() const {
176
2.22k
    auto TCs = getOffloadToolChains<Kind>();
177
178
2.22k
    assert(TCs.first != TCs.second &&
179
2.22k
           "No tool chains of the selected kind exist!");
180
0
    assert(std::next(TCs.first) == TCs.second &&
181
2.22k
           "More than one tool chain of the this kind exist.");
182
0
    return TCs.first->second;
183
2.22k
  }
clang::driver::ToolChain const* clang::driver::Compilation::getSingleOffloadToolChain<(clang::driver::Action::OffloadKind)8>() const
Line
Count
Source
175
907
  const ToolChain *getSingleOffloadToolChain() const {
176
907
    auto TCs = getOffloadToolChains<Kind>();
177
178
907
    assert(TCs.first != TCs.second &&
179
907
           "No tool chains of the selected kind exist!");
180
0
    assert(std::next(TCs.first) == TCs.second &&
181
907
           "More than one tool chain of the this kind exist.");
182
0
    return TCs.first->second;
183
907
  }
clang::driver::ToolChain const* clang::driver::Compilation::getSingleOffloadToolChain<(clang::driver::Action::OffloadKind)2>() const
Line
Count
Source
175
278
  const ToolChain *getSingleOffloadToolChain() const {
176
278
    auto TCs = getOffloadToolChains<Kind>();
177
178
278
    assert(TCs.first != TCs.second &&
179
278
           "No tool chains of the selected kind exist!");
180
0
    assert(std::next(TCs.first) == TCs.second &&
181
278
           "More than one tool chain of the this kind exist.");
182
0
    return TCs.first->second;
183
278
  }
184
185
  void addOffloadDeviceToolChain(const ToolChain *DeviceToolChain,
186
381
                                 Action::OffloadKind OffloadKind) {
187
381
    assert(OffloadKind != Action::OFK_Host && OffloadKind != Action::OFK_None &&
188
381
           "This is not a device tool chain!");
189
190
    // Update the host offload kind to also contain this kind.
191
0
    ActiveOffloadMask |= OffloadKind;
192
381
    OrderedOffloadingToolchains.insert(
193
381
        std::make_pair(OffloadKind, DeviceToolChain));
194
381
  }
195
196
157k
  const llvm::opt::InputArgList &getInputArgs() const { return *Args; }
197
198
1.56M
  const llvm::opt::DerivedArgList &getArgs() const { return *TranslatedArgs; }
199
200
588k
  llvm::opt::DerivedArgList &getArgs() { return *TranslatedArgs; }
201
202
117k
  ActionList &getActions() { return Actions; }
203
75
  const ActionList &getActions() const { return Actions; }
204
205
  /// Creates a new Action owned by this Compilation.
206
  ///
207
  /// The new Action is *not* added to the list returned by getActions().
208
195k
  template <typename T, typename... Args> T *MakeAction(Args &&... Arg) {
209
195k
    T *RawPtr = new T(std::forward<Args>(Arg)...);
210
195k
    AllActions.push_back(std::unique_ptr<Action>(RawPtr));
211
195k
    return RawPtr;
212
195k
  }
clang::driver::InputAction* clang::driver::Compilation::MakeAction<clang::driver::InputAction, llvm::opt::Arg const&, clang::driver::types::ID&, llvm::StringRef>(llvm::opt::Arg const&, clang::driver::types::ID&, llvm::StringRef&&)
Line
Count
Source
208
434
  template <typename T, typename... Args> T *MakeAction(Args &&... Arg) {
209
434
    T *RawPtr = new T(std::forward<Args>(Arg)...);
210
434
    AllActions.push_back(std::unique_ptr<Action>(RawPtr));
211
434
    return RawPtr;
212
434
  }
clang::driver::OffloadBundlingJobAction* clang::driver::Compilation::MakeAction<clang::driver::OffloadBundlingJobAction, llvm::SmallVector<clang::driver::Action*, 3u>&>(llvm::SmallVector<clang::driver::Action*, 3u>&)
Line
Count
Source
208
38
  template <typename T, typename... Args> T *MakeAction(Args &&... Arg) {
209
38
    T *RawPtr = new T(std::forward<Args>(Arg)...);
210
38
    AllActions.push_back(std::unique_ptr<Action>(RawPtr));
211
38
    return RawPtr;
212
38
  }
clang::driver::LinkJobAction* clang::driver::Compilation::MakeAction<clang::driver::LinkJobAction, llvm::SmallVector<clang::driver::Action*, 3u>&, clang::driver::types::ID&>(llvm::SmallVector<clang::driver::Action*, 3u>&, clang::driver::types::ID&)
Line
Count
Source
208
76
  template <typename T, typename... Args> T *MakeAction(Args &&... Arg) {
209
76
    T *RawPtr = new T(std::forward<Args>(Arg)...);
210
76
    AllActions.push_back(std::unique_ptr<Action>(RawPtr));
211
76
    return RawPtr;
212
76
  }
clang::driver::InputAction* clang::driver::Compilation::MakeAction<clang::driver::InputAction, llvm::opt::Arg const&, clang::driver::types::ID>(llvm::opt::Arg const&, clang::driver::types::ID&&)
Line
Count
Source
208
12
  template <typename T, typename... Args> T *MakeAction(Args &&... Arg) {
209
12
    T *RawPtr = new T(std::forward<Args>(Arg)...);
210
12
    AllActions.push_back(std::unique_ptr<Action>(RawPtr));
211
12
    return RawPtr;
212
12
  }
clang::driver::OffloadWrapperJobAction* clang::driver::Compilation::MakeAction<clang::driver::OffloadWrapperJobAction, llvm::SmallVector<clang::driver::Action*, 3u>&, clang::driver::types::ID>(llvm::SmallVector<clang::driver::Action*, 3u>&, clang::driver::types::ID&&)
Line
Count
Source
208
8
  template <typename T, typename... Args> T *MakeAction(Args &&... Arg) {
209
8
    T *RawPtr = new T(std::forward<Args>(Arg)...);
210
8
    AllActions.push_back(std::unique_ptr<Action>(RawPtr));
211
8
    return RawPtr;
212
8
  }
clang::driver::BackendJobAction* clang::driver::Compilation::MakeAction<clang::driver::BackendJobAction, clang::driver::OffloadWrapperJobAction*&, clang::driver::types::ID>(clang::driver::OffloadWrapperJobAction*&, clang::driver::types::ID&&)
Line
Count
Source
208
8
  template <typename T, typename... Args> T *MakeAction(Args &&... Arg) {
209
8
    T *RawPtr = new T(std::forward<Args>(Arg)...);
210
8
    AllActions.push_back(std::unique_ptr<Action>(RawPtr));
211
8
    return RawPtr;
212
8
  }
clang::driver::AssembleJobAction* clang::driver::Compilation::MakeAction<clang::driver::AssembleJobAction, clang::driver::BackendJobAction*&, clang::driver::types::ID>(clang::driver::BackendJobAction*&, clang::driver::types::ID&&)
Line
Count
Source
208
8
  template <typename T, typename... Args> T *MakeAction(Args &&... Arg) {
209
8
    T *RawPtr = new T(std::forward<Args>(Arg)...);
210
8
    AllActions.push_back(std::unique_ptr<Action>(RawPtr));
211
8
    return RawPtr;
212
8
  }
clang::driver::OffloadUnbundlingJobAction* clang::driver::Compilation::MakeAction<clang::driver::OffloadUnbundlingJobAction, clang::driver::Action*&>(clang::driver::Action*&)
Line
Count
Source
208
41
  template <typename T, typename... Args> T *MakeAction(Args &&... Arg) {
209
41
    T *RawPtr = new T(std::forward<Args>(Arg)...);
210
41
    AllActions.push_back(std::unique_ptr<Action>(RawPtr));
211
41
    return RawPtr;
212
41
  }
clang::driver::BindArchAction* clang::driver::Compilation::MakeAction<clang::driver::BindArchAction, clang::driver::Action*&, char const*&>(clang::driver::Action*&, char const*&)
Line
Count
Source
208
20.7k
  template <typename T, typename... Args> T *MakeAction(Args &&... Arg) {
209
20.7k
    T *RawPtr = new T(std::forward<Args>(Arg)...);
210
20.7k
    AllActions.push_back(std::unique_ptr<Action>(RawPtr));
211
20.7k
    return RawPtr;
212
20.7k
  }
clang::driver::LipoJobAction* clang::driver::Compilation::MakeAction<clang::driver::LipoJobAction, llvm::SmallVector<clang::driver::Action*, 3u>&, clang::driver::types::ID>(llvm::SmallVector<clang::driver::Action*, 3u>&, clang::driver::types::ID&&)
Line
Count
Source
208
28
  template <typename T, typename... Args> T *MakeAction(Args &&... Arg) {
209
28
    T *RawPtr = new T(std::forward<Args>(Arg)...);
210
28
    AllActions.push_back(std::unique_ptr<Action>(RawPtr));
211
28
    return RawPtr;
212
28
  }
clang::driver::DsymutilJobAction* clang::driver::Compilation::MakeAction<clang::driver::DsymutilJobAction, llvm::SmallVector<clang::driver::Action*, 3u>&, clang::driver::types::ID>(llvm::SmallVector<clang::driver::Action*, 3u>&, clang::driver::types::ID&&)
Line
Count
Source
208
69
  template <typename T, typename... Args> T *MakeAction(Args &&... Arg) {
209
69
    T *RawPtr = new T(std::forward<Args>(Arg)...);
210
69
    AllActions.push_back(std::unique_ptr<Action>(RawPtr));
211
69
    return RawPtr;
212
69
  }
clang::driver::VerifyDebugInfoJobAction* clang::driver::Compilation::MakeAction<clang::driver::VerifyDebugInfoJobAction, clang::driver::Action*&, clang::driver::types::ID>(clang::driver::Action*&, clang::driver::types::ID&&)
Line
Count
Source
208
3
  template <typename T, typename... Args> T *MakeAction(Args &&... Arg) {
209
3
    T *RawPtr = new T(std::forward<Args>(Arg)...);
210
3
    AllActions.push_back(std::unique_ptr<Action>(RawPtr));
211
3
    return RawPtr;
212
3
  }
clang::driver::OffloadAction* clang::driver::Compilation::MakeAction<clang::driver::OffloadAction, clang::driver::OffloadAction::DeviceDependences&, clang::driver::types::ID>(clang::driver::OffloadAction::DeviceDependences&, clang::driver::types::ID&&)
Line
Count
Source
208
592
  template <typename T, typename... Args> T *MakeAction(Args &&... Arg) {
209
592
    T *RawPtr = new T(std::forward<Args>(Arg)...);
210
592
    AllActions.push_back(std::unique_ptr<Action>(RawPtr));
211
592
    return RawPtr;
212
592
  }
clang::driver::LinkJobAction* clang::driver::Compilation::MakeAction<clang::driver::LinkJobAction, llvm::SmallVector<clang::driver::Action*, 3u>&, clang::driver::types::ID>(llvm::SmallVector<clang::driver::Action*, 3u>&, clang::driver::types::ID&&)
Line
Count
Source
208
7.75k
  template <typename T, typename... Args> T *MakeAction(Args &&... Arg) {
209
7.75k
    T *RawPtr = new T(std::forward<Args>(Arg)...);
210
7.75k
    AllActions.push_back(std::unique_ptr<Action>(RawPtr));
211
7.75k
    return RawPtr;
212
7.75k
  }
clang::driver::BackendJobAction* clang::driver::Compilation::MakeAction<clang::driver::BackendJobAction, clang::driver::Action*&, clang::driver::types::ID&>(clang::driver::Action*&, clang::driver::types::ID&)
Line
Count
Source
208
946
  template <typename T, typename... Args> T *MakeAction(Args &&... Arg) {
209
946
    T *RawPtr = new T(std::forward<Args>(Arg)...);
210
946
    AllActions.push_back(std::unique_ptr<Action>(RawPtr));
211
946
    return RawPtr;
212
946
  }
clang::driver::OffloadAction* clang::driver::Compilation::MakeAction<clang::driver::OffloadAction, clang::driver::OffloadAction::HostDependence&, clang::driver::OffloadAction::DeviceDependences&>(clang::driver::OffloadAction::HostDependence&, clang::driver::OffloadAction::DeviceDependences&)
Line
Count
Source
208
232
  template <typename T, typename... Args> T *MakeAction(Args &&... Arg) {
209
232
    T *RawPtr = new T(std::forward<Args>(Arg)...);
210
232
    AllActions.push_back(std::unique_ptr<Action>(RawPtr));
211
232
    return RawPtr;
212
232
  }
clang::driver::InputAction* clang::driver::Compilation::MakeAction<clang::driver::InputAction, llvm::opt::Arg const&, clang::driver::types::ID const&>(llvm::opt::Arg const&, clang::driver::types::ID const&)
Line
Count
Source
208
18
  template <typename T, typename... Args> T *MakeAction(Args &&... Arg) {
209
18
    T *RawPtr = new T(std::forward<Args>(Arg)...);
210
18
    AllActions.push_back(std::unique_ptr<Action>(RawPtr));
211
18
    return RawPtr;
212
18
  }
clang::driver::InputAction* clang::driver::Compilation::MakeAction<clang::driver::InputAction, llvm::opt::Arg const&, clang::driver::types::ID&>(llvm::opt::Arg const&, clang::driver::types::ID&)
Line
Count
Source
208
50.4k
  template <typename T, typename... Args> T *MakeAction(Args &&... Arg) {
209
50.4k
    T *RawPtr = new T(std::forward<Args>(Arg)...);
210
50.4k
    AllActions.push_back(std::unique_ptr<Action>(RawPtr));
211
50.4k
    return RawPtr;
212
50.4k
  }
clang::driver::StaticLibJobAction* clang::driver::Compilation::MakeAction<clang::driver::StaticLibJobAction, llvm::SmallVector<clang::driver::Action*, 3u>&, clang::driver::types::ID>(llvm::SmallVector<clang::driver::Action*, 3u>&, clang::driver::types::ID&&)
Line
Count
Source
208
10
  template <typename T, typename... Args> T *MakeAction(Args &&... Arg) {
209
10
    T *RawPtr = new T(std::forward<Args>(Arg)...);
210
10
    AllActions.push_back(std::unique_ptr<Action>(RawPtr));
211
10
    return RawPtr;
212
10
  }
clang::driver::LinkerWrapperJobAction* clang::driver::Compilation::MakeAction<clang::driver::LinkerWrapperJobAction, llvm::SmallVector<clang::driver::Action*, 3u>&, clang::driver::types::ID>(llvm::SmallVector<clang::driver::Action*, 3u>&, clang::driver::types::ID&&)
Line
Count
Source
208
8
  template <typename T, typename... Args> T *MakeAction(Args &&... Arg) {
209
8
    T *RawPtr = new T(std::forward<Args>(Arg)...);
210
8
    AllActions.push_back(std::unique_ptr<Action>(RawPtr));
211
8
    return RawPtr;
212
8
  }
clang::driver::IfsMergeJobAction* clang::driver::Compilation::MakeAction<clang::driver::IfsMergeJobAction, llvm::SmallVector<clang::driver::Action*, 3u>&, clang::driver::types::ID>(llvm::SmallVector<clang::driver::Action*, 3u>&, clang::driver::types::ID&&)
Line
Count
Source
208
23
  template <typename T, typename... Args> T *MakeAction(Args &&... Arg) {
209
23
    T *RawPtr = new T(std::forward<Args>(Arg)...);
210
23
    AllActions.push_back(std::unique_ptr<Action>(RawPtr));
211
23
    return RawPtr;
212
23
  }
clang::driver::CompileJobAction* clang::driver::Compilation::MakeAction<clang::driver::CompileJobAction, clang::driver::Action*&, clang::driver::types::ID>(clang::driver::Action*&, clang::driver::types::ID&&)
Line
Count
Source
208
43.9k
  template <typename T, typename... Args> T *MakeAction(Args &&... Arg) {
209
43.9k
    T *RawPtr = new T(std::forward<Args>(Arg)...);
210
43.9k
    AllActions.push_back(std::unique_ptr<Action>(RawPtr));
211
43.9k
    return RawPtr;
212
43.9k
  }
clang::driver::InputAction* clang::driver::Compilation::MakeAction<clang::driver::InputAction, llvm::opt::Arg&, clang::driver::types::ID>(llvm::opt::Arg&, clang::driver::types::ID&&)
Line
Count
Source
208
4
  template <typename T, typename... Args> T *MakeAction(Args &&... Arg) {
209
4
    T *RawPtr = new T(std::forward<Args>(Arg)...);
210
4
    AllActions.push_back(std::unique_ptr<Action>(RawPtr));
211
4
    return RawPtr;
212
4
  }
clang::driver::PrecompileJobAction* clang::driver::Compilation::MakeAction<clang::driver::PrecompileJobAction, clang::driver::Action*&, clang::driver::types::ID>(clang::driver::Action*&, clang::driver::types::ID&&)
Line
Count
Source
208
4
  template <typename T, typename... Args> T *MakeAction(Args &&... Arg) {
209
4
    T *RawPtr = new T(std::forward<Args>(Arg)...);
210
4
    AllActions.push_back(std::unique_ptr<Action>(RawPtr));
211
4
    return RawPtr;
212
4
  }
clang::driver::OffloadPackagerJobAction* clang::driver::Compilation::MakeAction<clang::driver::OffloadPackagerJobAction, llvm::SmallVector<clang::driver::Action*, 3u>&, clang::driver::types::ID>(llvm::SmallVector<clang::driver::Action*, 3u>&, clang::driver::types::ID&&)
Line
Count
Source
208
9
  template <typename T, typename... Args> T *MakeAction(Args &&... Arg) {
209
9
    T *RawPtr = new T(std::forward<Args>(Arg)...);
210
9
    AllActions.push_back(std::unique_ptr<Action>(RawPtr));
211
9
    return RawPtr;
212
9
  }
clang::driver::PreprocessJobAction* clang::driver::Compilation::MakeAction<clang::driver::PreprocessJobAction, clang::driver::Action*&, clang::driver::types::ID&>(clang::driver::Action*&, clang::driver::types::ID&)
Line
Count
Source
208
45.6k
  template <typename T, typename... Args> T *MakeAction(Args &&... Arg) {
209
45.6k
    T *RawPtr = new T(std::forward<Args>(Arg)...);
210
45.6k
    AllActions.push_back(std::unique_ptr<Action>(RawPtr));
211
45.6k
    return RawPtr;
212
45.6k
  }
clang::driver::ExtractAPIJobAction* clang::driver::Compilation::MakeAction<clang::driver::ExtractAPIJobAction, clang::driver::Action*&, clang::driver::types::ID>(clang::driver::Action*&, clang::driver::types::ID&&)
Line
Count
Source
208
17
  template <typename T, typename... Args> T *MakeAction(Args &&... Arg) {
209
17
    T *RawPtr = new T(std::forward<Args>(Arg)...);
210
17
    AllActions.push_back(std::unique_ptr<Action>(RawPtr));
211
17
    return RawPtr;
212
17
  }
clang::driver::HeaderModulePrecompileJobAction* clang::driver::Compilation::MakeAction<clang::driver::HeaderModulePrecompileJobAction, clang::driver::Action*&, clang::driver::types::ID&, char const*&>(clang::driver::Action*&, clang::driver::types::ID&, char const*&)
Line
Count
Source
208
3
  template <typename T, typename... Args> T *MakeAction(Args &&... Arg) {
209
3
    T *RawPtr = new T(std::forward<Args>(Arg)...);
210
3
    AllActions.push_back(std::unique_ptr<Action>(RawPtr));
211
3
    return RawPtr;
212
3
  }
clang::driver::PrecompileJobAction* clang::driver::Compilation::MakeAction<clang::driver::PrecompileJobAction, clang::driver::Action*&, clang::driver::types::ID&>(clang::driver::Action*&, clang::driver::types::ID&)
Line
Count
Source
208
91
  template <typename T, typename... Args> T *MakeAction(Args &&... Arg) {
209
91
    T *RawPtr = new T(std::forward<Args>(Arg)...);
210
91
    AllActions.push_back(std::unique_ptr<Action>(RawPtr));
211
91
    return RawPtr;
212
91
  }
clang::driver::AnalyzeJobAction* clang::driver::Compilation::MakeAction<clang::driver::AnalyzeJobAction, clang::driver::Action*&, clang::driver::types::ID>(clang::driver::Action*&, clang::driver::types::ID&&)
Line
Count
Source
208
57
  template <typename T, typename... Args> T *MakeAction(Args &&... Arg) {
209
57
    T *RawPtr = new T(std::forward<Args>(Arg)...);
210
57
    AllActions.push_back(std::unique_ptr<Action>(RawPtr));
211
57
    return RawPtr;
212
57
  }
Unexecuted instantiation: clang::driver::MigrateJobAction* clang::driver::Compilation::MakeAction<clang::driver::MigrateJobAction, clang::driver::Action*&, clang::driver::types::ID>(clang::driver::Action*&, clang::driver::types::ID&&)
clang::driver::VerifyPCHJobAction* clang::driver::Compilation::MakeAction<clang::driver::VerifyPCHJobAction, clang::driver::Action*&, clang::driver::types::ID>(clang::driver::Action*&, clang::driver::types::ID&&)
Line
Count
Source
208
2
  template <typename T, typename... Args> T *MakeAction(Args &&... Arg) {
209
2
    T *RawPtr = new T(std::forward<Args>(Arg)...);
210
2
    AllActions.push_back(std::unique_ptr<Action>(RawPtr));
211
2
    return RawPtr;
212
2
  }
clang::driver::BackendJobAction* clang::driver::Compilation::MakeAction<clang::driver::BackendJobAction, clang::driver::Action*&, clang::driver::types::ID>(clang::driver::Action*&, clang::driver::types::ID&&)
Line
Count
Source
208
12.3k
  template <typename T, typename... Args> T *MakeAction(Args &&... Arg) {
209
12.3k
    T *RawPtr = new T(std::forward<Args>(Arg)...);
210
12.3k
    AllActions.push_back(std::unique_ptr<Action>(RawPtr));
211
12.3k
    return RawPtr;
212
12.3k
  }
clang::driver::AssembleJobAction* clang::driver::Compilation::MakeAction<clang::driver::AssembleJobAction, clang::driver::Action*, clang::driver::types::ID>(clang::driver::Action*&&, clang::driver::types::ID&&)
Line
Count
Source
208
11.9k
  template <typename T, typename... Args> T *MakeAction(Args &&... Arg) {
209
11.9k
    T *RawPtr = new T(std::forward<Args>(Arg)...);
210
11.9k
    AllActions.push_back(std::unique_ptr<Action>(RawPtr));
211
11.9k
    return RawPtr;
212
11.9k
  }
213
214
156k
  JobList &getJobs() { return Jobs; }
215
3
  const JobList &getJobs() const { return Jobs; }
216
217
54.7k
  void addCommand(std::unique_ptr<Command> C) { Jobs.addJob(std::move(C)); }
218
219
38
  const llvm::opt::ArgStringList &getTempFiles() const { return TempFiles; }
220
221
282
  const ArgStringMap &getResultFiles() const { return ResultFiles; }
222
223
0
  const ArgStringMap &getFailureResultFiles() const {
224
0
    return FailureResultFiles;
225
0
  }
226
227
  /// Installs a handler that is executed when a compilation job is finished.
228
  /// The arguments of the callback specify the compilation job as an instance
229
  /// of class Command and the exit status of the child process executed that
230
  /// job.
231
5
  void setPostCallback(const std::function<void(const Command &, int)> &CB) {
232
5
    PostCallback = CB;
233
5
  }
234
235
  /// Returns the sysroot path.
236
  StringRef getSysRoot() const;
237
238
  /// getArgsForToolChain - Return the derived argument list for the
239
  /// tool chain \p TC (or the default tool chain, if TC is not specified).
240
  /// If a device offloading kind is specified, a translation specific for that
241
  /// kind is performed, if any.
242
  ///
243
  /// \param BoundArch - The bound architecture name, or 0.
244
  /// \param DeviceOffloadKind - The offload device kind that should be used in
245
  /// the translation, if any.
246
  const llvm::opt::DerivedArgList &
247
  getArgsForToolChain(const ToolChain *TC, StringRef BoundArch,
248
                      Action::OffloadKind DeviceOffloadKind);
249
250
  /// addTempFile - Add a file to remove on exit, and returns its
251
  /// argument.
252
5.88k
  const char *addTempFile(const char *Name) {
253
5.88k
    TempFiles.push_back(Name);
254
5.88k
    return Name;
255
5.88k
  }
256
257
  /// addResultFile - Add a file to remove on failure, and returns its
258
  /// argument.
259
18.2k
  const char *addResultFile(const char *Name, const JobAction *JA) {
260
18.2k
    ResultFiles[JA] = Name;
261
18.2k
    return Name;
262
18.2k
  }
263
264
  /// addFailureResultFile - Add a file to remove if we crash, and returns its
265
  /// argument.
266
3.40k
  const char *addFailureResultFile(const char *Name, const JobAction *JA) {
267
3.40k
    FailureResultFiles[JA] = Name;
268
3.40k
    return Name;
269
3.40k
  }
270
271
  /// CleanupFile - Delete a given file.
272
  ///
273
  /// \param IssueErrors - Report failures as errors.
274
  /// \return Whether the file was removed successfully.
275
  bool CleanupFile(const char *File, bool IssueErrors = false) const;
276
277
  /// CleanupFileList - Remove the files in the given list.
278
  ///
279
  /// \param IssueErrors - Report failures as errors.
280
  /// \return Whether all files were removed successfully.
281
  bool CleanupFileList(const llvm::opt::ArgStringList &Files,
282
                       bool IssueErrors = false) const;
283
284
  /// CleanupFileMap - Remove the files in the given map.
285
  ///
286
  /// \param JA - If specified, only delete the files associated with this
287
  /// JobAction.  Otherwise, delete all files in the map.
288
  /// \param IssueErrors - Report failures as errors.
289
  /// \return Whether all files were removed successfully.
290
  bool CleanupFileMap(const ArgStringMap &Files,
291
                      const JobAction *JA,
292
                      bool IssueErrors = false) const;
293
294
  /// ExecuteCommand - Execute an actual command.
295
  ///
296
  /// \param FailingCommand - For non-zero results, this will be set to the
297
  /// Command which failed, if any.
298
  /// \param LogOnly - When true, only tries to log the command, not actually
299
  /// execute it.
300
  /// \return The result code of the subprocess.
301
  int ExecuteCommand(const Command &C, const Command *&FailingCommand,
302
                     bool LogOnly = false) const;
303
304
  /// ExecuteJob - Execute a single job.
305
  ///
306
  /// \param FailingCommands - For non-zero results, this will be a vector of
307
  /// failing commands and their associated result code.
308
  /// \param LogOnly - When true, only tries to log the command, not actually
309
  /// execute it.
310
  void
311
  ExecuteJobs(const JobList &Jobs,
312
              SmallVectorImpl<std::pair<int, const Command *>> &FailingCommands,
313
              bool LogOnly = false) const;
314
315
  /// initCompilationForDiagnostics - Remove stale state and suppress output
316
  /// so compilation can be reexecuted to generate additional diagnostic
317
  /// information (e.g., preprocessed source(s)).
318
  void initCompilationForDiagnostics();
319
320
  /// Return true if we're compiling for diagnostics.
321
96.4k
  bool isForDiagnostics() const { return ForDiagnostics; }
322
323
  /// Return whether an error during the parsing of the input args.
324
19.8k
  bool containsError() const { return ContainsError; }
325
326
  /// Force driver to fail before toolchain is created. This is necessary when
327
  /// error happens in action builder.
328
12
  void setContainsError() { ContainsError = true; }
329
330
  /// Redirect - Redirect output of this compilation. Can only be done once.
331
  ///
332
  /// \param Redirects - array of optional paths. The array should have a size
333
  /// of three. The inferior process's stdin(0), stdout(1), and stderr(2) will
334
  /// be redirected to the corresponding paths, if provided (not llvm::None).
335
  void Redirect(ArrayRef<Optional<StringRef>> Redirects);
336
};
337
338
} // namespace driver
339
} // namespace clang
340
341
#endif // LLVM_CLANG_DRIVER_COMPILATION_H