ROSE 0.11.145.147
Typedefs | Functions
Rose::AST::Utility Namespace Reference

Description

Collection of utility functions to operate on the AST.

Typedefs

using replacement_map_t = std::map< SgNode *, SgNode * >
 

Functions

void edgePointerReplacement (replacement_map_t const &)
 For all nodes in the memory pool, it looks for the edges in the replacement map. If a match is found the edge is updated.
 
void edgePointerReplacement (SgNode *root, replacement_map_t const &)
 Traverse the AST root looking for the edges in the replacement map. If a match is found the edge is updated.
 
bool checkParentPointers (SgNode *root, std::ostream &out=std::cerr)
 Check that all parent pointers in the specified subtree are correct.
 
void repairParentPointers (SgNode *root)
 Set parent pointers based on child pointers in a subtree.
 

Typedef Documentation

◆ replacement_map_t

using Rose::AST::Utility::replacement_map_t = typedef std::map<SgNode *, SgNode *>

Definition at line 17 of file AST/Utility.h.

Function Documentation

◆ checkParentPointers()

bool Rose::AST::Utility::checkParentPointers ( SgNode root,
std::ostream &  out = std::cerr 
)

Check that all parent pointers in the specified subtree are correct.

This function does a traversal of the tree starting at the specified root and checks that each child points to the correct parent. If not, then an error message is printed and the function returns false. If you do not want error messages, then pass a closed output stream.

Safety: This function is not thread safe.

◆ repairParentPointers()

void Rose::AST::Utility::repairParentPointers ( SgNode root)

Set parent pointers based on child pointers in a subtree.

Traverses a subtree, and makes sure that each child points to its parent. No diagnostics are emitted; if you want diagnostics then you should call checkParentPointers instead. I.e., checking and repairing are two separate operations.

Caveats:

  • If root is null, then this function is a no-op.
  • The parent pointer for the node pointed to by root is not adjusted.
  • Parent pointers in other subtrees that might be reachable from non-tree pointers that cross from this subtree to another are not adjusted.

Safety: This function is not thread safe.