]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/clang/include/clang/Tooling/ASTDiff/ASTDiffInternal.h
Merge clang trunk r321017 to contrib/llvm/tools/clang.
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / clang / include / clang / Tooling / ASTDiff / ASTDiffInternal.h
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
16 namespace clang {
17 namespace diff {
18
19 using DynTypedNode = ast_type_traits::DynTypedNode;
20
21 class SyntaxTree;
22 class SyntaxTreeImpl;
23 struct ComparisonOptions;
24
25 /// Within a tree, this identifies a node by its preorder offset.
26 struct NodeId {
27 private:
28   static constexpr int InvalidNodeId = -1;
29
30 public:
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