Skip to content

sg

This namespace contains template functions that operate on the ROSE AST

Types

Name

Description

AncestorTypeFinder

helper class for _ancestor

ConstLike

projects the constness of T1 on T2

ConstLike<T1 const, T2>

DefaultHandler

struct DefaultHandler

DispatchHandler

Base class for any handlers passed to dispatch

DispatchHelper

InitNameCloner

Functor copying an initialized name into a different scope

SageInserter

Generic inserter for sage containers

ScopeSetter

Functor setting the scope of a sage node to a specified (at Functor construction time) scope

TraversalClass

TraversalFunction

executes a functor for a specific node type

TypeRecoveryHandler

VarRefBuilder

Functor building a variable reference from an initialized name

VisitDispatcher

Functions

Name

Description

_ancestor
template< class AncestorNode, class QualSgNode> AncestorNode* _ancestor(QualSgNode& n);

implements the ancestor search

_dispatch
template<class RoseVisitor> std::remove_const<std::remove_reference<RoseVisitor>::type>::type _dispatch(RoseVisitor&& rv, SgNode* n);

ancestor
template<class AncestorNode> AncestorNode& ancestor(SgNode& n);

finds an ancestor node with a given type

asBaseType
template<class SageNode> SageNode::base_node_type& asBaseType(SageNode& n);

returns the same node n upcasted to its base type

assert_sage_type
template<class SageNode> SageNode& assert_sage_type(SgNode& n, char const* f = 0, size_t ln = 0);

asserts that n has type SageNode

assume_sage_type
template<class SageNode> static SageNode& assume_sage_type(SgNode& n);

unchecked down cast from SgNode to SageNode

cloneNode
template<class SageNode> static SageNode* cloneNode(SageNode const* n);

returns a deep copy of a sage node

conv
template< class T, class E> static T conv(E const& el);

converts object of type E to T via string conversion

createTraversalFunction
template<class SageNode> static TraversalFunction<SageNode> createTraversalFunction(void(* fn)(SageNode*));

creates a functor that executes code for a specific node type

deref
template<class T> T& deref(T* ptr, char const* file = 0, size_t ln = 0);

dereferences an object (= checked dereference in debug mode)

dispatch
template<class RoseVisitor> std::remove_const<std::remove_reference<RoseVisitor>::type>::type dispatch(RoseVisitor&& rv, SgNode* n);

uncovers the type of SgNode and passes it to an function "handle" in RoseVisitor. which should be overloaded with every possible target node. After the traversal, RoseVisitor should contain the intended return data.

dispatchHelper
template<class GVisitor> static DispatchHelper<GVisitor> dispatchHelper(GVisitor gv, SgNode* parent = NULL);

forAllNodes
template<class F> static F forAllNodes(F fn, SgNode* root, AstSimpleProcessing::Order order = postorder);

calls fn with all applicable nodes in the AST

linkParentChild
template< class SageParent, class SageChild> void linkParentChild(SageParent& parent, SageChild& child, void(SageParent::* setter)(SageChild*));

report_error
[[noreturn]] void report_error(std::string desc, char const* file = nullptr, size_t ln = 0);

sage_inserter
template<class SageSequenceContainer> SageInserter<SageSequenceContainer> sage_inserter(SageSequenceContainer& cont);

generates a SageInserter, adding elements at the end of a sequence

swap_child
template< class SageNode, class SageChild> void swap_child(SageNode& lhs, SageNode& rhs, SageChild* const(SageNode::* getter)(), void(SageNode::* setter)(SageChild*));

swaps children (of equal kind) between two ancestor nodes of the same type

traverseChildren
template<class GVisitor> static GVisitor traverseChildren(GVisitor gv, SgNode& n);

unexpected_node
[[noreturn]] void unexpected_node(SgNode const& n, char const* file = nullptr, size_t ln = 0);

unused
template<class T> static void unused(T const&);

portable implementation to avoid compiler warnings for unused parameter.

Created with MrDocs