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