ROSE
0.9.6a
|
This normalization makes sure each function call argument is a side-effect free expression of only one variable. More...
#include <ExtractFunctionArguments.h>
Public Member Functions | |
void | NormalizeTree (SgNode *tree, bool doUnsafeNormalization=false) |
Performs the function argument extraction on all function calls in the given subtree of the AST. More... | |
std::vector < SgVariableDeclaration * > | GetTemporariesIntroduced () |
bool | IsNormalized (SgNode *tree) |
bool | IsNormalizable (SgNode *tree) |
Private Member Functions | |
bool | FunctionArgumentNeedsNormalization (SgExpression *argument) |
Given the expression which is the argument to a function call, returns true if that expression should be pulled out into a temporary variable on a separate line. More... | |
bool | FunctionArgsNeedNormalization (SgExprListExp *functionArgs) |
Returns true if any of the arguments of the given function call will need to be extracted. More... | |
bool | SubtreeNeedsNormalization (SgNode *top) |
Returns true if any function calls in the given subtree will need to be instrumented. More... | |
void | RewriteFunctionCallArguments (const FunctionCallInfo &functionCallInfo) |
Given the information about a function call (obtained through a traversal), extract its arguments into temporary variables where it is necessary. More... | |
void | InsertStatement (SgStatement *newStatement, SgStatement *location, const FunctionCallInfo &insertionMode) |
Insert a new statement in the specified location. More... | |
bool | FunctionArgumentCanBeNormalized (SgExpression *argument) |
bool | IsFunctionArgumentTrivial (SgExpression *argument) |
bool | AreAllFunctionCallsTrivial (std::vector< FunctionCallInfo > functions) |
bool | AreAllFunctionCallsNormalizable (std::vector< FunctionCallInfo > functions) |
Private Attributes | |
std::vector < SgVariableDeclaration * > | temporariesIntroduced |
std::pair< std::vector < FunctionCallInfo > , std::vector < FunctionCallInfo > > | functionCalls |
This normalization makes sure each function call argument is a side-effect free expression of only one variable.
To accomplish this, temporary variables are declared and the arguments of a function are evaluated before the function itself. Note: Normalization is not performed if it is unsafe. E,g.: while(Foo(Bar()) {} is not equal to t = Bar(); while(Foo(t) {} Note that only SgFunctionCall arguments are normalized. For example the arguments of the constructor initializer MyObject o(foo(), bar()) will not be extracted.
Definition at line 13 of file ExtractFunctionArguments.h.
void ExtractFunctionArguments::NormalizeTree | ( | SgNode * | tree, |
bool | doUnsafeNormalization = false |
||
) |
Performs the function argument extraction on all function calls in the given subtree of the AST.
It does not do transofrmations in places where it is not safe. If you pass doUnsafeNormalization= true, we will normalize all call sites ignoring the safety (Suggested by Markus Schordan)
std::vector<SgVariableDeclaration*> ExtractFunctionArguments::GetTemporariesIntroduced | ( | ) |
bool ExtractFunctionArguments::IsNormalized | ( | SgNode * | tree) |
bool ExtractFunctionArguments::IsNormalizable | ( | SgNode * | tree) |
|
private |
Given the expression which is the argument to a function call, returns true if that expression should be pulled out into a temporary variable on a separate line.
E.g. if the expression contains a function call, it needs to be normalized, while if it is a constant, there is no need to change it.
|
private |
Returns true if any of the arguments of the given function call will need to be extracted.
|
private |
Returns true if any function calls in the given subtree will need to be instrumented.
(to extract function arguments).
|
private |
Given the information about a function call (obtained through a traversal), extract its arguments into temporary variables where it is necessary.
|
private |
Insert a new statement in the specified location.
The actual insertion can occur either before or after the location depending on the insertion mode.
|
private |
|
private |
|
private |
|
private |
|
private |
Definition at line 38 of file ExtractFunctionArguments.h.
|
private |
Definition at line 39 of file ExtractFunctionArguments.h.