22 std::set<const NamedDecl *> Contributors;
24 bool VisitFunctionDecl(FunctionDecl *D)
override {
25 Contributors.insert(D);
29 bool VisitRecordDecl(RecordDecl *D)
override {
30 Contributors.insert(D);
34 bool VisitVarDecl(VarDecl *D)
override {
38 Contributors.insert(D);
52 llvm::function_ref<void(
const DynTypedNode &)> MatchActionRef;
53 const NamedDecl *RootDecl =
nullptr;
55 template <
typename NodeTy>
void match(
const NodeTy &Node) {
56 MatchActionRef(DynTypedNode::create(Node));
60 ContributorFactFinder(
61 llvm::function_ref<
void(
const DynTypedNode &)> MatchActionRef)
62 : MatchActionRef(MatchActionRef) {
63 ShouldVisitTemplateInstantiations =
true;
64 ShouldVisitImplicitCode =
false;
68 void findMatches(
const NamedDecl *Contributor) {
69 RootDecl = Contributor;
70 TraverseDecl(
const_cast<NamedDecl *
>(Contributor));
73 bool TraverseDecl(Decl *Node)
override {
77 if (Node != RootDecl &&
84 bool TraverseStmt(Stmt *Node)
override {
91 bool TraverseLambdaExpr(
LambdaExpr *L)
override {
102 ASTContext &Ctx, std::vector<const NamedDecl *> &Contributors) {
103 ContributorFinder Finder;
104 Finder.TraverseAST(Ctx);
105 Contributors.insert(Contributors.end(), Finder.Contributors.begin(),
106 Finder.Contributors.end());
111 llvm::function_ref<
void(
const DynTypedNode &)> MatchActionRef) {
112 ContributorFactFinder{MatchActionRef}.findMatches(Contributor);
117 return makeErrAtNode(Ctx, D,
"failed to create entity name for %s",
Defines the clang::ASTContext interface.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
bool isFileContext() const
DeclContext * getDeclContext()
A dynamically typed AST node container.
virtual bool TraverseDecl(MaybeConst< Decl > *D)
virtual bool TraverseStmt(MaybeConst< Stmt > *S)
This represents a decl that may have a name.
std::string getNameAsString() const
Get a human-readable name for the declaration, even if it is one of the special kinds of names (C++ c...
SmallVector< BoundNodes, 1 > match(MatcherT Matcher, const NodeT &Node, ASTContext &Context)
Returns the results of matching Matcher on Node.
llvm::Error makeErrAtNode(clang::ASTContext &Ctx, const NodeTy *N, llvm::StringRef Fmt, const Ts &...Args)
void findContributors(ASTContext &Ctx, std::vector< const NamedDecl * > &Contributors)
Find all contributors in an AST.
llvm::Error makeEntityNameErr(clang::ASTContext &Ctx, const clang::NamedDecl *D)
void findMatchesIn(const NamedDecl *Contributor, llvm::function_ref< void(const DynTypedNode &)> MatchActionRef)
Perform "MatchAction" on each Stmt and Decl belonging to the Contributor.
The JSON file list parser is used to communicate input to InstallAPI.
bool isa(CodeGen::Address addr)
DynamicRecursiveASTVisitorBase< false > DynamicRecursiveASTVisitor