Skip to content

SgVariableDefinition

This class represents the definition (initialization) of a variable.

Synopsis

Declared in <src/frontend/SageIII/Cxx_Grammar.h> (not stored in Git)

class [[visibility("default")]] SgVariableDefinition
    : public SgDeclarationStatement

Description

The most common use of the SgVariableDefinition is to store the associated bitfield specifier in declarations such as "int x:4;" which is a four bit integer variable. Each definition has an exact owning SgInitializedName.

  • Note: Both SgVariableDeclaration and SgVariableDefinition are both derived from SgDeclaration. This is because a SgVariableDefinition does not represent a scope like all other definitions (which are derived from SgScopeStatement).
  • Todo: If a SgVariableDefinition is built internally as part of a SgVariableDeclaration it should be marked as compiler generated if the "extern" keyword was not used in the SgVariableDeclaration. This needs to be looked into.
  • See also: Example of using a SgVariableDefinition object

Data members

SgVariableDefinition::p_vardefn

This pointer points to associated SgInitializedName object (the variable).

SgVariableDefinition::p_bitfield

This a pointer to a value specifies the bitwidth of the variable (used to control memory layout/padding of data members in data structures). This is a somewhat rare feature of C, and so C++. variables of some types can be specified to have a specific bit width (usually a number of bits smaller than the default size).

Member functions

SgVariableDefinition::get_vardefn() const

Access function for SgInitializedName stored in p_vardefn.

  • Return: Returns pointer to SgInitializedName.

SgVariableDefinition::set_vardefn(SgInitializedName* expr)

Access function for SgInitializedName in p_vardefn.

  • Return: Returns void.

SgVariableDefinition::get_bitfield() const

Access function for p_bitfield.

  • Return: Returns pointer to SgExpression.

SgVariableDefinition::set_bitfield(SgExpression* bitfield)

Access function for p_bitfield.

  • Return: Returns void.

Base Classes

Name Description
SgDeclarationStatement This class represents the concept of a declaration statement.

Type Aliases

Name
base_node_type

Enums

Name Description
Unnamed enum static variant value

Member Functions

Name Description
SgVariableDefinition
SgVariableDefinition( SgInitializedName* decl_item, SgInitializer* initializer); [constructor]
Constructors
~SgVariableDefinition
virtual ~SgVariableDefinition(); [destructor] [virtual]
Destructor
accept
virtual void accept(ROSE_VisitorPattern& visitor) override; [virtual]
support for the classic visitor pattern done in GoF
appendDestructorOwnedNodes
virtual void appendDestructorOwnedNodes(std::vector<SgNode*>& nodes) const override; [virtual]
class_name
virtual std::string class_name() const override; [virtual]
returns a string representing the class name
copy
virtual SgNode* copy(SgCopyHelp& help) const override; [virtual]
get_bitfield
SgExpression* get_bitfield() const;
get_childIndex
virtual size_t get_childIndex(SgNode* child) const override; [virtual]
index-based access to traversal successors by child node
get_declaration
SgVariableDeclaration* get_declaration();
get_has_no_unique_address
bool get_has_no_unique_address() const;
get_is_zero_width_bitfield
bool get_is_zero_width_bitfield() const;
get_mangled_name
virtual SgName get_mangled_name() const override; [virtual]
get_numberOfTraversalSuccessors
virtual size_t get_numberOfTraversalSuccessors() const override; [virtual]
return number of children in the traversal successor list
get_traversalSuccessorByIndex
virtual SgNode* get_traversalSuccessorByIndex(size_t idx) const override; [virtual]
index-based access to traversal successors by index number
get_traversalSuccessorContainer
virtual std::vector<SgNode*> get_traversalSuccessorContainer() const override; [virtual]
container of pointers to AST successor nodes used in the traversal overridden in every class by generated implementation
get_traversalSuccessorIsListElement
virtual std::vector<bool> get_traversalSuccessorIsListElement() const override; [virtual]
get_traversalSuccessorNamesContainer
virtual std::vector<std::string> get_traversalSuccessorNamesContainer() const override; [virtual]
container of names of variables or container indices used used in the traversal to access AST successor nodes overridden in every class by generated implementation
get_type
SgType* get_type();
get_vardefn
SgInitializedName* get_vardefn() const;
operator delete
void operator delete( void* pointer, size_t size);
deallocated memory for IR node (returns memory to memory pool for reuse)
operator new
void* operator new(size_t size);
returns pointer to newly allocated IR node
post_construction_initialization
virtual void post_construction_initialization() override; [virtual]
processDataMemberReferenceToPointers
virtual void processDataMemberReferenceToPointers(ReferenceToPointerHandler*) override; [virtual]
Pass references to stored node pointers to a handler.
returnDataMemberPointers
virtual std::vector<std::pair<SgNode*, std::string>> returnDataMemberPointers() const override; [virtual]
Return the node pointers stored in this node's data members.
roseRTI
virtual RTIReturnType roseRTI() override; [virtual]
return C++ Runtime-Time-Information
sage_class_name
virtual char const* sage_class_name() const override; [virtual]
returns a C style string (char*) representing the class name
set_bitfield
void set_bitfield(SgExpression* bitfield);
set_has_no_unique_address
void set_has_no_unique_address(bool has_no_unique_address);
set_is_zero_width_bitfield
void set_is_zero_width_bitfield(bool is_zero_width_bitfield);
set_vardefn
void set_vardefn(SgInitializedName* vardefn);
variantT
virtual VariantT variantT() const override; [virtual]
returns new style SageIII enum values

Static Member Functions

Name Description
memoryUsage
static size_t memoryUsage();
Returns the size in bytes of the total memory allocated for all IR nodes of this type
numberOfNodes
static size_t numberOfNodes();
Returns the total number of IR nodes of this type
traverseMemoryPoolNodes
static void traverseMemoryPoolNodes(ROSE_VisitTraversal& visit);
FOR INTERNAL USE Support for visitor pattern over all IR nodes by type of IR node.
traverseMemoryPoolVisitorPattern
static void traverseMemoryPoolVisitorPattern(ROSE_VisitorPattern& visitor);
FOR INTERNAL USE Support for visitor pattern.
visitRepresentativeNode
static void visitRepresentativeNode(ROSE_VisitTraversal& visit);
FOR INTERNAL USE Support for type-based traversal.

Static Data Members

Name Description
free_slots Free slots, each numbered pool_index * pool_size + slot_index. The last entry is allocated next.
pool_live_flags
pool_size
pools

Protected Data Members

Name
p_bitfield
p_has_no_unique_address
p_is_zero_width_bitfield
p_vardefn

Friends

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

Created with MrDocs