20 return llvm::formatv(
"{0:2}",
V).str();
24 return llvm::formatv(
"array of size {0}", A.size()).str();
28 return llvm::formatv(
"an object of {0} key(s)", O.size()).str();
35 std::set<const NamedDecl *> Contributors;
38 Contributors.insert(D);
43 Contributors.insert(D);
47 bool VisitVarDecl(VarDecl *D)
override {
52 Contributors.insert(D);
73 llvm::function_ref<void(
const DynTypedNode &)> MatchActionRef;
74 const NamedDecl *RootDecl =
nullptr;
76 template <
typename NodeTy>
void match(
const NodeTy &Node) {
77 MatchActionRef(DynTypedNode::create(Node));
81 ContributorFactFinder(
82 llvm::function_ref<
void(
const DynTypedNode &)> MatchActionRef)
83 : MatchActionRef(MatchActionRef) {
84 ShouldVisitTemplateInstantiations =
true;
85 ShouldVisitImplicitCode =
false;
89 void findMatches(
const NamedDecl *Contributor) {
90 RootDecl = Contributor;
91 TraverseDecl(
const_cast<NamedDecl *
>(Contributor));
94 bool TraverseDecl(Decl *Node)
override {
98 if (Node != RootDecl &&
105 bool TraverseStmt(Stmt *Node)
override {
112 bool TraverseLambdaExpr(
LambdaExpr *L)
override {
123 std::vector<const NamedDecl *> &Contributors) {
124 ContributorFinder Finder;
125 Finder.TraverseAST(Ctx);
126 Contributors.insert(Contributors.end(), Finder.Contributors.begin(),
127 Finder.Contributors.end());
132 llvm::function_ref<
void(
const DynTypedNode &)> MatchActionRef) {
133 ContributorFactFinder{MatchActionRef}.findMatches(Contributor);
138 return makeErrAtNode(Ctx, D,
"failed to create entity name for %s",
Defines the clang::ASTContext interface.
Defines the clang::Expr interface and subclasses for C++ expressions.
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)
Represents a function declaration or definition.
CXXMethodDecl * getCallOperator() const
Retrieve the function call operator associated with this lambda expression.
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...
Represents a struct/union/class.
bool isStaticDataMember() const
Determines whether this is a static data member.
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.
std::string describeJSONValue(const llvm::json::Value &V)
The JSON file list parser is used to communicate input to InstallAPI.
bool isa(CodeGen::Address addr)
DynamicRecursiveASTVisitorBase< false > DynamicRecursiveASTVisitor