Template Function sg::ancestor(SgNode *)

Template Function sg::ancestor(SgNode *)#

Function Documentation#

template<class AncestorNode>
AncestorNode *sg::ancestor(SgNode *n)#

finds an ancestor node with a given type

the function family comes in four variants:

  • SgNode* -> AncestorNode* ( result can be NULL )

  • const SgNode* -> const AncestorNode* ( result can be NULL )

  • SgNode& -> AncestorNode& ( assert(false) when an ancestor of the specified type cannot be found )

  • const SgNode& -> const AncestorNode& ( assert(false) when an ancestor of the specified type cannot be found )

    const SgStatement* enclosingStatement(const SgExpression* e)  { return sg::ancestor<SgStatement>(e); }