Coverage Report

Created: 2017-09-19 22:28

/Users/buildslave/jenkins/sharedspace/clang-stage2-coverage-R@2/llvm/tools/lld/include/lld/Core/Node.h
Line
Count
Source
1
//===- lld/Core/Node.h - Input file class -----------------------*- C++ -*-===//
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
/// \file
11
///
12
/// The classes in this file represents inputs to the linker.
13
///
14
//===----------------------------------------------------------------------===//
15
16
#ifndef LLD_CORE_NODE_H
17
#define LLD_CORE_NODE_H
18
19
#include "lld/Core/File.h"
20
#include <algorithm>
21
#include <memory>
22
23
namespace lld {
24
25
// A Node represents a FileNode or other type of Node. In the latter case,
26
// the node contains meta information about the input file list.
27
// Currently only GroupEnd node is defined as a meta node.
28
class Node {
29
public:
30
  enum class Kind { File, GroupEnd };
31
32
1.41k
  explicit Node(Kind type) : _kind(type) {}
33
1.41k
  virtual ~Node() = default;
34
35
4.42k
  virtual Kind kind() const { return _kind; }
36
37
private:
38
  Kind _kind;
39
};
40
41
// This is a marker for --end-group. getSize() returns the number of
42
// files between the corresponding --start-group and this marker.
43
class GroupEnd : public Node {
44
public:
45
182
  explicit GroupEnd(int size) : Node(Kind::GroupEnd), _size(size) {}
46
47
173
  int getSize() const { return _size; }
48
49
811
  static bool classof(const Node *a) {
50
811
    return a->kind() == Kind::GroupEnd;
51
811
  }
52
53
private:
54
  int _size;
55
};
56
57
// A container of File.
58
class FileNode : public Node {
59
public:
60
  explicit FileNode(std::unique_ptr<File> f)
61
1.23k
      : Node(Node::Kind::File), _file(std::move(f)) {}
62
63
3.61k
  static bool classof(const Node *a) {
64
3.61k
    return a->kind() == Node::Kind::File;
65
3.61k
  }
66
67
4.07k
  File *getFile() { return _file.get(); }
68
69
protected:
70
  std::unique_ptr<File> _file;
71
};
72
73
} // end namespace lld
74
75
#endif // LLD_CORE_NODE_H