Skip to content

SageBuilder::buildVarRefExp

buildVarRefExp overloads

Synopses

Declared in <SageIII/sageInterface/sageBuilder.h>

Build a variable reference from an existing variable declaration. The assumption is a SgVariableDeclartion only declares one variable in the ROSE AST.

[[visibility]]
SgVarRefExp*
buildVarRefExp(SgVariableDeclaration* vardecl);

Build a variable reference from an existing symbol

[[visibility]]
SgVarRefExp*
buildVarRefExp(SgVariableSymbol* varSymbol);

It is possible to build a reference to a variable with known name before thevariable is declared, especially during bottomup construction of AST. In thiscase, SgTypeUnknown is used to indicate the variable reference needingpostprocessing fix using fixVariableReferences() once the AST is complete andall variable declarations exist. But the side effect is that some get_type()operations may not recognize the unknown type before the fix. So far, I extendedSgPointerDerefExp::get_type() and SgPntrArrRefExp::get_type() for SgTypeUnknown.There may be others needing the same extension.

[[visibility]]
SgVarRefExp*
buildVarRefExp(
    SgName const& name,
    SgScopeStatement* scope = NULL);

Build SgVarRefExp based on a variable's name. It will lookup symbol table internally starting from scope. A variable is unique so type can be inferred.

[[visibility]]
SgVarRefExp*
buildVarRefExp(
    std::string const& varName,
    SgScopeStatement* scope = NULL);

Build a variable reference from an initialized name It first tries to grab the associated symbol, then call buildVarRefExp(const SgName& name, SgScopeStatement*) if symbol does not exist.

[[visibility]]
SgVarRefExp*
buildVarRefExp(
    SgInitializedName* initname,
    SgScopeStatement* scope = NULL);

Build a variable reference using a C style char array

[[visibility]]
SgVarRefExp*
buildVarRefExp(
    char const* varName,
    SgScopeStatement* scope = NULL);

Created with MrDocs