Skip to content

SgLocatedNode

This class represents the notion of an expression or statement which

Synopsis

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

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

Description

has a position within the source code. There are no uses of this IR node anywhere. All expressions and statements are derived from this IR node to build either SgExpression or SgStatement derived classes.

  • Note: SgLocatedNode objects have a set_startOfConstruct() and a set_endOfConstruct() these must be set explicitly to define a proper AST. The set_startOfConstruct() will be called if the constructor taking a Sg_File_Info object is called (depreicated) but the set_endOfConstruct() should be called explicitly.
  • Internal: The AttachedPreprocessingInfoType *p_attachedPreprocessingInfoPtr and the AstAttributeMechanism *p_attribute are implemented as pointers because they would take up 12 bytes each as STL lists and that would be wasteful when we have 20 million IR nodes held in memory. This is a violation of general rule in the IR design that we have STL containers as data member instead of pointers to data members (the file I/O handles this as a special case).
  • Todo: The AstAttributeMechanism type should be handed as other IR nodes with it's own memory pool, except that in all cases where it would be used, it would be a base class to a user-defined derived type and thus would not fix in our memory pool.
  • Todo: Consider name change of "SgLocatedNode" to "SgSourceNode".
  • Todo: Consider moving some of the IR nodes currently in SgSupport to this IR node. IR nodes that might be moved would include:

  • SgFile

  • SgDirectory (questionable)

  • SgInitializedName

  • SgBaseClass

  • SgTemplateArgument

  • SgTemplateParameter

  • Internal: This is a base class for all expressions and statements.
  • See also: Example of using a SgLocatedNode object

Data members

SgLocatedNode::p_startOfConstruct

This pointer is always valid and stores the source position of the start of the current construct.

SgLocatedNode::p_endOfConstruct

This pointer is always valid and stores the source position of the end of the current construct.

SgLocatedNode::p_attachedPreprocessingInfoPtr

Holds comments and/or preprocessor directives located before or after the current statement of expression.

Member functions

SgLocatedNode::SgLocatedNode (const SgLocatedNode &X)

Copy constructor (made private to prevent being called by accident).

SgLocatedNode::getFileName()

Access function for "get_file_info()->get_filename()". This function is just a simpler access function which retrives the filename from the Sg_File_Info object at the current IR node. This is only a convience function an as a result not a great idea.

  • Internal: This function should likely be removed from the SAGEIII interface.
  • Deprecated: This function should be removed because it is only an interface function of rather minor significance. Alternatively if we want to implement it, we should consider placing it at the SgNode object. If we do preserve the function then we should have it return a string instead of char*.

`SgLocatedNode::addToAttachedPreprocessingInfo (PreprocessingInfo

*prepInfoPtr,` PreprocessingInfo::RelativePositionType locationInList=PreprocessingInfo::after) This function adds comment or CPP directives to the current IR node.

  • Param prepInfoPtr: - This parameter is a pointer to the container for the comment/directive. It is used to specify if the new new comment/directive is added to the front or back of the current list of comments/directives. It does not change relative position field of the PreprocessingInfo object.
  • Param locationInList: - adds container before or after the current IR node.
  • Return: Returns void.

SgLocatedNode::getAttachedPreprocessingInfo (void)

Returns the attached comment and preprocessing-directive container by reference to its pointer.

SgLocatedNode::set_startOfConstruct (Sg_File_Info *startOfConstruct)

This function sets the current source location position of the start of the current construct.

  • Param startOfConstruct: - Pointer to Sg_File_Info object containing source location information.
  • Return: Returns void.

SgLocatedNode::set_endOfConstruct (Sg_File_Info *endOfConstruct)

This function sets the current source location position of the end of the current construct.

  • Param endOfConstruct: - Pointer to Sg_File_Info object containing source location information.
  • Return: Returns void.

Base Classes

Name Description
SgNode This class represents the base class for all IR nodes within Sage III.

Type Aliases

Name
base_node_type

Enums

Name Description
Unnamed enum static variant value
PreprocessingInfoInsertion

Member Functions

Name Description
SgLocatedNode
SgLocatedNode(Sg_File_Info* startOfConstruct = NULL); [constructor]
Default constructor
~SgLocatedNode
virtual ~SgLocatedNode(); [destructor] [virtual]
Destructor
accept
virtual void accept(ROSE_VisitorPattern& visitor) override; [virtual]
support for the classic visitor pattern done in GoF
addNewAttribute
virtual void addNewAttribute( std::string s, AstAttribute* a) override; [virtual]
Add a new attribute represented by the named string.
addToAttachedPreprocessingInfo
void addToAttachedPreprocessingInfo( PreprocessingInfo* prepInfoPtr, PreprocessingInfo::RelativePositionType locationInList = PreprocessingInfo::after);
appendDestructorOwnedNodes
virtual void appendDestructorOwnedNodes(std::vector<SgNode*>& nodes) const override; [virtual]
attachPreprocessingInfo
void attachPreprocessingInfo( PreprocessingInfo* record, PreprocessingInfo::RelativePositionType position, PreprocessingInfoInsertion insertion = PreprocessingInfoInsertion::back);
attachPreprocessingInfoRelative
void attachPreprocessingInfoRelative( PreprocessingInfo* record, PreprocessingInfo::RelativePositionType position, PreprocessingInfo* anchor, bool insertAfter);
attributeExists
virtual bool attributeExists(std::string s) const override; [virtual]
Tests if attribute of name 's' is present.
class_name
virtual std::string class_name() const override; [virtual]
returns a string representing the class name
clearAttachedPreprocessingInfo
void clearAttachedPreprocessingInfo();
cloneAttachedPreprocessingInfoFrom
void cloneAttachedPreprocessingInfoFrom( SgLocatedNode const* source, SgCopyHelp* help = nullptr);
copy
virtual SgNode* copy(SgCopyHelp& help) const override; [virtual]
detachPreprocessingInfo
PreprocessingInfo* detachPreprocessingInfo(PreprocessingInfo* record);
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]
generateMatchingFileInfo
Sg_File_Info* generateMatchingFileInfo();
getAttachedPreprocessingInfo
AttachedPreprocessingInfoType*& getAttachedPreprocessingInfo();
getAttribute
virtual AstAttribute* getAttribute(std::string s) const override; [virtual]
Returns attribute of name 's'.
getFileName
std::string const& getFileName() const;
getFilenameString
std::string const& getFilenameString() const;
get_attachedPreprocessingInfoPtr
AttachedPreprocessingInfoType* get_attachedPreprocessingInfoPtr() const;
get_attributeMechanism
virtual AstAttributeMechanism* get_attributeMechanism() 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_containsTransformationToSurroundingWhitespace
bool get_containsTransformationToSurroundingWhitespace() const;
get_endOfConstruct
virtual Sg_File_Info* get_endOfConstruct() const override; [virtual]
get_file_info
virtual Sg_File_Info* get_file_info() const override; [virtual]
get_numberOfTraversalSuccessors
virtual size_t get_numberOfTraversalSuccessors() const override; [virtual]
return number of children in the traversal successor list
get_physical_file_id
int get_physical_file_id() const;
Return the physical file ID after checking all available source positions.
get_source_range_ends_in_macro_expansion
bool get_source_range_ends_in_macro_expansion() const;
get_source_range_is_macro_expansion_fragment
bool get_source_range_is_macro_expansion_fragment() const;
get_startOfConstruct
virtual Sg_File_Info* get_startOfConstruct() const override; [virtual]
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
insertToAttachedPreprocessingInfo
void insertToAttachedPreprocessingInfo( PreprocessingInfo* prepInfoPtr, PreprocessingInfo* anchorInfoPtr, bool insertAfter = true);
isCompilerGenerated
bool isCompilerGenerated() const;
isFrontendSpecific
bool isFrontendSpecific() const;
isOutputInCodeGeneration
bool isOutputInCodeGeneration() const;
isShared
bool isShared() const;
isTransformation
bool isTransformation() const;
numberOfAttributes
virtual int numberOfAttributes() const override; [virtual]
Returns the number of attributes on this IR node.
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
processDataMemberReferenceToPointers
virtual void processDataMemberReferenceToPointers(ReferenceToPointerHandler*) override; [virtual]
Pass references to stored node pointers to a handler.
removeAttribute
virtual void removeAttribute(std::string s) override; [virtual]
Remove attribute of name 's' if present.
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
setAttachedPreprocessingInfoPosition
void setAttachedPreprocessingInfoPosition( PreprocessingInfo* record, PreprocessingInfo::RelativePositionType position);
setAttribute
virtual void setAttribute( std::string s, AstAttribute* a) override; [virtual]
This is a wrapper function with the following semantics: if no attribute of name 's' exists then addNewAttribute(s,a); is called, otherwise updateAttribute(s,a); is called.
setCompilerGenerated
void setCompilerGenerated();
setFrontendSpecific
void setFrontendSpecific();
setOutputInCodeGeneration
void setOutputInCodeGeneration();
setShared
void setShared();
setSourcePositionUnavailableInFrontend
void setSourcePositionUnavailableInFrontend();
setTransformation
void setTransformation();
set_attachedPreprocessingInfoPtr
void set_attachedPreprocessingInfoPtr(AttachedPreprocessingInfoType* attachedPreprocessingInfoPtr);
set_attributeMechanism
virtual void set_attributeMechanism(AstAttributeMechanism* attributeMechanism) override; [virtual]
set_containsTransformationToSurroundingWhitespace
void set_containsTransformationToSurroundingWhitespace(bool containsTransformationToSurroundingWhitespace);
set_endOfConstruct
void set_endOfConstruct(Sg_File_Info* position);
set_file_info
virtual void set_file_info(Sg_File_Info* X); [virtual]
set_source_range_ends_in_macro_expansion
void set_source_range_ends_in_macro_expansion(bool value);
set_source_range_is_macro_expansion_fragment
void set_source_range_is_macro_expansion_fragment(bool value);
set_startOfConstruct
void set_startOfConstruct(Sg_File_Info* position);
transferPreprocessingInfo
void transferPreprocessingInfo( PreprocessingInfo* record, SgLocatedNode* destination, PreprocessingInfo::RelativePositionType destinationPosition, PreprocessingInfoInsertion insertion = PreprocessingInfoInsertion::back);
unsetCompilerGenerated
void unsetCompilerGenerated();
unsetFrontendSpecific
void unsetFrontendSpecific();
unsetOutputInCodeGeneration
void unsetOutputInCodeGeneration();
unsetShared
void unsetShared();
unsetSourcePositionUnavailableInFrontend
void unsetSourcePositionUnavailableInFrontend();
unsetTransformation
void unsetTransformation();
updateAttribute
virtual void updateAttribute( std::string s, AstAttribute* a) override; [virtual]
Replace existing attribute of name 's' with new AstAttribute.
validateAttachedPreprocessingInfoOwnership
void validateAttachedPreprocessingInfoOwnership() const;
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
post_construction_initialization
virtual void post_construction_initialization() override; [virtual]

Protected Data Members

Name
p_attachedPreprocessingInfoPtr
p_attributeMechanism
p_containsTransformationToSurroundingWhitespace
p_endOfConstruct
p_source_range_ends_in_macro_expansion
p_source_range_is_macro_expansion_fragment
p_startOfConstruct

Private Member Functions

Name Description
SgLocatedNode
SgLocatedNode(SgLocatedNode const& X); [constructor]
Copy constructor

Friends

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

Derived Classes

Name Description
SgExpression This class represents the notion of an expression. Expressions
SgLocatedNodeSupport
SgStatement This class represents the notion of a statement.
SgToken

Created with MrDocs