1//===- ASTDiffInternal.h --------------------------------------*- C++ -*- -===//
2//
3//
4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5// See https://llvm.org/LICENSE.txt for license information.
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef LLVM_CLANG_TOOLING_ASTDIFF_ASTDIFFINTERNAL_H
11#define LLVM_CLANG_TOOLING_ASTDIFF_ASTDIFFINTERNAL_H
12
13#include "clang/AST/ASTTypeTraits.h"
14
15namespace clang {
16namespace diff {
17
18using DynTypedNode = DynTypedNode;
19
20class SyntaxTree;
21class SyntaxTreeImpl;
22struct ComparisonOptions;
23
24/// Within a tree, this identifies a node by its preorder offset.
25struct NodeId {
26private:
27  static constexpr int InvalidNodeId = -1;
28
29public:
30  int Id;
31
32  NodeId() : Id(InvalidNodeId) {}
33  NodeId(int Id) : Id(Id) {}
34
35  operator int() const { return Id; }
36  NodeId &operator++() { return ++Id, *this; }
37  NodeId &operator--() { return --Id, *this; }
38  // Support defining iterators on NodeId.
39  NodeId &operator*() { return *this; }
40
41  bool isValid() const { return Id != InvalidNodeId; }
42  bool isInvalid() const { return Id == InvalidNodeId; }
43};
44
45} // end namespace diff
46} // end namespace clang
47#endif
48