Skip to content

SageInterface::createTempVariableForExpression

Given an expression, generates a temporary variable whose initializer optionally evaluates that expression. Then, the var reference expression returned can be used instead of the original expression. The temporary variable created can be reassigned to the expression by the returned SgAssignOp; this can be used when the expression the variable represents needs to be evaluated. NOTE: This handles reference types correctly by using pointer types for the temporary.

Synopsis

Declared in <SageIII/sageInterface/sageInterface.h>

std::pair<SgVariableDeclaration*, SgExpression*>
createTempVariableForExpression(
    SgExpression* expression,
    SgScopeStatement* scope,
    bool initializeInDeclaration,
    SgAssignOp** reEvaluate = NULL);

Return Value

declaration of the temporary variable, and a a variable reference expression to use instead of the original expression.

Parameters

Name

Description

expression

Expression which will be replaced by a variable

scope

scope in which the temporary variable will be generated

reEvaluate

an assignment op to reevaluate the expression. Leave NULL if not needed

Created with MrDocs