24 std::vector<ASTFunction *> vertices;
25 std::vector<std::pair<ASTFunction *, ASTFunction *>> edges;
28 std::map<ASTFunction *, std::set<ASTFunction *>> callGraph;
29 std::map<std::string, ASTFunction *> fromFunNameToASTFuns;
30 std::map<ASTFunAppExpr *, std::set<ASTFunction *>> mayCall;
35 std::vector<ASTFunction *> funs,
36 std::map<std::string, ASTFunction *> fmap)
37 : callGraph(cGraph), mayCall(mc), vertices(funs),
38 total_vertices(vertices.size()), fromFunNameToASTFuns(fmap) {}
60 std::vector<std::pair<ASTFunction *, ASTFunction *>>
getEdges();
72 std::set<ASTFunction *>
getCallees(std::string caller);
79 std::set<std::string>
getCallers(std::string callee);
82 void print(std::ostream &os);
88 bool existEdge(std::string caller, std::string callee);
Class for function call expressions.
Definition: ASTFunAppExpr.h:7
Class for defining the signature, local declarations, and a body of a function.
Definition: ASTFunction.h:11
Class for a program which is a name and a list of functions.
Definition: ASTProgram.h:11
Performs control flow analysis and records results for subsequent phases Generates call graph of a pr...
Definition: CallGraph.h:22
std::vector< ASTFunction * > getVertices()
Return the set of vertices for a given call graph.
Definition: CallGraph.cpp:23
std::vector< std::pair< ASTFunction *, ASTFunction * > > getEdges()
Return the set of edges for a given call graph.
Definition: CallGraph.cpp:25
static std::shared_ptr< CallGraph > build(ASTProgram *, SymbolTable *st)
Return the shared pointer of the call graph for a given program.
Definition: CallGraph.cpp:4
std::set< ASTFunction * > getCallees(ASTFunction *f)
Returns all the subroutines called by function f. this is an overloaded function.
Definition: CallGraph.cpp:39
void print(std::ostream &os)
Print call graph contents to output stream.
Definition: CallGraph.cpp:78
int getTotalVertices()
Return the total num of vertices for a given call graph.
Definition: CallGraph.cpp:12
std::set< ASTFunction * > getCalledFuns(ASTFunAppExpr *e)
Return the set of functions that may be called at an application expr.
Definition: CallGraph.cpp:35
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)
Definition: CallGraph.h:33
ASTFunction * getASTFun(std::string f_name)
Returns the ASTFunction* for a given function name .
Definition: CallGraph.cpp:104
bool existEdge(std::string caller, std::string callee)
Returns bool value indicating whether there is an edge between two subroutines.
Definition: CallGraph.cpp:95
int getTotalEdges()
Return the total num of edges for a given call graph.
Definition: CallGraph.cpp:14
std::set< ASTFunction * > getCallers(ASTFunction *f)
Returns all the subroutines that call function f.
Definition: CallGraph.cpp:68
Performs symbol analysis and records results for subsequent phases.
Definition: SymbolTable.h:17