Coverage Report

Created: 2019-05-19 14:56

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/tools/lld/include/lld/Core/PassManager.h
Line
Count
Source
1
//===- lld/Core/PassManager.h - Manage linker passes ----------------------===//
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 LLD_CORE_PASS_MANAGER_H
10
#define LLD_CORE_PASS_MANAGER_H
11
12
#include "lld/Common/LLVM.h"
13
#include "lld/Core/Pass.h"
14
#include "llvm/Support/Error.h"
15
#include <memory>
16
#include <vector>
17
18
namespace lld {
19
class SimpleFile;
20
class Pass;
21
22
/// Owns and runs a collection of passes.
23
///
24
/// This class is currently just a container for passes and a way to run them.
25
///
26
/// In the future this should handle timing pass runs, running parallel passes,
27
/// and validate/satisfy pass dependencies.
28
class PassManager {
29
public:
30
546
  void add(std::unique_ptr<Pass> pass) {
31
546
    _passes.push_back(std::move(pass));
32
546
  }
33
34
170
  llvm::Error runOnFile(SimpleFile &file) {
35
170
    for (std::unique_ptr<Pass> &pass : _passes)
36
546
      if (llvm::Error EC = pass->perform(file))
37
1
        return EC;
38
170
    
return llvm::Error::success()169
;
39
170
  }
40
41
private:
42
  /// Passes in the order they should run.
43
  std::vector<std::unique_ptr<Pass>> _passes;
44
};
45
} // end namespace lld
46
47
#endif