Class VirtualFunctionAnalysis#
Defined in File VirtualFunctionAnalysis.h
Inheritance Relationships#
Base Type#
public PtrAliasAnalysis(Class PtrAliasAnalysis)
Class Documentation#
-
class VirtualFunctionAnalysis : public PtrAliasAnalysis#
To resolve virtual funcitons correctly we need to answer the question “What are the possible types that an object point to at a call site?” So we basically need to perform Pointer Aliasing Analysis.
For this project we opted to do InterProcedural FlowSensitive DataFlow Analysis as described in
“Flow-Sensitive Interprocedural Type Analysis for C++”, TechReport ‘95 Paul Carini Harini Srinivasan
So we perform Pointer Alias Analysis and Virtual Function Analysis simultenously which in turn complements each other to be more precise. The basic idea is as follows:
Compute a call graph ignoring all the virtual function calls.
Iterate over the nodes of the call graph topologically and reverse topologically in alternative iteration until no Alias information is modified. i. For each function:
Compute a Control Flow Graph consists of nodes which can generate new aliases eg. SgAssignOp, SgAssignInitializer, SgFunctionCallExp, SgConstructorInitializer etc.
Compute the alias relations for each node ii. Perform IntraProcDataFlowAnalysis util they stabilizes
Propagate the Alias relation over the ControlFlow Graph to generate entry and exit CompactRepresentation
for each node.
iii. Using the Alias Information resolve the possible function callsites within this function
Handle the Function Parameters, return types and Constructor parameters correctly. iv. Compute Entry for all the functions called from this function
Virutal Function Analysis and PointerAliasAnalysis are dependent on each other for their accuracy. That’s why they are done together
Public Functions
-
inline VirtualFunctionAnalysis(SgProject *__project)#
-
virtual void run()#
Function which actually performs the DataFlowAnalyis.
-
void reset()#
DataFlow based Virtual function resolve technique is expensive. So it’s memorized so that subsequent resolve calls can be answered. This function reset the memorization.
-
void pruneCallGraph(CallGraphBuilder&)#
Using the DataFlow based Virtual Function Analysis it prunes the call graph to generate more precise and accurate call graph.
-
void resolveFunctionCall(SgExpression*, std::vector<SgFunctionDeclaration*>&)#
Given a Callsite(SgFunctionCallExp or SgConstructionInitializer) it resolves the function calls. For Virtual Functions it returns the minimal set of functions that may be execute at runtime.
-
inline ~VirtualFunctionAnalysis()#