Skip to content

SgStatement

This class represents the notion of a statement.

Synopsis

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

class [[visibility("default")]] SgStatement
    : public SgLocatedNode

Description

There are no uses of this IR node anywhere. All statements are derived from this SgStatement class.

  • Internal: This is a base class for all statements.
  • Todo: Fortran support for modifiers can be used as statement (must be added to IR): see section 5.2, 5.3 in Fortran 2003 standard. Note that type modifiers can be used as statements.
  • Todo: Fortran support requires statements in section 6.3.
  • Todo: Fortran support requires for case statement ranges (gnu extension for C, but standard in Fortran).
  • Todo: Fortran support requires statements in section 8.1.4, 8.1.5.
  • Todo: Fortran support requires statements in section 15 (modifiers for ISO_C_BINDING).
  • See also: Example of using a SgStatement object

Member functions

SgStatement::get_scope() const

Returns scope of current statement. Returns the explicit semantic scope for declarations that store one, or the scope defined by the owning AST structure for other statements. Producers establish those identities during construction. Function parameter scopes follow their owning declaration's signature or definition role.

  • Return: Returns valid pointer to SgScopeStatement.

`SgStatement::replace_child (SgStatement *, SgStatement *, bool

extractListFromBasicBlock=false)` Private supporting function for low level SageIII rewrite interface. This function implements special semantics for the insertion of a collection of statements in a block. If extractListFromBasicBlock is true then the statements in the block are extracts and placed into the same scope as the target position.

  • Return: Returns bool.

`SgStatement::insert_child (SgStatement *, SgStatement *, bool

inFront=true, bool extractListFromBasicBlock=false)` Private supporting function for low level SageIII rewrite interface. This function implements special semantics for the insertion of a collection of statements in a block. If extractListFromBasicBlock is true then the statements in the block are extracts and placed into the same scope as the target position.

  • Return: Returns bool.

SgStatement::get_symbol_from_symbol_table()

Virtual function to obtain the SgSymbol from the scope's symbol table. This function permits retrival of the associated SgSymbol, where it exists for that IR node, where is is associated with this exact declaration. If no symbol is found in the symbol table the function returns NULL. If it is not implemented for the associated statement or declaration it is an error (assertion failure). This fucntion is ONLY defined for those IR nodes for which symbols can be constructed.

  • Return: Returns SgSymbol pointer.

SgStatement::isChildUsedAsLValue(SgExpression *)

Virtual function to determine if the provided expression is used as an l-value within the cotext of this statement.

  • Return: True if the expression is used within this statement as an l-value.

Additional notes Low-level Support for mutation of the AST. This is the lowest level of support for the mutation of the AST.

  • Internal: Need to document this section more fully.

Base Classes

Name Description
SgLocatedNode This class represents the notion of an expression or statement which

Type Aliases

Name
base_node_type

Enums

Name Description
Unnamed enum static variant value
directive_end_kind_enum
omp_fortran_spelling_enum

Member Functions

Name Description
SgStatement
SgStatement(); [constructor]
Constructors
~SgStatement
virtual ~SgStatement(); [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]
cfgFindChildIndex
virtual unsigned int cfgFindChildIndex(SgNode* n) override; [virtual]
cfgFindNextChildIndex
virtual unsigned int cfgFindNextChildIndex(SgNode* n) override; [virtual]
cfgInEdges
virtual std::vector<VirtualCFG::CFGEdge> cfgInEdges(unsigned int index) override; [virtual]
cfgIndexForEnd
virtual unsigned int cfgIndexForEnd() const override; [virtual]
cfgIsIndexInteresting
virtual bool cfgIsIndexInteresting(unsigned int index) 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_childIndex
virtual size_t get_childIndex(SgNode* child) const override; [virtual]
index-based access to traversal successors by child node
get_directive_end_kind
SgStatement::directive_end_kind_enum get_directive_end_kind() const;
get_end_numeric_label
virtual SgLabelRefExp* get_end_numeric_label() const; [virtual]
get_is_short_circuit_generated
bool get_is_short_circuit_generated() const;
get_numberOfTraversalSuccessors
virtual size_t get_numberOfTraversalSuccessors() const override; [virtual]
return number of children in the traversal successor list
get_numeric_label
SgLabelRefExp* get_numeric_label() const;
get_omp_fortran_spelling
SgStatement::omp_fortran_spelling_enum get_omp_fortran_spelling() const;
get_scope
virtual SgScopeStatement* get_scope() const; [virtual]
get_source_sequence_value
int get_source_sequence_value() const;
get_symbol_from_symbol_table
virtual SgSymbol* get_symbol_from_symbol_table() const; [virtual]
Get the associated symbol from the symbol table in the stored scope
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
hasExplicitScope
virtual bool hasExplicitScope() const; [virtual]
Support for where the scope is explicitly required
hasExplicitType
bool hasExplicitType();
Some statement store internal SgType pointers explicitly. This function is true if it has a data member that is a type (only applies to SgTypedefDeclaration).
has_end_numeric_label
virtual bool has_end_numeric_label() const; [virtual]
insert_statement
void insert_statement( SgStatement* target, SgStatementPtrList const& newstmtList, bool inFront = true);
insert_statement overloads
insert_statement_from_basicBlock
void insert_statement_from_basicBlock( SgStatement* target, SgStatement* newstmt, bool inFront = true);
This function inserts a statement at the position indicated by target. If newstmt is a basicBlock, statements inside newstmt are extracted and then inserted.
isChildUsedAsLValue
virtual bool isChildUsedAsLValue(SgExpression const* child) const; [virtual]
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.
remove_statement
void remove_statement(SgStatement* target);
This function removes the target statement from the AST.
replace_expression
virtual int replace_expression( SgExpression* original_expression, SgExpression* new_expression); [virtual]
support general replace functions, used in statements that directly contain SgExpression IR nodes.
replace_statement
void replace_statement( SgStatement* target, SgStatementPtrList const& newstmtList);
replace_statement overloads
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_directive_end_kind
void set_directive_end_kind(SgStatement::directive_end_kind_enum directive_end_kind);
set_end_numeric_label
virtual void set_end_numeric_label(SgLabelRefExp* end_numeric_label); [virtual]
set_is_short_circuit_generated
void set_is_short_circuit_generated(bool is_short_circuit_generated);
set_numeric_label
void set_numeric_label(SgLabelRefExp* numeric_label);
set_omp_fortran_spelling
void set_omp_fortran_spelling(SgStatement::omp_fortran_spelling_enum omp_fortran_spelling);
set_scope
virtual void set_scope(SgScopeStatement* newScope); [virtual]
Support for setting scopes (only meaningful on IR statements that store the scope explicitly).
set_source_sequence_value
void set_source_sequence_value(int source_sequence_value);
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
insert_child
virtual bool insert_child( SgStatement*, SgStatement*, bool inFront = true, bool extractListFromBasicBlock = false); [virtual]
replace_child
virtual bool replace_child( SgStatement* target, SgStatement* newStmt, bool extractListFromBasicBlock = false); [virtual]

Protected Data Members

Name
p_directive_end_kind
p_is_short_circuit_generated
p_numeric_label
p_omp_fortran_spelling
p_source_sequence_value

Friends

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

Derived Classes

Name Description
SgAccBodyStatement
SgAccClauseStatement
SgAllocateStatement
SgArithmeticIfStatement
SgAssignStatement
SgAssignedGotoStatement
SgAttributedStatement
SgBreakStmt This class represents the notion of a break statement
SgCaseOptionStmt This class represents the concept of a C and C++ case option (used within a switch statement).
SgCatchStatementSeq This class represents the concept of a C++ sequence of catch statements.
SgComputedGotoStatement
SgContinueStmt This class represents the concept of a C or C++ continue statement.
SgDeallocateStatement
SgDeclarationStatement This class represents the concept of a declaration statement.
SgDefaultOptionStmt This class represents the concept of a C or C++ default case within a switch
SgElseWhereStatement
SgExprStatement This class represents the concept of a C or C++ statement which contains a
SgForInitStatement This class represents the variable declaration or variable initialization withn a
SgFortranContinueStmt
SgFunctionTypeTable Canonical function types indexed by semantic signatures.
SgGotoStatement This class represents the concept of a C or C++ goto statement.
SgIOStatement
SgImageControlStatement
SgLabelStatement This class represents the concept of a C or C++ label statement.
SgNullStatement
SgNullifyStatement
SgOmpExecStatement
SgProcessControlStatement
SgReturnStmt A return statement with an optional expression.
SgScopeStatement This class represents the concept of a scope in C++ (e.g. global scope, fuction scope, etc.).
SgTryStmt This class represents the concept of try statement within the try-catch
SgWhereStatement

Created with MrDocs