Coverage Report

Created: 2019-07-24 05:18

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