1//===- ASTDiffInternal.h --------------------------------------*- C++ -*- -===//
2//
3//
4//                     The LLVM Compiler Infrastructure
5//
6// This file is distributed under the University of Illinois Open Source
7// License. See LICENSE.TXT for details.
8//
9//===----------------------------------------------------------------------===//
10
11#ifndef LLVM_CLANG_TOOLING_ASTDIFF_ASTDIFFINTERNAL_H
12#define LLVM_CLANG_TOOLING_ASTDIFF_ASTDIFFINTERNAL_H
13
14#include "clang/AST/ASTTypeTraits.h"
15
16namespace clang {
17namespace diff {
18
19using DynTypedNode = ast_type_traits::DynTypedNode;
20
21class SyntaxTree;
22class SyntaxTreeImpl;
23struct ComparisonOptions;
24
25/// Within a tree, this identifies a node by its preorder offset.
26struct NodeId {
27private:
28  static constexpr int InvalidNodeId = -1;
29
30public:
31  int Id;
32
33  NodeId() : Id(InvalidNodeId) {}
34  NodeId(int Id) : Id(Id) {}
35
36  operator int() const { return Id; }
37  NodeId &operator++() { return ++Id, *this; }
38  NodeId &operator--() { return --Id, *this; }
39  // Support defining iterators on NodeId.
40  NodeId &operator*() { return *this; }
41
42  bool isValid() const { return Id != InvalidNodeId; }
43  bool isInvalid() const { return Id == InvalidNodeId; }
44};
45
46} // end namespace diff
47} // end namespace clang
48#endif
49