1 //===- lld/Core/Node.h - Input file class -----------------------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
11 /// The classes in this file represents inputs to the linker.
13 //===----------------------------------------------------------------------===//
15 #ifndef LLD_CORE_NODE_H
16 #define LLD_CORE_NODE_H
18 #include "lld/Core/File.h"
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.
29 enum class Kind { File, GroupEnd };
31 explicit Node(Kind type) : _kind(type) {}
32 virtual ~Node() = default;
34 virtual Kind kind() const { return _kind; }
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 {
44 explicit GroupEnd(int size) : Node(Kind::GroupEnd), _size(size) {}
46 int getSize() const { return _size; }
48 static bool classof(const Node *a) {
49 return a->kind() == Kind::GroupEnd;
56 // A container of File.
57 class FileNode : public Node {
59 explicit FileNode(std::unique_ptr<File> f)
60 : Node(Node::Kind::File), _file(std::move(f)) {}
62 static bool classof(const Node *a) {
63 return a->kind() == Node::Kind::File;
66 File *getFile() { return _file.get(); }
69 std::unique_ptr<File> _file;
72 } // end namespace lld
74 #endif // LLD_CORE_NODE_H