ROSE  0.11.96.11
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 
27 };
28 
31 {
34 
38 
41  {
46  INVALID
47  };
48 
51 
53  functionCall(function),
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 
FunctionCallInfo
Stores a function call expression, along with associated information about its context.
Definition: functionEvaluationOrderTraversal.h:30
AstTopDownBottomUpProcessing
Attribute Evaluator for inherited and synthesized attributes.
Definition: AstProcessing.h:184
FunctionEvaluationOrderTraversal::evaluateInheritedAttribute
FunctionCallInheritedAttribute evaluateInheritedAttribute(SgNode *astNode, FunctionCallInheritedAttribute parentAttribute)
Visits AST nodes in pre-order.
FunctionEvaluationOrderTraversal::GetFunctionCalls
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
This class represents the concept of a C++ function call (which is an expression).
Definition: Cxx_Grammar.h:288304
FunctionCallInfo::functionCall
SgFunctionCallExp * functionCall
The function call expression.
Definition: functionEvaluationOrderTraversal.h:33
FunctionCallInheritedAttribute::FunctionCallInheritedAttribute
FunctionCallInheritedAttribute()
Default constructor.
Definition: functionEvaluationOrderTraversal.h:26
FunctionCallInfo::InsertionMode
InsertionMode
How a statement should be inserted.
Definition: functionEvaluationOrderTraversal.h:40
FunctionCallInfo::APPEND_SCOPE
@ APPEND_SCOPE
Insert at the bottom of the scope defined by the given statement.
Definition: functionEvaluationOrderTraversal.h:45
SgNode
This class represents the base class for all IR nodes within Sage III.
Definition: Cxx_Grammar.h:6739
FunctionEvaluationOrderTraversal
Traverses a given AST and finds all function calls in the order in which they're evaluated Also,...
Definition: functionEvaluationOrderTraversal.h:62
FunctionCallInheritedAttribute
Definition: functionEvaluationOrderTraversal.h:8
FunctionCallInheritedAttribute::lastStatement
SgStatement * lastStatement
The last statement encountered before the current node in the AST.
Definition: functionEvaluationOrderTraversal.h:15
StackFrameVector
Definition: StackFrameVector.h:43
FunctionEvaluationOrderTraversal::IsFunctionCallSideEffectFree
virtual bool IsFunctionCallSideEffectFree(SgFunctionCallExp *functionCall)
Returns true if the function call has no side effects.
FunctionEvaluationOrderTraversal::evaluateSynthesizedAttribute
bool evaluateSynthesizedAttribute(SgNode *astNode, FunctionCallInheritedAttribute parentAttribute, SynthesizedAttributesList)
Visits AST nodes in post-order.
FunctionCallInfo::tempVarDeclarationInsertionMode
InsertionMode tempVarDeclarationInsertionMode
How to insert the temporary variable declaration.
Definition: functionEvaluationOrderTraversal.h:50
FunctionCallInheritedAttribute::currentScope
SgNode * currentScope
The innermost scope inside of which this AST node resides.
Definition: functionEvaluationOrderTraversal.h:12
SgStatement
This class represents the notion of a statement.
Definition: Cxx_Grammar.h:122747
FunctionCallInfo::INSERT_BEFORE
@ INSERT_BEFORE
Insert right before the given statement.
Definition: functionEvaluationOrderTraversal.h:43
FunctionCallInfo::tempVarDeclarationLocation
SgStatement * tempVarDeclarationLocation
When a variable is created to replace one of the arguments of this function, where should it be inser...
Definition: functionEvaluationOrderTraversal.h:37
FunctionCallInheritedAttribute::scopeStatus
enum FunctionCallInheritedAttribute::@681 scopeStatus
Is the current node inside a for loop or conditional expresion structure (not the body).