ROSE  0.9.9.139
functionState.h
1 #if !defined(FUNCTION_STATE_H) && !defined(NO_FUNCTION_STATE_H)
2 #define FUNCTION_STATE_H
3 
4 #include "analysisCommon.h"
5 #include "nodeState.h"
6 #include "CallGraphTraverse.h"
7 #include <map>
8 #include <set>
9 
11 {
12  friend class CollectFunctions;
13  public:
14  Function func;
15  NodeState state;
16  // The lattices that describe the value of the function's return variables
17  NodeState retState;
18 
19  private:
20  static std::set<FunctionState*> allDefinedFuncs;
21  static std::set<FunctionState*> allFuncs;
22  static bool allFuncsComputed;
23 
24  public:
25  FunctionState(Function &func):
26  func(func),
27  state(/*func.get_declaration()->cfgForBeginning()*/)
28  {}
29 
30  Function& getFunc();
31 
32  // returns a set of all the functions whose bodies are in the project
33  static std::set<FunctionState*>& getAllDefinedFuncs();
34 
35  // returns a set of all the functions whose declarations are in the project
36  static std::set<FunctionState*>& getAllFuncs();
37 
38  // returns the FunctionState associated with the given function
39  // func may be any defined function
40  static FunctionState* getDefinedFuncState(const Function& func);
41 
42  // returns the FunctionState associated with the given function
43  // func may be any declared function
44  static FunctionState* getFuncState(const Function& func);
45 
46  // given a function call, sets argParamMap to map all simple arguments to this function to their
47  // corresponding parameters
48  static void setArgParamMap(SgFunctionCallExp* call, std::map<varID, varID>& argParamMap);
49 
50  // given a function call, sets argParamMap to map all the parameters of this function to their
51  // corresponding simple arguments, if those arguments are passed by reference
52  static void setParamArgByRefMap(SgFunctionCallExp* call, std::map<varID, varID>& paramArgByRefMap);
53 };
54 
55 class CollectFunctions : public TraverseCallGraphUnordered/*TraverseCallGraphBottomUp<int>*/
56 {
57  public:
58  CollectFunctions(SgIncidenceDirectedGraph* graph) : TraverseCallGraphUnordered/*TraverseCallGraphBottomUp<int>*/(graph)
59  {}
60 
61  //int visit(const CGFunction* func, list<int> fromCallees);
62  void visit(const CGFunction* func);
63 
64  virtual ~CollectFunctions() {}
65 };
66 
67 #endif
This class represents the concept of a C++ function call (which is an expression).