tipc
A TIP to LLVM compiler
Public Member Functions | Static Public Member Functions | List of all members
CallGraph Class Reference

Performs control flow analysis and records results for subsequent phases Generates call graph of a program that represents calling relationships between subroutines in a computer program. Each node represents a subroutine and each edge (a1, a0) indicates that procedure a1 calls procedure a0. A cycle in the graph indicates recursive procedure calls, e.g., a0 -> a0 indicates that a0 calls itself recursively this call graph is sometimes approximations. Not all the call relationship that exist in the graph will occur in the actual runs of the program. More...

#include <CallGraph.h>

Public Member Functions

 CallGraph (std::map< ASTFunction *, std::set< ASTFunction * >> cGraph, std::map< ASTFunAppExpr *, std::set< ASTFunction * >> mc, std::vector< ASTFunction * > funs, std::map< std::string, ASTFunction * > fmap)
 
int getTotalVertices ()
 Return the total num of vertices for a given call graph. More...
 
int getTotalEdges ()
 Return the total num of edges for a given call graph. More...
 
std::vector< ASTFunction * > getVertices ()
 Return the set of vertices for a given call graph. More...
 
std::vector< std::pair< ASTFunction *, ASTFunction * > > getEdges ()
 Return the set of edges for a given call graph. More...
 
std::set< ASTFunction * > getCalledFuns (ASTFunAppExpr *e)
 Return the set of functions that may be called at an application expr. More...
 
std::set< ASTFunction * > getCallees (ASTFunction *f)
 Returns all the subroutines called by function f. this is an overloaded function. More...
 
std::set< ASTFunction * > getCallees (std::string caller)
 
std::set< ASTFunction * > getCallers (ASTFunction *f)
 Returns all the subroutines that call function f. More...
 
std::set< std::string > getCallers (std::string callee)
 
void print (std::ostream &os)
 Print call graph contents to output stream. More...
 
bool existEdge (std::string caller, std::string callee)
 Returns bool value indicating whether there is an edge between two subroutines. More...
 
ASTFunctiongetASTFun (std::string f_name)
 Returns the ASTFunction* for a given function name . More...
 

Static Public Member Functions

static std::shared_ptr< CallGraphbuild (ASTProgram *, SymbolTable *st)
 Return the shared pointer of the call graph for a given program. More...
 

Detailed Description

Performs control flow analysis and records results for subsequent phases Generates call graph of a program that represents calling relationships between subroutines in a computer program. Each node represents a subroutine and each edge (a1, a0) indicates that procedure a1 calls procedure a0. A cycle in the graph indicates recursive procedure calls, e.g., a0 -> a0 indicates that a0 calls itself recursively this call graph is sometimes approximations. Not all the call relationship that exist in the graph will occur in the actual runs of the program.

Constructor & Destructor Documentation

◆ CallGraph()

CallGraph::CallGraph ( std::map< ASTFunction *, std::set< ASTFunction * >>  cGraph,
std::map< ASTFunAppExpr *, std::set< ASTFunction * >>  mc,
std::vector< ASTFunction * >  funs,
std::map< std::string, ASTFunction * >  fmap 
)
inline

Member Function Documentation

◆ build()

std::shared_ptr< CallGraph > CallGraph::build ( ASTProgram ast,
SymbolTable st 
)
static

Return the shared pointer of the call graph for a given program.

Parameters
TheAST of the program and symbol table

◆ existEdge()

bool CallGraph::existEdge ( std::string  caller,
std::string  callee 
)

Returns bool value indicating whether there is an edge between two subroutines.

Parameters
callerand callee are the str name of the subroutines
Returns
returns true if an edge exists otherwise false

◆ getASTFun()

ASTFunction * CallGraph::getASTFun ( std::string  f_name)

Returns the ASTFunction* for a given function name .

Parameters
strname of the subroutines
Returns
ASTFunction*

◆ getCalledFuns()

std::set< ASTFunction * > CallGraph::getCalledFuns ( ASTFunAppExpr e)

Return the set of functions that may be called at an application expr.

◆ getCallees() [1/2]

std::set< ASTFunction * > CallGraph::getCallees ( ASTFunction f)

Returns all the subroutines called by function f. this is an overloaded function.

Parameters
fThe AST Function node, caller is the string name of a function
Returns
The set of all callee functions node

◆ getCallees() [2/2]

std::set< ASTFunction * > CallGraph::getCallees ( std::string  caller)

◆ getCallers() [1/2]

std::set< ASTFunction * > CallGraph::getCallers ( ASTFunction f)

Returns all the subroutines that call function f.

Parameters
fThe AST Function node or sting name of the function
Returns
The set of all callers functions node

◆ getCallers() [2/2]

std::set< std::string > CallGraph::getCallers ( std::string  callee)

◆ getEdges()

std::vector< std::pair< ASTFunction *, ASTFunction * > > CallGraph::getEdges ( )

Return the set of edges for a given call graph.

◆ getTotalEdges()

int CallGraph::getTotalEdges ( )

Return the total num of edges for a given call graph.

◆ getTotalVertices()

int CallGraph::getTotalVertices ( )

Return the total num of vertices for a given call graph.

◆ getVertices()

std::vector< ASTFunction * > CallGraph::getVertices ( )

Return the set of vertices for a given call graph.

◆ print()

void CallGraph::print ( std::ostream &  os)

Print call graph contents to output stream.


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