Coverage Report

Created: 2017-10-03 07:32

/Users/buildslave/jenkins/sharedspace/clang-stage2-coverage-R@2/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/Core/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
/// \brief 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
540
  void add(std::unique_ptr<Pass> pass) {
32
540
    _passes.push_back(std::move(pass));
33
540
  }
34
35
168
  llvm::Error runOnFile(SimpleFile &file) {
36
168
    for (std::unique_ptr<Pass> &pass : _passes)
37
540
      
if (llvm::Error 540
EC540
= pass->perform(file))
38
1
        return EC;
39
167
    return llvm::Error::success();
40
168
  }
41
42
private:
43
  /// \brief Passes in the order they should run.
44
  std::vector<std::unique_ptr<Pass>> _passes;
45
};
46
} // end namespace lld
47
48
#endif