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.
A declaration with a defining declaration redirects the semantic search through that definition unless it is the first non-defining declaration. The immediate parent is redirected before testing its type; later ancestors are redirected only when their type does not match. Cycles in either visited physical or semantic parent path are hard errors.
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