ROSE 0.11.145.192
filteredCFG.h
1#ifndef FILTEREDCFGVIEW_H
2#define FILTEREDCFGVIEW_H
3
4//#include "rose.h"
5#include "virtualCFG.h"
6#include <string>
7#include <vector>
8
9namespace VirtualCFG
10{
11 // Function call node and edge filters
12
13 template < typename FilterFunction > class FilteredCFGEdge;
14
15 template < typename FilterFunction > class FilteredCFGNode
16 {
17 CFGNode n;
18 FilterFunction filter;
19
20 public:
21 FilteredCFGNode(const CFGNode& n):n(n)
22 {
23 }
24
27 {
28 }
29
30 void setFilter(const FilterFunction& f)
31 {
32 filter = f;
33 }
34
35 const CFGNode& toNode() const
36 {
37 return n;
38 }
39 std::string toString() const
40 {
41 std::string nToString= n.toString();
42 if (nToString.find('>',0)>0)
43 nToString.insert(nToString.find('>',0)+1,"\n");
44 return nToString;
45 }
46 std::string toStringForDebugging() const
47 {
48 return n.toStringForDebugging();
49 }
50 std::string id() const
51 {
52 return n.id();
53 }
54 SgNode *getNode() const
55 {
56 return n.getNode();
57 }
58 unsigned int getIndex() const
59 {
60 return n.getIndex();
61 }
62 std::vector < FilteredCFGEdge < FilterFunction > >outEdges() const;
63 std::vector < FilteredCFGEdge < FilterFunction > >inEdges() const;
64 bool isInteresting() const
65 {
66 return true;
67 }
68 bool operator==(const FilteredCFGNode & o)const
69 {
70 return n == o.n;
71 }
72 bool operator!=(const FilteredCFGNode & o)const
73 {
74 return !(*this == o);
75 }
76 bool operator<(const FilteredCFGNode & o)const
77 {
78 return n < o.n;
79 }
80 };
81
82 template < typename FilterFunction > class FilteredCFGEdge
83 {
84 CFGPath p;
85 FilterFunction filter;
86
87 public:
89 {
90 }
91
94 {
95 }
96
97 void setFilter(const FilterFunction& f)
98 {
99 filter = f;
100 }
101
102 std::string toString()const
103 {
104 return p.toString();
105 }
106 std::string toStringForDebugging() const
107 {
108 return p.toStringForDebugging();
109 }
110 std::string id() const
111 {
112 return p.id();
113 }
114 FilteredCFGNode < FilterFunction > source() const
115 {
116 return FilteredCFGNode < FilterFunction > (p.source());
117 }
118 FilteredCFGNode < FilterFunction > target() const
119 {
120 return FilteredCFGNode < FilterFunction > (p.target());
121 }
122 EdgeConditionKind condition() const
123 {
124 return p.condition();
125 }
126 SgExpression *caseLabel() const
127 {
128 return p.caseLabel();
129 }
130 std::vector < SgInitializedName * >scopesBeingExited() const
131 {
132 return p.scopesBeingExited();
133 }
134 std::vector < SgInitializedName * >scopesBeingEntered() const
135 {
136 return p.scopesBeingEntered();
137 }
138 bool operator==(const FilteredCFGEdge < FilterFunction > &o)const
139 {
140 return p == o.p;
141 }
142 bool operator!=(const FilteredCFGEdge < FilterFunction > &o)const
143 {
144 return p != o.p;
145 }
146 bool operator<(const FilteredCFGEdge < FilterFunction > &o)const
147 {
148 return p < o.p;
149 }
150
152 const CFGPath& getPath() const
153 {
154 return p;
155 }
156 };
157
158 template < typename FilterFunction > std::ostream & cfgToDot(std::ostream & o,
159 std::string graphName,
160 FilteredCFGNode <
161 FilterFunction > start);
162}
163
164#include "filteredCFGImpl.h"
165#endif // XCFGVIEW_H
This class represents the notion of an expression. Expressions are derived from SgLocatedNodes,...
This class represents the base class for all IR nodes within Sage III.
A node in the control flow graph.
Definition virtualCFG.h:70
SgNode * getNode() const
The underlying AST node.
Definition virtualCFG.h:89
std::string toString() const
Pretty string for Dot node labels, etc.
unsigned int getIndex() const
An identifying index within the AST node given by getNode()
Definition virtualCFG.h:91
std::string id() const
ID to use for Dot, etc.
std::string toStringForDebugging() const
String for debugging graphs.
const CFGPath & getPath() const
The underlying path in the full CFG represented by this edge in the filtered CFG.
FilteredCFGEdge()
Need a default constructor to use with boost_graph.
Definition filteredCFG.h:93
FilteredCFGNode()
Need a default constructor to use with boost_graph.
Definition filteredCFG.h:26