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

Builds call graph of a program that represents calling relationships between subroutines This class overrides several ASTVisitor's methods to populate the call graph's vertices and edges. Each vertex is a subroutine of the given program, and each edge represents which subroutine calls which subroutines. More...

#include <CallGraphBuilder.h>

Inheritance diagram for CallGraphBuilder:
Inheritance graph
[legend]
Collaboration diagram for CallGraphBuilder:
Collaboration graph
[legend]

Public Member Functions

bool visit (ASTFunction *element) override
 
bool visit (ASTFunAppExpr *element) override
 
std::map< ASTFunction *, std::set< ASTFunction * > > getCallGraph ()
 Returns the call graph, call graph a map from caller to callee, the callee is a set of ASTFunction* and the caller is an ASTFunction*. More...
 
std::map< ASTFunAppExpr *, std::set< ASTFunction * > > getMayCall ()
 Returns the may call relation, which relates each call expression to the set of possible called functions. More...
 
std::map< std::string, ASTFunction * > getFunMap ()
 Returns the map from a function name to its ASTFunction*, ASTFunction* is then used to fetch further information from the graph such as to fetch the subroutines called by a function, or that call the function. More...
 

Static Public Member Functions

static CallGraphBuilder build (ASTProgram *ast, CFAnalyzer cfa)
 Returns the CallGraphBuilder for a given program. More...
 

Detailed Description

Builds call graph of a program that represents calling relationships between subroutines This class overrides several ASTVisitor's methods to populate the call graph's vertices and edges. Each vertex is a subroutine of the given program, and each edge represents which subroutine calls which subroutines.

Member Function Documentation

◆ build()

CallGraphBuilder CallGraphBuilder::build ( ASTProgram ast,
CFAnalyzer  cfa 
)
static

Returns the CallGraphBuilder for a given program.

Parameters
astThe AST of the program
cfaThe control flow analyzer
Returns
the CallGraphBuilder for the given program

◆ getCallGraph()

std::map< ASTFunction *, std::set< ASTFunction * > > CallGraphBuilder::getCallGraph ( )

Returns the call graph, call graph a map from caller to callee, the callee is a set of ASTFunction* and the caller is an ASTFunction*.

◆ getFunMap()

std::map< std::string, ASTFunction * > CallGraphBuilder::getFunMap ( )

Returns the map from a function name to its ASTFunction*, ASTFunction* is then used to fetch further information from the graph such as to fetch the subroutines called by a function, or that call the function.

Returns
std::map<std::string, ASTFunction*> fromFunNameToASTFun

◆ getMayCall()

std::map< ASTFunAppExpr *, std::set< ASTFunction * > > CallGraphBuilder::getMayCall ( )

Returns the may call relation, which relates each call expression to the set of possible called functions.

◆ visit() [1/2]

bool CallGraphBuilder::visit ( ASTFunAppExpr element)
overridevirtual

Reimplemented from ASTVisitor.

◆ visit() [2/2]

bool CallGraphBuilder::visit ( ASTFunction element)
overridevirtual

Reimplemented from ASTVisitor.


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