clang 8.0.0

StmtGraphTraits.h
Go to the documentation of this file.
1 //===- StmtGraphTraits.h - Graph Traits for the class Stmt ------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file defines a template specialization of llvm::GraphTraits to
11 // treat ASTs (Stmt*) as graphs
12 //
13 //===----------------------------------------------------------------------===//
14
15 #ifndef LLVM_CLANG_AST_STMTGRAPHTRAITS_H
16 #define LLVM_CLANG_AST_STMTGRAPHTRAITS_H
17
18 #include "clang/AST/Stmt.h"
19 #include "llvm/ADT/DepthFirstIterator.h"
20 #include "llvm/ADT/GraphTraits.h"
21
22 namespace llvm {
23
24 template <> struct GraphTraits<clang::Stmt *> {
25 using NodeRef = clang::Stmt *;
26 using ChildIteratorType = clang::Stmt::child_iterator;
27 using nodes_iterator = llvm::df_iterator<clang::Stmt *>;
28
29 static NodeRef getEntryNode(clang::Stmt *S) { return S; }
30
31 static ChildIteratorType child_begin(NodeRef N) {
32 if (N) return N->child_begin();
33 else return ChildIteratorType();
34 }
35
36 static ChildIteratorType child_end(NodeRef N) {
37 if (N) return N->child_end();
38 else return ChildIteratorType();
39 }
40
41 static nodes_iterator nodes_begin(clang::Stmt* S) {
42 return df_begin(S);
43 }
44
45 static nodes_iterator nodes_end(clang::Stmt* S) {
46 return df_end(S);
47 }
48 };
49
50 template <> struct GraphTraits<const clang::Stmt *> {
51 using NodeRef = const clang::Stmt *;
52 using ChildIteratorType = clang::Stmt::const_child_iterator;
53 using nodes_iterator = llvm::df_iterator<const clang::Stmt *>;
54
55 static NodeRef getEntryNode(const clang::Stmt *S) { return S; }
56
57 static ChildIteratorType child_begin(NodeRef N) {
58 if (N) return N->child_begin();
59 else return ChildIteratorType();
60 }
61
62 static ChildIteratorType child_end(NodeRef N) {
63 if (N) return N->child_end();
64 else return ChildIteratorType();
65 }
66
67 static nodes_iterator nodes_begin(const clang::Stmt* S) {
68 return df_begin(S);
69 }
70
71 static nodes_iterator nodes_end(const clang::Stmt* S) {
72 return df_end(S);
73 }
74 };
75
76 } // namespace llvm
77
78 #endif // LLVM_CLANG_AST_STMTGRAPHTRAITS_H
clang::Stmt::child_begin
child_iterator child_begin()
Definition: Stmt.h:1108
llvm::GraphTraits< const clang::Stmt * >::child_end
static ChildIteratorType child_end(NodeRef N)
Definition: StmtGraphTraits.h:62
llvm
DominatorTree GraphTraits specialization so the DominatorTree can be iterable by generic graph iterat...
Definition: Dominators.h:30
clang::Stmt
Stmt - This represents one statement.
Definition: Stmt.h:66
llvm::GraphTraits< clang::Stmt * >::child_end
static ChildIteratorType child_end(NodeRef N)
Definition: StmtGraphTraits.h:36
llvm::GraphTraits< const clang::Stmt * >::getEntryNode
static NodeRef getEntryNode(const clang::Stmt *S)
Definition: StmtGraphTraits.h:55
llvm::GraphTraits< clang::Stmt * >::child_begin
static ChildIteratorType child_begin(NodeRef N)
Definition: StmtGraphTraits.h:31
llvm::GraphTraits< clang::Stmt * >::nodes_end
static nodes_iterator nodes_end(clang::Stmt *S)
Definition: StmtGraphTraits.h:45
llvm::GraphTraits< const clang::Stmt * >::nodes_iterator
llvm::df_iterator< const clang::Stmt * > nodes_iterator
Definition: StmtGraphTraits.h:53
llvm::GraphTraits< const clang::Stmt * >::child_begin
static ChildIteratorType child_begin(NodeRef N)
Definition: StmtGraphTraits.h:57
clang::Stmt::const_child_iterator
ConstStmtIterator const_child_iterator
Definition: Stmt.h:1096
llvm::GraphTraits< const clang::Stmt * >::nodes_begin
static nodes_iterator nodes_begin(const clang::Stmt *S)
Definition: StmtGraphTraits.h:67
llvm::GraphTraits< clang::Stmt * >::nodes_iterator
llvm::df_iterator< clang::Stmt * > nodes_iterator
Definition: StmtGraphTraits.h:27
llvm::GraphTraits< const clang::Stmt * >::nodes_end
static nodes_iterator nodes_end(const clang::Stmt *S)
Definition: StmtGraphTraits.h:71
Stmt.h
clang::Stmt::child_iterator
StmtIterator child_iterator
Child Iterators: All subclasses must implement &#39;children&#39; to permit easy iteration over the substatem...
Definition: Stmt.h:1095
clang::StmtIterator
Definition: StmtIterator.h:125
GraphTraits
clang
Dataflow Directional Tag Classes.
Definition: CFGReachabilityAnalysis.h:22
clang::ConstStmtIterator
Definition: StmtIterator.h:141
llvm::GraphTraits< clang::Stmt * >::nodes_begin
static nodes_iterator nodes_begin(clang::Stmt *S)
Definition: StmtGraphTraits.h:41
llvm::GraphTraits< clang::Stmt * >::getEntryNode
static NodeRef getEntryNode(clang::Stmt *S)
Definition: StmtGraphTraits.h:29
clang::Stmt::child_end
child_iterator child_end()
Definition: Stmt.h:1109