ROSE  0.11.145.0
functionEvaluationOrderTraversal.h
1 #pragma once
2 
3 // DQ (10/5/2014): This is more strict now that we include rose_config.h in the sage3basic.h.
4 // #include "rose.h"
5 // rose.h and sage3basic.h should not be included in librose header files. [Robb P. Matzke 2014-10-15]
6 // #include "sage3basic.h"
7 
9 {
13 
16 
18  enum
19  {
20  INSIDE_FOR_INIT, INSIDE_FOR_TEST, INSIDE_FOR_INCREMENT, INSIDE_WHILE_CONDITION,
21  INSIDE_DO_WHILE_CONDITION, IN_SAFE_PLACE, INSIDE_CONDITIONAL_EXP_TRUE_ARM, INSIDE_CONDITIONAL_EXP_FALSE_ARM, INSIDE_SHORT_CIRCUIT_EXP_RHS
22  }
24 
26  FunctionCallInheritedAttribute() : currentScope(NULL), lastStatement(NULL), scopeStatus(IN_SAFE_PLACE) { }
27 };
28 
31 {
34 
38 
41  {
46  INVALID
47  };
48 
51 
53  functionCall(function),
54  tempVarDeclarationLocation(NULL),
55  tempVarDeclarationInsertionMode(INVALID) { }
56 };
57 
58 
61 
62 class FunctionEvaluationOrderTraversal : public AstTopDownBottomUpProcessing<FunctionCallInheritedAttribute, bool>
63 {
64 public:
67  static std::pair< std::vector<FunctionCallInfo>, std::vector<FunctionCallInfo> > GetFunctionCalls(SgNode* root);
68 
71 
74 
76  virtual bool IsFunctionCallSideEffectFree(SgFunctionCallExp* functionCall);
77 
78 private:
79 
81 
83 
85  std::vector<FunctionCallInfo> normalizableFunctionCalls;
87  std::vector<FunctionCallInfo> nonNormalizableFunctionCalls;
88 };
89 
SgNode * currentScope
The innermost scope inside of which this AST node resides.
virtual bool IsFunctionCallSideEffectFree(SgFunctionCallExp *functionCall)
Returns true if the function call has no side effects.
SgStatement * lastStatement
The last statement encountered before the current node in the AST.
static std::pair< std::vector< FunctionCallInfo >, std::vector< FunctionCallInfo > > GetFunctionCalls(SgNode *root)
Traverses the subtree of the given AST node and finds all function calls in function-evaluation order...
SgFunctionCallExp * functionCall
The function call expression.
enum FunctionCallInheritedAttribute::@712 scopeStatus
Is the current node inside a for loop or conditional expresion structure (not the body)...
Stores a function call expression, along with associated information about its context.
This class represents the base class for all IR nodes within Sage III.
Definition: Cxx_Grammar.h:9846
InsertionMode
How a statement should be inserted.
This class represents the notion of a statement.
FunctionCallInheritedAttribute evaluateInheritedAttribute(SgNode *astNode, FunctionCallInheritedAttribute parentAttribute)
Visits AST nodes in pre-order.
Insert right before the given statement.
InsertionMode tempVarDeclarationInsertionMode
How to insert the temporary variable declaration.
Traverses a given AST and finds all function calls in the order in which they're evaluated Also...
bool evaluateSynthesizedAttribute(SgNode *astNode, FunctionCallInheritedAttribute parentAttribute, SynthesizedAttributesList)
Visits AST nodes in post-order.
Insert at the bottom of the scope defined by the given statement.
SgStatement * tempVarDeclarationLocation
When a variable is created to replace one of the arguments of this function, where should it be inser...
Attribute Evaluator for inherited and synthesized attributes.
This class represents the concept of a C++ function call (which is an expression).