ROSE  0.9.6a
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SDG::ControlDependenceGraph Class Reference

#include <newCDG.h>

Inheritance diagram for SDG::ControlDependenceGraph:
Collaboration diagram for SDG::ControlDependenceGraph:

Classes

struct  ControlDependence
 

Public Types

typedef boost::graph_traits
< ControlDependenceGraph
GraphTraits
 
typedef
GraphTraits::vertex_descriptor 
Vertex
 
typedef
GraphTraits::edge_descriptor 
Edge
 
typedef std::vector
< ControlDependence
ControlDependences
 

Public Member Functions

 ControlDependenceGraph ()
 The default constructor. More...
 
 ControlDependenceGraph (const ControlFlowGraph &cfg)
 The constructor building the CDG from a CFG. More...
 
void build (const ControlFlowGraph &cfg)
 Build the CDG from the given CFG. More...
 
ControlDependences getControlDependences (CFGNodePtr cfgNode)
 Given a CFG node, return all its control dependences. More...
 
ControlDependences getControlDependences (SgNode *astNode)
 Given a AST node, return all its control dependences. More...
 
Vertex getCDGVertex (SgNode *astNode)
 Given an AST node, return its corresponding CDG node. More...
 
void toDot (const std::string &filename) const
 Write the CDG to a dot file. More...
 

Static Public Member Functions

static void writeGraphEdge (std::ostream &out, const CDGEdge &edge)
 This function helps to write the DOT file for edges. More...
 

Protected Types

typedef std::map
< ControlFlowGraph::Vertex,
std::map
< ControlFlowGraph::Vertex,
std::vector
< ControlFlowGraph::Edge > > > 
DominanceFrontiersT
 The data structure holding the dominance frontiers for all nodes in a CFG. More...
 

Protected Member Functions

bool checkCycle (const ControlFlowGraph &cfg)
 Check if the CFG contains any cycle without exit. If there is such a cycle, return false. More...
 
void writeGraphNode (std::ostream &out, const Vertex &node) const
 This function helps to write the DOT file for vertices. More...
 
void writeGraphEdge (std::ostream &out, const Edge &edge) const
 This function helps to write the DOT file for edges. More...
 
void appendSuccessors (Vertex v, std::vector< Vertex > &vertices, const std::map< Vertex, std::set< Vertex > > &iSucc)
 A function help to find all successors for the given node in the CFG. More...
 
DominanceFrontiersT buildDominanceFrontiers (const std::map< ControlFlowGraph::Vertex, ControlFlowGraph::Vertex > &iDom, const ControlFlowGraph &cfg)
 Build dominance frontiers for all nodes in the given CFG. More...
 

Detailed Description

Definition at line 42 of file newCDG.h.

Member Typedef Documentation

Definition at line 46 of file newCDG.h.

typedef GraphTraits::vertex_descriptor SDG::ControlDependenceGraph::Vertex

Definition at line 47 of file newCDG.h.

typedef GraphTraits::edge_descriptor SDG::ControlDependenceGraph::Edge

Definition at line 48 of file newCDG.h.

Definition at line 66 of file newCDG.h.

The data structure holding the dominance frontiers for all nodes in a CFG.

Note that the control dependence information is all included. Each node is mapped to its all control dependent nodes. It is possible that a node is control dependent on another node in different conditions (switch case), so there is a vector of CFG edges for each control dependence.

Definition at line 106 of file newCDG.h.

Constructor & Destructor Documentation

SDG::ControlDependenceGraph::ControlDependenceGraph ( )
inline

The default constructor.

Definition at line 69 of file newCDG.h.

SDG::ControlDependenceGraph::ControlDependenceGraph ( const ControlFlowGraph cfg)
inline

The constructor building the CDG from a CFG.

Definition at line 72 of file newCDG.h.

Member Function Documentation

void SDG::ControlDependenceGraph::build ( const ControlFlowGraph cfg)

Build the CDG from the given CFG.

ControlDependences SDG::ControlDependenceGraph::getControlDependences ( CFGNodePtr  cfgNode)

Given a CFG node, return all its control dependences.

ControlDependences SDG::ControlDependenceGraph::getControlDependences ( SgNode astNode)

Given a AST node, return all its control dependences.

Vertex SDG::ControlDependenceGraph::getCDGVertex ( SgNode astNode)

Given an AST node, return its corresponding CDG node.

Note that it is possile that there are several CDG nodes containing the same AST node, in which case we just return one of them, since they have the same control dependence.

void SDG::ControlDependenceGraph::toDot ( const std::string &  filename) const

Write the CDG to a dot file.

static void SDG::ControlDependenceGraph::writeGraphEdge ( std::ostream &  out,
const CDGEdge edge 
)
static

This function helps to write the DOT file for edges.

It's a static function which can be used by other classes (PDG for example).

bool SDG::ControlDependenceGraph::checkCycle ( const ControlFlowGraph cfg)
protected

Check if the CFG contains any cycle without exit. If there is such a cycle, return false.

void SDG::ControlDependenceGraph::writeGraphNode ( std::ostream &  out,
const Vertex node 
) const
inlineprotected

This function helps to write the DOT file for vertices.

Definition at line 112 of file newCDG.h.

References StaticCFG::writeCFGNode().

void SDG::ControlDependenceGraph::writeGraphEdge ( std::ostream &  out,
const Edge edge 
) const
inlineprotected

This function helps to write the DOT file for edges.

Definition at line 118 of file newCDG.h.

void SDG::ControlDependenceGraph::appendSuccessors ( Vertex  v,
std::vector< Vertex > &  vertices,
const std::map< Vertex, std::set< Vertex > > &  iSucc 
)
protected

A function help to find all successors for the given node in the CFG.

DominanceFrontiersT SDG::ControlDependenceGraph::buildDominanceFrontiers ( const std::map< ControlFlowGraph::Vertex, ControlFlowGraph::Vertex > &  iDom,
const ControlFlowGraph cfg 
)
protected

Build dominance frontiers for all nodes in the given CFG.


The documentation for this class was generated from the following file: