clang  15.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 
14 
15 namespace clang {
16 namespace diff {
17 
19 
20 /// Within a tree, this identifies a node by its preorder offset.
21 struct NodeId {
22 private:
23  static constexpr int InvalidNodeId = -1;
24 
25 public:
26  int Id;
27 
28  NodeId() : Id(InvalidNodeId) {}
29  NodeId(int Id) : Id(Id) {}
30 
31  operator int() const { return Id; }
32  NodeId &operator++() { return ++Id, *this; }
33  NodeId &operator--() { return --Id, *this; }
34  // Support defining iterators on NodeId.
35  NodeId &operator*() { return *this; }
36 
37  bool isValid() const { return Id != InvalidNodeId; }
38  bool isInvalid() const { return Id == InvalidNodeId; }
39 };
40 
41 } // end namespace diff
42 } // end namespace clang
43 #endif
clang::diff::NodeId
Within a tree, this identifies a node by its preorder offset.
Definition: ASTDiffInternal.h:21
int
__device__ int
Definition: __clang_hip_libdevice_declares.h:63
clang::diff::NodeId::NodeId
NodeId(int Id)
Definition: ASTDiffInternal.h:29
clang::diff::NodeId::Id
int Id
Definition: ASTDiffInternal.h:26
clang::diff::DynTypedNode
DynTypedNode DynTypedNode
Definition: ASTDiffInternal.h:18
clang::diff::NodeId::operator++
NodeId & operator++()
Definition: ASTDiffInternal.h:32
clang::diff::NodeId::isInvalid
bool isInvalid() const
Definition: ASTDiffInternal.h:38
clang::diff::NodeId::operator*
NodeId & operator*()
Definition: ASTDiffInternal.h:35
ASTTypeTraits.h
clang
Definition: CalledOnceCheck.h:17
clang::diff::NodeId::NodeId
NodeId()
Definition: ASTDiffInternal.h:28
clang::diff::NodeId::isValid
bool isValid() const
Definition: ASTDiffInternal.h:37
clang::diff::NodeId::operator--
NodeId & operator--()
Definition: ASTDiffInternal.h:33