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 |
|---|---|
SgLocatedNodeSgLocatedNode(Sg_File_Info* startOfConstruct = NULL); [constructor] | Default constructor |
~SgLocatedNodevirtual ~SgLocatedNode(); [destructor] [virtual] | Destructor |
acceptvirtual void accept(ROSE_VisitorPattern& visitor) override; [virtual] | support for the classic visitor pattern done in GoF |
addNewAttributevirtual void addNewAttribute( std::string s, AstAttribute* a) override; [virtual] | Add a new attribute represented by the named string. |
addToAttachedPreprocessingInfovoid addToAttachedPreprocessingInfo( PreprocessingInfo* prepInfoPtr, PreprocessingInfo::RelativePositionType locationInList = PreprocessingInfo::after); | |
appendDestructorOwnedNodesvirtual void appendDestructorOwnedNodes(std::vector<SgNode*>& nodes) const override; [virtual] | |
attachPreprocessingInfovoid attachPreprocessingInfo( PreprocessingInfo* record, PreprocessingInfo::RelativePositionType position, PreprocessingInfoInsertion insertion = PreprocessingInfoInsertion::back); | |
attachPreprocessingInfoRelativevoid attachPreprocessingInfoRelative( PreprocessingInfo* record, PreprocessingInfo::RelativePositionType position, PreprocessingInfo* anchor, bool insertAfter); | |
attributeExistsvirtual bool attributeExists(std::string s) const override; [virtual] | Tests if attribute of name 's' is present. |
class_namevirtual std::string class_name() const override; [virtual] | returns a string representing the class name |
clearAttachedPreprocessingInfovoid clearAttachedPreprocessingInfo(); | |
cloneAttachedPreprocessingInfoFromvoid cloneAttachedPreprocessingInfoFrom( SgLocatedNode const* source, SgCopyHelp* help = nullptr); | |
copyvirtual SgNode* copy(SgCopyHelp& help) const override; [virtual] | |
detachPreprocessingInfoPreprocessingInfo* detachPreprocessingInfo(PreprocessingInfo* record); | |
fixupCopy_referencesvirtual void fixupCopy_references( SgNode* copy, SgCopyHelp& help) const override; [virtual] | |
fixupCopy_scopesvirtual void fixupCopy_scopes( SgNode* copy, SgCopyHelp& help) const override; [virtual] | |
fixupCopy_symbolsvirtual void fixupCopy_symbols( SgNode* copy, SgCopyHelp& help) const override; [virtual] | |
generateMatchingFileInfoSg_File_Info* generateMatchingFileInfo(); | |
getAttachedPreprocessingInfoAttachedPreprocessingInfoType*& getAttachedPreprocessingInfo(); | |
getAttributevirtual AstAttribute* getAttribute(std::string s) const override; [virtual] | Returns attribute of name 's'. |
getFileNamestd::string const& getFileName() const; | |
getFilenameStringstd::string const& getFilenameString() const; | |
get_attachedPreprocessingInfoPtrAttachedPreprocessingInfoType* get_attachedPreprocessingInfoPtr() const; | |
get_attributeMechanismvirtual AstAttributeMechanism* get_attributeMechanism() const override; [virtual] | |
get_childIndexvirtual size_t get_childIndex(SgNode* child) const override; [virtual] | index-based access to traversal successors by child node |
get_containsTransformationToSurroundingWhitespacebool get_containsTransformationToSurroundingWhitespace() const; | |
get_endOfConstructvirtual Sg_File_Info* get_endOfConstruct() const override; [virtual] | |
get_file_infovirtual Sg_File_Info* get_file_info() const override; [virtual] | |
get_numberOfTraversalSuccessorsvirtual size_t get_numberOfTraversalSuccessors() const override; [virtual] | return number of children in the traversal successor list |
get_physical_file_idint get_physical_file_id() const; | Return the physical file ID after checking all available source positions. |
get_source_range_ends_in_macro_expansionbool get_source_range_ends_in_macro_expansion() const; | |
get_source_range_is_macro_expansion_fragmentbool get_source_range_is_macro_expansion_fragment() const; | |
get_startOfConstructvirtual Sg_File_Info* get_startOfConstruct() const override; [virtual] | |
get_traversalSuccessorByIndexvirtual SgNode* get_traversalSuccessorByIndex(size_t idx) const override; [virtual] | index-based access to traversal successors by index number |
get_traversalSuccessorContainervirtual 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_traversalSuccessorIsListElementvirtual std::vector<bool> get_traversalSuccessorIsListElement() const override; [virtual] | |
get_traversalSuccessorNamesContainervirtual 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 |
insertToAttachedPreprocessingInfovoid insertToAttachedPreprocessingInfo( PreprocessingInfo* prepInfoPtr, PreprocessingInfo* anchorInfoPtr, bool insertAfter = true); | |
isCompilerGeneratedbool isCompilerGenerated() const; | |
isFrontendSpecificbool isFrontendSpecific() const; | |
isOutputInCodeGenerationbool isOutputInCodeGeneration() const; | |
isSharedbool isShared() const; | |
isTransformationbool isTransformation() const; | |
numberOfAttributesvirtual int numberOfAttributes() const override; [virtual] | Returns the number of attributes on this IR node. |
operator deletevoid operator delete( void* pointer, size_t size); | deallocated memory for IR node (returns memory to memory pool for reuse) |
operator newvoid* operator new(size_t size); | returns pointer to newly allocated IR node |
processDataMemberReferenceToPointersvirtual void processDataMemberReferenceToPointers(ReferenceToPointerHandler*) override; [virtual] | Pass references to stored node pointers to a handler. |
removeAttributevirtual void removeAttribute(std::string s) override; [virtual] | Remove attribute of name 's' if present. |
returnDataMemberPointersvirtual std::vector<std::pair<SgNode*, std::string>> returnDataMemberPointers() const override; [virtual] | Return the node pointers stored in this node's data members. |
roseRTIvirtual RTIReturnType roseRTI() override; [virtual] | return C++ Runtime-Time-Information |
sage_class_namevirtual char const* sage_class_name() const override; [virtual] | returns a C style string (char*) representing the class name |
setAttachedPreprocessingInfoPositionvoid setAttachedPreprocessingInfoPosition( PreprocessingInfo* record, PreprocessingInfo::RelativePositionType position); | |
setAttributevirtual 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. |
setCompilerGeneratedvoid setCompilerGenerated(); | |
setFrontendSpecificvoid setFrontendSpecific(); | |
setOutputInCodeGenerationvoid setOutputInCodeGeneration(); | |
setSharedvoid setShared(); | |
setSourcePositionUnavailableInFrontendvoid setSourcePositionUnavailableInFrontend(); | |
setTransformationvoid setTransformation(); | |
set_attachedPreprocessingInfoPtrvoid set_attachedPreprocessingInfoPtr(AttachedPreprocessingInfoType* attachedPreprocessingInfoPtr); | |
set_attributeMechanismvirtual void set_attributeMechanism(AstAttributeMechanism* attributeMechanism) override; [virtual] | |
set_containsTransformationToSurroundingWhitespacevoid set_containsTransformationToSurroundingWhitespace(bool containsTransformationToSurroundingWhitespace); | |
set_endOfConstructvoid set_endOfConstruct(Sg_File_Info* position); | |
set_file_infovirtual void set_file_info(Sg_File_Info* X); [virtual] | |
set_source_range_ends_in_macro_expansionvoid set_source_range_ends_in_macro_expansion(bool value); | |
set_source_range_is_macro_expansion_fragmentvoid set_source_range_is_macro_expansion_fragment(bool value); | |
set_startOfConstructvoid set_startOfConstruct(Sg_File_Info* position); | |
transferPreprocessingInfovoid transferPreprocessingInfo( PreprocessingInfo* record, SgLocatedNode* destination, PreprocessingInfo::RelativePositionType destinationPosition, PreprocessingInfoInsertion insertion = PreprocessingInfoInsertion::back); | |
unsetCompilerGeneratedvoid unsetCompilerGenerated(); | |
unsetFrontendSpecificvoid unsetFrontendSpecific(); | |
unsetOutputInCodeGenerationvoid unsetOutputInCodeGeneration(); | |
unsetSharedvoid unsetShared(); | |
unsetSourcePositionUnavailableInFrontendvoid unsetSourcePositionUnavailableInFrontend(); | |
unsetTransformationvoid unsetTransformation(); | |
updateAttributevirtual void updateAttribute( std::string s, AstAttribute* a) override; [virtual] | Replace existing attribute of name 's' with new AstAttribute. |
validateAttachedPreprocessingInfoOwnershipvoid validateAttachedPreprocessingInfoOwnership() const; | |
variantTvirtual VariantT variantT() const override; [virtual] | returns new style SageIII enum values |
Static Member Functions¶
| Name | Description |
|---|---|
memoryUsagestatic size_t memoryUsage(); | Returns the size in bytes of the total memory allocated for all IR nodes of this type |
numberOfNodesstatic size_t numberOfNodes(); | Returns the total number of IR nodes of this type |
traverseMemoryPoolNodesstatic void traverseMemoryPoolNodes(ROSE_VisitTraversal& visit); | FOR INTERNAL USE Support for visitor pattern over all IR nodes by type of IR node. |
traverseMemoryPoolVisitorPatternstatic void traverseMemoryPoolVisitorPattern(ROSE_VisitorPattern& visitor); | FOR INTERNAL USE Support for visitor pattern. |
visitRepresentativeNodestatic 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_initializationvirtual void post_construction_initialization() override; [virtual] |
Protected Data Members¶
Private Member Functions¶
| Name | Description |
|---|---|
SgLocatedNodeSgLocatedNode(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