Coverage Report

Created: 2018-06-18 20:01

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