1#include <boost/graph/adjacency_list.hpp>
2#include <boost/graph/astar_search.hpp>
5#include <interproceduralCFG.h>
16typedef boost::adjacency_list<
19 boost::bidirectionalS,
24typedef myGraph::vertex_descriptor VertexID;
25typedef myGraph::edge_descriptor EdgeID;
29std::map<VertexID, SgGraphNode*> getGraphNode;
30std::map<SgGraphNode*, VertexID> VSlink;
37 ROSE_ASSERT(startN != NULL);
38 ROSE_ASSERT(start != NULL);
39 myGraph* graph =
new myGraph;
41 std::pair<std::vector<SgGraphNode*>, std::vector<SgDirectedGraphEdge*> > alledsnds = getAllNodesAndEdges(g, start);
42 std::vector<SgGraphNode*> nods = alledsnds.first;
43 std::vector<SgDirectedGraphEdge*> eds = alledsnds.second;
44 std::set<std::pair<VertexID, VertexID> > prs;
49 for (std::vector<SgDirectedGraphEdge*>::iterator j = eds.begin(); j != eds.end(); j++) {
55 if (VSlink.find(u1) == VSlink.end()) {
56 v1 = boost::add_vertex(*graph);
57 getGraphNode[v1] = u1;
65 if (VSlink.find(u2) != VSlink.end()) {
69 v2 = boost::add_vertex(*graph);
72 getGraphNode[v2] = u2;
77 std::pair<VertexID, VertexID> pr;
80 if (prs.find(pr) == prs.end()) {
82 boost::tie(uE, ok) = boost::add_edge(v1, v2, *graph);
93 myGraph* graph =
new myGraph;
95 std::pair<std::vector<SgGraphNode*>, std::vector<SgDirectedGraphEdge*> > alledsnds = getAllNodesAndEdges(g, start);
96 std::vector<SgGraphNode*> nods = alledsnds.first;
97 std::vector<SgDirectedGraphEdge*> eds = alledsnds.second;
98 std::set<std::pair<VertexID, VertexID> > prs;
103 for (std::vector<SgDirectedGraphEdge*>::iterator j = eds.begin(); j != eds.end(); j++) {
109 if (VSlink.find(u1) == VSlink.end()) {
110 v1 = boost::add_vertex(*graph);
111 getGraphNode[v1] = u1;
113 (*graph)[v1].sg = u1;
119 if (VSlink.find(u2) != VSlink.end()) {
123 v2 = boost::add_vertex(*graph);
125 (*graph)[v2].sg = u2;
126 getGraphNode[v2] = u2;
131 std::pair<VertexID, VertexID> pr;
134 if (prs.find(pr) == prs.end()) {
136 boost::tie(uE, ok) = boost::add_edge(v1, v2, *graph);
149 std::vector<SgGraphNode*> nods;
150 std::vector<SgGraphNode*> newnods;
151 std::set<SgDirectedGraphEdge*> edsnew;
152 std::vector<SgDirectedGraphEdge*> eds;
153 std::vector<SgDirectedGraphEdge*> feds;
154 std::vector<SgGraphNode*> fnods;
155 std::set<std::pair<EdgeID, EdgeID> > prs;
156 std::set<SgDirectedGraphEdge*> oeds = g->computeEdgeSetOut(start);
157 fnods.push_back(start);
158 newnods.push_back(n);
160 while (oeds.size() > 0) {
161 for (std::set<SgDirectedGraphEdge*>::iterator j = oeds.begin(); j != oeds.end(); j++) {
163 if (find(feds.begin(), feds.end(), *j) == feds.end()) {
167 if (find(fnods.begin(), fnods.end(), (*j)->get_to()) == fnods.end()) {
168 fnods.push_back((*j)->get_to());
170 newnods.push_back((*j)->get_to());
174 for (
unsigned int i = 0; i < newnods.size(); i++) {
175 std::set<SgDirectedGraphEdge*> oedsp = g->computeEdgeSetOut(newnods[i]);
176 for (std::set<SgDirectedGraphEdge*>::iterator j = oedsp.begin(); j != oedsp.end(); j++) {
177 if (find(feds.begin(), feds.end(), *j) == feds.end()) {
194 std::pair<std::vector<SgGraphNode*>, std::vector<SgDirectedGraphEdge*> > retpr;
This class represents the base class for all IR nodes within Sage III.
SgGraphNode * getEntry() const
Get the entry node of the CFG.
SgGraphNode * toGraphNode(CFGNode &n)
Turn a CFG node into a GraphNode which is defined in VirtualCFG namespace.
CFGNode toCFGNode(SgGraphNode *node)
Turn a graph node into a CFGNode which is defined in VirtualCFG namespace.
This namespace contains template functions that operate on the ROSE AST.