clang 22.0.0git
|
#include "clang/AST/ParentMapContext.h"
Classes | |
class | ParentMap |
Public Member Functions | |
ParentMapContext (ASTContext &Ctx) | |
~ParentMapContext () | |
template<typename NodeT> | |
DynTypedNodeList | getParents (const NodeT &Node) |
Returns the parents of the given node (within the traversal scope). | |
DynTypedNodeList | getParents (const DynTypedNode &Node) |
void | clear () |
Clear parent maps. | |
TraversalKind | getTraversalKind () const |
void | setTraversalKind (TraversalKind TK) |
const Expr * | traverseIgnored (const Expr *E) const |
Expr * | traverseIgnored (Expr *E) const |
DynTypedNode | traverseIgnored (const DynTypedNode &N) const |
Definition at line 23 of file ParentMapContext.h.
ParentMapContext::ParentMapContext | ( | ASTContext & | Ctx | ) |
Definition at line 23 of file ParentMapContext.cpp.
|
default |
void ParentMapContext::clear | ( | ) |
Clear parent maps.
Definition at line 27 of file ParentMapContext.cpp.
Referenced by clang::ASTContext::setTraversalScope().
DynTypedNodeList ParentMapContext::getParents | ( | const DynTypedNode & | Node | ) |
Definition at line 486 of file ParentMapContext.cpp.
References getTraversalKind().
|
inline |
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.
Definition at line 126 of file ParentMapContext.h.
References clang::DynTypedNode::create(), and getParents().
Referenced by clang::ASTContext::getParents(), clang::ASTContext::getParents(), getParents(), isInCondition(), and matchesPostDecrInWhile().
|
inline |
Definition at line 60 of file ParentMapContext.h.
Referenced by getParents().
|
inline |
Definition at line 61 of file ParentMapContext.h.
DynTypedNode ParentMapContext::traverseIgnored | ( | const DynTypedNode & | N | ) | const |
Definition at line 46 of file ParentMapContext.cpp.
References clang::DynTypedNode::create(), clang::DynTypedNode::get(), and traverseIgnored().
Definition at line 29 of file ParentMapContext.cpp.
References traverseIgnored().
Referenced by traverseIgnored(), and traverseIgnored().
Definition at line 33 of file ParentMapContext.cpp.
References clang::Expr::IgnoreUnlessSpelledInSource(), clang::TK_AsIs, and clang::TK_IgnoreUnlessSpelledInSource.