class ParentMapContext
Declaration
class ParentMapContext { /* full declaration omitted */ };
Declared at: clang/include/clang/AST/ParentMapContext.h:23
Member Variables
- private clang::ASTContext& ASTCtx
- private clang::TraversalKind Traversal = TK_AsIs
- private std::unique_ptr<ParentMap> Parents
Method Overview
- public ParentMapContext(clang::ASTContext & Ctx)
- public void clear()
- public clang::DynTypedNodeList getParents(const clang::DynTypedNode & Node)
- public template <typename NodeT>clang::DynTypedNodeList getParents(const NodeT & Node)
- public clang::TraversalKind getTraversalKind() const
- public void setTraversalKind(clang::TraversalKind TK)
- public const clang::Expr * traverseIgnored(const clang::Expr * E) const
- public clang::Expr * traverseIgnored(clang::Expr * E) const
- public clang::DynTypedNode traverseIgnored(const clang::DynTypedNode & N) const
- public ~ParentMapContext()
Methods
¶ParentMapContext(clang::ASTContext& Ctx)
ParentMapContext(clang::ASTContext& Ctx)
Declared at: clang/include/clang/AST/ParentMapContext.h:25
Parameters
- clang::ASTContext& Ctx
¶void clear()
void clear()
Description
Clear parent maps.
Declared at: clang/include/clang/AST/ParentMapContext.h:58
¶clang::DynTypedNodeList getParents(
const clang::DynTypedNode& Node)
clang::DynTypedNodeList getParents(
const clang::DynTypedNode& Node)
Declared at: clang/include/clang/AST/ParentMapContext.h:55
Parameters
- const clang::DynTypedNode& Node
¶template <typename NodeT>
clang::DynTypedNodeList getParents(
const NodeT& Node)
template <typename NodeT>
clang::DynTypedNodeList getParents(
const NodeT& Node)
Description
Returns the parents of the given node (within the traversal scope). Note that this will lazily compute the parents of all nodes and store them for later retrieval. Thus, the first call is O(n) in the number of AST nodes. Caveats and FIXMEs: Calculating the parent map over all AST nodes will need to load the full AST. This can be undesirable in the case where the full AST is expensive to create (for example, when using precompiled header preambles). Thus, there are good opportunities for optimization here. One idea is to walk the given node downwards, looking for references to declaration contexts - once a declaration context is found, compute the parent map for the declaration context; if that can satisfy the request, loading the whole AST can be avoided. Note that this is made more complex by statements in templates having multiple parents - those problems can be solved by building closure over the templated parts of the AST, which also avoids touching large parts of the AST. Additionally, we will want to add an interface to already give a hint where to search for the parents, for example when looking at a statement inside a certain function. 'NodeT' can be one of Decl, Stmt, Type, TypeLoc, NestedNameSpecifier or NestedNameSpecifierLoc.
Declared at: clang/include/clang/AST/ParentMapContext.h:53
Templates
- NodeT
Parameters
- const NodeT& Node
¶clang::TraversalKind getTraversalKind() const
clang::TraversalKind getTraversalKind() const
Declared at: clang/include/clang/AST/ParentMapContext.h:60
¶void setTraversalKind(clang::TraversalKind TK)
void setTraversalKind(clang::TraversalKind TK)
Declared at: clang/include/clang/AST/ParentMapContext.h:61
Parameters
- clang::TraversalKind TK
¶const clang::Expr* traverseIgnored(
const clang::Expr* E) const
const clang::Expr* traverseIgnored(
const clang::Expr* E) const
Declared at: clang/include/clang/AST/ParentMapContext.h:63
Parameters
- const clang::Expr* E
¶clang::Expr* traverseIgnored(clang::Expr* E) const
clang::Expr* traverseIgnored(clang::Expr* E) const
Declared at: clang/include/clang/AST/ParentMapContext.h:64
Parameters
- clang::Expr* E
¶clang::DynTypedNode traverseIgnored(
const clang::DynTypedNode& N) const
clang::DynTypedNode traverseIgnored(
const clang::DynTypedNode& N) const
Declared at: clang/include/clang/AST/ParentMapContext.h:65
Parameters
- const clang::DynTypedNode& N
¶~ParentMapContext()
~ParentMapContext()
Declared at: clang/include/clang/AST/ParentMapContext.h:27