Skip to content

SgInitializedName

This class represents the notion of a declared variable.

Synopsis

Declared in <src/frontend/SageIII/Cxx_Grammar.h>

class SgInitializedName
    : public SgLocatedNodeSupport

Base Classes

Name

Description

SgLocatedNodeSupport

Friends

Name

Description

isSgInitializedName

Casts pointer from base class to derived class (for const pointers)

isSgInitializedName

Casts pointer from base class to derived class

Non-Member Functions

Name

Description

findVariablesUsedInRegion

Find all variables referenced in a region

operator!=

Inequality operator

operator==

Equality operator

removeVariableDeclaration

Remove the declaration of a given variable

OmpSupport::addClauseVariable

Add a variable into a non‐reduction clause of an OpenMP statement, create the clause transparently if it does not exist

OmpSupport::collectThreadprivateVariables

Collect threadprivate variables within the current project, return a set to avoid duplicated elements. No input parameters are needed since it finds match from memory pools

OmpSupport::getReductionOperationType

Return a reduction variable's reduction operation type

OmpSupport::isInClauseVariableList

Check if a variable is in a variable list of a given clause type

OmpSupport::isInClauseVariableList

Check if a variable is in variable lists of given clause types

SageBuilder::buildFunctionParameterList

Build an empty SgFunctionParameterList, possibly with some initialized names filled in

SageBuilder::buildInitializedName

e.g the scope of arguments of functions are different for defining and nondefining functions.

SageBuilder::buildVarRefExp

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.

SageInterface::convertRefToInitializedName

Variable references can be introduced by SgVarRef, SgPntrArrRefExp, SgInitializedName, SgMemberFunctionRef etc. For Dot and Arrow Expressions, their lhs is used to obtain SgInitializedName (coarse grain) by default. Otherwise, fine‐grain rhs is used.

SageInterface::getFirstInitializedName

Get the first initialized name of a declaration statement

SageInterface::getFirstVariable

convenience function that returns the first initialized name in a list of variable declarations.

SageInterface::getInParameters

Get a vector of input parameters from the function parameter list

SageInterface::getLoopIndexVariable

Return the loop index variable for a for loop

SageInterface::getOutParameters

Get a vector of output parameters from the function parameter list

SageInterface::isLoopIndexVariable

Check if a SgInitializedName is used as a loop index within a AST subtree This function will use a bottom‐up traverse starting from the subtree_root to find all enclosing loops and check if ivar is used as an index for either of them.

SageInterface::isMutable

True if an SgInitializedName is "mutable' (has storage modifier set)

SageInterface::set_name

set_name of symbol in symbol table.

SgNodeHelper::getInitializedNameOfVariableDeclaration

returns the initialized name object of a variable declaration. Otherwise it throws an exception.

SgNodeHelper::getSymbolOfInitializedName

returns the SgSymbol* of a SgInitializedName

Description

Each variable in the program has a SgInitializedName object which represents its definition. A SgVariableDeclaration for example might contain several SgInitializedName objects, while the SgInitializedName contains the declaration for one variable. Each variable use (VarRefExp for example) must have a link to the SgInitializedName object where that specific variable was defined. What really happens Currently, each SgVariableDeclaration contains only one SgInitializedName In order to have a valid SgInitializedName object, this information must be provided : ‐ the variable name which represents the variable that is being declared in this class. ‐ the variable type ‐ the declaration object which contains the SgInitializedName ( this might be a SgVariableDeclaration, SgFunctionParameterList, SgClassDeclaration,etc) ‐ See also: Example of creating an SgInitializedName object Example of using an SgInitializedName object

Data members

#### SgInitializedName::p_fileInfo This pointer is always valid and stores the source position of the start a name. This is an Sg_File_Info object which represents the source position of the starting of the name represented by the SgInitializedName object (variable name, function name, etc.).

#### SgInitializedName::p_name The variable that is declared in this declaration This is a SgName object which represents the variable that is being declared in this SgInitializedName object. For example, if there is a "int x" declaration in the code, "x" is the variable that will be stored in SgInitializedName::p_name as a SgName object.

#### SgInitializedName::p_typeptr Pointer to a type object that has been associated with SgInitializedName::p_name This is a pointer that points to an SgType object that represents the type the variable SgInitializedName::p_name declared in this SgInitializedName class (in this declaration). For example, if the variable is of type "int" (as in "int x"), then a SgTypeInt object has to be allocated , and a pointer to this SgTypeInt object has to be stored in SgInitializedName::p_typeptr to represent the type of SgInitializedName::p_name.

#### SgInitializedName::p_initptr Pointer to an initializer for the variable. In the case that the declaration contains an initializer for the variable, for example "int x=5" or "int x=y" (in these cases the intializers for the declared variable are "5" and "y"), that initializer has to be stored in SgInitializedName::p_initptr as a pointer that points to the SgInitializer object that the SgInitializedName::p_name variable is initialized with.

#### SgInitializedName::p_prev_decl_item Pointer to the initial uses of this variable previous to its redeclaration declaration. Dan's intuitive explanation This pointer references any initialized name previously built to define a SgVarRefExp, which requires a pointer to a variable declaration (but points to a SgInitializedName since a SgVariableDeclaration could stand for many variables (not just one, e.g. "int x,y,z;"), since uniqueness is required. Although non‐intuative, C++ code defined within a class definition can reference variables before they are defined (e.g. "class X { int foo() { return x; } int x; };"), see test2005_67.C (non‐static data member) and test2005_68.C (static data member). It is also used by a SgInitializedName in a static declaration outside the class to refer to the preliminary declaration inside the class. (e.g. "class X { static int a;}; int X::a = 0; };")

#### SgInitializedName::p_is_initializer flag to determine whether the declaration has an initializer. If the declaration has an initializer, for example "int x=5", then this flag is set to true. The flag is set to false otherwise.

#### SgInitializedName::p_declptr Pointer to the declaration object where this SgInitializedName object belongs to. Alin's intuitive explanation Each SgInitializedName object contains the declaration of one variable. In the case where the code has more declarations in a single statement, for example "int x=5,y=3;", that declaration is composed of two SgInitializedName objects, one for each variable declared in that statment. So, this SgInitializedName::p_declptr points to the statement (actually the declaration ‐ SgDeclaration) that contains it. What really happens For the first SgInitializedName, this points to the the SgDeclarationStatement that contains this SgInitializedName. For the second one, it is set to an unknown SgDeclarationStatement that does not show up in the pdf or the dot files (not traversed). Dan's explaination This points to the SgVariableDefinition and is the same as get_definition().

#### SgInitializedName::p_itemptr Pointer to the next SgInitializedName in the declaration. Alin's intuitive explanation This is a pointer to the next SgInitializedName in a declaration statement. For example, if there is a declaration statement of this form "int x=5,y=3", and the current SgInitializedName represents variable "x", the next SgInitializedName in the current declaration is for the variable "y". What really happens This is the pointer that points to a nested SgInitializedName object that has the same variable name, variable type, but it has a different declaration statement and a different SgStorageModifier (this one makes sens). For the nested SgInitalizedName::p_itemptr object, this data member is set to 0 and the SgInitializedName::p_prev_itemptr data member is set to the parent SgInitializedName.

#### SgInitializedName::p_prev_itemptr Pointer to the previous SgInitializedName in the declaration. Alin's intuitive explanation This is a pointer to the previous SgInitializedName in a declaration statement. For example, if there is a declaration statement of this form "int x=5,y=3", and the current SgInitializedName represents variable "y", the next SgInitializedName in the current declaration is for the variable "x". What really happens For the first level SgInitializedName, this data member is set to 0. For the nested one, this is set to the parent SgInitializedName.

#### SgInitializedName::p_storageModifier This is the storage modifier (static, auto, register, mutable, asm, etc.). This is the storage modifier (static, auto, register, mutable, asm, etc.), see complete list in source code for more details. This is an implementation of the modifier system as outlined in appendix A of Bjarne's book. ‐ Internal: Note that isStatic() in the SgInitializedName is always false, is is set in the SgStorageModifier stored in the SgVariableDeclaration (where it is filed of the SgDeclarationModifier).

#### SgInitializedName::p_scope This pointer is always valid and stores the current scope of the variable. This is the current scope of the variable (required because variables can be defined separately from their declaration). See test2004_133.C (approx).

#### SgInitializedName::p_preinitialization This data member stores an enum value. This value is set based on an enum value to indicate the type of use of the initialized name (valid values are: virtual base class, non‐virtual base, data member). ‐ Internal: I think that the preinitalization information might be redundant with the SgStorageModifier information.

#### SgInitializedName::p_register_name_code Code (following GNU standard) for register name. This value is set based on an enum value of GNU standard codes mappings to register names. ‐ Internal: This is a very architecture dependent aspect of the Sage III IR. We only currently represent code for the Intel X86 processor.

#### SgInitializedName::p_register_name_name String representing the register name, used when associated GNU code can't be translated. This is a string value representing the name specified (untranslated to the GNU standard register codes). The string is used when the name specified by theused was untranslatable to a more compact GNU code. This forces the IR to hold an rarely used string object in a frequently used IR node, but I don't think we have any simple way around this detail since we have to support the more general use of the asm options in C and C++. ‐ Internal: This is less architecture dependent than the GNU standard register codes, but takes more storage (though it is not used often).

Member functions

#### SgInitializedName::get_storageModifier() returns a reference to the storage modifier

#### SgInitializedName::post_construction_initialization () Allocates a new storage modifier and sets the storage modifier to default values

#### SgInitializedName::SgInitializedName (const SgInitializedName &ptr) This is the copy constructor

#### SgInitializedName::SgInitializedName ( Sg_File_Info* fileInfo, const SgName& name, SgType *typeptr, SgInitializer* iptr, SgDeclarationStatement declptr, SgScopeStatement scope, SgInitializedName *prev_itemptr ); This is the constructor ‐ Param fileInfo: pointer to source position (also used to mark compiler generated or transformed code) ‐ Param name: the variable name ‐ Param typeptr: a pointer to the variable's type object ‐ Param iptr: pointer to the initializer of the variable ( if any) ‐ Param declptr: pointer to the declaration statement to which this SgInitializedName belongs to ‐ Param scope: pointer to SgScopeStatement to explicitly represent the scope of the variable (required for ROSE, but mostly useful in C++) ‐ Param itemptr: the next SgInitializedName object in the parent declaration statement ‐ Param prev_itemptr: the previous SgInitializedName object in the parent declaration statement ‐ See also: Example:create an SgInitializedName object

#### SgInitializedName::SgInitializedName(const SgName &name, SgType *typeptr, SgInitializer *iptr=0, SgDeclarationStatement *declptr=0, SgInitializedName *itemptr=0, SgInitializedName *prev_itemptr=0) This is the constructor ‐ Deprecated: This is an older constructor which does not include the Sg_File_Info or the SgScopeStatement in its parameter list. These must be set explicitly using the data member's access functions when using this constructor. ‐ Param name: the variable name ‐ Param typeptr: a pointer to the variable's type object ‐ Param iptr: pointer to the initializer of the variable ( if any) ‐ Param declptr: pointer to the declaration statement to which this SgInitializedName belongs to ‐ Param itemptr: the next SgInitializedName object in the parent declaration statement ‐ Param prev_itemptr: the previous SgInitializedName object in the parent declaration statement ‐ See also: Example:create an SgInitializedName object

#### SgNode * SgInitializedName::copy (const SgCopyHelp &help) const It clones the current SgInitializedName object recursively or not, depending on the argument ‐ Param help: ‐ If this argument is of type SgTreeCopy, then the SgInitializedName is cloned recursively. If it's of type SgShallowCopy only the first level of SgInitializedName is copied, everything else pointing to the the original SgInitializedName object's data members. ‐ Return: a pointer to the new clone.

#### SgInitializedName & SgInitializedName::operator= (const SgInitializedName &ptr) assignment operator. It copies everything (including pointers) from the rhs object to the lhs object It copies all the data members of the rhs SgInitializedName object to the lhs (this) object. The copying is done by value, so all the data member pointers are copied by value. After the assignment operator is executed, both operands share the same data members. Actually there is a note in the source code (Cxx_Grammar.h) that says that this needs to be executed recursively ( allocating new data members for the newly assigned object).

#### bool SgInitializedName::operator== (const SgInitializedName &) const Equal operator : it checks if all the data members are the same or point to the same objects What really happens It returns false all the time.

#### SgInitializedName::p_name variable x detailed variable x

#### bool SgInitializedName::get_declaration() const Equal operator : it checks if all the data members are the same or point to the same objects ‐ Return: Pointer to SgDeclarationStatement

#### SgInitializedName::get_symbol_from_symbol_table() const FOR INTERNAL USE Get the associated symbol from the symbol table in the stored scope. Users should use the SgInitializedName::search_for_symbol_from_symbol_table() instead.

#### SgInitializedName::search_for_symbol_from_symbol_table() const User interface for retrieving the associated symbol. It searches through the possible chain of prev_decl_item.

Created with MrDocs