#include "clang/Tooling/Refactoring/ASTSelection.h"
#include "clang/AST/LexicallyOrderedRecursiveASTVisitor.h"
#include "clang/Lex/Lexer.h"
#include "llvm/Support/SaveAndRestore.h"
#include <optional>
usingnamespaceclang;
usingnamespacetooling;
namespace {
CharSourceRange getLexicalDeclRange(Decl *D, const SourceManager &SM,
const LangOptions &LangOpts) { … }
class ASTSelectionFinder
: public LexicallyOrderedRecursiveASTVisitor<ASTSelectionFinder> { … };
}
std::optional<SelectedASTNode>
clang::tooling::findSelectedASTNodes(const ASTContext &Context,
SourceRange SelectionRange) { … }
static const char *selectionKindToString(SourceSelectionKind Kind) { … }
static void dump(const SelectedASTNode &Node, llvm::raw_ostream &OS,
unsigned Indent = 0) { … }
void SelectedASTNode::dump(llvm::raw_ostream &OS) const { … }
static bool hasAnyDirectChildrenWithKind(const SelectedASTNode &Node,
SourceSelectionKind Kind) { … }
namespace {
struct SelectedNodeWithParents { … };
enum SelectionCanonicalizationAction { … };
SelectionCanonicalizationAction
getSelectionCanonizalizationAction(const Stmt *S, const Stmt *Parent) { … }
}
void SelectedNodeWithParents::canonicalize() { … }
static void findDeepestWithKind(
const SelectedASTNode &ASTSelection,
llvm::SmallVectorImpl<SelectedNodeWithParents> &MatchingNodes,
SourceSelectionKind Kind,
llvm::SmallVectorImpl<SelectedASTNode::ReferenceType> &ParentStack) { … }
static void findDeepestWithKind(
const SelectedASTNode &ASTSelection,
llvm::SmallVectorImpl<SelectedNodeWithParents> &MatchingNodes,
SourceSelectionKind Kind) { … }
std::optional<CodeRangeASTSelection>
CodeRangeASTSelection::create(SourceRange SelectionRange,
const SelectedASTNode &ASTSelection) { … }
static bool isFunctionLikeDeclaration(const Decl *D) { … }
bool CodeRangeASTSelection::isInFunctionLikeBodyOfCode() const { … }
const Decl *CodeRangeASTSelection::getFunctionLikeNearestParent() const { … }