ROSE  0.9.6a
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ExtractFunctionArguments.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <rose.h>
5 
6 //class FunctionCallInfo;
7 
14 {
15 public:
16 
19  void NormalizeTree(SgNode* tree, bool doUnsafeNormalization = false);
20 
21  // returns a vector of newly introduced temporaries
22  std::vector<SgVariableDeclaration*> GetTemporariesIntroduced();
23 
24  /*
25  IsNormalized: Given a subtree, returns true if every argument of every function call is a trivial arguemnt.
26  */
27  bool IsNormalized(SgNode* tree);
28 
29  /*
30  IsNormalizable: Given a subtree, returns true if every argument of every function call is a either trivial arguemnt or
31  is present in a SAFE place from where lifting is possible.
32  */
33  bool IsNormalizable(SgNode* tree);
34 
35 
36 private:
37 
38  std::vector<SgVariableDeclaration*> temporariesIntroduced;
39  std::pair< std::vector<FunctionCallInfo>, std::vector<FunctionCallInfo> > functionCalls;
40 
46 
49  bool FunctionArgsNeedNormalization(SgExprListExp* functionArgs);
50 
54 
57  void RewriteFunctionCallArguments(const FunctionCallInfo& functionCallInfo);
58 
61  void InsertStatement(SgStatement* newStatement, SgStatement* location, const FunctionCallInfo& insertionMode);
62 
64 
65 
66  /* Given the expression which is the argument to a function call, returns true if that
67  expression is trivial. Trivial expressions are those which are simple variable references or constants.
68  */
70 
71  /* Given a vector of function call sites returns true if every argument of every function call is a trivial expression
72  (IsFunctionArgumentTrivial). Such functions don't need to be normalized.
73  */
74  bool AreAllFunctionCallsTrivial(std::vector<FunctionCallInfo> functions);
75 
76  /* Given a vector of function call sites, returns true if every argument
77  at every function call site is either trivial (IsFunctionArgumentTrivial) or can be normalized (FunctionArgumentCanBeNormalized).
78  */
79  bool AreAllFunctionCallsNormalizable(std::vector<FunctionCallInfo> functions);
80 };