clang 10.0.0git

ASTDiffInternal.h
Go to the documentation of this file.
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
15 namespace clang {
16 namespace diff {
17
18 using DynTypedNode = ast_type_traits::DynTypedNode;
19
20 class SyntaxTree;
21 class SyntaxTreeImpl;
22 struct ComparisonOptions;
23
24 /// Within a tree, this identifies a node by its preorder offset.
25 struct NodeId {
26 private:
27 static constexpr int InvalidNodeId = -1;
28
29 public:
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
clang::diff::NodeId::operator*
NodeId & operator*()
Definition: ASTDiffInternal.h:39
clang::diff::NodeId::isValid
bool isValid() const
Definition: ASTDiffInternal.h:41
clang::diff::NodeId
Within a tree, this identifies a node by its preorder offset.
Definition: ASTDiffInternal.h:25
clang::diff::NodeId::NodeId
NodeId()
Definition: ASTDiffInternal.h:32
ASTTypeTraits.h
clang::diff::NodeId::NodeId
NodeId(int Id)
Definition: ASTDiffInternal.h:33
clang::diff::NodeId::operator++
NodeId & operator++()
Definition: ASTDiffInternal.h:36
clang::diff::ComparisonOptions
Definition: ASTDiff.h:103
clang::diff::SyntaxTree
SyntaxTree objects represent subtrees of the AST.
Definition: ASTDiff.h:67
clang::diff::DynTypedNode
ast_type_traits::DynTypedNode DynTypedNode
Definition: ASTDiffInternal.h:18
clang
Dataflow Directional Tag Classes.
Definition: CFGReachabilityAnalysis.h:21
clang::diff::NodeId::operator--
NodeId & operator--()
Definition: ASTDiffInternal.h:37
clang::ast_type_traits::DynTypedNode
A dynamically typed AST node container.
Definition: ASTTypeTraits.h:230
clang::diff::NodeId::Id
int Id
Definition: ASTDiffInternal.h:30
clang::diff::NodeId::isInvalid
bool isInvalid() const
Definition: ASTDiffInternal.h:42