Skip to content

ExtractFunctionArguments

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.

Synopsis

Declared in <src/midend/programTransformation/extractFunctionArgumentsNormalization/ExtractFunctionArguments.h>

class ExtractFunctionArguments;

Member Functions

Name Description
GetTemporariesIntroduced
std::vector<SgVariableDeclaration*> GetTemporariesIntroduced();
IsNormalizable
bool IsNormalizable(SgNode* tree);
IsNormalized
bool IsNormalized(SgNode* tree);
NormalizeTree
void NormalizeTree( SgNode* tree, bool doUnsafeNormalization = false);
Performs the function argument extraction on all function calls in the given subtree of the AST.

Private Member Functions

Name Description
AreAllFunctionCallsNormalizable
bool AreAllFunctionCallsNormalizable(std::vector<FunctionCallInfo> functions);
AreAllFunctionCallsTrivial
bool AreAllFunctionCallsTrivial(std::vector<FunctionCallInfo> functions);
FunctionArgsNeedNormalization
bool FunctionArgsNeedNormalization(SgExprListExp* functionArgs);
Returns true if any of the arguments of the given function call will need to be extracted.
FunctionArgumentCanBeNormalized
bool FunctionArgumentCanBeNormalized(SgExpression* argument);
FunctionArgumentNeedsNormalization
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. 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.
InsertStatement
void InsertStatement( SgStatement* newStatement, SgStatement* location, FunctionCallInfo const& insertionMode);
Insert a new statement in the specified location. The actual insertion can occur either before or after the location depending on the insertion mode.
IsFunctionArgumentTrivial
bool IsFunctionArgumentTrivial(SgExpression* argument);
RewriteFunctionCallArguments
void RewriteFunctionCallArguments(FunctionCallInfo const& functionCallInfo);
Given the information about a function call (obtained through a traversal), extract its arguments into temporary variables where it is necessary.
SubtreeNeedsNormalization
bool SubtreeNeedsNormalization(SgNode* top);
Returns true if any function calls in the given subtree will need to be instrumented. (to extract function arguments).

Private Data Members

Name
functionCalls
temporariesIntroduced

Created with MrDocs