clang  6.0.0svn
ASTDiffInternal.h
Go to the documentation of this file.
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 
15 
16 namespace clang {
17 namespace diff {
18 
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
bool isValid() const
Within a tree, this identifies a node by its preorder offset.
SyntaxTree objects represent subtrees of the AST.
Definition: ASTDiff.h:68
ast_type_traits::DynTypedNode DynTypedNode
Dataflow Directional Tag Classes.
A dynamically typed AST node container.
bool isInvalid() const