Skip to content

SgVariableDeclaration

This class represents the concept of a C or C++ variable declaration.

Synopsis

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

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

Description

A variable declaration can be either a forward declaration (specified as "extern") or a defining declaration (typical case). Because of this separation (as with classes, functions, etc.) the scope of a variable must be stored explicitly because name qualification can associate a definition in a scope different from the original declaration (see test2005_34.C for examples).

  • Internal: Since multiple variables may be declared in a single variable declaration, the scope information is held in the SgInitializedName object directly, and not the SgVariableDeclaration. The scope of a SgVariableDeclaration is ...
  • Todo: Finish explaination of variable declaration, relationship to variable definition, and the scope issue.
  • Todo: template static variable declaration are instantiated and this is at least sometimes an error (at least when not part of a transformation). See test2005_69.C for example of this problem.
  • See also: Example of using a SgVariableDeclaration object

Data members

SgVariableDeclaration::p_baseTypeDefiningDeclaration

This is used to traverse type definitions within variable declarations. In cases where a class or other named type is defined within (and as the base type of) a variable declaration, the traversal code must be able to traverse this definition. The traversal code computes the appropriate value for this pointer when needed.

SgVariableDeclaration::p_variables

This is an STL list of pointers to SgInitializedName objects. Each variable is a SgInitializedName object, their can be a list of then, so this list holds that collection of variables.

SgVariableDeclaration::p_specialization

This is part of template support (variables of templated types). This is most often set to SgDeclarationStatement::e_no_specialization, but where templates are involved can be set to either SgDeclarationStatement::e_specialization or SgDeclarationStatement::e_partial_specialization.

Member functions

SgVariableDeclaration::get_variables() const

Access function for p_variables.

  • Return: Returns a const reference to SgInitializedNamePtrList.

SgVariableDeclaration::get_variables()

Access function for p_variables.

  • Return: Returns a non-const reference to SgInitializedNamePtrList.

SgVariableDeclaration::get_baseTypeDefiningDeclaration() const

Returns the exact class or enum definition structurally owned by this declaration, or null when the declaration only references its base type.

SgVariableDeclaration::set_baseTypeDefiningDeclaration(SgDeclarationStatement*) Sets the exact owned, non-autonomous class or enum definition. Null is not a valid setter argument; absence is the construction-time default. The definition must already have this variable declaration as its parent and must be the base definition named by every declarator type.

SgVariableDeclaration::get_specialization() const

Access function for p_specialization.

  • Return: Returns value of type SgDeclarationStatement::template_specialization_enum.

`SgVariableDeclaration::set_specialization(SgDeclarationStatement::template_specialization_enum specialization)` Access function for p_specialization.

  • 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
fortran_declaration_origin_enum
gnu_extension_declaration_attributes_enum GNU extension for declaration modifiers (multiple values may be specified)
inline_kind

Member Functions

Name Description
SgVariableDeclaration
SgVariableDeclaration(); [constructor]
Constructors
~SgVariableDeclaration
virtual ~SgVariableDeclaration(); [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]
append_variable
void append_variable( SgInitializedName* what, SgInitializer* init);
cfgFindChildIndex
virtual unsigned int cfgFindChildIndex(SgNode* n) override; [virtual]
cfgInEdges
virtual std::vector<VirtualCFG::CFGEdge> cfgInEdges(unsigned int index) override; [virtual]
cfgIndexForEnd
virtual unsigned int cfgIndexForEnd() const override; [virtual]
cfgOutEdges
virtual std::vector<VirtualCFG::CFGEdge> cfgOutEdges(unsigned int index) 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]
fixupCopy_references
virtual void fixupCopy_references( SgNode* copy, SgCopyHelp& help) const override; [virtual]
fixupCopy_scopes
virtual void fixupCopy_scopes( SgNode* copy, SgCopyHelp& help) const override; [virtual]
fixupCopy_symbols
virtual void fixupCopy_symbols( SgNode* copy, SgCopyHelp& help) const override; [virtual]
get_baseTypeDefiningDeclaration
SgDeclarationStatement* get_baseTypeDefiningDeclaration() const;
Returns the exact defining declaration structurally owned by this variable declaration, or NULL when the declared type is only referenced.
get_baseTypeNondefiningDeclaration
SgDeclarationStatement* get_baseTypeNondefiningDeclaration() const;
Returns the exact nondefining tag introduction structurally owned by this variable declaration, or NULL when no declarator introduces a tag.
get_bitfield
SgExpression* get_bitfield();
get_childIndex
virtual size_t get_childIndex(SgNode* child) const override; [virtual]
index-based access to traversal successors by child node
get_decl_item
SgInitializedName* get_decl_item(SgName const&);
get_definition
SgVariableDefinition* get_definition(SgInitializedName* ditem = 0);
get_explicitTemplateSpecializationHeaderCount
unsigned int get_explicitTemplateSpecializationHeaderCount() const;
get_fortran_declaration_origin
SgVariableDeclaration::fortran_declaration_origin_enum get_fortran_declaration_origin() const;
get_global_qualification_required
bool get_global_qualification_required() const;
get_gnu_extension_alias
std::string get_gnu_extension_alias() const;
get_gnu_extension_declaration_attribute
SgVariableDeclaration::gnu_extension_declaration_attributes_enum get_gnu_extension_declaration_attribute() const;
get_gnu_extension_initialization_priority
unsigned short get_gnu_extension_initialization_priority() const;
get_gnu_extension_section
std::string get_gnu_extension_section() const;
get_inline_kind
inline_kind get_inline_kind() const;
get_isAssociatedWithDeclarationList
bool get_isAssociatedWithDeclarationList() const;
get_is_constexpr
bool get_is_constexpr() const;
get_is_thread_local
bool get_is_thread_local() const;
get_mangled_name
virtual SgName get_mangled_name() const override; [virtual]
get_name_qualification_length
int get_name_qualification_length() const;
get_next
SgStatement* get_next(int&) const;
get_numberOfTraversalSuccessors
virtual size_t get_numberOfTraversalSuccessors() const override; [virtual]
return number of children in the traversal successor list
get_requiresClause
SgExpression* get_requiresClause() const;
get_requiresGlobalNameQualificationOnType
bool get_requiresGlobalNameQualificationOnType() const;
get_sourceSpelledTemplateHeaders
SgTemplateParameterListPtrList const& get_sourceSpelledTemplateHeaders() const;
get_sourceSpelledTemplateOwnerType
SgNamedType* get_sourceSpelledTemplateOwnerType() const;
get_specialization
SgDeclarationStatement::template_specialization_enum get_specialization() const;
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_elaboration_required
bool get_type_elaboration_required() const;
get_variables
SgInitializedNamePtrList const& get_variables() const;
initializeData
void initializeData( Sg_File_Info* info, SgInitializedName* c_item);
isPartialSpecialization
bool isPartialSpecialization() const;
isSpecialization
bool isSpecialization() 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.
reset_initializer
void reset_initializer(SgInitializer*);
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_baseTypeDefiningDeclaration
void set_baseTypeDefiningDeclaration(SgDeclarationStatement* d);
Publishes a non-null, non-autonomous class or enum definition already owned by this declaration and named by every declarator type.
set_baseTypeNondefiningDeclaration
void set_baseTypeNondefiningDeclaration(SgDeclarationStatement* d);
Publishes a non-null, non-autonomous class or enum forward declaration already owned by this declaration and named by every declarator type.
set_bitfield
void set_bitfield(SgExpression*);
set_explicitTemplateSpecializationHeaderCount
void set_explicitTemplateSpecializationHeaderCount(unsigned int explicitTemplateSpecializationHeaderCount);
set_fortran_declaration_origin
void set_fortran_declaration_origin(SgVariableDeclaration::fortran_declaration_origin_enum fortran_declaration_origin);
set_global_qualification_required
void set_global_qualification_required(bool global_qualification_required);
set_gnu_extension_alias
void set_gnu_extension_alias(std::string gnu_extension_alias);
set_gnu_extension_declaration_attribute
void set_gnu_extension_declaration_attribute(SgVariableDeclaration::gnu_extension_declaration_attributes_enum gnu_extension_declaration_attribute);
set_gnu_extension_initialization_priority
void set_gnu_extension_initialization_priority(unsigned short gnu_extension_initialization_priority);
set_gnu_extension_section
void set_gnu_extension_section(std::string gnu_extension_section);
set_inline_kind
void set_inline_kind(inline_kind kind);
set_isAssociatedWithDeclarationList
void set_isAssociatedWithDeclarationList(bool isAssociatedWithDeclarationList);
set_is_constexpr
void set_is_constexpr(bool is_constexpr);
set_is_thread_local
void set_is_thread_local(bool is_thread_local);
set_name_qualification_length
void set_name_qualification_length(int name_qualification_length);
set_requiresClause
void set_requiresClause(SgExpression* requiresClause);
set_requiresGlobalNameQualificationOnType
void set_requiresGlobalNameQualificationOnType(bool requiresGlobalNameQualificationOnType);
set_sourceSpelledTemplateOwnerType
void set_sourceSpelledTemplateOwnerType(SgNamedType* sourceSpelledTemplateOwnerType);
set_specialization
void set_specialization(SgDeclarationStatement::template_specialization_enum specialization);
set_type_elaboration_required
void set_type_elaboration_required(bool type_elaboration_required);
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 Member Functions

Name
compute_baseTypeDefiningDeclaration
SgDeclarationStatement* compute_baseTypeDefiningDeclaration() const;

Protected Data Members

Name
p_baseTypeDefiningDeclaration
p_baseTypeNondefiningDeclaration
p_explicitTemplateSpecializationHeaderCount
p_fortran_declaration_origin
p_global_qualification_required
p_gnu_extension_alias
p_gnu_extension_declaration_attribute
p_gnu_extension_initialization_priority
p_gnu_extension_section
p_inline_kind
p_isAssociatedWithDeclarationList
p_is_constexpr
p_is_thread_local
p_name_qualification_length
p_requiresClause
p_requiresGlobalNameQualificationOnType
p_sourceSpelledTemplateHeaders
p_sourceSpelledTemplateOwnerType
p_specialization
p_type_elaboration_required
p_variables

Friends

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

Derived Classes

Name Description
SgTemplateVariableDeclaration

Created with MrDocs