Coverage Report

Created: 2021-08-24 07:12

/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
106k
        : TC(TC), BoundArch(BoundArch), DeviceOffloadKind(DeviceOffloadKind) {}
91
92
129k
    bool operator<(const TCArgsKey &K) const {
93
129k
      if (TC < K.TC)
94
2.73k
        return true;
95
126k
      else if (TC == K.TC && 
BoundArch < K.BoundArch125k
)
96
3.03k
        return true;
97
123k
      else if (TC == K.TC && 
BoundArch == K.BoundArch122k
&&
98
123k
               
DeviceOffloadKind < K.DeviceOffloadKind120k
)
99
948
        return true;
100
122k
      return false;
101
129k
    }
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
301k
  const Driver &getDriver() const { return TheDriver; }
139
140
275k
  const ToolChain &getDefaultToolChain() const { return DefaultToolChain; }
141
142
0
  unsigned isOffloadingHostKind(Action::OffloadKind Kind) const {
143
0
    return ActiveOffloadMask & Kind;
144
0
  }
145
146
  /// Iterator that visits device toolchains of a given kind.
147
  using const_offload_toolchains_iterator =
148
      const std::multimap<Action::OffloadKind,
149
                          const ToolChain *>::const_iterator;
150
  using const_offload_toolchains_range =
151
      std::pair<const_offload_toolchains_iterator,
152
                const_offload_toolchains_iterator>;
153
154
  template <Action::OffloadKind Kind>
155
50.9k
  const_offload_toolchains_range getOffloadToolChains() const {
156
50.9k
    return OrderedOffloadingToolchains.equal_range(Kind);
157
50.9k
  }
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
155
3.32k
  const_offload_toolchains_range getOffloadToolChains() const {
156
3.32k
    return OrderedOffloadingToolchains.equal_range(Kind);
157
3.32k
  }
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
155
1.00k
  const_offload_toolchains_range getOffloadToolChains() const {
156
1.00k
    return OrderedOffloadingToolchains.equal_range(Kind);
157
1.00k
  }
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
155
816
  const_offload_toolchains_range getOffloadToolChains() const {
156
816
    return OrderedOffloadingToolchains.equal_range(Kind);
157
816
  }
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
155
45.7k
  const_offload_toolchains_range getOffloadToolChains() const {
156
45.7k
    return OrderedOffloadingToolchains.equal_range(Kind);
157
45.7k
  }
158
159
  /// Return true if an offloading tool chain of a given kind exists.
160
91.3k
  template <Action::OffloadKind Kind> bool hasOffloadToolChain() const {
161
91.3k
    return OrderedOffloadingToolchains.find(Kind) !=
162
91.3k
           OrderedOffloadingToolchains.end();
163
91.3k
  }
bool clang::driver::Compilation::hasOffloadToolChain<(clang::driver::Action::OffloadKind)2>() const
Line
Count
Source
160
45.6k
  template <Action::OffloadKind Kind> bool hasOffloadToolChain() const {
161
45.6k
    return OrderedOffloadingToolchains.find(Kind) !=
162
45.6k
           OrderedOffloadingToolchains.end();
163
45.6k
  }
bool clang::driver::Compilation::hasOffloadToolChain<(clang::driver::Action::OffloadKind)8>() const
Line
Count
Source
160
45.6k
  template <Action::OffloadKind Kind> bool hasOffloadToolChain() const {
161
45.6k
    return OrderedOffloadingToolchains.find(Kind) !=
162
45.6k
           OrderedOffloadingToolchains.end();
163
45.6k
  }
164
165
  /// Return an offload toolchain of the provided kind. Only one is expected to
166
  /// exist.
167
  template <Action::OffloadKind Kind>
168
5.15k
  const ToolChain *getSingleOffloadToolChain() const {
169
5.15k
    auto TCs = getOffloadToolChains<Kind>();
170
171
5.15k
    assert(TCs.first != TCs.second &&
172
5.15k
           "No tool chains of the selected kind exist!");
173
0
    assert(std::next(TCs.first) == TCs.second &&
174
5.15k
           "More than one tool chain of the this kind exist.");
175
0
    return TCs.first->second;
176
5.15k
  }
clang::driver::ToolChain const* clang::driver::Compilation::getSingleOffloadToolChain<(clang::driver::Action::OffloadKind)1>() const
Line
Count
Source
168
3.32k
  const ToolChain *getSingleOffloadToolChain() const {
169
3.32k
    auto TCs = getOffloadToolChains<Kind>();
170
171
3.32k
    assert(TCs.first != TCs.second &&
172
3.32k
           "No tool chains of the selected kind exist!");
173
0
    assert(std::next(TCs.first) == TCs.second &&
174
3.32k
           "More than one tool chain of the this kind exist.");
175
0
    return TCs.first->second;
176
3.32k
  }
clang::driver::ToolChain const* clang::driver::Compilation::getSingleOffloadToolChain<(clang::driver::Action::OffloadKind)2>() const
Line
Count
Source
168
1.00k
  const ToolChain *getSingleOffloadToolChain() const {
169
1.00k
    auto TCs = getOffloadToolChains<Kind>();
170
171
1.00k
    assert(TCs.first != TCs.second &&
172
1.00k
           "No tool chains of the selected kind exist!");
173
0
    assert(std::next(TCs.first) == TCs.second &&
174
1.00k
           "More than one tool chain of the this kind exist.");
175
0
    return TCs.first->second;
176
1.00k
  }
clang::driver::ToolChain const* clang::driver::Compilation::getSingleOffloadToolChain<(clang::driver::Action::OffloadKind)8>() const
Line
Count
Source
168
816
  const ToolChain *getSingleOffloadToolChain() const {
169
816
    auto TCs = getOffloadToolChains<Kind>();
170
171
816
    assert(TCs.first != TCs.second &&
172
816
           "No tool chains of the selected kind exist!");
173
0
    assert(std::next(TCs.first) == TCs.second &&
174
816
           "More than one tool chain of the this kind exist.");
175
0
    return TCs.first->second;
176
816
  }
177
178
  void addOffloadDeviceToolChain(const ToolChain *DeviceToolChain,
179
620
                                 Action::OffloadKind OffloadKind) {
180
620
    assert(OffloadKind != Action::OFK_Host && OffloadKind != Action::OFK_None &&
181
620
           "This is not a device tool chain!");
182
183
    // Update the host offload kind to also contain this kind.
184
0
    ActiveOffloadMask |= OffloadKind;
185
620
    OrderedOffloadingToolchains.insert(
186
620
        std::make_pair(OffloadKind, DeviceToolChain));
187
620
  }
188
189
91.9k
  const llvm::opt::InputArgList &getInputArgs() const { return *Args; }
190
191
1.42M
  const llvm::opt::DerivedArgList &getArgs() const { return *TranslatedArgs; }
192
193
468k
  llvm::opt::DerivedArgList &getArgs() { return *TranslatedArgs; }
194
195
111k
  ActionList &getActions() { return Actions; }
196
80
  const ActionList &getActions() const { return Actions; }
197
198
  /// Creates a new Action owned by this Compilation.
199
  ///
200
  /// The new Action is *not* added to the list returned by getActions().
201
185k
  template <typename T, typename... Args> T *MakeAction(Args &&... Arg) {
202
185k
    T *RawPtr = new T(std::forward<Args>(Arg)...);
203
185k
    AllActions.push_back(std::unique_ptr<Action>(RawPtr));
204
185k
    return RawPtr;
205
185k
  }
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
201
933
  template <typename T, typename... Args> T *MakeAction(Args &&... Arg) {
202
933
    T *RawPtr = new T(std::forward<Args>(Arg)...);
203
933
    AllActions.push_back(std::unique_ptr<Action>(RawPtr));
204
933
    return RawPtr;
205
933
  }
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
201
568
  template <typename T, typename... Args> T *MakeAction(Args &&... Arg) {
202
568
    T *RawPtr = new T(std::forward<Args>(Arg)...);
203
568
    AllActions.push_back(std::unique_ptr<Action>(RawPtr));
204
568
    return RawPtr;
205
568
  }
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
201
47
  template <typename T, typename... Args> T *MakeAction(Args &&... Arg) {
202
47
    T *RawPtr = new T(std::forward<Args>(Arg)...);
203
47
    AllActions.push_back(std::unique_ptr<Action>(RawPtr));
204
47
    return RawPtr;
205
47
  }
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
201
105
  template <typename T, typename... Args> T *MakeAction(Args &&... Arg) {
202
105
    T *RawPtr = new T(std::forward<Args>(Arg)...);
203
105
    AllActions.push_back(std::unique_ptr<Action>(RawPtr));
204
105
    return RawPtr;
205
105
  }
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
201
404
  template <typename T, typename... Args> T *MakeAction(Args &&... Arg) {
202
404
    T *RawPtr = new T(std::forward<Args>(Arg)...);
203
404
    AllActions.push_back(std::unique_ptr<Action>(RawPtr));
204
404
    return RawPtr;
205
404
  }
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
201
80
  template <typename T, typename... Args> T *MakeAction(Args &&... Arg) {
202
80
    T *RawPtr = new T(std::forward<Args>(Arg)...);
203
80
    AllActions.push_back(std::unique_ptr<Action>(RawPtr));
204
80
    return RawPtr;
205
80
  }
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
201
80
  template <typename T, typename... Args> T *MakeAction(Args &&... Arg) {
202
80
    T *RawPtr = new T(std::forward<Args>(Arg)...);
203
80
    AllActions.push_back(std::unique_ptr<Action>(RawPtr));
204
80
    return RawPtr;
205
80
  }
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
201
80
  template <typename T, typename... Args> T *MakeAction(Args &&... Arg) {
202
80
    T *RawPtr = new T(std::forward<Args>(Arg)...);
203
80
    AllActions.push_back(std::unique_ptr<Action>(RawPtr));
204
80
    return RawPtr;
205
80
  }
clang::driver::OffloadUnbundlingJobAction* clang::driver::Compilation::MakeAction<clang::driver::OffloadUnbundlingJobAction, clang::driver::Action*&>(clang::driver::Action*&)
Line
Count
Source
201
42
  template <typename T, typename... Args> T *MakeAction(Args &&... Arg) {
202
42
    T *RawPtr = new T(std::forward<Args>(Arg)...);
203
42
    AllActions.push_back(std::unique_ptr<Action>(RawPtr));
204
42
    return RawPtr;
205
42
  }
clang::driver::BindArchAction* clang::driver::Compilation::MakeAction<clang::driver::BindArchAction, clang::driver::Action*&, char const*&>(clang::driver::Action*&, char const*&)
Line
Count
Source
201
19.1k
  template <typename T, typename... Args> T *MakeAction(Args &&... Arg) {
202
19.1k
    T *RawPtr = new T(std::forward<Args>(Arg)...);
203
19.1k
    AllActions.push_back(std::unique_ptr<Action>(RawPtr));
204
19.1k
    return RawPtr;
205
19.1k
  }
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
201
17
  template <typename T, typename... Args> T *MakeAction(Args &&... Arg) {
202
17
    T *RawPtr = new T(std::forward<Args>(Arg)...);
203
17
    AllActions.push_back(std::unique_ptr<Action>(RawPtr));
204
17
    return RawPtr;
205
17
  }
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
201
95
  template <typename T, typename... Args> T *MakeAction(Args &&... Arg) {
202
95
    T *RawPtr = new T(std::forward<Args>(Arg)...);
203
95
    AllActions.push_back(std::unique_ptr<Action>(RawPtr));
204
95
    return RawPtr;
205
95
  }
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
201
3
  template <typename T, typename... Args> T *MakeAction(Args &&... Arg) {
202
3
    T *RawPtr = new T(std::forward<Args>(Arg)...);
203
3
    AllActions.push_back(std::unique_ptr<Action>(RawPtr));
204
3
    return RawPtr;
205
3
  }
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
201
7.75k
  template <typename T, typename... Args> T *MakeAction(Args &&... Arg) {
202
7.75k
    T *RawPtr = new T(std::forward<Args>(Arg)...);
203
7.75k
    AllActions.push_back(std::unique_ptr<Action>(RawPtr));
204
7.75k
    return RawPtr;
205
7.75k
  }
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
201
18
  template <typename T, typename... Args> T *MakeAction(Args &&... Arg) {
202
18
    T *RawPtr = new T(std::forward<Args>(Arg)...);
203
18
    AllActions.push_back(std::unique_ptr<Action>(RawPtr));
204
18
    return RawPtr;
205
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
201
47.2k
  template <typename T, typename... Args> T *MakeAction(Args &&... Arg) {
202
47.2k
    T *RawPtr = new T(std::forward<Args>(Arg)...);
203
47.2k
    AllActions.push_back(std::unique_ptr<Action>(RawPtr));
204
47.2k
    return RawPtr;
205
47.2k
  }
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
201
7
  template <typename T, typename... Args> T *MakeAction(Args &&... Arg) {
202
7
    T *RawPtr = new T(std::forward<Args>(Arg)...);
203
7
    AllActions.push_back(std::unique_ptr<Action>(RawPtr));
204
7
    return RawPtr;
205
7
  }
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
201
24
  template <typename T, typename... Args> T *MakeAction(Args &&... Arg) {
202
24
    T *RawPtr = new T(std::forward<Args>(Arg)...);
203
24
    AllActions.push_back(std::unique_ptr<Action>(RawPtr));
204
24
    return RawPtr;
205
24
  }
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
201
41.3k
  template <typename T, typename... Args> T *MakeAction(Args &&... Arg) {
202
41.3k
    T *RawPtr = new T(std::forward<Args>(Arg)...);
203
41.3k
    AllActions.push_back(std::unique_ptr<Action>(RawPtr));
204
41.3k
    return RawPtr;
205
41.3k
  }
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
201
4
  template <typename T, typename... Args> T *MakeAction(Args &&... Arg) {
202
4
    T *RawPtr = new T(std::forward<Args>(Arg)...);
203
4
    AllActions.push_back(std::unique_ptr<Action>(RawPtr));
204
4
    return RawPtr;
205
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
201
4
  template <typename T, typename... Args> T *MakeAction(Args &&... Arg) {
202
4
    T *RawPtr = new T(std::forward<Args>(Arg)...);
203
4
    AllActions.push_back(std::unique_ptr<Action>(RawPtr));
204
4
    return RawPtr;
205
4
  }
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
201
42.8k
  template <typename T, typename... Args> T *MakeAction(Args &&... Arg) {
202
42.8k
    T *RawPtr = new T(std::forward<Args>(Arg)...);
203
42.8k
    AllActions.push_back(std::unique_ptr<Action>(RawPtr));
204
42.8k
    return RawPtr;
205
42.8k
  }
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
201
3
  template <typename T, typename... Args> T *MakeAction(Args &&... Arg) {
202
3
    T *RawPtr = new T(std::forward<Args>(Arg)...);
203
3
    AllActions.push_back(std::unique_ptr<Action>(RawPtr));
204
3
    return RawPtr;
205
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
201
74
  template <typename T, typename... Args> T *MakeAction(Args &&... Arg) {
202
74
    T *RawPtr = new T(std::forward<Args>(Arg)...);
203
74
    AllActions.push_back(std::unique_ptr<Action>(RawPtr));
204
74
    return RawPtr;
205
74
  }
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
201
44
  template <typename T, typename... Args> T *MakeAction(Args &&... Arg) {
202
44
    T *RawPtr = new T(std::forward<Args>(Arg)...);
203
44
    AllActions.push_back(std::unique_ptr<Action>(RawPtr));
204
44
    return RawPtr;
205
44
  }
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
201
2
  template <typename T, typename... Args> T *MakeAction(Args &&... Arg) {
202
2
    T *RawPtr = new T(std::forward<Args>(Arg)...);
203
2
    AllActions.push_back(std::unique_ptr<Action>(RawPtr));
204
2
    return RawPtr;
205
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
201
940
  template <typename T, typename... Args> T *MakeAction(Args &&... Arg) {
202
940
    T *RawPtr = new T(std::forward<Args>(Arg)...);
203
940
    AllActions.push_back(std::unique_ptr<Action>(RawPtr));
204
940
    return RawPtr;
205
940
  }
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
201
11.9k
  template <typename T, typename... Args> T *MakeAction(Args &&... Arg) {
202
11.9k
    T *RawPtr = new T(std::forward<Args>(Arg)...);
203
11.9k
    AllActions.push_back(std::unique_ptr<Action>(RawPtr));
204
11.9k
    return RawPtr;
205
11.9k
  }
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
201
11.5k
  template <typename T, typename... Args> T *MakeAction(Args &&... Arg) {
202
11.5k
    T *RawPtr = new T(std::forward<Args>(Arg)...);
203
11.5k
    AllActions.push_back(std::unique_ptr<Action>(RawPtr));
204
11.5k
    return RawPtr;
205
11.5k
  }
206
207
110k
  JobList &getJobs() { return Jobs; }
208
3
  const JobList &getJobs() const { return Jobs; }
209
210
52.4k
  void addCommand(std::unique_ptr<Command> C) { Jobs.addJob(std::move(C)); }
211
212
27
  const llvm::opt::ArgStringList &getTempFiles() const { return TempFiles; }
213
214
272
  const ArgStringMap &getResultFiles() const { return ResultFiles; }
215
216
0
  const ArgStringMap &getFailureResultFiles() const {
217
0
    return FailureResultFiles;
218
0
  }
219
220
  /// Installs a handler that is executed when a compilation job is finished.
221
  /// The arguments of the callback specify the compilation job as an instance
222
  /// of class Command and the exit status of the child process executed that
223
  /// job.
224
5
  void setPostCallback(const std::function<void(const Command &, int)> &CB) {
225
5
    PostCallback = CB;
226
5
  }
227
228
  /// Returns the sysroot path.
229
  StringRef getSysRoot() const;
230
231
  /// getArgsForToolChain - Return the derived argument list for the
232
  /// tool chain \p TC (or the default tool chain, if TC is not specified).
233
  /// If a device offloading kind is specified, a translation specific for that
234
  /// kind is performed, if any.
235
  ///
236
  /// \param BoundArch - The bound architecture name, or 0.
237
  /// \param DeviceOffloadKind - The offload device kind that should be used in
238
  /// the translation, if any.
239
  const llvm::opt::DerivedArgList &
240
  getArgsForToolChain(const ToolChain *TC, StringRef BoundArch,
241
                      Action::OffloadKind DeviceOffloadKind);
242
243
  /// addTempFile - Add a file to remove on exit, and returns its
244
  /// argument.
245
6.41k
  const char *addTempFile(const char *Name) {
246
6.41k
    TempFiles.push_back(Name);
247
6.41k
    return Name;
248
6.41k
  }
249
250
  /// addResultFile - Add a file to remove on failure, and returns its
251
  /// argument.
252
17.6k
  const char *addResultFile(const char *Name, const JobAction *JA) {
253
17.6k
    ResultFiles[JA] = Name;
254
17.6k
    return Name;
255
17.6k
  }
256
257
  /// addFailureResultFile - Add a file to remove if we crash, and returns its
258
  /// argument.
259
3.19k
  const char *addFailureResultFile(const char *Name, const JobAction *JA) {
260
3.19k
    FailureResultFiles[JA] = Name;
261
3.19k
    return Name;
262
3.19k
  }
263
264
  /// CleanupFile - Delete a given file.
265
  ///
266
  /// \param IssueErrors - Report failures as errors.
267
  /// \return Whether the file was removed successfully.
268
  bool CleanupFile(const char *File, bool IssueErrors = false) const;
269
270
  /// CleanupFileList - Remove the files in the given list.
271
  ///
272
  /// \param IssueErrors - Report failures as errors.
273
  /// \return Whether all files were removed successfully.
274
  bool CleanupFileList(const llvm::opt::ArgStringList &Files,
275
                       bool IssueErrors = false) const;
276
277
  /// CleanupFileMap - Remove the files in the given map.
278
  ///
279
  /// \param JA - If specified, only delete the files associated with this
280
  /// JobAction.  Otherwise, delete all files in the map.
281
  /// \param IssueErrors - Report failures as errors.
282
  /// \return Whether all files were removed successfully.
283
  bool CleanupFileMap(const ArgStringMap &Files,
284
                      const JobAction *JA,
285
                      bool IssueErrors = false) const;
286
287
  /// ExecuteCommand - Execute an actual command.
288
  ///
289
  /// \param FailingCommand - For non-zero results, this will be set to the
290
  /// Command which failed, if any.
291
  /// \return The result code of the subprocess.
292
  int ExecuteCommand(const Command &C, const Command *&FailingCommand) const;
293
294
  /// ExecuteJob - Execute a single job.
295
  ///
296
  /// \param FailingCommands - For non-zero results, this will be a vector of
297
  /// failing commands and their associated result code.
298
  void ExecuteJobs(
299
      const JobList &Jobs,
300
      SmallVectorImpl<std::pair<int, const Command *>> &FailingCommands) const;
301
302
  /// initCompilationForDiagnostics - Remove stale state and suppress output
303
  /// so compilation can be reexecuted to generate additional diagnostic
304
  /// information (e.g., preprocessed source(s)).
305
  void initCompilationForDiagnostics();
306
307
  /// Return true if we're compiling for diagnostics.
308
91.2k
  bool isForDiagnostics() const { return ForDiagnostics; }
309
310
  /// Return whether an error during the parsing of the input args.
311
18.8k
  bool containsError() const { return ContainsError; }
312
313
  /// Force driver to fail before toolchain is created. This is necessary when
314
  /// error happens in action builder.
315
12
  void setContainsError() { ContainsError = true; }
316
317
  /// Redirect - Redirect output of this compilation. Can only be done once.
318
  ///
319
  /// \param Redirects - array of optional paths. The array should have a size
320
  /// of three. The inferior process's stdin(0), stdout(1), and stderr(2) will
321
  /// be redirected to the corresponding paths, if provided (not llvm::None).
322
  void Redirect(ArrayRef<Optional<StringRef>> Redirects);
323
};
324
325
} // namespace driver
326
} // namespace clang
327
328
#endif // LLVM_CLANG_DRIVER_COMPILATION_H