23#include "llvm/ADT/ArrayRef.h"
24#include "llvm/ADT/IntrusiveRefCntPtr.h"
25#include "llvm/ADT/SmallString.h"
26#include "llvm/ADT/SmallVector.h"
27#include "llvm/ADT/StringRef.h"
28#include "llvm/Support/Casting.h"
29#include "llvm/Support/ErrorHandling.h"
30#include "llvm/Support/ManagedStatic.h"
31#include "llvm/Support/Regex.h"
32#include "llvm/Support/WithColor.h"
33#include "llvm/Support/raw_ostream.h"
43namespace ast_matchers {
47 return llvm::is_contained(Matches,
Node.getSelector().getAsString());
53 ASTMatchFinder *Finder,
54 BoundNodesTreeBuilder *Builder,
58 ASTMatchFinder *Finder,
59 BoundNodesTreeBuilder *Builder,
63 ASTMatchFinder *Finder,
64 BoundNodesTreeBuilder *Builder,
68 ASTMatchFinder *Finder,
69 BoundNodesTreeBuilder *Builder,
73 ASTMatchFinder *Finder,
74 BoundNodesTreeBuilder *Builder,
78 const Matcher<CXXBaseSpecifier> &BaseSpecMatcher,
79 ASTMatchFinder *Finder, BoundNodesTreeBuilder *Builder) {
80 if (!
Node.hasDefinition())
84 Paths.setOrigin(&
Node);
86 const auto basePredicate =
89 BoundNodesTreeBuilder
Result(*Builder);
90 if (BaseSpecMatcher.matches(*BaseSpec, Finder, Builder)) {
91 *Builder = std::move(
Result);
97 return Node.lookupInBases(basePredicate, Paths,
101void BoundNodesTreeBuilder::visitMatches(Visitor *ResultVisitor) {
103 Bindings.push_back(BoundNodesMap());
104 for (BoundNodesMap &Binding :
Bindings) {
105 ResultVisitor->visitMatch(
BoundNodes(Binding));
111using VariadicOperatorFunction =
bool (*)(
112 const DynTypedNode &DynNode, ASTMatchFinder *Finder,
113 BoundNodesTreeBuilder *Builder, ArrayRef<DynTypedMatcher> InnerMatchers);
115template <VariadicOperatorFunction Func>
116class VariadicMatcher :
public DynMatcherInterface {
118 VariadicMatcher(std::vector<DynTypedMatcher> InnerMatchers)
119 : InnerMatchers(
std::move(InnerMatchers)) {}
121 bool dynMatches(
const DynTypedNode &DynNode, ASTMatchFinder *Finder,
122 BoundNodesTreeBuilder *Builder)
const override {
123 return Func(DynNode, Finder, Builder, InnerMatchers);
127 std::vector<DynTypedMatcher> InnerMatchers;
130class IdDynMatcher :
public DynMatcherInterface {
132 IdDynMatcher(StringRef ID,
133 IntrusiveRefCntPtr<DynMatcherInterface> InnerMatcher)
134 :
ID(
ID), InnerMatcher(
std::move(InnerMatcher)) {}
136 bool dynMatches(
const DynTypedNode &DynNode, ASTMatchFinder *Finder,
137 BoundNodesTreeBuilder *Builder)
const override {
138 bool Result = InnerMatcher->dynMatches(DynNode, Finder, Builder);
139 if (
Result) Builder->setBinding(ID, DynNode);
143 std::optional<clang::TraversalKind>
TraversalKind()
const override {
144 return InnerMatcher->TraversalKind();
148 const std::string
ID;
149 const IntrusiveRefCntPtr<DynMatcherInterface> InnerMatcher;
153class TrueMatcherImpl :
public DynMatcherInterface {
155 TrueMatcherImpl() =
default;
157 bool dynMatches(
const DynTypedNode &, ASTMatchFinder *,
158 BoundNodesTreeBuilder *)
const override {
167class DynTraversalMatcherImpl :
public DynMatcherInterface {
169 explicit DynTraversalMatcherImpl(
171 IntrusiveRefCntPtr<DynMatcherInterface> InnerMatcher)
172 : TK(TK), InnerMatcher(
std::move(InnerMatcher)) {}
174 bool dynMatches(
const DynTypedNode &DynNode, ASTMatchFinder *Finder,
175 BoundNodesTreeBuilder *Builder)
const override {
176 return this->InnerMatcher->dynMatches(DynNode, Finder, Builder);
179 std::optional<clang::TraversalKind>
TraversalKind()
const override {
185 IntrusiveRefCntPtr<DynMatcherInterface> InnerMatcher;
190bool ASTMatchFinder::isTraversalIgnoringImplicitNodes()
const {
191 return getASTContext().getParentMapContext().getTraversalKind() ==
196DynTypedMatcher::constructVariadic(DynTypedMatcher::VariadicOperator Op,
197 ASTNodeKind SupportedKind,
198 std::vector<DynTypedMatcher> InnerMatchers) {
199 assert(!InnerMatchers.empty() &&
"Array must not be empty.");
200 assert(llvm::all_of(InnerMatchers,
201 [SupportedKind](
const DynTypedMatcher &M) {
202 return M.canConvertTo(SupportedKind);
204 "InnerMatchers must be convertible to SupportedKind!");
210 auto RestrictKind = SupportedKind;
218 for (
auto &IM : InnerMatchers) {
222 return DynTypedMatcher(
223 SupportedKind, RestrictKind,
224 new VariadicMatcher<allOfVariadicOperator>(std::move(InnerMatchers)));
227 return DynTypedMatcher(
228 SupportedKind, RestrictKind,
229 new VariadicMatcher<anyOfVariadicOperator>(std::move(InnerMatchers)));
232 return DynTypedMatcher(
233 SupportedKind, RestrictKind,
234 new VariadicMatcher<eachOfVariadicOperator>(std::move(InnerMatchers)));
237 return DynTypedMatcher(SupportedKind, RestrictKind,
238 new VariadicMatcher<optionallyVariadicOperator>(
239 std::move(InnerMatchers)));
244 return DynTypedMatcher(
245 SupportedKind, RestrictKind,
246 new VariadicMatcher<notUnaryOperator>(std::move(InnerMatchers)));
248 llvm_unreachable(
"Invalid Op value.");
252DynTypedMatcher::constructRestrictedWrapper(
const DynTypedMatcher &InnerMatcher,
253 ASTNodeKind RestrictKind) {
254 DynTypedMatcher Copy = InnerMatcher;
255 Copy.RestrictKind = RestrictKind;
259DynTypedMatcher DynTypedMatcher::withTraversalKind(
TraversalKind TK) {
261 Copy.Implementation =
262 new DynTraversalMatcherImpl(TK, std::move(Copy.Implementation));
266DynTypedMatcher DynTypedMatcher::trueMatcher(ASTNodeKind NodeKind) {
271 new TrueMatcherImpl();
272 return DynTypedMatcher(NodeKind, NodeKind, Instance);
275bool DynTypedMatcher::canMatchNodesOfKind(ASTNodeKind Kind)
const {
276 return RestrictKind.isBaseOf(Kind);
279DynTypedMatcher DynTypedMatcher::dynCastTo(
const ASTNodeKind Kind)
const {
281 Copy.SupportedKind =
Kind;
286bool DynTypedMatcher::matches(
const DynTypedNode &DynNode,
287 ASTMatchFinder *Finder,
288 BoundNodesTreeBuilder *Builder)
const {
289 TraversalKindScope RAII(Finder->getASTContext(),
290 Implementation->TraversalKind());
292 if (Finder->isTraversalIgnoringImplicitNodes() &&
293 Finder->IsMatchingInASTNodeNotSpelledInSource())
296 if (!Finder->isTraversalIgnoringImplicitNodes() &&
297 Finder->IsMatchingInASTNodeNotAsIs())
301 Finder->getASTContext().getParentMapContext().traverseIgnored(DynNode);
303 if (RestrictKind.isBaseOf(N.getNodeKind()) &&
304 Implementation->dynMatches(N, Finder, Builder)) {
310 Builder->removeBindings([](
const BoundNodesMap &) {
return true; });
314bool DynTypedMatcher::matchesNoKindCheck(
const DynTypedNode &DynNode,
315 ASTMatchFinder *Finder,
316 BoundNodesTreeBuilder *Builder)
const {
317 TraversalKindScope raii(Finder->getASTContext(),
318 Implementation->TraversalKind());
320 if (Finder->isTraversalIgnoringImplicitNodes() &&
321 Finder->IsMatchingInASTNodeNotSpelledInSource())
324 if (!Finder->isTraversalIgnoringImplicitNodes() &&
325 Finder->IsMatchingInASTNodeNotAsIs())
329 Finder->getASTContext().getParentMapContext().traverseIgnored(DynNode);
331 assert(RestrictKind.isBaseOf(N.getNodeKind()));
332 if (Implementation->dynMatches(N, Finder, Builder)) {
338 Builder->removeBindings([](
const BoundNodesMap &) {
return true; });
342std::optional<DynTypedMatcher> DynTypedMatcher::tryBind(StringRef ID)
const {
347 new IdDynMatcher(ID, std::move(
Result.Implementation));
351bool DynTypedMatcher::canConvertTo(ASTNodeKind To)
const {
352 const auto From = getSupportedKind();
353 auto QualKind = ASTNodeKind::getFromNodeKind<QualType>();
354 auto TypeKind = ASTNodeKind::getFromNodeKind<Type>();
357 if (From.isSame(TypeKind) && To.isSame(QualKind))
return true;
359 return From.isBaseOf(To);
362void BoundNodesTreeBuilder::addMatch(
const BoundNodesTreeBuilder &Other) {
367 ASTMatchFinder *Finder,
368 BoundNodesTreeBuilder *Builder,
370 if (InnerMatchers.size() != 1)
383 BoundNodesTreeBuilder Discard(*Builder);
384 return !InnerMatchers[0].matches(DynNode, Finder, &Discard);
388 ASTMatchFinder *Finder,
389 BoundNodesTreeBuilder *Builder,
394 return llvm::all_of(InnerMatchers, [&](
const DynTypedMatcher &InnerMatcher) {
395 return InnerMatcher.matchesNoKindCheck(DynNode, Finder, Builder);
400 ASTMatchFinder *Finder,
401 BoundNodesTreeBuilder *Builder,
403 BoundNodesTreeBuilder
Result;
404 bool Matched =
false;
405 for (
const DynTypedMatcher &InnerMatcher : InnerMatchers) {
406 BoundNodesTreeBuilder BuilderInner(*Builder);
407 if (InnerMatcher.matches(DynNode, Finder, &BuilderInner)) {
409 Result.addMatch(BuilderInner);
412 *Builder = std::move(
Result);
417 ASTMatchFinder *Finder,
418 BoundNodesTreeBuilder *Builder,
420 for (
const DynTypedMatcher &InnerMatcher : InnerMatchers) {
421 BoundNodesTreeBuilder
Result = *Builder;
422 if (InnerMatcher.matches(DynNode, Finder, &
Result)) {
423 *Builder = std::move(
Result);
432 BoundNodesTreeBuilder *Builder,
434 if (InnerMatchers.size() != 1)
437 BoundNodesTreeBuilder
Result(*Builder);
438 if (InnerMatchers[0].matches(DynNode, Finder, &
Result))
439 *Builder = std::move(
Result);
445 std::vector<std::string> Names;
446 Names.reserve(NameRefs.size());
447 for (
auto *Name : NameRefs)
448 Names.emplace_back(*Name);
453 return internal::Matcher<NamedDecl>(
466HasOverloadOpNameMatcher
471HasNameMatcher::HasNameMatcher(std::vector<std::string> N)
472 : UseUnqualifiedMatch(
473 llvm::all_of(N, [](StringRef Name) {
return !Name.contains(
"::"); })),
474 Names(std::move(N)) {
476 for (StringRef Name : Names)
477 assert(!Name.empty());
482 StringRef Name = FullName;
483 if (!Name.endswith(Suffix))
485 Name = Name.drop_back(Suffix.size());
487 if (!Name.endswith(
"::"))
489 Name = Name.drop_back(2);
498 if (
Node.getIdentifier())
499 return Node.getName();
501 if (
Node.getDeclName()) {
504 llvm::raw_svector_ostream OS(Scratch);
509 return "(anonymous)";
514 if (
Node.getIdentifier()) {
515 return Node.getName();
518 return (
"(anonymous " +
Node.getKindName() +
")").toStringRef(Scratch);
523 return Node.isAnonymousNamespace() ?
"(anonymous namespace)" :
Node.getName();
531 Patterns.reserve(Names.size());
532 for (StringRef Name : Names)
533 Patterns.push_back({Name, Name.startswith(
"::")});
539 bool consumeNameSuffix(StringRef NodeName,
bool CanSkip) {
540 for (
size_t I = 0; I < Patterns.size();) {
546 Patterns.erase(Patterns.begin() + I);
549 return !Patterns.empty();
555 bool foundMatch(
bool AllowFullyQualified)
const {
556 return llvm::any_of(Patterns, [&](
const Pattern &Pattern) {
557 return Pattern.P.empty() &&
558 (AllowFullyQualified || !Pattern.IsFullyQualified);
573bool HasNameMatcher::matchesNodeUnqualified(
const NamedDecl &
Node)
const {
574 assert(UseUnqualifiedMatch);
577 return llvm::any_of(Names, [&](StringRef Name) {
582bool HasNameMatcher::matchesNodeFullFast(
const NamedDecl &
Node)
const {
583 PatternSet Patterns(Names);
600 const DeclContext *Ctx =
Node.getDeclContext();
602 if (Ctx->isFunctionOrMethod())
603 return Patterns.foundMatch(
false);
605 for (; Ctx; Ctx = Ctx->getParent()) {
608 if (isa<LinkageSpecDecl>(Ctx))
610 if (!isa<NamedDecl>(Ctx))
612 if (Patterns.foundMatch(
false))
615 if (
const auto *ND = dyn_cast<NamespaceDecl>(Ctx)) {
617 if (Patterns.consumeNameSuffix(
getNodeName(*ND, Scratch),
618 ND->isAnonymousNamespace() ||
623 if (
const auto *RD = dyn_cast<RecordDecl>(Ctx)) {
624 if (!isa<ClassTemplateSpecializationDecl>(Ctx)) {
625 if (Patterns.consumeNameSuffix(
getNodeName(*RD, Scratch),
635 return matchesNodeFullSlow(
Node);
638 return Patterns.foundMatch(
true);
641bool HasNameMatcher::matchesNodeFullSlow(
const NamedDecl &
Node)
const {
642 const bool SkipUnwrittenCases[] = {
false,
true};
643 for (
bool SkipUnwritten : SkipUnwrittenCases) {
645 llvm::raw_svector_ostream OS(NodeName);
647 PrintingPolicy Policy =
Node.getASTContext().getPrintingPolicy();
648 Policy.SuppressUnwrittenScope = SkipUnwritten;
649 Policy.SuppressInlineNamespace = SkipUnwritten;
650 Node.printQualifiedName(OS, Policy);
652 const StringRef FullName = OS.str();
654 for (
const StringRef Pattern : Names) {
655 if (Pattern.startswith(
"::")) {
656 if (FullName == Pattern)
658 }
else if (FullName.endswith(Pattern) &&
659 FullName.drop_back(Pattern.size()).endswith(
"::")) {
668bool HasNameMatcher::matchesNode(
const NamedDecl &
Node)
const {
669 assert(matchesNodeFullFast(
Node) == matchesNodeFullSlow(
Node));
670 if (UseUnqualifiedMatch) {
671 assert(matchesNodeUnqualified(
Node) == matchesNodeFullFast(
Node));
672 return matchesNodeUnqualified(
Node);
674 return matchesNodeFullFast(
Node);
689std::optional<SourceLocation>
692 auto &
SM = Context.getSourceManager();
693 const LangOptions &LangOpts = Context.getLangOpts();
696 SM.getSLocEntry(
SM.getFileID(Loc)).getExpansion();
711 llvm::Regex::RegexFlags Flags,
713 assert(!Regex.empty() &&
"Empty regex string");
714 auto SharedRegex = std::make_shared<llvm::Regex>(Regex, Flags);
716 if (!SharedRegex->isValid(
Error)) {
717 llvm::WithColor::error()
719 llvm::WithColor::note() <<
" input was '" << Regex <<
"'\n";
725const internal::VariadicDynCastAllOfMatcher<Stmt, ObjCAutoreleasePoolStmt>
727const internal::VariadicDynCastAllOfMatcher<Decl, TranslationUnitDecl>
729const internal::VariadicDynCastAllOfMatcher<Decl, TypedefDecl>
typedefDecl;
730const internal::VariadicDynCastAllOfMatcher<Decl, TypedefNameDecl>
732const internal::VariadicDynCastAllOfMatcher<Decl, TypeAliasDecl>
typeAliasDecl;
733const internal::VariadicDynCastAllOfMatcher<Decl, TypeAliasTemplateDecl>
735const internal::VariadicAllOfMatcher<Decl>
decl;
737const internal::VariadicDynCastAllOfMatcher<Decl, BindingDecl>
bindingDecl;
738const internal::VariadicDynCastAllOfMatcher<Decl, LinkageSpecDecl>
740const internal::VariadicDynCastAllOfMatcher<Decl, NamedDecl>
namedDecl;
741const internal::VariadicDynCastAllOfMatcher<Decl, LabelDecl>
labelDecl;
742const internal::VariadicDynCastAllOfMatcher<Decl, NamespaceDecl>
namespaceDecl;
743const internal::VariadicDynCastAllOfMatcher<Decl, NamespaceAliasDecl>
745const internal::VariadicDynCastAllOfMatcher<Decl, RecordDecl>
recordDecl;
746const internal::VariadicDynCastAllOfMatcher<Decl, CXXRecordDecl>
cxxRecordDecl;
747const internal::VariadicDynCastAllOfMatcher<Decl, ClassTemplateDecl>
749const internal::VariadicDynCastAllOfMatcher<
Decl,
752const internal::VariadicDynCastAllOfMatcher<
755const internal::VariadicDynCastAllOfMatcher<Decl, DeclaratorDecl>
757const internal::VariadicDynCastAllOfMatcher<Decl, ParmVarDecl>
parmVarDecl;
758const internal::VariadicDynCastAllOfMatcher<Decl, AccessSpecDecl>
765const internal::VariadicDynCastAllOfMatcher<Decl, NonTypeTemplateParmDecl>
767const internal::VariadicDynCastAllOfMatcher<Decl, TemplateTypeParmDecl>
769const internal::VariadicDynCastAllOfMatcher<Decl, TemplateTemplateParmDecl>
773const internal::VariadicAllOfMatcher<QualType>
qualType;
774const internal::VariadicAllOfMatcher<Type>
type;
775const internal::VariadicAllOfMatcher<TypeLoc>
typeLoc;
777const internal::VariadicDynCastAllOfMatcher<TypeLoc, QualifiedTypeLoc>
779const internal::VariadicDynCastAllOfMatcher<TypeLoc, PointerTypeLoc>
781const internal::VariadicDynCastAllOfMatcher<TypeLoc, ReferenceTypeLoc>
783const internal::VariadicDynCastAllOfMatcher<
TypeLoc,
786const internal::VariadicDynCastAllOfMatcher<TypeLoc, ElaboratedTypeLoc>
789const internal::VariadicDynCastAllOfMatcher<Stmt, UnaryExprOrTypeTraitExpr>
791const internal::VariadicDynCastAllOfMatcher<Decl, ValueDecl>
valueDecl;
792const internal::VariadicDynCastAllOfMatcher<Decl, CXXConstructorDecl>
794const internal::VariadicDynCastAllOfMatcher<Decl, CXXDestructorDecl>
796const internal::VariadicDynCastAllOfMatcher<Decl, EnumDecl>
enumDecl;
797const internal::VariadicDynCastAllOfMatcher<Decl, EnumConstantDecl>
799const internal::VariadicDynCastAllOfMatcher<Decl, TagDecl>
tagDecl;
800const internal::VariadicDynCastAllOfMatcher<Decl, CXXMethodDecl>
cxxMethodDecl;
801const internal::VariadicDynCastAllOfMatcher<Decl, CXXConversionDecl>
803const internal::VariadicDynCastAllOfMatcher<Decl, VarDecl>
varDecl;
804const internal::VariadicDynCastAllOfMatcher<Decl, FieldDecl>
fieldDecl;
805const internal::VariadicDynCastAllOfMatcher<Decl, IndirectFieldDecl>
807const internal::VariadicDynCastAllOfMatcher<Decl, FunctionDecl>
functionDecl;
808const internal::VariadicDynCastAllOfMatcher<Decl, FunctionTemplateDecl>
810const internal::VariadicDynCastAllOfMatcher<Decl, FriendDecl>
friendDecl;
811const internal::VariadicAllOfMatcher<Stmt>
stmt;
812const internal::VariadicDynCastAllOfMatcher<Stmt, DeclStmt>
declStmt;
813const internal::VariadicDynCastAllOfMatcher<Stmt, MemberExpr>
memberExpr;
814const internal::VariadicDynCastAllOfMatcher<Stmt, UnresolvedMemberExpr>
816const internal::VariadicDynCastAllOfMatcher<Stmt, CXXDependentScopeMemberExpr>
818const internal::VariadicDynCastAllOfMatcher<Stmt, CallExpr>
callExpr;
819const internal::VariadicDynCastAllOfMatcher<Stmt, LambdaExpr>
lambdaExpr;
820const internal::VariadicDynCastAllOfMatcher<Stmt, CXXMemberCallExpr>
822const internal::VariadicDynCastAllOfMatcher<Stmt, ObjCMessageExpr>
824const internal::VariadicDynCastAllOfMatcher<Decl, ObjCInterfaceDecl>
826const internal::VariadicDynCastAllOfMatcher<Decl, ObjCImplementationDecl>
828const internal::VariadicDynCastAllOfMatcher<Decl, ObjCProtocolDecl>
830const internal::VariadicDynCastAllOfMatcher<Decl, ObjCCategoryDecl>
832const internal::VariadicDynCastAllOfMatcher<Decl, ObjCCategoryImplDecl>
834const internal::VariadicDynCastAllOfMatcher<Decl, ObjCMethodDecl>
836const internal::VariadicDynCastAllOfMatcher<Decl, BlockDecl>
838const internal::VariadicDynCastAllOfMatcher<Decl, ObjCIvarDecl>
objcIvarDecl;
839const internal::VariadicDynCastAllOfMatcher<Decl, ObjCPropertyDecl>
841const internal::VariadicDynCastAllOfMatcher<Stmt, ObjCAtThrowStmt>
843const internal::VariadicDynCastAllOfMatcher<Stmt, ObjCAtTryStmt>
objcTryStmt;
844const internal::VariadicDynCastAllOfMatcher<Stmt, ObjCAtCatchStmt>
846const internal::VariadicDynCastAllOfMatcher<Stmt, ObjCAtFinallyStmt>
848const internal::VariadicDynCastAllOfMatcher<Stmt, ExprWithCleanups>
850const internal::VariadicDynCastAllOfMatcher<Stmt, InitListExpr>
initListExpr;
851const internal::VariadicDynCastAllOfMatcher<Stmt, CXXStdInitializerListExpr>
853const internal::VariadicDynCastAllOfMatcher<Stmt, ImplicitValueInitExpr>
855const internal::VariadicDynCastAllOfMatcher<Stmt, ParenListExpr>
parenListExpr;
856const internal::VariadicDynCastAllOfMatcher<Stmt, SubstNonTypeTemplateParmExpr>
858const internal::VariadicDynCastAllOfMatcher<Decl, UsingDecl>
usingDecl;
859const internal::VariadicDynCastAllOfMatcher<Decl, UsingEnumDecl>
usingEnumDecl;
860const internal::VariadicDynCastAllOfMatcher<Decl, UsingDirectiveDecl>
862const internal::VariadicDynCastAllOfMatcher<Stmt, UnresolvedLookupExpr>
864const internal::VariadicDynCastAllOfMatcher<Decl, UnresolvedUsingValueDecl>
866const internal::VariadicDynCastAllOfMatcher<Decl, UnresolvedUsingTypenameDecl>
868const internal::VariadicDynCastAllOfMatcher<Stmt, ConstantExpr>
constantExpr;
869const internal::VariadicDynCastAllOfMatcher<Stmt, ParenExpr>
parenExpr;
870const internal::VariadicDynCastAllOfMatcher<Stmt, CXXConstructExpr>
872const internal::VariadicDynCastAllOfMatcher<Stmt, CXXUnresolvedConstructExpr>
874const internal::VariadicDynCastAllOfMatcher<Stmt, CXXThisExpr>
cxxThisExpr;
875const internal::VariadicDynCastAllOfMatcher<Stmt, CXXBindTemporaryExpr>
877const internal::VariadicDynCastAllOfMatcher<Stmt, MaterializeTemporaryExpr>
879const internal::VariadicDynCastAllOfMatcher<Stmt, CXXNewExpr>
cxxNewExpr;
880const internal::VariadicDynCastAllOfMatcher<Stmt, CXXDeleteExpr>
cxxDeleteExpr;
881const internal::VariadicDynCastAllOfMatcher<Stmt, CXXNoexceptExpr>
883const internal::VariadicDynCastAllOfMatcher<Stmt, ArraySubscriptExpr>
885const internal::VariadicDynCastAllOfMatcher<Stmt, CXXDefaultArgExpr>
887const internal::VariadicDynCastAllOfMatcher<Stmt, CXXOperatorCallExpr>
889const internal::VariadicDynCastAllOfMatcher<Stmt, CXXRewrittenBinaryOperator>
891const internal::VariadicDynCastAllOfMatcher<Stmt, Expr>
expr;
892const internal::VariadicDynCastAllOfMatcher<Stmt, DeclRefExpr>
declRefExpr;
894const internal::VariadicDynCastAllOfMatcher<Stmt, BlockExpr>
blockExpr;
895const internal::VariadicDynCastAllOfMatcher<Stmt, IfStmt>
ifStmt;
896const internal::VariadicDynCastAllOfMatcher<Stmt, ForStmt>
forStmt;
897const internal::VariadicDynCastAllOfMatcher<Stmt, CXXForRangeStmt>
899const internal::VariadicDynCastAllOfMatcher<Stmt, WhileStmt>
whileStmt;
900const internal::VariadicDynCastAllOfMatcher<Stmt, DoStmt>
doStmt;
901const internal::VariadicDynCastAllOfMatcher<Stmt, BreakStmt>
breakStmt;
902const internal::VariadicDynCastAllOfMatcher<Stmt, ContinueStmt>
continueStmt;
903const internal::VariadicDynCastAllOfMatcher<Stmt, CoreturnStmt>
coreturnStmt;
904const internal::VariadicDynCastAllOfMatcher<Stmt, ReturnStmt>
returnStmt;
905const internal::VariadicDynCastAllOfMatcher<Stmt, GotoStmt>
gotoStmt;
906const internal::VariadicDynCastAllOfMatcher<Stmt, LabelStmt>
labelStmt;
907const internal::VariadicDynCastAllOfMatcher<Stmt, AddrLabelExpr>
addrLabelExpr;
908const internal::VariadicDynCastAllOfMatcher<Stmt, SwitchStmt>
switchStmt;
909const internal::VariadicDynCastAllOfMatcher<Stmt, SwitchCase>
switchCase;
910const internal::VariadicDynCastAllOfMatcher<Stmt, CaseStmt>
caseStmt;
911const internal::VariadicDynCastAllOfMatcher<Stmt, DefaultStmt>
defaultStmt;
912const internal::VariadicDynCastAllOfMatcher<Stmt, CompoundStmt>
compoundStmt;
913const internal::VariadicDynCastAllOfMatcher<Stmt, CoroutineBodyStmt>
915const internal::VariadicDynCastAllOfMatcher<Stmt, CXXCatchStmt>
cxxCatchStmt;
916const internal::VariadicDynCastAllOfMatcher<Stmt, CXXTryStmt>
cxxTryStmt;
917const internal::VariadicDynCastAllOfMatcher<Stmt, CXXThrowExpr>
cxxThrowExpr;
918const internal::VariadicDynCastAllOfMatcher<Stmt, NullStmt>
nullStmt;
919const internal::VariadicDynCastAllOfMatcher<Stmt, AsmStmt>
asmStmt;
920const internal::VariadicDynCastAllOfMatcher<Stmt, CXXBoolLiteralExpr>
922const internal::VariadicDynCastAllOfMatcher<Stmt, StringLiteral>
stringLiteral;
924const internal::VariadicDynCastAllOfMatcher<Stmt, CharacterLiteral>
926const internal::VariadicDynCastAllOfMatcher<Stmt, IntegerLiteral>
928const internal::VariadicDynCastAllOfMatcher<Stmt, FloatingLiteral>
floatLiteral;
930const internal::VariadicDynCastAllOfMatcher<Stmt, FixedPointLiteral>
932const internal::VariadicDynCastAllOfMatcher<Stmt, UserDefinedLiteral>
934const internal::VariadicDynCastAllOfMatcher<Stmt, CompoundLiteralExpr>
936const internal::VariadicDynCastAllOfMatcher<Stmt, CXXNullPtrLiteralExpr>
938const internal::VariadicDynCastAllOfMatcher<Stmt, ChooseExpr>
chooseExpr;
939const internal::VariadicDynCastAllOfMatcher<Stmt, CoawaitExpr>
941const internal::VariadicDynCastAllOfMatcher<Stmt, DependentCoawaitExpr>
943const internal::VariadicDynCastAllOfMatcher<Stmt, CoyieldExpr>
945const internal::VariadicDynCastAllOfMatcher<Stmt, GNUNullExpr>
gnuNullExpr;
946const internal::VariadicDynCastAllOfMatcher<Stmt, GenericSelectionExpr>
948const internal::VariadicDynCastAllOfMatcher<Stmt, AtomicExpr>
atomicExpr;
949const internal::VariadicDynCastAllOfMatcher<Stmt, StmtExpr>
stmtExpr;
950const internal::VariadicDynCastAllOfMatcher<Stmt, BinaryOperator>
955const internal::MapAnyOfMatcher<CallExpr, CXXConstructExpr>
invocation;
956const internal::VariadicDynCastAllOfMatcher<Stmt, UnaryOperator>
unaryOperator;
957const internal::VariadicDynCastAllOfMatcher<Stmt, ConditionalOperator>
959const internal::VariadicDynCastAllOfMatcher<Stmt, BinaryConditionalOperator>
961const internal::VariadicDynCastAllOfMatcher<Stmt, OpaqueValueExpr>
963const internal::VariadicDynCastAllOfMatcher<Decl, StaticAssertDecl>
965const internal::VariadicDynCastAllOfMatcher<Stmt, CXXReinterpretCastExpr>
967const internal::VariadicDynCastAllOfMatcher<Stmt, CXXStaticCastExpr>
969const internal::VariadicDynCastAllOfMatcher<Stmt, CXXDynamicCastExpr>
971const internal::VariadicDynCastAllOfMatcher<Stmt, CXXConstCastExpr>
973const internal::VariadicDynCastAllOfMatcher<Stmt, CStyleCastExpr>
975const internal::VariadicDynCastAllOfMatcher<Stmt, ExplicitCastExpr>
977const internal::VariadicDynCastAllOfMatcher<Stmt, ImplicitCastExpr>
979const internal::VariadicDynCastAllOfMatcher<Stmt, CastExpr>
castExpr;
980const internal::VariadicDynCastAllOfMatcher<Stmt, CXXFunctionalCastExpr>
982const internal::VariadicDynCastAllOfMatcher<Stmt, CXXTemporaryObjectExpr>
984const internal::VariadicDynCastAllOfMatcher<Stmt, PredefinedExpr>
986const internal::VariadicDynCastAllOfMatcher<Stmt, DesignatedInitExpr>
988const internal::VariadicOperatorMatcherFunc<
989 2, std::numeric_limits<unsigned>::max()>
990 eachOf = {internal::DynTypedMatcher::VO_EachOf};
991const internal::VariadicOperatorMatcherFunc<
992 2, std::numeric_limits<unsigned>::max()>
993 anyOf = {internal::DynTypedMatcher::VO_AnyOf};
994const internal::VariadicOperatorMatcherFunc<
995 2, std::numeric_limits<unsigned>::max()>
996 allOf = {internal::DynTypedMatcher::VO_AllOf};
997const internal::VariadicOperatorMatcherFunc<1, 1>
optionally = {
998 internal::DynTypedMatcher::VO_Optionally};
999const internal::VariadicFunction<internal::Matcher<NamedDecl>, StringRef,
1000 internal::hasAnyNameFunc>
1003const internal::VariadicFunction<internal::HasOpNameMatcher, StringRef,
1004 internal::hasAnyOperatorNameFunc>
1006const internal::VariadicFunction<internal::HasOverloadOpNameMatcher, StringRef,
1007 internal::hasAnyOverloadedOperatorNameFunc>
1009const internal::VariadicFunction<internal::Matcher<ObjCMessageExpr>, StringRef,
1010 internal::hasAnySelectorFunc>
1012const internal::ArgumentAdaptingMatcherFunc<internal::HasMatcher>
has = {};
1013const internal::ArgumentAdaptingMatcherFunc<internal::HasDescendantMatcher>
1015const internal::ArgumentAdaptingMatcherFunc<internal::ForEachMatcher>
forEach =
1017const internal::ArgumentAdaptingMatcherFunc<internal::ForEachDescendantMatcher>
1019const internal::ArgumentAdaptingMatcherFunc<
1020 internal::HasParentMatcher,
1021 internal::TypeList<Decl, NestedNameSpecifierLoc, Stmt, TypeLoc, Attr>,
1022 internal::TypeList<Decl, NestedNameSpecifierLoc, Stmt, TypeLoc, Attr>>
1024const internal::ArgumentAdaptingMatcherFunc<
1025 internal::HasAncestorMatcher,
1026 internal::TypeList<Decl, NestedNameSpecifierLoc, Stmt, TypeLoc, Attr>,
1027 internal::TypeList<Decl, NestedNameSpecifierLoc, Stmt, TypeLoc, Attr>>
1029const internal::VariadicOperatorMatcherFunc<1, 1>
unless = {
1030 internal::DynTypedMatcher::VO_UnaryNot};
1032const internal::VariadicAllOfMatcher<NestedNameSpecifierLoc>
1034const internal::VariadicAllOfMatcher<Attr>
attr;
1035const internal::VariadicDynCastAllOfMatcher<Stmt, CUDAKernelCallExpr>
1081const internal::VariadicDynCastAllOfMatcher<Stmt, OMPExecutableDirective>
1083const internal::VariadicDynCastAllOfMatcher<OMPClause, OMPDefaultClause>
1085const internal::VariadicDynCastAllOfMatcher<Decl, CXXDeductionGuideDecl>
Defines the clang::ASTContext interface.
DynTypedMatcher::MatcherIDType MatcherID
#define AST_POLYMORPHIC_SUPPORTED_TYPES(...)
Construct a type-list to be passed to the AST_POLYMORPHIC_MATCHER* macros.
#define AST_TYPELOC_TRAVERSE_MATCHER_DEF(MatcherName, ReturnTypesF)
#define AST_MATCHER_P(Type, DefineMatcher, ParamType, Param)
AST_MATCHER_P(Type, DefineMatcher, ParamType, Param) { ... } defines a single-parameter function name...
Defines the C++ template declaration subclasses.
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
static ASTNodeKind getMostDerivedType(ASTNodeKind Kind1, ASTNodeKind Kind2)
Return the most derived type between Kind1 and Kind2.
Represents an array type, per C99 6.7.5.2 - Array Declarators.
A builtin binary operation expression such as "x + y" or "x <= y".
Represents a path from a specific derived class (which is not represented as part of the path) to a p...
BasePaths - Represents the set of paths from a derived class to one of its (direct or indirect) bases...
Represents a base class of a C++ class.
A call to an overloaded operator written using operator syntax.
Represents a C++ struct/union/class.
A rewritten comparison expression that was originally written using operator syntax.
Represents a class template specialization, which refers to a class template with a given set of temp...
Complex values, per C99 6.2.5p11.
Decl - This represents one declaration (or definition), e.g.
A dynamically typed AST node container.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
static unsigned getSpelling(const Token &Tok, const char *&Buffer, const SourceManager &SourceMgr, const LangOptions &LangOpts, bool *Invalid=nullptr)
getSpelling - This method is used to get the spelling of a token into a preallocated buffer,...
A pointer to member type per C++ 8.3.3 - Pointers to members.
This represents a decl that may have a name.
Represent a C++ namespace.
An expression that sends a message to the given Objective-C object or class.
PointerType - C99 6.7.5.1 - Pointer Declarators.
Represents a struct/union/class.
Base for LValueReferenceType and RValueReferenceType.
Encodes a location in the source.
This class handles loading and caching of source files into memory.
Each ExpansionInfo encodes the expansion location - where the token was ultimately expanded,...
SourceLocation getExpansionLocStart() const
SourceLocation getSpellingLoc() const
bool isMacroArgExpansion() const
Base wrapper for a particular "section" of type source info.
Maps string IDs to AST nodes matched by parts of a matcher.
HasOverloadOpNameMatcher hasAnyOverloadedOperatorNameFunc(ArrayRef< const StringRef * > NameRefs)
static std::vector< std::string > vectorFromRefs(ArrayRef< const StringRef * > NameRefs)
std::shared_ptr< llvm::Regex > createAndVerifyRegex(StringRef Regex, llvm::Regex::RegexFlags Flags, StringRef MatcherID)
Matcher< ObjCMessageExpr > hasAnySelectorFunc(ArrayRef< const StringRef * > NameRefs)
static bool eachOfVariadicOperator(const DynTypedNode &DynNode, ASTMatchFinder *Finder, BoundNodesTreeBuilder *Builder, ArrayRef< DynTypedMatcher > InnerMatchers)
static bool isTokenAtLoc(const SourceManager &SM, const LangOptions &LangOpts, StringRef Text, SourceLocation Loc)
static StringRef getNodeName(const NamedDecl &Node, llvm::SmallString< 128 > &Scratch)
static bool anyOfVariadicOperator(const DynTypedNode &DynNode, ASTMatchFinder *Finder, BoundNodesTreeBuilder *Builder, ArrayRef< DynTypedMatcher > InnerMatchers)
static bool optionallyVariadicOperator(const DynTypedNode &DynNode, ASTMatchFinder *Finder, BoundNodesTreeBuilder *Builder, ArrayRef< DynTypedMatcher > InnerMatchers)
Matcher< NamedDecl > hasAnyNameFunc(ArrayRef< const StringRef * > NameRefs)
HasOpNameMatcher hasAnyOperatorNameFunc(ArrayRef< const StringRef * > NameRefs)
static bool notUnaryOperator(const DynTypedNode &DynNode, ASTMatchFinder *Finder, BoundNodesTreeBuilder *Builder, ArrayRef< DynTypedMatcher > InnerMatchers)
std::optional< SourceLocation > getExpansionLocOfMacro(StringRef MacroName, SourceLocation Loc, const ASTContext &Context)
static bool consumeNameSuffix(StringRef &FullName, StringRef Suffix)
bool matchesAnyBase(const CXXRecordDecl &Node, const Matcher< CXXBaseSpecifier > &BaseSpecMatcher, ASTMatchFinder *Finder, BoundNodesTreeBuilder *Builder)
static bool allOfVariadicOperator(const DynTypedNode &DynNode, ASTMatchFinder *Finder, BoundNodesTreeBuilder *Builder, ArrayRef< DynTypedMatcher > InnerMatchers)
const internal::VariadicDynCastAllOfMatcher< Stmt, FixedPointLiteral > fixedPointLiteral
Matches fixed point literals.
const internal::VariadicDynCastAllOfMatcher< Stmt, CStyleCastExpr > cStyleCastExpr
Matches a C-style cast expression.
const internal::VariadicDynCastAllOfMatcher< Decl, TagDecl > tagDecl
Matches tag declarations.
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXReinterpretCastExpr > cxxReinterpretCastExpr
Matches a reinterpret_cast expression.
const internal::VariadicDynCastAllOfMatcher< Decl, VarDecl > varDecl
Matches variable declarations.
const internal::VariadicDynCastAllOfMatcher< TypeLoc, ElaboratedTypeLoc > elaboratedTypeLoc
Matches C or C++ elaborated TypeLocs.
const internal::VariadicDynCastAllOfMatcher< Stmt, StmtExpr > stmtExpr
Matches statement expression (GNU extension).
const internal::VariadicDynCastAllOfMatcher< Stmt, ExprWithCleanups > exprWithCleanups
Matches expressions that introduce cleanups to be run at the end of the sub-expression's evaluation.
const internal::VariadicDynCastAllOfMatcher< Stmt, DeclRefExpr > declRefExpr
Matches expressions that refer to declarations.
const internal::VariadicDynCastAllOfMatcher< Decl, TypedefNameDecl > typedefNameDecl
Matches typedef name declarations.
const internal::VariadicDynCastAllOfMatcher< Decl, ObjCIvarDecl > objcIvarDecl
Matches Objective-C instance variable declarations.
const AstTypeMatcher< EnumType > enumType
Matches enum types.
const AstTypeMatcher< FunctionProtoType > functionProtoType
Matches FunctionProtoType nodes.
const AstTypeMatcher< ElaboratedType > elaboratedType
Matches types specified with an elaborated type keyword or with a qualified name.
const internal::VariadicDynCastAllOfMatcher< Decl, TypeAliasDecl > typeAliasDecl
Matches type alias declarations.
const internal::VariadicDynCastAllOfMatcher< Decl, UsingEnumDecl > usingEnumDecl
Matches using-enum declarations.
const AstTypeMatcher< ObjCObjectPointerType > objcObjectPointerType
Matches an Objective-C object pointer type, which is different from a pointer type,...
const internal::VariadicDynCastAllOfMatcher< Stmt, ConstantExpr > constantExpr
Matches a constant expression wrapper.
const internal::VariadicDynCastAllOfMatcher< Stmt, ObjCIvarRefExpr > objcIvarRefExpr
Matches a reference to an ObjCIvar.
const AstTypeMatcher< BuiltinType > builtinType
Matches builtin Types.
const internal::VariadicOperatorMatcherFunc< 1, 1 > unless
Matches if the provided matcher does not match.
const internal::VariadicDynCastAllOfMatcher< Stmt, CoyieldExpr > coyieldExpr
Matches co_yield expressions.
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXDeleteExpr > cxxDeleteExpr
Matches delete expressions.
const internal::VariadicAllOfMatcher< TemplateName > templateName
Matches template name.
const internal::VariadicDynCastAllOfMatcher< Decl, ObjCProtocolDecl > objcProtocolDecl
Matches Objective-C protocol declarations.
const internal::VariadicDynCastAllOfMatcher< Stmt, ImplicitCastExpr > implicitCastExpr
Matches the implicit cast nodes of Clang's AST.
const internal::VariadicOperatorMatcherFunc< 1, 1 > optionally
Matches any node regardless of the submatcher.
const internal::VariadicDynCastAllOfMatcher< Decl, UsingDecl > usingDecl
Matches using declarations.
const internal::ArgumentAdaptingMatcherFunc< internal::HasDescendantMatcher > hasDescendant
Matches AST nodes that have descendant AST nodes that match the provided matcher.
const internal::VariadicDynCastAllOfMatcher< Decl, ObjCPropertyDecl > objcPropertyDecl
Matches Objective-C property declarations.
const internal::VariadicDynCastAllOfMatcher< Stmt, StringLiteral > stringLiteral
Matches string literals (also matches wide string literals).
const internal::VariadicAllOfMatcher< CXXCtorInitializer > cxxCtorInitializer
Matches constructor initializers.
const internal::VariadicDynCastAllOfMatcher< Stmt, ObjCAtFinallyStmt > objcFinallyStmt
Matches Objective-C @finally statements.
const AstTypeMatcher< DependentSizedArrayType > dependentSizedArrayType
Matches C++ arrays whose size is a value-dependent expression.
const AstTypeMatcher< TemplateSpecializationType > templateSpecializationType
Matches template specialization types.
const internal::VariadicDynCastAllOfMatcher< Stmt, AtomicExpr > atomicExpr
Matches atomic builtins.
const AstTypeMatcher< DeducedTemplateSpecializationType > deducedTemplateSpecializationType
Matches C++17 deduced template specialization types, e.g.
const internal::VariadicDynCastAllOfMatcher< Stmt, CoawaitExpr > coawaitExpr
Matches co_await expressions.
const internal::VariadicDynCastAllOfMatcher< Decl, EnumDecl > enumDecl
Matches enum declarations.
const internal::VariadicDynCastAllOfMatcher< Stmt, AddrLabelExpr > addrLabelExpr
Matches address of label statements (GNU extension).
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXDependentScopeMemberExpr > cxxDependentScopeMemberExpr
Matches member expressions where the actual member referenced could not be resolved because the base ...
const internal::VariadicDynCastAllOfMatcher< Stmt, PredefinedExpr > predefinedExpr
Matches predefined identifier expressions [C99 6.4.2.2].
const internal::VariadicAllOfMatcher< NestedNameSpecifier > nestedNameSpecifier
Matches nested name specifiers.
const AstTypeMatcher< PointerType > pointerType
Matches pointer types, but does not match Objective-C object pointer types.
const internal::VariadicDynCastAllOfMatcher< Stmt, DependentCoawaitExpr > dependentCoawaitExpr
Matches co_await expressions where the type of the promise is dependent.
const internal::VariadicDynCastAllOfMatcher< Stmt, BreakStmt > breakStmt
Matches break statements.
const internal::VariadicDynCastAllOfMatcher< Decl, BindingDecl > bindingDecl
Matches binding declarations Example matches foo and bar (matcher = bindingDecl()
const internal::VariadicDynCastAllOfMatcher< Stmt, UnresolvedLookupExpr > unresolvedLookupExpr
Matches reference to a name that can be looked up during parsing but could not be resolved to a speci...
const internal::VariadicDynCastAllOfMatcher< Stmt, OMPExecutableDirective > ompExecutableDirective
Matches any #pragma omp executable directive.
const internal::VariadicDynCastAllOfMatcher< Stmt, ObjCStringLiteral > objcStringLiteral
Matches ObjectiveC String literal expressions.
const internal::VariadicDynCastAllOfMatcher< Decl, ObjCMethodDecl > objcMethodDecl
Matches Objective-C method declarations.
const internal::VariadicDynCastAllOfMatcher< Decl, ParmVarDecl > parmVarDecl
Matches parameter variable declarations.
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXRewrittenBinaryOperator > cxxRewrittenBinaryOperator
Matches rewritten binary operators.
const internal::VariadicDynCastAllOfMatcher< Decl, TypedefDecl > typedefDecl
Matches typedef declarations.
const internal::VariadicDynCastAllOfMatcher< Stmt, GenericSelectionExpr > genericSelectionExpr
Matches C11 _Generic expression.
const internal::VariadicDynCastAllOfMatcher< Decl, CXXDeductionGuideDecl > cxxDeductionGuideDecl
Matches user-defined and implicitly generated deduction guide.
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXBoolLiteralExpr > cxxBoolLiteral
Matches bool literals.
const internal::VariadicDynCastAllOfMatcher< Stmt, ReturnStmt > returnStmt
Matches return statements.
const internal::VariadicDynCastAllOfMatcher< Stmt, AsmStmt > asmStmt
Matches asm statements.
const internal::VariadicAllOfMatcher< Attr > attr
Matches attributes.
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXDynamicCastExpr > cxxDynamicCastExpr
Matches a dynamic_cast expression.
const internal::VariadicDynCastAllOfMatcher< Stmt, CoreturnStmt > coreturnStmt
Matches co_return statements.
const internal::VariadicDynCastAllOfMatcher< Stmt, CallExpr > callExpr
Matches call expressions.
const internal::VariadicDynCastAllOfMatcher< Stmt, LambdaExpr > lambdaExpr
Matches lambda expressions.
const internal::VariadicDynCastAllOfMatcher< Stmt, CompoundStmt > compoundStmt
Matches compound statements.
const internal::VariadicDynCastAllOfMatcher< Stmt, FloatingLiteral > floatLiteral
Matches float literals of all sizes / encodings, e.g.
const internal::VariadicDynCastAllOfMatcher< Stmt, ObjCAutoreleasePoolStmt > autoreleasePoolStmt
Matches an Objective-C autorelease pool statement.
const internal::VariadicFunction< internal::PolymorphicMatcher< internal::HasOverloadedOperatorNameMatcher, AST_POLYMORPHIC_SUPPORTED_TYPES(CXXOperatorCallExpr, FunctionDecl), std::vector< std::string > >, StringRef, internal::hasAnyOverloadedOperatorNameFunc > hasAnyOverloadedOperatorName
Matches overloaded operator names.
const internal::VariadicDynCastAllOfMatcher< Decl, NonTypeTemplateParmDecl > nonTypeTemplateParmDecl
Matches non-type template parameter declarations.
const AstTypeMatcher< VariableArrayType > variableArrayType
Matches C arrays with a specified size that is not an integer-constant-expression.
const internal::VariadicDynCastAllOfMatcher< Stmt, UnaryExprOrTypeTraitExpr > unaryExprOrTypeTraitExpr
Matches sizeof (C99), alignof (C++11) and vec_step (OpenCL)
const internal::VariadicDynCastAllOfMatcher< Stmt, NullStmt > nullStmt
Matches null statements.
const internal::VariadicDynCastAllOfMatcher< TypeLoc, TemplateSpecializationTypeLoc > templateSpecializationTypeLoc
Matches template specialization TypeLocs.
const internal::ArgumentAdaptingMatcherFunc< internal::ForEachDescendantMatcher > forEachDescendant
Matches AST nodes that have descendant AST nodes that match the provided matcher.
const internal::VariadicAllOfMatcher< CXXBaseSpecifier > cxxBaseSpecifier
Matches class bases.
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXDefaultArgExpr > cxxDefaultArgExpr
Matches the value of a default argument at the call site.
const internal::VariadicAllOfMatcher< TemplateArgument > templateArgument
Matches template arguments.
const internal::ArgumentAdaptingMatcherFunc< internal::ForEachMatcher > forEach
Matches AST nodes that have child AST nodes that match the provided matcher.
const internal::VariadicDynCastAllOfMatcher< Stmt, CaseStmt > caseStmt
Matches case statements inside switch statements.
const internal::VariadicAllOfMatcher< NestedNameSpecifierLoc > nestedNameSpecifierLoc
Same as nestedNameSpecifier but matches NestedNameSpecifierLoc.
const internal::VariadicDynCastAllOfMatcher< Decl, NamedDecl > namedDecl
Matches a declaration of anything that could have a name.
const internal::VariadicDynCastAllOfMatcher< Decl, UnresolvedUsingTypenameDecl > unresolvedUsingTypenameDecl
Matches unresolved using value declarations that involve the typename.
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
const AstTypeMatcher< DecltypeType > decltypeType
Matches types nodes representing C++11 decltype(<expr>) types.
const internal::VariadicAllOfMatcher< TypeLoc > typeLoc
Matches TypeLocs in the clang AST.
const internal::VariadicDynCastAllOfMatcher< Stmt, ParenListExpr > parenListExpr
Matches paren list expressions.
const internal::VariadicDynCastAllOfMatcher< Decl, ClassTemplatePartialSpecializationDecl > classTemplatePartialSpecializationDecl
Matches C++ class template partial specializations.
const internal::VariadicDynCastAllOfMatcher< Stmt, WhileStmt > whileStmt
Matches while statements.
const internal::VariadicDynCastAllOfMatcher< Decl, ObjCCategoryDecl > objcCategoryDecl
Matches Objective-C category declarations.
const internal::VariadicFunction< internal::Matcher< ObjCMessageExpr >, StringRef, internal::hasAnySelectorFunc > hasAnySelector
Matches when at least one of the supplied string equals to the Selector.getAsString()
const AstTypeMatcher< AutoType > autoType
Matches types nodes representing C++11 auto types.
const AstTypeMatcher< ArrayType > arrayType
Matches all kinds of arrays.
const internal::VariadicDynCastAllOfMatcher< Decl, CXXConversionDecl > cxxConversionDecl
Matches conversion operator declarations.
const AstTypeMatcher< ParenType > parenType
Matches ParenType nodes.
const internal::VariadicDynCastAllOfMatcher< Decl, LabelDecl > labelDecl
Matches a declaration of label.
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXFunctionalCastExpr > cxxFunctionalCastExpr
Matches functional cast expressions.
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXConstCastExpr > cxxConstCastExpr
Matches a const_cast expression.
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXTemporaryObjectExpr > cxxTemporaryObjectExpr
Matches functional cast expressions having N != 1 arguments.
const internal::VariadicDynCastAllOfMatcher< Stmt, UnaryOperator > unaryOperator
Matches unary operator expressions.
const internal::VariadicDynCastAllOfMatcher< TypeLoc, ReferenceTypeLoc > referenceTypeLoc
Matches reference TypeLocs.
const internal::VariadicFunction< internal::Matcher< NamedDecl >, StringRef, internal::hasAnyNameFunc > hasAnyName
Matches NamedDecl nodes that have any of the specified names.
const internal::VariadicDynCastAllOfMatcher< Stmt, ObjCMessageExpr > objcMessageExpr
Matches ObjectiveC Message invocation expressions.
const internal::MapAnyOfMatcher< BinaryOperator, CXXOperatorCallExpr, CXXRewrittenBinaryOperator > binaryOperation
Matches nodes which can be used with binary operators.
const internal::VariadicDynCastAllOfMatcher< Stmt, ArraySubscriptExpr > arraySubscriptExpr
Matches array subscript expressions.
const internal::VariadicDynCastAllOfMatcher< OMPClause, OMPDefaultClause > ompDefaultClause
Matches OpenMP default clause.
const internal::VariadicDynCastAllOfMatcher< Decl, AccessSpecDecl > accessSpecDecl
Matches C++ access specifier declarations.
const internal::VariadicDynCastAllOfMatcher< Decl, LinkageSpecDecl > linkageSpecDecl
Matches a declaration of a linkage specification.
const AstTypeMatcher< InjectedClassNameType > injectedClassNameType
Matches injected class name types.
const internal::VariadicDynCastAllOfMatcher< Stmt, GNUNullExpr > gnuNullExpr
Matches GNU __null expression.
const internal::VariadicDynCastAllOfMatcher< TypeLoc, PointerTypeLoc > pointerTypeLoc
Matches pointer TypeLocs.
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXForRangeStmt > cxxForRangeStmt
Matches range-based for statements.
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXMemberCallExpr > cxxMemberCallExpr
Matches member call expressions.
const internal::VariadicDynCastAllOfMatcher< Decl, CXXConstructorDecl > cxxConstructorDecl
Matches C++ constructor declarations.
const AstTypeMatcher< BlockPointerType > blockPointerType
Matches block pointer types, i.e.
const internal::VariadicDynCastAllOfMatcher< Stmt, InitListExpr > initListExpr
Matches init list expressions.
const AstTypeMatcher< AtomicType > atomicType
Matches atomic types.
const internal::VariadicDynCastAllOfMatcher< Decl, TypeAliasTemplateDecl > typeAliasTemplateDecl
Matches type alias template declarations.
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXNoexceptExpr > cxxNoexceptExpr
Matches noexcept expressions.
internal::VariadicDynCastAllOfMatcher< Type, NodeType > AstTypeMatcher
const AstTypeMatcher< UsingType > usingType
Matches types specified through a using declaration.
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXNewExpr > cxxNewExpr
Matches new expressions.
const internal::VariadicDynCastAllOfMatcher< Decl, EnumConstantDecl > enumConstantDecl
Matches enum constants.
const internal::VariadicDynCastAllOfMatcher< Stmt, ForStmt > forStmt
Matches for statements.
const internal::VariadicDynCastAllOfMatcher< Stmt, GotoStmt > gotoStmt
Matches goto statements.
const internal::VariadicDynCastAllOfMatcher< Decl, DeclaratorDecl > declaratorDecl
Matches declarator declarations (field, variable, function and non-type template parameter declaratio...
const internal::VariadicDynCastAllOfMatcher< Stmt, ObjCAtCatchStmt > objcCatchStmt
Matches Objective-C @catch statements.
const internal::VariadicDynCastAllOfMatcher< Stmt, BinaryOperator > binaryOperator
Matches binary operator expressions.
const internal::VariadicDynCastAllOfMatcher< TypeLoc, QualifiedTypeLoc > qualifiedTypeLoc
Matches QualifiedTypeLocs in the clang AST.
const internal::VariadicDynCastAllOfMatcher< Decl, TemplateTypeParmDecl > templateTypeParmDecl
Matches template type parameter declarations.
const internal::VariadicDynCastAllOfMatcher< Stmt, BlockExpr > blockExpr
Matches a reference to a block.
const internal::VariadicDynCastAllOfMatcher< Decl, FunctionTemplateDecl > functionTemplateDecl
Matches C++ function template declarations.
const internal::VariadicDynCastAllOfMatcher< Stmt, ParenExpr > parenExpr
Matches parentheses used in expressions.
const internal::VariadicDynCastAllOfMatcher< Decl, StaticAssertDecl > staticAssertDecl
Matches a C++ static_assert declaration.
const internal::ArgumentAdaptingMatcherFunc< internal::HasMatcher > has
Matches AST nodes that have child AST nodes that match the provided matcher.
const internal::VariadicDynCastAllOfMatcher< Stmt, CoroutineBodyStmt > coroutineBodyStmt
Matches coroutine body statements.
const internal::VariadicDynCastAllOfMatcher< Decl, ObjCCategoryImplDecl > objcCategoryImplDecl
Matches Objective-C category definitions.
const AstTypeMatcher< TypedefType > typedefType
Matches typedef types.
const internal::VariadicDynCastAllOfMatcher< Stmt, MaterializeTemporaryExpr > materializeTemporaryExpr
Matches nodes where temporaries are materialized.
const AstTypeMatcher< TagType > tagType
Matches tag types (record and enum types).
const internal::VariadicDynCastAllOfMatcher< Stmt, BinaryConditionalOperator > binaryConditionalOperator
Matches binary conditional operator expressions (GNU extension).
const internal::VariadicDynCastAllOfMatcher< Stmt, ObjCAtTryStmt > objcTryStmt
Matches Objective-C @try statements.
const internal::VariadicDynCastAllOfMatcher< Stmt, ExplicitCastExpr > explicitCastExpr
Matches explicit cast expressions.
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXStaticCastExpr > cxxStaticCastExpr
Matches a C++ static_cast expression.
const internal::VariadicDynCastAllOfMatcher< Decl, ValueDecl > valueDecl
Matches any value declaration.
const internal::VariadicDynCastAllOfMatcher< Decl, TranslationUnitDecl > translationUnitDecl
Matches the top declaration context.
const AstTypeMatcher< TemplateTypeParmType > templateTypeParmType
Matches template type parameter types.
const AstTypeMatcher< ConstantArrayType > constantArrayType
Matches C arrays with a specified constant size.
const internal::VariadicAllOfMatcher< LambdaCapture > lambdaCapture
Matches lambda captures.
const internal::VariadicOperatorMatcherFunc< 2, std::numeric_limits< unsigned >::max()> eachOf
Matches if any of the given matchers matches.
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXConstructExpr > cxxConstructExpr
Matches constructor call expressions (including implicit ones).
const internal::VariadicDynCastAllOfMatcher< Decl, ObjCInterfaceDecl > objcInterfaceDecl
Matches Objective-C interface declarations.
const internal::VariadicDynCastAllOfMatcher< Decl, TemplateTemplateParmDecl > templateTemplateParmDecl
Matches template template parameter declarations.
const internal::VariadicDynCastAllOfMatcher< Decl, FieldDecl > fieldDecl
Matches field declarations.
const internal::VariadicDynCastAllOfMatcher< Stmt, UserDefinedLiteral > userDefinedLiteral
Matches user defined literal operator call.
const internal::VariadicDynCastAllOfMatcher< Stmt, ChooseExpr > chooseExpr
Matches GNU __builtin_choose_expr.
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXOperatorCallExpr > cxxOperatorCallExpr
Matches overloaded operator calls.
const internal::VariadicDynCastAllOfMatcher< Decl, NamespaceAliasDecl > namespaceAliasDecl
Matches a declaration of a namespace alias.
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXBindTemporaryExpr > cxxBindTemporaryExpr
Matches nodes where temporaries are created.
const internal::VariadicDynCastAllOfMatcher< Stmt, SwitchCase > switchCase
Matches case and default statements inside switch statements.
const internal::VariadicDynCastAllOfMatcher< Stmt, DefaultStmt > defaultStmt
Matches default statements inside switch statements.
const internal::VariadicOperatorMatcherFunc< 2, std::numeric_limits< unsigned >::max()> allOf
Matches if all given matchers match.
const internal::VariadicDynCastAllOfMatcher< Decl, ClassTemplateSpecializationDecl > classTemplateSpecializationDecl
Matches C++ class template specializations.
const internal::VariadicDynCastAllOfMatcher< Decl, DecompositionDecl > decompositionDecl
Matches decomposition-declarations.
const AstTypeMatcher< SubstTemplateTypeParmType > substTemplateTypeParmType
Matches types that represent the result of substituting a type for a template type parameter.
const internal::VariadicDynCastAllOfMatcher< Decl, FunctionDecl > functionDecl
Matches function declarations.
const AstTypeMatcher< UnaryTransformType > unaryTransformType
Matches types nodes representing unary type transformations.
const internal::VariadicDynCastAllOfMatcher< Stmt, UnresolvedMemberExpr > unresolvedMemberExpr
Matches unresolved member expressions.
const internal::VariadicDynCastAllOfMatcher< Stmt, ObjCAtThrowStmt > objcThrowStmt
Matches Objective-C @throw statements.
const internal::MapAnyOfMatcher< CallExpr, CXXConstructExpr > invocation
Matches function calls and constructor calls.
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXThrowExpr > cxxThrowExpr
Matches throw expressions.
const internal::VariadicDynCastAllOfMatcher< Stmt, SwitchStmt > switchStmt
Matches switch statements.
const AstTypeMatcher< RecordType > recordType
Matches record types (e.g.
const internal::VariadicDynCastAllOfMatcher< Stmt, MemberExpr > memberExpr
Matches member expressions.
const internal::VariadicDynCastAllOfMatcher< Decl, CXXRecordDecl > cxxRecordDecl
Matches C++ class declarations.
const internal::VariadicAllOfMatcher< TemplateArgumentLoc > templateArgumentLoc
Matches template arguments (with location info).
const AstTypeMatcher< ReferenceType > referenceType
Matches both lvalue and rvalue reference types.
const internal::VariadicDynCastAllOfMatcher< Stmt, DesignatedInitExpr > designatedInitExpr
Matches C99 designated initializer expressions [C99 6.7.8].
const internal::VariadicAllOfMatcher< Decl > decl
Matches declarations.
const internal::VariadicDynCastAllOfMatcher< Decl, CXXDestructorDecl > cxxDestructorDecl
Matches explicit C++ destructor declarations.
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXUnresolvedConstructExpr > cxxUnresolvedConstructExpr
Matches unresolved constructor call expressions.
const internal::VariadicDynCastAllOfMatcher< Decl, ObjCImplementationDecl > objcImplementationDecl
Matches Objective-C implementation declarations.
const internal::VariadicDynCastAllOfMatcher< Decl, RecordDecl > recordDecl
Matches class, struct, and union declarations.
const internal::VariadicDynCastAllOfMatcher< Stmt, IntegerLiteral > integerLiteral
Matches integer literals of all sizes / encodings, e.g.
const internal::VariadicDynCastAllOfMatcher< Stmt, ImplicitValueInitExpr > implicitValueInitExpr
Matches implicit initializers of init list expressions.
const internal::VariadicDynCastAllOfMatcher< Stmt, DoStmt > doStmt
Matches do statements.
const internal::VariadicDynCastAllOfMatcher< Decl, NamespaceDecl > namespaceDecl
Matches a declaration of a namespace.
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXNullPtrLiteralExpr > cxxNullPtrLiteralExpr
Matches nullptr literal.
const AstTypeMatcher< DecayedType > decayedType
Matches decayed type Example matches i[] in declaration of f.
const internal::VariadicDynCastAllOfMatcher< Stmt, DeclStmt > declStmt
Matches declaration statements.
const internal::VariadicDynCastAllOfMatcher< Stmt, CompoundLiteralExpr > compoundLiteralExpr
Matches compound (i.e.
const AstTypeMatcher< MemberPointerType > memberPointerType
Matches member pointer types.
const internal::VariadicDynCastAllOfMatcher< Stmt, LabelStmt > labelStmt
Matches label statements.
const internal::VariadicAllOfMatcher< Stmt > stmt
Matches statements.
const internal::VariadicDynCastAllOfMatcher< Decl, FriendDecl > friendDecl
Matches friend declarations.
const internal::VariadicDynCastAllOfMatcher< Stmt, Expr > expr
Matches expressions.
const AstTypeMatcher< IncompleteArrayType > incompleteArrayType
Matches C arrays with unspecified size.
const internal::VariadicDynCastAllOfMatcher< Stmt, CharacterLiteral > characterLiteral
Matches character literals (also matches wchar_t).
const internal::VariadicDynCastAllOfMatcher< Stmt, ConditionalOperator > conditionalOperator
Matches conditional operator expressions.
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXStdInitializerListExpr > cxxStdInitializerListExpr
Matches C++ initializer list expressions.
const internal::VariadicOperatorMatcherFunc< 2, std::numeric_limits< unsigned >::max()> anyOf
Matches if any of the given matchers matches.
const internal::VariadicFunction< internal::PolymorphicMatcher< internal::HasAnyOperatorNameMatcher, AST_POLYMORPHIC_SUPPORTED_TYPES(BinaryOperator, CXXOperatorCallExpr, CXXRewrittenBinaryOperator, UnaryOperator), std::vector< std::string > >, StringRef, internal::hasAnyOperatorNameFunc > hasAnyOperatorName
Matches operator expressions (binary or unary) that have any of the specified names.
const internal::VariadicDynCastAllOfMatcher< Stmt, OpaqueValueExpr > opaqueValueExpr
Matches opaque value expressions.
const AstTypeMatcher< ComplexType > complexType
Matches C99 complex types.
const internal::VariadicDynCastAllOfMatcher< Stmt, CUDAKernelCallExpr > cudaKernelCallExpr
Matches CUDA kernel call expression.
const internal::VariadicDynCastAllOfMatcher< Decl, IndirectFieldDecl > indirectFieldDecl
Matches indirect field declarations.
const AstTypeMatcher< FunctionType > functionType
Matches FunctionType nodes.
const internal::VariadicDynCastAllOfMatcher< Decl, BlockDecl > blockDecl
Matches block declarations.
const internal::VariadicDynCastAllOfMatcher< Decl, CXXMethodDecl > cxxMethodDecl
Matches method declarations.
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXCatchStmt > cxxCatchStmt
Matches catch statements.
const internal::VariadicDynCastAllOfMatcher< Stmt, CastExpr > castExpr
Matches any cast nodes of Clang's AST.
const internal::VariadicAllOfMatcher< QualType > qualType
Matches QualTypes in the clang AST.
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXTryStmt > cxxTryStmt
Matches try statements.
const internal::VariadicDynCastAllOfMatcher< Stmt, SubstNonTypeTemplateParmExpr > substNonTypeTemplateParmExpr
Matches substitutions of non-type template parameters.
const internal::VariadicDynCastAllOfMatcher< Decl, UsingDirectiveDecl > usingDirectiveDecl
Matches using namespace declarations.
const internal::VariadicDynCastAllOfMatcher< Decl, UnresolvedUsingValueDecl > unresolvedUsingValueDecl
Matches unresolved using value declarations.
const internal::ArgumentAdaptingMatcherFunc< internal::HasAncestorMatcher, internal::TypeList< Decl, NestedNameSpecifierLoc, Stmt, TypeLoc, Attr >, internal::TypeList< Decl, NestedNameSpecifierLoc, Stmt, TypeLoc, Attr > > hasAncestor
Matches AST nodes that have an ancestor that matches the provided matcher.
const internal::ArgumentAdaptingMatcherFunc< internal::HasParentMatcher, internal::TypeList< Decl, NestedNameSpecifierLoc, Stmt, TypeLoc, Attr >, internal::TypeList< Decl, NestedNameSpecifierLoc, Stmt, TypeLoc, Attr > > hasParent
Matches AST nodes that have a parent that matches the provided matcher.
const internal::VariadicDynCastAllOfMatcher< Stmt, IfStmt > ifStmt
Matches if statements.
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXThisExpr > cxxThisExpr
Matches implicit and explicit this expressions.
const internal::VariadicDynCastAllOfMatcher< Stmt, ImaginaryLiteral > imaginaryLiteral
Matches imaginary literals, which are based on integer and floating point literals e....
const AstTypeMatcher< RValueReferenceType > rValueReferenceType
Matches rvalue reference types.
const internal::VariadicDynCastAllOfMatcher< Stmt, ContinueStmt > continueStmt
Matches continue statements.
const internal::VariadicDynCastAllOfMatcher< Decl, ClassTemplateDecl > classTemplateDecl
Matches C++ class template declarations.
const AstTypeMatcher< LValueReferenceType > lValueReferenceType
Matches lvalue reference types.
TraversalKind
Defines how we descend a level in the AST when we pass through expressions.
@ TK_IgnoreUnlessSpelledInSource
Ignore AST nodes not written in the source.
@ Result
The result type of a method or function.
YAML serialization mapping.