1 #include <featureTests.h>
2 #ifdef ROSE_ENABLE_SOURCE_ANALYSIS
7 #include "analysisCommon.h"
9 #include "functionState.h"
13 #include <boost/shared_ptr.hpp>
42 std::vector<Lattice*>& initLattices, std::vector<NodeFact*>& initFacts)=0;
48 std::set<Function> visited;
54 { this->interAnalysis = intraDFAnalysis->interAnalysis; }
64 virtual bool runAnalysis(
const Function& func,
NodeState* state,
bool analyzeDueToCallers, std::set<Function> calleesUpdated)=0;
72 bool analyzeDueToCallers =
true;
75 std::set<Function> calleesUpdated;
77 return runAnalysis(func, state, analyzeDueToCallers, calleesUpdated);
94 const std::vector<Lattice*> &dfInfo;
99 : func(f), dfNode(n), nodeState(s), dfInfo(d)
102 virtual bool finish() = 0;
130 void visit(
SgNode *n) { modified = analysis->transfer(func, dfNode, nodeState, dfInfo); }
131 bool finish() {
return modified; }
149 virtual boost::shared_ptr<IntraDFTransferVisitor> getTransferVisitor(
const Function& func,
const DataflowNode& n,
150 NodeState& state,
const std::vector<Lattice*>& dfInfo)
151 {
return boost::shared_ptr<IntraDFTransferVisitor>(
new DefaultTransfer(func, n, state, dfInfo,
this)); }
171 const std::vector<Lattice*>& dfInfo, std::vector<Lattice*>** retState,
bool fw)=0;
182 this->dfAnalysis = dfAnalysis;
183 this->filter = dfAnalysis->filter;
194 const std::set<Function>& funcsToFind;
197 std::map<Function, std::set<DataflowNode> > funcCalls;
206 std::map<Function, std::set<DataflowNode> >& getFuncCalls() {
return funcCalls; }
217 bool runAnalysis(
const Function& func,
NodeState* state,
bool analyzeDueToCallers, std::set<Function> calleesUpdated);
222 bool propagateStateToNextNode(
223 const std::vector<Lattice*>& curNodeState,
DataflowNode curDFNode,
int nodeIndex,
224 const std::vector<Lattice*>& nextNodeState,
DataflowNode nextDFNode);
226 std::vector<DataflowNode> gatherDescendants(std::vector<DataflowEdge> edges,
231 getInitialWorklist(
const Function &func,
bool firstVisit,
bool analyzeDueToCallers,
const set<Function> &calleesUpdated,
NodeState *fState) = 0;
232 virtual vector<Lattice*> getLatticeAnte(
NodeState *state) = 0;
233 virtual vector<Lattice*> getLatticePost(
NodeState *state) = 0;
240 virtual vector<DataflowNode> getDescendants(
const DataflowNode &n) = 0;
254 getInitialWorklist(
const Function &func,
bool firstVisit,
bool analyzeDueToCallers,
const set<Function> &calleesUpdated,
NodeState *fState);
255 vector<Lattice*> getLatticeAnte(
NodeState *state);
256 vector<Lattice*> getLatticePost(
NodeState *state);
258 vector<DataflowNode> getDescendants(
const DataflowNode &n);
272 getInitialWorklist(
const Function &func,
bool firstVisit,
bool analyzeDueToCallers,
const set<Function> &calleesUpdated,
NodeState *fState);
273 virtual vector<Lattice*> getLatticeAnte(
NodeState *state);
274 virtual vector<Lattice*> getLatticePost(
NodeState *state);
276 vector<DataflowNode> getDescendants(
const DataflowNode &n);
339 this->analysis = analysis;
345 std::vector<Lattice*>& initLattices, std::vector<NodeFact*>& initFacts);
377 const std::vector<Lattice*>& dfInfo, std::vector<Lattice*>** retState,
bool fw)
395 std::vector<Lattice*> mergedLatsRetStmt;
396 std::vector<Lattice*> mergedLatsRetVal;
411 MergeAllReturnStates(
Analysis* analysis,
const std::vector<Lattice*>& mergedLatsRetStmt,
const std::vector<Lattice*>& mergedLatsRetVal):
412 analysis(analysis), mergedLatsRetStmt(mergedLatsRetStmt), mergedLatsRetVal(mergedLatsRetVal)
419 static bool mergeLats(std::vector<Lattice*>& mergedLat,
const std::vector<Lattice*>& lats);
422 std::vector<Lattice*>& getMergedLatsRetStmt() {
return mergedLatsRetStmt; }
425 std::vector<Lattice*>& getMergedLatsRetVal() {
return mergedLatsRetVal; }
428 bool getModified() {
return modified; }
440 std::vector<Lattice*>& latsAtFuncReturn;
442 std::vector<Lattice*>& latsRetVal;
447 DFStateAtReturns(std::vector<Lattice*>& latsAtFuncReturn, std::vector<Lattice*>& latsRetVal);
458 std::vector<Lattice*>& getLatsAtFuncReturn() {
return latsAtFuncReturn; }
461 std::vector<Lattice*>& getLatsRetVal() {
return latsRetVal; }
463 std::string str(std::string indent);
475 std::set<Function> remainingDueToCallers;
481 std::map<Function, std::set<Function> > remainingDueToCalls;
500 const std::vector<Lattice*>& dfInfo, std::vector<Lattice*>** retState,
bool fw);