SageInterface::getEnclosingNode
Find a node by type using upward traversal.
Synopsis
Declared in <SageIII/sageInterface/sageInterface.h>
template<typename NodeType>
NodeType*
getEnclosingNode(
SgNode const* astNode,
bool const includingSelf = false);
Description
Traverse backward through a specified node's ancestors, starting with the node's parent and progressing to more distant ancestors, to find the first node matching the specified or derived type. If includingSelf is true then the starting node, astNode, is returned if its type matches, otherwise the search starts at the parent of astNode.
For the purposes of this function, the parent (P) of an SgDeclarationStatement node (N) is considered to be the first non‐defining declaration of N if N has both a defining declaration and a first non‐defining declaration and the defining declaration is different than the first non‐defining declaration.
If no ancestor of the requisite type of subtypes is found then this function returns a null pointer.
If astNode is the null pointer, then the return value is a null pointer. That is, if there is no node, then there cannot be an enclosing node of the specified type.
Parameters
Name |
Description |
astNode |
This class represents the base class for all IR nodes within Sage III. |
Created with MrDocs