clang 19.0.0git
Functions
ASTSelection.cpp File Reference
#include "clang/Tooling/Refactoring/ASTSelection.h"
#include "clang/AST/LexicallyOrderedRecursiveASTVisitor.h"
#include "clang/Lex/Lexer.h"
#include "llvm/Support/SaveAndRestore.h"
#include <optional>

Go to the source code of this file.

Functions

static const char * selectionKindToString (SourceSelectionKind Kind)
 
static void dump (const SelectedASTNode &Node, llvm::raw_ostream &OS, unsigned Indent=0)
 
static bool hasAnyDirectChildrenWithKind (const SelectedASTNode &Node, SourceSelectionKind Kind)
 Returns true if the given node has any direct children with the following selection kind.
 
static void findDeepestWithKind (const SelectedASTNode &ASTSelection, llvm::SmallVectorImpl< SelectedNodeWithParents > &MatchingNodes, SourceSelectionKind Kind, llvm::SmallVectorImpl< SelectedASTNode::ReferenceType > &ParentStack)
 Finds the set of bottom-most selected AST nodes that are in the selection tree with the specified selection kind.
 
static void findDeepestWithKind (const SelectedASTNode &ASTSelection, llvm::SmallVectorImpl< SelectedNodeWithParents > &MatchingNodes, SourceSelectionKind Kind)
 
static bool isFunctionLikeDeclaration (const Decl *D)
 

Function Documentation

◆ dump()

static void dump ( const SelectedASTNode Node,
llvm::raw_ostream &  OS,
unsigned  Indent = 0 
)
static

◆ findDeepestWithKind() [1/2]

static void findDeepestWithKind ( const SelectedASTNode ASTSelection,
llvm::SmallVectorImpl< SelectedNodeWithParents > &  MatchingNodes,
SourceSelectionKind  Kind 
)
static

Definition at line 371 of file ASTSelection.cpp.

References findDeepestWithKind().

◆ findDeepestWithKind() [2/2]

static void findDeepestWithKind ( const SelectedASTNode ASTSelection,
llvm::SmallVectorImpl< SelectedNodeWithParents > &  MatchingNodes,
SourceSelectionKind  Kind,
llvm::SmallVectorImpl< SelectedASTNode::ReferenceType > &  ParentStack 
)
static

Finds the set of bottom-most selected AST nodes that are in the selection tree with the specified selection kind.

For example, given the following selection tree:

FunctionDecl "f" contains-selection CompoundStmt contains-selection [#1] CallExpr inside ImplicitCastExpr inside DeclRefExpr inside IntegerLiteral inside IntegerLiteral inside FunctionDecl "f2" contains-selection CompoundStmt contains-selection [#2] CallExpr inside ImplicitCastExpr inside DeclRefExpr inside IntegerLiteral inside IntegerLiteral inside

This function will find references to nodes #1 and #2 when searching for the ContainsSelection kind.

Definition at line 341 of file ASTSelection.cpp.

References clang::tooling::SelectedASTNode::Children, findDeepestWithKind(), clang::DynTypedNode::get(), hasAnyDirectChildrenWithKind(), and clang::tooling::SelectedASTNode::Node.

Referenced by clang::tooling::CodeRangeASTSelection::create(), and findDeepestWithKind().

◆ hasAnyDirectChildrenWithKind()

static bool hasAnyDirectChildrenWithKind ( const SelectedASTNode Node,
SourceSelectionKind  Kind 
)
static

Returns true if the given node has any direct children with the following selection kind.

Note: The direct children also include children of direct children with the "None" selection kind.

Definition at line 238 of file ASTSelection.cpp.

References hasAnyDirectChildrenWithKind(), Node, and clang::tooling::None.

Referenced by findDeepestWithKind(), and hasAnyDirectChildrenWithKind().

◆ isFunctionLikeDeclaration()

static bool isFunctionLikeDeclaration ( const Decl D)
static

◆ selectionKindToString()

static const char * selectionKindToString ( SourceSelectionKind  Kind)
static

Definition at line 200 of file ASTSelection.cpp.

Referenced by dump().