clang 20.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 22 of file ParentMapContext.cpp.
|
default |
void ParentMapContext::clear | ( | ) |
Clear parent maps.
Definition at line 26 of file ParentMapContext.cpp.
Referenced by clang::ASTContext::setTraversalScope().
DynTypedNodeList ParentMapContext::getParents | ( | const DynTypedNode & | Node | ) |
Definition at line 478 of file ParentMapContext.cpp.
References getTraversalKind(), and Node.
|
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(), getParents(), and Node.
Referenced by clang::ASTContext::getParents(), getParents(), isInCondition(), and matchesPostDecrInWhile().
|
inline |
Definition at line 60 of file ParentMapContext.h.
Referenced by getParents(), and clang::TraversalKindScope::TraversalKindScope().
|
inline |
Definition at line 61 of file ParentMapContext.h.
Referenced by clang::TraversalKindScope::TraversalKindScope(), and clang::TraversalKindScope::~TraversalKindScope().
DynTypedNode ParentMapContext::traverseIgnored | ( | const DynTypedNode & | N | ) | const |
Definition at line 45 of file ParentMapContext.cpp.
References clang::DynTypedNode::create(), E, clang::DynTypedNode::get(), and traverseIgnored().
Definition at line 28 of file ParentMapContext.cpp.
References E, and traverseIgnored().
Referenced by traverseIgnored().
Definition at line 32 of file ParentMapContext.cpp.
References E, clang::Expr::IgnoreUnlessSpelledInSource(), clang::TK_AsIs, and clang::TK_IgnoreUnlessSpelledInSource.