Coverage Report

Created: 2018-09-25 23:22

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/tools/clang/include/clang/Driver/Compilation.h
Line
Count
Source (jump to first uncovered line)
1
//===- Compilation.h - Compilation Task Data Structure ----------*- C++ -*-===//
2
//
3
//                     The LLVM Compiler Infrastructure
4
//
5
// This file is distributed under the University of Illinois Open Source
6
// License. See LICENSE.TXT for details.
7
//
8
//===----------------------------------------------------------------------===//
9
10
#ifndef LLVM_CLANG_DRIVER_COMPILATION_H
11
#define LLVM_CLANG_DRIVER_COMPILATION_H
12
13
#include "clang/Basic/LLVM.h"
14
#include "clang/Driver/Action.h"
15
#include "clang/Driver/Job.h"
16
#include "clang/Driver/Util.h"
17
#include "llvm/ADT/ArrayRef.h"
18
#include "llvm/ADT/DenseMap.h"
19
#include "llvm/ADT/Optional.h"
20
#include "llvm/ADT/StringRef.h"
21
#include "llvm/Option/Option.h"
22
#include <cassert>
23
#include <iterator>
24
#include <map>
25
#include <memory>
26
#include <utility>
27
#include <vector>
28
29
namespace llvm {
30
namespace opt {
31
32
class DerivedArgList;
33
class InputArgList;
34
35
} // namespace opt
36
} // namespace llvm
37
38
namespace clang {
39
namespace driver {
40
41
class Driver;
42
class ToolChain;
43
44
/// Compilation - A set of tasks to perform for a single driver
45
/// invocation.
46
class Compilation {
47
  /// The driver we were created by.
48
  const Driver &TheDriver;
49
50
  /// The default tool chain.
51
  const ToolChain &DefaultToolChain;
52
53
  /// A mask of all the programming models the host has to support in the
54
  /// current compilation.
55
  unsigned ActiveOffloadMask = 0;
56
57
  /// Array with the toolchains of offloading host and devices in the order they
58
  /// were requested by the user. We are preserving that order in case the code
59
  /// generation needs to derive a programming-model-specific semantic out of
60
  /// it.
61
  std::multimap<Action::OffloadKind, const ToolChain *>
62
      OrderedOffloadingToolchains;
63
64
  /// The original (untranslated) input argument list.
65
  llvm::opt::InputArgList *Args;
66
67
  /// The driver translated arguments. Note that toolchains may perform their
68
  /// own argument translation.
69
  llvm::opt::DerivedArgList *TranslatedArgs;
70
71
  /// The list of actions we've created via MakeAction.  This is not accessible
72
  /// to consumers; it's here just to manage ownership.
73
  std::vector<std::unique_ptr<Action>> AllActions;
74
75
  /// The list of actions.  This is maintained and modified by consumers, via
76
  /// getActions().
77
  ActionList Actions;
78
79
  /// The root list of jobs.
80
  JobList Jobs;
81
82
  /// Cache of translated arguments for a particular tool chain, bound
83
  /// architecture, and device offload kind.
84
  struct TCArgsKey final {
85
    const ToolChain *TC = nullptr;
86
    StringRef BoundArch;
87
    Action::OffloadKind DeviceOffloadKind = Action::OFK_None;
88
89
    TCArgsKey(const ToolChain *TC, StringRef BoundArch,
90
              Action::OffloadKind DeviceOffloadKind)
91
69.2k
        : TC(TC), BoundArch(BoundArch), DeviceOffloadKind(DeviceOffloadKind) {}
92
93
92.1k
    bool operator<(const TCArgsKey &K) const {
94
92.1k
      if (TC < K.TC)
95
4.78k
        return true;
96
87.3k
      else if (TC == K.TC && 
BoundArch < K.BoundArch85.3k
)
97
4.50k
        return true;
98
82.8k
      else if (TC == K.TC && 
BoundArch == K.BoundArch80.8k
&&
99
82.8k
               
DeviceOffloadKind < K.DeviceOffloadKind79.2k
)
100
336
        return true;
101
82.5k
      return false;
102
82.5k
    }
103
  };
104
  std::map<TCArgsKey, llvm::opt::DerivedArgList *> TCArgs;
105
106
  /// Temporary files which should be removed on exit.
107
  llvm::opt::ArgStringList TempFiles;
108
109
  /// Result files which should be removed on failure.
110
  ArgStringMap ResultFiles;
111
112
  /// Result files which are generated correctly on failure, and which should
113
  /// only be removed if we crash.
114
  ArgStringMap FailureResultFiles;
115
116
  /// Optional redirection for stdin, stdout, stderr.
117
  std::vector<Optional<StringRef>> Redirects;
118
119
  /// Whether we're compiling for diagnostic purposes.
120
  bool ForDiagnostics = false;
121
122
  /// Whether an error during the parsing of the input args.
123
  bool ContainsError;
124
125
  /// Whether to keep temporary files regardless of -save-temps.
126
  bool ForceKeepTempFiles = false;
127
128
public:
129
  Compilation(const Driver &D, const ToolChain &DefaultToolChain,
130
              llvm::opt::InputArgList *Args,
131
              llvm::opt::DerivedArgList *TranslatedArgs, bool ContainsError);
132
  ~Compilation();
133
134
180k
  const Driver &getDriver() const { return TheDriver; }
135
136
187k
  const ToolChain &getDefaultToolChain() const { return DefaultToolChain; }
137
138
0
  unsigned isOffloadingHostKind(Action::OffloadKind Kind) const {
139
0
    return ActiveOffloadMask & Kind;
140
0
  }
141
142
  /// Iterator that visits device toolchains of a given kind.
143
  using const_offload_toolchains_iterator =
144
      const std::multimap<Action::OffloadKind,
145
                          const ToolChain *>::const_iterator;
146
  using const_offload_toolchains_range =
147
      std::pair<const_offload_toolchains_iterator,
148
                const_offload_toolchains_iterator>;
149
150
  template <Action::OffloadKind Kind>
151
29.8k
  const_offload_toolchains_range getOffloadToolChains() const {
152
29.8k
    return OrderedOffloadingToolchains.equal_range(Kind);
153
29.8k
  }
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
151
1.88k
  const_offload_toolchains_range getOffloadToolChains() const {
152
1.88k
    return OrderedOffloadingToolchains.equal_range(Kind);
153
1.88k
  }
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
151
833
  const_offload_toolchains_range getOffloadToolChains() const {
152
833
    return OrderedOffloadingToolchains.equal_range(Kind);
153
833
  }
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
151
36
  const_offload_toolchains_range getOffloadToolChains() const {
152
36
    return OrderedOffloadingToolchains.equal_range(Kind);
153
36
  }
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
151
27.1k
  const_offload_toolchains_range getOffloadToolChains() const {
152
27.1k
    return OrderedOffloadingToolchains.equal_range(Kind);
153
27.1k
  }
154
155
  /// Return true if an offloading tool chain of a given kind exists.
156
54.0k
  template <Action::OffloadKind Kind> bool hasOffloadToolChain() const {
157
54.0k
    return OrderedOffloadingToolchains.find(Kind) !=
158
54.0k
           OrderedOffloadingToolchains.end();
159
54.0k
  }
bool clang::driver::Compilation::hasOffloadToolChain<(clang::driver::Action::OffloadKind)2>() const
Line
Count
Source
156
27.0k
  template <Action::OffloadKind Kind> bool hasOffloadToolChain() const {
157
27.0k
    return OrderedOffloadingToolchains.find(Kind) !=
158
27.0k
           OrderedOffloadingToolchains.end();
159
27.0k
  }
bool clang::driver::Compilation::hasOffloadToolChain<(clang::driver::Action::OffloadKind)8>() const
Line
Count
Source
156
27.0k
  template <Action::OffloadKind Kind> bool hasOffloadToolChain() const {
157
27.0k
    return OrderedOffloadingToolchains.find(Kind) !=
158
27.0k
           OrderedOffloadingToolchains.end();
159
27.0k
  }
160
161
  /// Return an offload toolchain of the provided kind. Only one is expected to
162
  /// exist.
163
  template <Action::OffloadKind Kind>
164
2.75k
  const ToolChain *getSingleOffloadToolChain() const {
165
2.75k
    auto TCs = getOffloadToolChains<Kind>();
166
2.75k
167
2.75k
    assert(TCs.first != TCs.second &&
168
2.75k
           "No tool chains of the selected kind exist!");
169
2.75k
    assert(std::next(TCs.first) == TCs.second &&
170
2.75k
           "More than one tool chain of the this kind exist.");
171
2.75k
    return TCs.first->second;
172
2.75k
  }
clang::driver::ToolChain const* clang::driver::Compilation::getSingleOffloadToolChain<(clang::driver::Action::OffloadKind)1>() const
Line
Count
Source
164
1.88k
  const ToolChain *getSingleOffloadToolChain() const {
165
1.88k
    auto TCs = getOffloadToolChains<Kind>();
166
1.88k
167
1.88k
    assert(TCs.first != TCs.second &&
168
1.88k
           "No tool chains of the selected kind exist!");
169
1.88k
    assert(std::next(TCs.first) == TCs.second &&
170
1.88k
           "More than one tool chain of the this kind exist.");
171
1.88k
    return TCs.first->second;
172
1.88k
  }
clang::driver::ToolChain const* clang::driver::Compilation::getSingleOffloadToolChain<(clang::driver::Action::OffloadKind)2>() const
Line
Count
Source
164
833
  const ToolChain *getSingleOffloadToolChain() const {
165
833
    auto TCs = getOffloadToolChains<Kind>();
166
833
167
833
    assert(TCs.first != TCs.second &&
168
833
           "No tool chains of the selected kind exist!");
169
833
    assert(std::next(TCs.first) == TCs.second &&
170
833
           "More than one tool chain of the this kind exist.");
171
833
    return TCs.first->second;
172
833
  }
clang::driver::ToolChain const* clang::driver::Compilation::getSingleOffloadToolChain<(clang::driver::Action::OffloadKind)8>() const
Line
Count
Source
164
36
  const ToolChain *getSingleOffloadToolChain() const {
165
36
    auto TCs = getOffloadToolChains<Kind>();
166
36
167
36
    assert(TCs.first != TCs.second &&
168
36
           "No tool chains of the selected kind exist!");
169
36
    assert(std::next(TCs.first) == TCs.second &&
170
36
           "More than one tool chain of the this kind exist.");
171
36
    return TCs.first->second;
172
36
  }
173
174
  void addOffloadDeviceToolChain(const ToolChain *DeviceToolChain,
175
372
                                 Action::OffloadKind OffloadKind) {
176
372
    assert(OffloadKind != Action::OFK_Host && OffloadKind != Action::OFK_None &&
177
372
           "This is not a device tool chain!");
178
372
179
372
    // Update the host offload kind to also contain this kind.
180
372
    ActiveOffloadMask |= OffloadKind;
181
372
    OrderedOffloadingToolchains.insert(
182
372
        std::make_pair(OffloadKind, DeviceToolChain));
183
372
  }
184
185
54.5k
  const llvm::opt::InputArgList &getInputArgs() const { return *Args; }
186
187
763k
  const llvm::opt::DerivedArgList &getArgs() const { return *TranslatedArgs; }
188
189
414k
  llvm::opt::DerivedArgList &getArgs() { return *TranslatedArgs; }
190
191
74.6k
  ActionList &getActions() { return Actions; }
192
60
  const ActionList &getActions() const { return Actions; }
193
194
  /// Creates a new Action owned by this Compilation.
195
  ///
196
  /// The new Action is *not* added to the list returned by getActions().
197
145k
  template <typename T, typename... Args> T *MakeAction(Args &&... Arg) {
198
145k
    T *RawPtr = new T(std::forward<Args>(Arg)...);
199
145k
    AllActions.push_back(std::unique_ptr<Action>(RawPtr));
200
145k
    return RawPtr;
201
145k
  }
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
197
464
  template <typename T, typename... Args> T *MakeAction(Args &&... Arg) {
198
464
    T *RawPtr = new T(std::forward<Args>(Arg)...);
199
464
    AllActions.push_back(std::unique_ptr<Action>(RawPtr));
200
464
    return RawPtr;
201
464
  }
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
197
93
  template <typename T, typename... Args> T *MakeAction(Args &&... Arg) {
198
93
    T *RawPtr = new T(std::forward<Args>(Arg)...);
199
93
    AllActions.push_back(std::unique_ptr<Action>(RawPtr));
200
93
    return RawPtr;
201
93
  }
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
197
320
  template <typename T, typename... Args> T *MakeAction(Args &&... Arg) {
198
320
    T *RawPtr = new T(std::forward<Args>(Arg)...);
199
320
    AllActions.push_back(std::unique_ptr<Action>(RawPtr));
200
320
    return RawPtr;
201
320
  }
clang::driver::OffloadUnbundlingJobAction* clang::driver::Compilation::MakeAction<clang::driver::OffloadUnbundlingJobAction, clang::driver::Action*&>(clang::driver::Action*&&&)
Line
Count
Source
197
15
  template <typename T, typename... Args> T *MakeAction(Args &&... Arg) {
198
15
    T *RawPtr = new T(std::forward<Args>(Arg)...);
199
15
    AllActions.push_back(std::unique_ptr<Action>(RawPtr));
200
15
    return RawPtr;
201
15
  }
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
197
27
  template <typename T, typename... Args> T *MakeAction(Args &&... Arg) {
198
27
    T *RawPtr = new T(std::forward<Args>(Arg)...);
199
27
    AllActions.push_back(std::unique_ptr<Action>(RawPtr));
200
27
    return RawPtr;
201
27
  }
clang::driver::BindArchAction* clang::driver::Compilation::MakeAction<clang::driver::BindArchAction, clang::driver::Action*&, char const*&>(clang::driver::Action*&&&, char const*&&&)
Line
Count
Source
197
20.7k
  template <typename T, typename... Args> T *MakeAction(Args &&... Arg) {
198
20.7k
    T *RawPtr = new T(std::forward<Args>(Arg)...);
199
20.7k
    AllActions.push_back(std::unique_ptr<Action>(RawPtr));
200
20.7k
    return RawPtr;
201
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
197
828
  template <typename T, typename... Args> T *MakeAction(Args &&... Arg) {
198
828
    T *RawPtr = new T(std::forward<Args>(Arg)...);
199
828
    AllActions.push_back(std::unique_ptr<Action>(RawPtr));
200
828
    return RawPtr;
201
828
  }
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
197
33
  template <typename T, typename... Args> T *MakeAction(Args &&... Arg) {
198
33
    T *RawPtr = new T(std::forward<Args>(Arg)...);
199
33
    AllActions.push_back(std::unique_ptr<Action>(RawPtr));
200
33
    return RawPtr;
201
33
  }
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
197
3
  template <typename T, typename... Args> T *MakeAction(Args &&... Arg) {
198
3
    T *RawPtr = new T(std::forward<Args>(Arg)...);
199
3
    AllActions.push_back(std::unique_ptr<Action>(RawPtr));
200
3
    return RawPtr;
201
3
  }
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
197
39.6k
  template <typename T, typename... Args> T *MakeAction(Args &&... Arg) {
198
39.6k
    T *RawPtr = new T(std::forward<Args>(Arg)...);
199
39.6k
    AllActions.push_back(std::unique_ptr<Action>(RawPtr));
200
39.6k
    return RawPtr;
201
39.6k
  }
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
197
5.14k
  template <typename T, typename... Args> T *MakeAction(Args &&... Arg) {
198
5.14k
    T *RawPtr = new T(std::forward<Args>(Arg)...);
199
5.14k
    AllActions.push_back(std::unique_ptr<Action>(RawPtr));
200
5.14k
    return RawPtr;
201
5.14k
  }
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
197
17
  template <typename T, typename... Args> T *MakeAction(Args &&... Arg) {
198
17
    T *RawPtr = new T(std::forward<Args>(Arg)...);
199
17
    AllActions.push_back(std::unique_ptr<Action>(RawPtr));
200
17
    return RawPtr;
201
17
  }
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
197
20.7k
  template <typename T, typename... Args> T *MakeAction(Args &&... Arg) {
198
20.7k
    T *RawPtr = new T(std::forward<Args>(Arg)...);
199
20.7k
    AllActions.push_back(std::unique_ptr<Action>(RawPtr));
200
20.7k
    return RawPtr;
201
20.7k
  }
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
197
1
  template <typename T, typename... Args> T *MakeAction(Args &&... Arg) {
198
1
    T *RawPtr = new T(std::forward<Args>(Arg)...);
199
1
    AllActions.push_back(std::unique_ptr<Action>(RawPtr));
200
1
    return RawPtr;
201
1
  }
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
197
60
  template <typename T, typename... Args> T *MakeAction(Args &&... Arg) {
198
60
    T *RawPtr = new T(std::forward<Args>(Arg)...);
199
60
    AllActions.push_back(std::unique_ptr<Action>(RawPtr));
200
60
    return RawPtr;
201
60
  }
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
197
23.2k
  template <typename T, typename... Args> T *MakeAction(Args &&... Arg) {
198
23.2k
    T *RawPtr = new T(std::forward<Args>(Arg)...);
199
23.2k
    AllActions.push_back(std::unique_ptr<Action>(RawPtr));
200
23.2k
    return RawPtr;
201
23.2k
  }
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
197
12
  template <typename T, typename... Args> T *MakeAction(Args &&... Arg) {
198
12
    T *RawPtr = new T(std::forward<Args>(Arg)...);
199
12
    AllActions.push_back(std::unique_ptr<Action>(RawPtr));
200
12
    return RawPtr;
201
12
  }
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
197
2
  template <typename T, typename... Args> T *MakeAction(Args &&... Arg) {
198
2
    T *RawPtr = new T(std::forward<Args>(Arg)...);
199
2
    AllActions.push_back(std::unique_ptr<Action>(RawPtr));
200
2
    return RawPtr;
201
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
197
385
  template <typename T, typename... Args> T *MakeAction(Args &&... Arg) {
198
385
    T *RawPtr = new T(std::forward<Args>(Arg)...);
199
385
    AllActions.push_back(std::unique_ptr<Action>(RawPtr));
200
385
    return RawPtr;
201
385
  }
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
197
16.7k
  template <typename T, typename... Args> T *MakeAction(Args &&... Arg) {
198
16.7k
    T *RawPtr = new T(std::forward<Args>(Arg)...);
199
16.7k
    AllActions.push_back(std::unique_ptr<Action>(RawPtr));
200
16.7k
    return RawPtr;
201
16.7k
  }
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
197
17.1k
  template <typename T, typename... Args> T *MakeAction(Args &&... Arg) {
198
17.1k
    T *RawPtr = new T(std::forward<Args>(Arg)...);
199
17.1k
    AllActions.push_back(std::unique_ptr<Action>(RawPtr));
200
17.1k
    return RawPtr;
201
17.1k
  }
202
203
44.6k
  JobList &getJobs() { return Jobs; }
204
0
  const JobList &getJobs() const { return Jobs; }
205
206
34.3k
  void addCommand(std::unique_ptr<Command> C) { Jobs.addJob(std::move(C)); }
207
208
22
  const llvm::opt::ArgStringList &getTempFiles() const { return TempFiles; }
209
210
184
  const ArgStringMap &getResultFiles() const { return ResultFiles; }
211
212
6
  const ArgStringMap &getFailureResultFiles() const {
213
6
    return FailureResultFiles;
214
6
  }
215
216
  /// Returns the sysroot path.
217
  StringRef getSysRoot() const;
218
219
  /// getArgsForToolChain - Return the derived argument list for the
220
  /// tool chain \p TC (or the default tool chain, if TC is not specified).
221
  /// If a device offloading kind is specified, a translation specific for that
222
  /// kind is performed, if any.
223
  ///
224
  /// \param BoundArch - The bound architecture name, or 0.
225
  /// \param DeviceOffloadKind - The offload device kind that should be used in
226
  /// the translation, if any.
227
  const llvm::opt::DerivedArgList &
228
  getArgsForToolChain(const ToolChain *TC, StringRef BoundArch,
229
                      Action::OffloadKind DeviceOffloadKind);
230
231
  /// addTempFile - Add a file to remove on exit, and returns its
232
  /// argument.
233
7.23k
  const char *addTempFile(const char *Name) {
234
7.23k
    TempFiles.push_back(Name);
235
7.23k
    return Name;
236
7.23k
  }
237
238
  /// addResultFile - Add a file to remove on failure, and returns its
239
  /// argument.
240
21.0k
  const char *addResultFile(const char *Name, const JobAction *JA) {
241
21.0k
    ResultFiles[JA] = Name;
242
21.0k
    return Name;
243
21.0k
  }
244
245
  /// addFailureResultFile - Add a file to remove if we crash, and returns its
246
  /// argument.
247
8.66k
  const char *addFailureResultFile(const char *Name, const JobAction *JA) {
248
8.66k
    FailureResultFiles[JA] = Name;
249
8.66k
    return Name;
250
8.66k
  }
251
252
  /// CleanupFile - Delete a given file.
253
  ///
254
  /// \param IssueErrors - Report failures as errors.
255
  /// \return Whether the file was removed successfully.
256
  bool CleanupFile(const char *File, bool IssueErrors = false) const;
257
258
  /// CleanupFileList - Remove the files in the given list.
259
  ///
260
  /// \param IssueErrors - Report failures as errors.
261
  /// \return Whether all files were removed successfully.
262
  bool CleanupFileList(const llvm::opt::ArgStringList &Files,
263
                       bool IssueErrors = false) const;
264
265
  /// CleanupFileMap - Remove the files in the given map.
266
  ///
267
  /// \param JA - If specified, only delete the files associated with this
268
  /// JobAction.  Otherwise, delete all files in the map.
269
  /// \param IssueErrors - Report failures as errors.
270
  /// \return Whether all files were removed successfully.
271
  bool CleanupFileMap(const ArgStringMap &Files,
272
                      const JobAction *JA,
273
                      bool IssueErrors = false) const;
274
275
  /// ExecuteCommand - Execute an actual command.
276
  ///
277
  /// \param FailingCommand - For non-zero results, this will be set to the
278
  /// Command which failed, if any.
279
  /// \return The result code of the subprocess.
280
  int ExecuteCommand(const Command &C, const Command *&FailingCommand) const;
281
282
  /// ExecuteJob - Execute a single job.
283
  ///
284
  /// \param FailingCommands - For non-zero results, this will be a vector of
285
  /// failing commands and their associated result code.
286
  void ExecuteJobs(
287
      const JobList &Jobs,
288
      SmallVectorImpl<std::pair<int, const Command *>> &FailingCommands) const;
289
290
  /// initCompilationForDiagnostics - Remove stale state and suppress output
291
  /// so compilation can be reexecuted to generate additional diagnostic
292
  /// information (e.g., preprocessed source(s)).
293
  void initCompilationForDiagnostics();
294
295
  /// Return true if we're compiling for diagnostics.
296
53.2k
  bool isForDiagnostics() const { return ForDiagnostics; }
297
298
  /// Return whether an error during the parsing of the input args.
299
21.2k
  bool containsError() const { return ContainsError; }
300
301
  /// Redirect - Redirect output of this compilation. Can only be done once.
302
  ///
303
  /// \param Redirects - array of optional paths. The array should have a size
304
  /// of three. The inferior process's stdin(0), stdout(1), and stderr(2) will
305
  /// be redirected to the corresponding paths, if provided (not llvm::None).
306
  void Redirect(ArrayRef<Optional<StringRef>> Redirects);
307
};
308
309
} // namespace driver
310
} // namespace clang
311
312
#endif // LLVM_CLANG_DRIVER_COMPILATION_H