ROSE  0.9.6a
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ExtractFunctionArguments Class Reference

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
 

Detailed Description

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.

Member Function Documentation

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)
bool ExtractFunctionArguments::FunctionArgumentNeedsNormalization ( SgExpression argument)
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.

bool ExtractFunctionArguments::FunctionArgsNeedNormalization ( SgExprListExp functionArgs)
private

Returns true if any of the arguments of the given function call will need to be extracted.

bool ExtractFunctionArguments::SubtreeNeedsNormalization ( SgNode top)
private

Returns true if any function calls in the given subtree will need to be instrumented.

(to extract function arguments).

void ExtractFunctionArguments::RewriteFunctionCallArguments ( const FunctionCallInfo functionCallInfo)
private

Given the information about a function call (obtained through a traversal), extract its arguments into temporary variables where it is necessary.

void ExtractFunctionArguments::InsertStatement ( SgStatement newStatement,
SgStatement location,
const FunctionCallInfo insertionMode 
)
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.

bool ExtractFunctionArguments::FunctionArgumentCanBeNormalized ( SgExpression argument)
private
bool ExtractFunctionArguments::IsFunctionArgumentTrivial ( SgExpression argument)
private
bool ExtractFunctionArguments::AreAllFunctionCallsTrivial ( std::vector< FunctionCallInfo functions)
private
bool ExtractFunctionArguments::AreAllFunctionCallsNormalizable ( std::vector< FunctionCallInfo functions)
private

Member Data Documentation

std::vector<SgVariableDeclaration*> ExtractFunctionArguments::temporariesIntroduced
private

Definition at line 38 of file ExtractFunctionArguments.h.

std::pair< std::vector<FunctionCallInfo>, std::vector<FunctionCallInfo> > ExtractFunctionArguments::functionCalls
private

Definition at line 39 of file ExtractFunctionArguments.h.


The documentation for this class was generated from the following file: