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 ShouldVisitTemplateInstantiations =
true;
39 ShouldVisitImplicitCode =
false;
43 Contributors.insert(D);
47 bool VisitRecordDecl(RecordDecl *D)
override {
48 Contributors.insert(D);
52 bool VisitVarDecl(VarDecl *D)
override {
57 Contributors.insert(D);
78 llvm::function_ref<void(
const DynTypedNode &)> MatchActionRef;
79 const NamedDecl *RootDecl =
nullptr;
81 template <
typename NodeTy>
void match(
const NodeTy &Node) {
82 MatchActionRef(DynTypedNode::create(Node));
86 ContributorFactFinder(
87 llvm::function_ref<
void(
const DynTypedNode &)> MatchActionRef)
88 : MatchActionRef(MatchActionRef) {
89 ShouldVisitTemplateInstantiations =
true;
90 ShouldVisitImplicitCode =
false;
94 void findMatches(
const NamedDecl *Contributor) {
95 RootDecl = Contributor;
96 TraverseDecl(
const_cast<NamedDecl *
>(Contributor));
99 bool TraverseDecl(Decl *Node)
override {
103 if (Node != RootDecl &&
110 bool TraverseStmt(Stmt *Node)
override {
117 bool TraverseLambdaExpr(
LambdaExpr *L)
override {
128 std::vector<const NamedDecl *> &Contributors) {
129 ContributorFinder Finder;
130 Finder.TraverseAST(Ctx);
131 Contributors.insert(Contributors.end(), Finder.Contributors.begin(),
132 Finder.Contributors.end());
137 llvm::function_ref<
void(
const DynTypedNode &)> MatchActionRef) {
138 ContributorFactFinder{MatchActionRef}.findMatches(Contributor);
143 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...
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