clang: clang::DynTypedNode Class Reference (original) (raw)

A dynamically typed AST node container. More...

#include "[clang/AST/ASTTypeTraits.h](ASTTypeTraits%5F8h%5Fsource.html)"

Classes
struct BaseConverter< ConceptReference, void >
struct BaseConverter< CXXBaseSpecifier, void >
struct BaseConverter< CXXCtorInitializer, void >
struct BaseConverter< LambdaCapture, void >
struct BaseConverter< NestedNameSpecifier, void >
struct BaseConverter< NestedNameSpecifierLoc, void >
struct BaseConverter< ObjCProtocolLoc, void >
struct BaseConverter< QualType, void >
struct BaseConverter< T, std::enable_if_t< std::is_base_of< Attr, T >::value > >
struct BaseConverter< T, std::enable_if_t< std::is_base_of< Decl, T >::value > >
struct BaseConverter< T, std::enable_if_t< std::is_base_of< OMPClause, T >::value > >
struct BaseConverter< T, std::enable_if_t< std::is_base_of< Stmt, T >::value > >
struct BaseConverter< T, std::enable_if_t< std::is_base_of< Type, T >::value > >
struct BaseConverter< T, std::enable_if_t< std::is_base_of< TypeLoc, T >::value > >
struct BaseConverter< TemplateArgument, void >
struct BaseConverter< TemplateArgumentLoc, void >
struct BaseConverter< TemplateName, void >
struct DenseMapInfo
Hooks for using DynTypedNode as a key in a DenseMap. More...
Public Member Functions
template<typename T >
const T * get () const
Retrieve the stored node as type T.
template<typename T >
const T & getUnchecked () const
Retrieve the stored node as type T.
ASTNodeKind getNodeKind () const
const void * getMemoizationData () const
Returns a pointer that identifies the stored AST node.
void print (llvm::raw_ostream &OS, const PrintingPolicy &PP) const
Prints the node to the given output stream.
void dump (llvm::raw_ostream &OS, const ASTContext &Context) const
Dumps the node to the given output stream.
SourceRange getSourceRange () const
For nodes which represent textual entities in the source code, return their SourceRange.
bool operator< (const DynTypedNode &Other) const
bool operator== (const DynTypedNode &Other) const
bool operator!= (const DynTypedNode &Other) const

A dynamically typed AST node container.

Stores an AST node in a type safe way. This allows writing code that works with different kinds of AST nodes, despite the fact that they don't have a common base class.

Use create(Node) to create a [DynTypedNode](classclang%5F1%5F1DynTypedNode.html "A dynamically typed AST node container.") from an AST node, and [get<T>()](classclang%5F1%5F1DynTypedNode.html#a5577aae931c4e6d37a8d330190e09ffe "Retrieve the stored node as type T.") to retrieve the node as type T if the types match.

See [ASTNodeKind](classclang%5F1%5F1ASTNodeKind.html "Kind identifier.") for which node base types are currently supported; You can create DynTypedNodes for all nodes in the inheritance hierarchy of the supported base types.

Definition at line 257 of file ASTTypeTraits.h.

create()

template<typename T >

static DynTypedNode clang::DynTypedNode::create ( const T & Node) inlinestatic

dump()

void DynTypedNode::dump ( llvm::raw_ostream & OS,
const ASTContext & Context
) const

get()

template<typename T >

const T * clang::DynTypedNode::get ( ) const inline

Retrieve the stored node as type T.

Returns NULL if the stored node does not have a type that is convertible to T.

For types that have identity via their pointer in the AST (like [Stmt](classclang%5F1%5F1Stmt.html "Stmt - This represents one statement."), [Decl](classclang%5F1%5F1Decl.html "Decl - This represents one declaration (or definition), e.g."), [Type](classclang%5F1%5F1Type.html "The base class of the type hierarchy.") and [NestedNameSpecifier](classclang%5F1%5F1NestedNameSpecifier.html "Represents a C++ nested name specifier, such as "\::std::vector<int>::".")) the returned pointer points to the referenced AST node. For other types (like [QualType](classclang%5F1%5F1QualType.html "A (possibly-)qualified type.")) the value is stored directly in the [DynTypedNode](classclang%5F1%5F1DynTypedNode.html "A dynamically typed AST node container."), and the returned pointer points at the storage inside DynTypedNode. For those nodes, do not use the pointer outside the scope of the DynTypedNode.

Definition at line 277 of file ASTTypeTraits.h.

Referenced by clang::ast_matchers::AST_MATCHER_P(), dump(), findDeepestWithKind(), clang::ast_matchers::MatchDescendantVisitor::findMatch(), clang::tooling::CodeRangeASTSelection::getFunctionLikeNearestParent(), clang::diff::SyntaxTree::Impl::getNodeValue(), clang::CallGraph::getOrInsertNode(), clang::ParentMapContext::ParentMap::getParents(), clang::tooling::CodeRangeASTSelection::isInFunctionLikeBodyOfCode(), clang::transformer::member(), clang::transformer::name(), clang::transformer::node(), clang::transformer::detail::rewriteDescendants(), clang::ParentMapContext::traverseIgnored(), and clang::ASTNodeTraverser< Derived, NodeDelegateType >::Visit().

getMemoizationData()

const void * clang::DynTypedNode::getMemoizationData ( ) const inline

getNodeKind()

ASTNodeKind clang::DynTypedNode::getNodeKind ( ) const inline

getSourceRange()

getUnchecked()

template<typename T >

const T & clang::DynTypedNode::getUnchecked ( ) const inline

operator!=()

operator<()

operator==()

print()

void DynTypedNode::print ( llvm::raw_ostream & OS,
const PrintingPolicy & PP
) const

The documentation for this class was generated from the following files: