119 auto IsInSpecialization = hasAncestor(
120 decl(anyOf(cxxRecordDecl(isExplicitTemplateSpecialization()),
121 functionDecl(isExplicitTemplateSpecialization()))));
127 allOf(unless(isImplicit()), unless(isExpansionInMainFile()));
129 auto HasNSOrTUCtxMatcher =
130 hasDeclContext(anyOf(namespaceDecl(), translationUnitDecl()));
138 allOf(HasNSOrTUCtxMatcher, unless(IsInSpecialization),
139 unless(ast_matchers::isTemplateInstantiation()),
140 unless(isInstantiated()), unless(isFullySpecialized()));
143 auto ExternCMatcher = hasDeclContext(linkageSpecDecl());
156 auto Vars = varDecl(CommonFilter, anyOf(ExternCMatcher, CCMatcher),
157 unless(parmVarDecl()));
160 auto CRecords = recordDecl(CommonFilter, ExternCMatcher, isDefinition());
162 auto CXXRecords = cxxRecordDecl(CommonFilter, CCMatcher, isDefinition());
168 auto Functions = functionDecl(CommonFilter, unless(hasParent(friendDecl())),
169 anyOf(ExternCMatcher, CCMatcher));
183 typedefNameDecl(CommonFilter, anyOf(HasNSOrTUCtxMatcher,
184 hasDeclContext(linkageSpecDecl())));
187 auto Enums = enumDecl(CommonFilter, isDefinition(),
188 anyOf(HasNSOrTUCtxMatcher, ExternCMatcher));
193 auto EnumConstants = enumConstantDecl(
194 CommonFilter, unless(isInScopedEnum()),
195 anyOf(hasDeclContext(enumDecl(HasNSOrTUCtxMatcher)), ExternCMatcher));
198 auto Types = namedDecl(anyOf(CRecords, CXXRecords, Enums));
199 auto Decls = namedDecl(anyOf(CRecords, CXXRecords, Enums, Typedefs, Vars,
200 EnumConstants, Functions));
203 MatchFinder->addMatcher(Decls.bind(
"decl"),
this);
207 MatchFinder->addMatcher(
208 declRefExpr(isExpansionInMainFile(), to(Decls.bind(
"use"))),
this);
210 MatchFinder->addMatcher(
211 declRefExpr(isExpansionInMainFile(),
212 to(functionDecl(hasParent(
213 functionTemplateDecl(has(Functions.bind(
"use"))))))),
217 MatchFinder->addMatcher(
218 typeLoc(isExpansionInMainFile(),
219 loc(qualType(hasDeclaration(Types.bind(
"use"))))),
223 MatchFinder->addMatcher(
224 typeLoc(isExpansionInMainFile(),
225 loc(typedefType(hasDeclaration(Typedefs.bind(
"use"))))),
230 MatchFinder->addMatcher(
231 typeLoc(isExpansionInMainFile(),
232 loc(templateSpecializationType(hasDeclaration(
233 classTemplateSpecializationDecl(hasSpecializedTemplate(
234 classTemplateDecl(has(CXXRecords.bind(
"use"))))))))),
240 if (Result.Context->getDiagnostics().hasErrorOccurred()) {
246 if ((ND = Result.Nodes.getNodeAs<NamedDecl>(
"use")))
248 else if ((ND = Result.Nodes.getNodeAs<NamedDecl>(
"decl")))
251 assert(
false &&
"Must match a NamedDecl!");
253 const SourceManager *SM = Result.SourceManager;
254 if (
auto Symbol = CreateSymbolInfo(ND, *SM, Collector)) {
256 std::string(SM->getFileEntryRefForID(SM->getMainFileID())->getName());
257 FileSymbols[*Symbol] += Signals;
clang::find_all_symbols::SymbolInfo SymbolInfo