Bug Summary

File:build/source/clang-tools-extra/clang-tidy/bugprone/StandaloneEmptyCheck.cpp
Warning:line 210, column 12
Called C++ object pointer is null

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-pc-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name StandaloneEmptyCheck.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -analyzer-config-compatibility-mode=true -mrelocation-model pic -pic-level 2 -mframe-pointer=none -relaxed-aliasing -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -ffunction-sections -fdata-sections -fcoverage-compilation-dir=/build/source/build-llvm/tools/clang/stage2-bins -resource-dir /usr/lib/llvm-17/lib/clang/17 -D CLANG_REPOSITORY_STRING="++20230510111145+7df43bdb42ae-1~exp1~20230510111303.1288" -D _DEBUG -D _GLIBCXX_ASSERTIONS -D _GNU_SOURCE -D _LIBCPP_ENABLE_ASSERTIONS -D __STDC_CONSTANT_MACROS -D __STDC_FORMAT_MACROS -D __STDC_LIMIT_MACROS -I tools/clang/tools/extra/clang-tidy/bugprone -I /build/source/clang-tools-extra/clang-tidy/bugprone -I tools/clang/tools/extra/clang-tidy -I /build/source/clang/include -I tools/clang/include -I include -I /build/source/llvm/include -D _FORTIFY_SOURCE=2 -D NDEBUG -U NDEBUG -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/10/../../../../include/x86_64-linux-gnu/c++/10 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/backward -internal-isystem /usr/lib/llvm-17/lib/clang/17/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/10/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -fmacro-prefix-map=/build/source/build-llvm/tools/clang/stage2-bins=build-llvm/tools/clang/stage2-bins -fmacro-prefix-map=/build/source/= -fcoverage-prefix-map=/build/source/build-llvm/tools/clang/stage2-bins=build-llvm/tools/clang/stage2-bins -fcoverage-prefix-map=/build/source/= -source-date-epoch 1683717183 -O2 -Wno-unused-command-line-argument -Wno-unused-parameter -Wwrite-strings -Wno-missing-field-initializers -Wno-long-long -Wno-maybe-uninitialized -Wno-class-memaccess -Wno-redundant-move -Wno-pessimizing-move -Wno-noexcept-type -Wno-comment -Wno-misleading-indentation -std=c++17 -fdeprecated-macro -fdebug-compilation-dir=/build/source/build-llvm/tools/clang/stage2-bins -fdebug-prefix-map=/build/source/build-llvm/tools/clang/stage2-bins=build-llvm/tools/clang/stage2-bins -fdebug-prefix-map=/build/source/= -ferror-limit 19 -fvisibility-inlines-hidden -stack-protector 2 -fgnuc-version=4.2.1 -fcolor-diagnostics -vectorize-loops -vectorize-slp -analyzer-output=html -analyzer-config stable-report-filename=true -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/scan-build-2023-05-10-133810-16478-1 -x c++ /build/source/clang-tools-extra/clang-tidy/bugprone/StandaloneEmptyCheck.cpp

/build/source/clang-tools-extra/clang-tidy/bugprone/StandaloneEmptyCheck.cpp

1//===--- StandaloneEmptyCheck.cpp - clang-tidy ----------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#include "StandaloneEmptyCheck.h"
10#include "clang/AST/ASTContext.h"
11#include "clang/AST/Decl.h"
12#include "clang/AST/DeclBase.h"
13#include "clang/AST/DeclCXX.h"
14#include "clang/AST/Expr.h"
15#include "clang/AST/ExprCXX.h"
16#include "clang/AST/Stmt.h"
17#include "clang/AST/Type.h"
18#include "clang/ASTMatchers/ASTMatchFinder.h"
19#include "clang/ASTMatchers/ASTMatchers.h"
20#include "clang/Basic/Diagnostic.h"
21#include "clang/Basic/SourceLocation.h"
22#include "clang/Lex/Lexer.h"
23#include "llvm/ADT/STLExtras.h"
24#include "llvm/ADT/SmallVector.h"
25#include "llvm/Support/Casting.h"
26
27namespace clang::tidy::bugprone {
28
29using ast_matchers::BoundNodes;
30using ast_matchers::callee;
31using ast_matchers::callExpr;
32using ast_matchers::classTemplateDecl;
33using ast_matchers::cxxMemberCallExpr;
34using ast_matchers::cxxMethodDecl;
35using ast_matchers::expr;
36using ast_matchers::functionDecl;
37using ast_matchers::hasAncestor;
38using ast_matchers::hasName;
39using ast_matchers::hasParent;
40using ast_matchers::ignoringImplicit;
41using ast_matchers::ignoringParenImpCasts;
42using ast_matchers::MatchFinder;
43using ast_matchers::optionally;
44using ast_matchers::returns;
45using ast_matchers::stmt;
46using ast_matchers::stmtExpr;
47using ast_matchers::unless;
48using ast_matchers::voidType;
49
50const Expr *getCondition(const BoundNodes &Nodes, const StringRef NodeId) {
51 const auto *If = Nodes.getNodeAs<IfStmt>(NodeId);
52 if (If != nullptr)
53 return If->getCond();
54
55 const auto *For = Nodes.getNodeAs<ForStmt>(NodeId);
56 if (For != nullptr)
57 return For->getCond();
58
59 const auto *While = Nodes.getNodeAs<WhileStmt>(NodeId);
60 if (While != nullptr)
61 return While->getCond();
62
63 const auto *Do = Nodes.getNodeAs<DoStmt>(NodeId);
64 if (Do != nullptr)
65 return Do->getCond();
66
67 const auto *Switch = Nodes.getNodeAs<SwitchStmt>(NodeId);
68 if (Switch != nullptr)
69 return Switch->getCond();
70
71 return nullptr;
72}
73
74void StandaloneEmptyCheck::registerMatchers(ast_matchers::MatchFinder *Finder) {
75 // Ignore empty calls in a template definition which fall under callExpr
76 // non-member matcher even if they are methods.
77 const auto NonMemberMatcher = expr(ignoringImplicit(ignoringParenImpCasts(
78 callExpr(
79 hasParent(stmt(optionally(hasParent(stmtExpr().bind("stexpr"))))
80 .bind("parent")),
81 unless(hasAncestor(classTemplateDecl())),
82 callee(functionDecl(hasName("empty"), unless(returns(voidType())))))
83 .bind("empty"))));
84 const auto MemberMatcher =
85 expr(ignoringImplicit(ignoringParenImpCasts(cxxMemberCallExpr(
86 hasParent(stmt(optionally(hasParent(stmtExpr().bind("stexpr"))))
87 .bind("parent")),
88 callee(cxxMethodDecl(hasName("empty"),
89 unless(returns(voidType()))))))))
90 .bind("empty");
91
92 Finder->addMatcher(MemberMatcher, this);
93 Finder->addMatcher(NonMemberMatcher, this);
94}
95
96void StandaloneEmptyCheck::check(const MatchFinder::MatchResult &Result) {
97 // Skip if the parent node is Expr.
98 if (Result.Nodes.getNodeAs<Expr>("parent"))
1
Taking false branch
99 return;
100
101 const auto PParentStmtExpr = Result.Nodes.getNodeAs<Expr>("stexpr");
2
Calling 'BoundNodes::getNodeAs'
16
Returning from 'BoundNodes::getNodeAs'
102 const auto ParentCompStmt = Result.Nodes.getNodeAs<CompoundStmt>("parent");
103 const auto *ParentCond = getCondition(Result.Nodes, "parent");
104 const auto *ParentReturnStmt = Result.Nodes.getNodeAs<ReturnStmt>("parent");
17
Calling 'BoundNodes::getNodeAs'
23
Returning from 'BoundNodes::getNodeAs'
105
106 if (const auto *MemberCall
30.1
'MemberCall' is null
30.1
'MemberCall' is null
30.1
'MemberCall' is null
30.1
'MemberCall' is null
=
31
Taking false branch
107 Result.Nodes.getNodeAs<CXXMemberCallExpr>("empty")) {
24
Calling 'BoundNodes::getNodeAs'
30
Returning from 'BoundNodes::getNodeAs'
108 // Skip if it's a condition of the parent statement.
109 if (ParentCond == MemberCall->getExprStmt())
110 return;
111 // Skip if it's the last statement in the GNU extension
112 // statement expression.
113 if (PParentStmtExpr && ParentCompStmt &&
114 ParentCompStmt->body_back() == MemberCall->getExprStmt())
115 return;
116 // Skip if it's a return statement
117 if (ParentReturnStmt)
118 return;
119
120 SourceLocation MemberLoc = MemberCall->getBeginLoc();
121 SourceLocation ReplacementLoc = MemberCall->getExprLoc();
122 SourceRange ReplacementRange = SourceRange(ReplacementLoc, ReplacementLoc);
123
124 ASTContext &Context = MemberCall->getRecordDecl()->getASTContext();
125 DeclarationName Name =
126 Context.DeclarationNames.getIdentifier(&Context.Idents.get("clear"));
127
128 auto Candidates = MemberCall->getRecordDecl()->lookupDependentName(
129 Name, [](const NamedDecl *ND) {
130 return isa<CXXMethodDecl>(ND) &&
131 llvm::cast<CXXMethodDecl>(ND)->getMinRequiredArguments() ==
132 0 &&
133 !llvm::cast<CXXMethodDecl>(ND)->isConst();
134 });
135
136 bool HasClear = !Candidates.empty();
137 if (HasClear) {
138 const CXXMethodDecl *Clear = llvm::cast<CXXMethodDecl>(Candidates.at(0));
139 QualType RangeType = MemberCall->getImplicitObjectArgument()->getType();
140 bool QualifierIncompatible =
141 (!Clear->isVolatile() && RangeType.isVolatileQualified()) ||
142 RangeType.isConstQualified();
143 if (!QualifierIncompatible) {
144 diag(MemberLoc,
145 "ignoring the result of 'empty()'; did you mean 'clear()'? ")
146 << FixItHint::CreateReplacement(ReplacementRange, "clear");
147 return;
148 }
149 }
150
151 diag(MemberLoc, "ignoring the result of 'empty()'");
152
153 } else if (const auto *NonMemberCall
46.1
'NonMemberCall' is non-null
46.1
'NonMemberCall' is non-null
46.1
'NonMemberCall' is non-null
46.1
'NonMemberCall' is non-null
=
47
Taking true branch
154 Result.Nodes.getNodeAs<CallExpr>("empty")) {
32
Calling 'BoundNodes::getNodeAs'
46
Returning from 'BoundNodes::getNodeAs'
155 if (ParentCond == NonMemberCall->getExprStmt())
48
Assuming the condition is false
156 return;
157 if (PParentStmtExpr
48.1
'PParentStmtExpr' is null
48.1
'PParentStmtExpr' is null
48.1
'PParentStmtExpr' is null
48.1
'PParentStmtExpr' is null
&& ParentCompStmt &&
158 ParentCompStmt->body_back() == NonMemberCall->getExprStmt())
159 return;
160 if (ParentReturnStmt
48.2
'ParentReturnStmt' is null
48.2
'ParentReturnStmt' is null
48.2
'ParentReturnStmt' is null
48.2
'ParentReturnStmt' is null
)
49
Taking false branch
161 return;
162 if (NonMemberCall->getNumArgs() != 1)
50
Assuming the condition is false
51
Taking false branch
163 return;
164
165 SourceLocation NonMemberLoc = NonMemberCall->getExprLoc();
166 SourceLocation NonMemberEndLoc = NonMemberCall->getEndLoc();
167
168 const Expr *Arg = NonMemberCall->getArg(0);
169 CXXRecordDecl *ArgRecordDecl = Arg->getType()->getAsCXXRecordDecl();
170 if (ArgRecordDecl == nullptr)
52
Assuming the condition is false
53
Taking false branch
171 return;
172
173 ASTContext &Context = ArgRecordDecl->getASTContext();
174 DeclarationName Name =
175 Context.DeclarationNames.getIdentifier(&Context.Idents.get("clear"));
176
177 auto Candidates =
178 ArgRecordDecl->lookupDependentName(Name, [](const NamedDecl *ND) {
179 return isa<CXXMethodDecl>(ND) &&
180 llvm::cast<CXXMethodDecl>(ND)->getMinRequiredArguments() ==
181 0 &&
182 !llvm::cast<CXXMethodDecl>(ND)->isConst();
183 });
184
185 bool HasClear = !Candidates.empty();
54
Assuming the condition is false
186
187 if (HasClear
54.1
'HasClear' is false
54.1
'HasClear' is false
54.1
'HasClear' is false
54.1
'HasClear' is false
) {
55
Taking false branch
188 const CXXMethodDecl *Clear = llvm::cast<CXXMethodDecl>(Candidates.at(0));
189 bool QualifierIncompatible =
190 (!Clear->isVolatile() && Arg->getType().isVolatileQualified()) ||
191 Arg->getType().isConstQualified();
192 if (!QualifierIncompatible) {
193 std::string ReplacementText =
194 std::string(Lexer::getSourceText(
195 CharSourceRange::getTokenRange(Arg->getSourceRange()),
196 *Result.SourceManager, getLangOpts())) +
197 ".clear()";
198 SourceRange ReplacementRange =
199 SourceRange(NonMemberLoc, NonMemberEndLoc);
200 diag(NonMemberLoc,
201 "ignoring the result of '%0'; did you mean 'clear()'?")
202 << llvm::dyn_cast<NamedDecl>(NonMemberCall->getCalleeDecl())
203 ->getQualifiedNameAsString()
204 << FixItHint::CreateReplacement(ReplacementRange, ReplacementText);
205 return;
206 }
207 }
208
209 diag(NonMemberLoc, "ignoring the result of '%0'")
210 << llvm::dyn_cast<NamedDecl>(NonMemberCall->getCalleeDecl())
56
Assuming the object is not a 'CastReturnType'
57
Called C++ object pointer is null
211 ->getQualifiedNameAsString();
212 }
213}
214
215} // namespace clang::tidy::bugprone

/build/source/clang/include/clang/ASTMatchers/ASTMatchers.h

1//===- ASTMatchers.h - Structural query framework ---------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file implements matchers to be used together with the MatchFinder to
10// match AST nodes.
11//
12// Matchers are created by generator functions, which can be combined in
13// a functional in-language DSL to express queries over the C++ AST.
14//
15// For example, to match a class with a certain name, one would call:
16// cxxRecordDecl(hasName("MyClass"))
17// which returns a matcher that can be used to find all AST nodes that declare
18// a class named 'MyClass'.
19//
20// For more complicated match expressions we're often interested in accessing
21// multiple parts of the matched AST nodes once a match is found. In that case,
22// call `.bind("name")` on match expressions that match the nodes you want to
23// access.
24//
25// For example, when we're interested in child classes of a certain class, we
26// would write:
27// cxxRecordDecl(hasName("MyClass"), has(recordDecl().bind("child")))
28// When the match is found via the MatchFinder, a user provided callback will
29// be called with a BoundNodes instance that contains a mapping from the
30// strings that we provided for the `.bind()` calls to the nodes that were
31// matched.
32// In the given example, each time our matcher finds a match we get a callback
33// where "child" is bound to the RecordDecl node of the matching child
34// class declaration.
35//
36// See ASTMatchersInternal.h for a more in-depth explanation of the
37// implementation details of the matcher framework.
38//
39// See ASTMatchFinder.h for how to use the generated matchers to run over
40// an AST.
41//
42//===----------------------------------------------------------------------===//
43
44#ifndef LLVM_CLANG_ASTMATCHERS_ASTMATCHERS_H
45#define LLVM_CLANG_ASTMATCHERS_ASTMATCHERS_H
46
47#include "clang/AST/ASTContext.h"
48#include "clang/AST/ASTTypeTraits.h"
49#include "clang/AST/Attr.h"
50#include "clang/AST/CXXInheritance.h"
51#include "clang/AST/Decl.h"
52#include "clang/AST/DeclCXX.h"
53#include "clang/AST/DeclFriend.h"
54#include "clang/AST/DeclObjC.h"
55#include "clang/AST/DeclTemplate.h"
56#include "clang/AST/Expr.h"
57#include "clang/AST/ExprCXX.h"
58#include "clang/AST/ExprObjC.h"
59#include "clang/AST/LambdaCapture.h"
60#include "clang/AST/NestedNameSpecifier.h"
61#include "clang/AST/OpenMPClause.h"
62#include "clang/AST/OperationKinds.h"
63#include "clang/AST/ParentMapContext.h"
64#include "clang/AST/Stmt.h"
65#include "clang/AST/StmtCXX.h"
66#include "clang/AST/StmtObjC.h"
67#include "clang/AST/StmtOpenMP.h"
68#include "clang/AST/TemplateBase.h"
69#include "clang/AST/TemplateName.h"
70#include "clang/AST/Type.h"
71#include "clang/AST/TypeLoc.h"
72#include "clang/ASTMatchers/ASTMatchersInternal.h"
73#include "clang/ASTMatchers/ASTMatchersMacros.h"
74#include "clang/Basic/AttrKinds.h"
75#include "clang/Basic/ExceptionSpecificationType.h"
76#include "clang/Basic/FileManager.h"
77#include "clang/Basic/IdentifierTable.h"
78#include "clang/Basic/LLVM.h"
79#include "clang/Basic/SourceManager.h"
80#include "clang/Basic/Specifiers.h"
81#include "clang/Basic/TypeTraits.h"
82#include "llvm/ADT/ArrayRef.h"
83#include "llvm/ADT/SmallVector.h"
84#include "llvm/ADT/StringRef.h"
85#include "llvm/Support/Casting.h"
86#include "llvm/Support/Compiler.h"
87#include "llvm/Support/ErrorHandling.h"
88#include "llvm/Support/Regex.h"
89#include <cassert>
90#include <cstddef>
91#include <iterator>
92#include <limits>
93#include <optional>
94#include <string>
95#include <utility>
96#include <vector>
97
98namespace clang {
99namespace ast_matchers {
100
101/// Maps string IDs to AST nodes matched by parts of a matcher.
102///
103/// The bound nodes are generated by calling \c bind("id") on the node matchers
104/// of the nodes we want to access later.
105///
106/// The instances of BoundNodes are created by \c MatchFinder when the user's
107/// callbacks are executed every time a match is found.
108class BoundNodes {
109public:
110 /// Returns the AST node bound to \c ID.
111 ///
112 /// Returns NULL if there was no node bound to \c ID or if there is a node but
113 /// it cannot be converted to the specified type.
114 template <typename T>
115 const T *getNodeAs(StringRef ID) const {
116 return MyBoundNodes.getNodeAs<T>(ID);
3
Calling 'BoundNodesMap::getNodeAs'
14
Returning from 'BoundNodesMap::getNodeAs'
15
Returning null pointer, which participates in a condition later
18
Calling 'BoundNodesMap::getNodeAs'
21
Returning from 'BoundNodesMap::getNodeAs'
22
Returning null pointer, which participates in a condition later
25
Calling 'BoundNodesMap::getNodeAs'
28
Returning from 'BoundNodesMap::getNodeAs'
29
Returning null pointer, which participates in a condition later
33
Calling 'BoundNodesMap::getNodeAs'
44
Returning from 'BoundNodesMap::getNodeAs'
45
Returning pointer, which participates in a condition later
117 }
118
119 /// Type of mapping from binding identifiers to bound nodes. This type
120 /// is an associative container with a key type of \c std::string and a value
121 /// type of \c clang::DynTypedNode
122 using IDToNodeMap = internal::BoundNodesMap::IDToNodeMap;
123
124 /// Retrieve mapping from binding identifiers to bound nodes.
125 const IDToNodeMap &getMap() const {
126 return MyBoundNodes.getMap();
127 }
128
129private:
130 friend class internal::BoundNodesTreeBuilder;
131
132 /// Create BoundNodes from a pre-filled map of bindings.
133 BoundNodes(internal::BoundNodesMap &MyBoundNodes)
134 : MyBoundNodes(MyBoundNodes) {}
135
136 internal::BoundNodesMap MyBoundNodes;
137};
138
139/// Types of matchers for the top-level classes in the AST class
140/// hierarchy.
141/// @{
142using DeclarationMatcher = internal::Matcher<Decl>;
143using StatementMatcher = internal::Matcher<Stmt>;
144using TypeMatcher = internal::Matcher<QualType>;
145using TypeLocMatcher = internal::Matcher<TypeLoc>;
146using NestedNameSpecifierMatcher = internal::Matcher<NestedNameSpecifier>;
147using NestedNameSpecifierLocMatcher = internal::Matcher<NestedNameSpecifierLoc>;
148using CXXBaseSpecifierMatcher = internal::Matcher<CXXBaseSpecifier>;
149using CXXCtorInitializerMatcher = internal::Matcher<CXXCtorInitializer>;
150using TemplateArgumentMatcher = internal::Matcher<TemplateArgument>;
151using TemplateArgumentLocMatcher = internal::Matcher<TemplateArgumentLoc>;
152using LambdaCaptureMatcher = internal::Matcher<LambdaCapture>;
153using AttrMatcher = internal::Matcher<Attr>;
154/// @}
155
156/// Matches any node.
157///
158/// Useful when another matcher requires a child matcher, but there's no
159/// additional constraint. This will often be used with an explicit conversion
160/// to an \c internal::Matcher<> type such as \c TypeMatcher.
161///
162/// Example: \c DeclarationMatcher(anything()) matches all declarations, e.g.,
163/// \code
164/// "int* p" and "void f()" in
165/// int* p;
166/// void f();
167/// \endcode
168///
169/// Usable as: Any Matcher
170inline internal::TrueMatcher anything() { return internal::TrueMatcher(); }
171
172/// Matches the top declaration context.
173///
174/// Given
175/// \code
176/// int X;
177/// namespace NS {
178/// int Y;
179/// } // namespace NS
180/// \endcode
181/// decl(hasDeclContext(translationUnitDecl()))
182/// matches "int X", but not "int Y".
183extern const internal::VariadicDynCastAllOfMatcher<Decl, TranslationUnitDecl>
184 translationUnitDecl;
185
186/// Matches typedef declarations.
187///
188/// Given
189/// \code
190/// typedef int X;
191/// using Y = int;
192/// \endcode
193/// typedefDecl()
194/// matches "typedef int X", but not "using Y = int"
195extern const internal::VariadicDynCastAllOfMatcher<Decl, TypedefDecl>
196 typedefDecl;
197
198/// Matches typedef name declarations.
199///
200/// Given
201/// \code
202/// typedef int X;
203/// using Y = int;
204/// \endcode
205/// typedefNameDecl()
206/// matches "typedef int X" and "using Y = int"
207extern const internal::VariadicDynCastAllOfMatcher<Decl, TypedefNameDecl>
208 typedefNameDecl;
209
210/// Matches type alias declarations.
211///
212/// Given
213/// \code
214/// typedef int X;
215/// using Y = int;
216/// \endcode
217/// typeAliasDecl()
218/// matches "using Y = int", but not "typedef int X"
219extern const internal::VariadicDynCastAllOfMatcher<Decl, TypeAliasDecl>
220 typeAliasDecl;
221
222/// Matches type alias template declarations.
223///
224/// typeAliasTemplateDecl() matches
225/// \code
226/// template <typename T>
227/// using Y = X<T>;
228/// \endcode
229extern const internal::VariadicDynCastAllOfMatcher<Decl, TypeAliasTemplateDecl>
230 typeAliasTemplateDecl;
231
232/// Matches AST nodes that were expanded within the main-file.
233///
234/// Example matches X but not Y
235/// (matcher = cxxRecordDecl(isExpansionInMainFile())
236/// \code
237/// #include <Y.h>
238/// class X {};
239/// \endcode
240/// Y.h:
241/// \code
242/// class Y {};
243/// \endcode
244///
245/// Usable as: Matcher<Decl>, Matcher<Stmt>, Matcher<TypeLoc>
246AST_POLYMORPHIC_MATCHER(isExpansionInMainFile,namespace internal { template <typename NodeType> class
matcher_isExpansionInMainFileMatcher : public ::clang::ast_matchers
::internal::MatcherInterface<NodeType> { public: bool matches
(const NodeType &Node, ::clang::ast_matchers::internal::ASTMatchFinder
*Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; }; } inline ::clang::ast_matchers::
internal::PolymorphicMatcher< internal::matcher_isExpansionInMainFileMatcher
, void(::clang::ast_matchers::internal::TypeList<Decl, Stmt
, TypeLoc>)> isExpansionInMainFile() { return ::clang::
ast_matchers::internal::PolymorphicMatcher< internal::matcher_isExpansionInMainFileMatcher
, void(::clang::ast_matchers::internal::TypeList<Decl, Stmt
, TypeLoc>)>(); } template <typename NodeType> bool
internal::matcher_isExpansionInMainFileMatcher<NodeType>
::matches( const NodeType &Node, ::clang::ast_matchers::internal
::ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
247 AST_POLYMORPHIC_SUPPORTED_TYPES(Decl, Stmt, TypeLoc))namespace internal { template <typename NodeType> class
matcher_isExpansionInMainFileMatcher : public ::clang::ast_matchers
::internal::MatcherInterface<NodeType> { public: bool matches
(const NodeType &Node, ::clang::ast_matchers::internal::ASTMatchFinder
*Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; }; } inline ::clang::ast_matchers::
internal::PolymorphicMatcher< internal::matcher_isExpansionInMainFileMatcher
, void(::clang::ast_matchers::internal::TypeList<Decl, Stmt
, TypeLoc>)> isExpansionInMainFile() { return ::clang::
ast_matchers::internal::PolymorphicMatcher< internal::matcher_isExpansionInMainFileMatcher
, void(::clang::ast_matchers::internal::TypeList<Decl, Stmt
, TypeLoc>)>(); } template <typename NodeType> bool
internal::matcher_isExpansionInMainFileMatcher<NodeType>
::matches( const NodeType &Node, ::clang::ast_matchers::internal
::ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
248 auto &SourceManager = Finder->getASTContext().getSourceManager();
249 return SourceManager.isInMainFile(
250 SourceManager.getExpansionLoc(Node.getBeginLoc()));
251}
252
253/// Matches AST nodes that were expanded within system-header-files.
254///
255/// Example matches Y but not X
256/// (matcher = cxxRecordDecl(isExpansionInSystemHeader())
257/// \code
258/// #include <SystemHeader.h>
259/// class X {};
260/// \endcode
261/// SystemHeader.h:
262/// \code
263/// class Y {};
264/// \endcode
265///
266/// Usable as: Matcher<Decl>, Matcher<Stmt>, Matcher<TypeLoc>
267AST_POLYMORPHIC_MATCHER(isExpansionInSystemHeader,namespace internal { template <typename NodeType> class
matcher_isExpansionInSystemHeaderMatcher : public ::clang::ast_matchers
::internal::MatcherInterface<NodeType> { public: bool matches
(const NodeType &Node, ::clang::ast_matchers::internal::ASTMatchFinder
*Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; }; } inline ::clang::ast_matchers::
internal::PolymorphicMatcher< internal::matcher_isExpansionInSystemHeaderMatcher
, void(::clang::ast_matchers::internal::TypeList<Decl, Stmt
, TypeLoc>)> isExpansionInSystemHeader() { return ::clang
::ast_matchers::internal::PolymorphicMatcher< internal::matcher_isExpansionInSystemHeaderMatcher
, void(::clang::ast_matchers::internal::TypeList<Decl, Stmt
, TypeLoc>)>(); } template <typename NodeType> bool
internal::matcher_isExpansionInSystemHeaderMatcher<NodeType
>::matches( const NodeType &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
268 AST_POLYMORPHIC_SUPPORTED_TYPES(Decl, Stmt, TypeLoc))namespace internal { template <typename NodeType> class
matcher_isExpansionInSystemHeaderMatcher : public ::clang::ast_matchers
::internal::MatcherInterface<NodeType> { public: bool matches
(const NodeType &Node, ::clang::ast_matchers::internal::ASTMatchFinder
*Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; }; } inline ::clang::ast_matchers::
internal::PolymorphicMatcher< internal::matcher_isExpansionInSystemHeaderMatcher
, void(::clang::ast_matchers::internal::TypeList<Decl, Stmt
, TypeLoc>)> isExpansionInSystemHeader() { return ::clang
::ast_matchers::internal::PolymorphicMatcher< internal::matcher_isExpansionInSystemHeaderMatcher
, void(::clang::ast_matchers::internal::TypeList<Decl, Stmt
, TypeLoc>)>(); } template <typename NodeType> bool
internal::matcher_isExpansionInSystemHeaderMatcher<NodeType
>::matches( const NodeType &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
{
269 auto &SourceManager = Finder->getASTContext().getSourceManager();
270 auto ExpansionLoc = SourceManager.getExpansionLoc(Node.getBeginLoc());
271 if (ExpansionLoc.isInvalid()) {
272 return false;
273 }
274 return SourceManager.isInSystemHeader(ExpansionLoc);
275}
276
277/// Matches AST nodes that were expanded within files whose name is
278/// partially matching a given regex.
279///
280/// Example matches Y but not X
281/// (matcher = cxxRecordDecl(isExpansionInFileMatching("AST.*"))
282/// \code
283/// #include "ASTMatcher.h"
284/// class X {};
285/// \endcode
286/// ASTMatcher.h:
287/// \code
288/// class Y {};
289/// \endcode
290///
291/// Usable as: Matcher<Decl>, Matcher<Stmt>, Matcher<TypeLoc>
292AST_POLYMORPHIC_MATCHER_REGEX(isExpansionInFileMatching,namespace internal { template <typename NodeType, typename
ParamT> class matcher_isExpansionInFileMatching0Matcher :
public ::clang::ast_matchers::internal::MatcherInterface<
NodeType> { public: explicit matcher_isExpansionInFileMatching0Matcher
( std::shared_ptr<llvm::Regex> RE) : RegExp(std::move(RE
)) {} bool matches(const NodeType &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const override; private: std
::shared_ptr<llvm::Regex> RegExp; }; } inline ::clang::
ast_matchers::internal::PolymorphicMatcher< internal::matcher_isExpansionInFileMatching0Matcher
, void(::clang::ast_matchers::internal::TypeList<Decl, Stmt
, TypeLoc>), std::shared_ptr<llvm::Regex>> isExpansionInFileMatching
(llvm::StringRef RegExp, llvm::Regex::RegexFlags RegexFlags) {
return ::clang::ast_matchers::internal::PolymorphicMatcher<
internal::matcher_isExpansionInFileMatching0Matcher, void(::
clang::ast_matchers::internal::TypeList<Decl, Stmt, TypeLoc
>), std::shared_ptr<llvm::Regex>>( ::clang::ast_matchers
::internal::createAndVerifyRegex( RegExp, RegexFlags, "isExpansionInFileMatching"
)); } inline ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_isExpansionInFileMatching0Matcher, void
(::clang::ast_matchers::internal::TypeList<Decl, Stmt, TypeLoc
>), std::shared_ptr<llvm::Regex>> isExpansionInFileMatching
(llvm::StringRef RegExp) { return isExpansionInFileMatching(RegExp
, llvm::Regex::NoFlags); } typedef ::clang::ast_matchers::internal
::PolymorphicMatcher< internal::matcher_isExpansionInFileMatching0Matcher
, void(::clang::ast_matchers::internal::TypeList<Decl, Stmt
, TypeLoc>), std::shared_ptr<llvm::Regex>> ( &
isExpansionInFileMatching_Type0Flags)( llvm::StringRef RegExp
, llvm::Regex::RegexFlags RegexFlags); typedef ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_isExpansionInFileMatching0Matcher
, void(::clang::ast_matchers::internal::TypeList<Decl, Stmt
, TypeLoc>), std::shared_ptr<llvm::Regex>> (&
isExpansionInFileMatching_Type0)( llvm::StringRef RegExp); template
<typename NodeType, typename ParamT> bool internal:: matcher_isExpansionInFileMatching0Matcher
<NodeType, ParamT>::matches( const NodeType &Node, ::
clang::ast_matchers::internal::ASTMatchFinder *Finder, ::clang
::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
293 AST_POLYMORPHIC_SUPPORTED_TYPES(Decl, Stmt,namespace internal { template <typename NodeType, typename
ParamT> class matcher_isExpansionInFileMatching0Matcher :
public ::clang::ast_matchers::internal::MatcherInterface<
NodeType> { public: explicit matcher_isExpansionInFileMatching0Matcher
( std::shared_ptr<llvm::Regex> RE) : RegExp(std::move(RE
)) {} bool matches(const NodeType &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const override; private: std
::shared_ptr<llvm::Regex> RegExp; }; } inline ::clang::
ast_matchers::internal::PolymorphicMatcher< internal::matcher_isExpansionInFileMatching0Matcher
, void(::clang::ast_matchers::internal::TypeList<Decl, Stmt
, TypeLoc>), std::shared_ptr<llvm::Regex>> isExpansionInFileMatching
(llvm::StringRef RegExp, llvm::Regex::RegexFlags RegexFlags) {
return ::clang::ast_matchers::internal::PolymorphicMatcher<
internal::matcher_isExpansionInFileMatching0Matcher, void(::
clang::ast_matchers::internal::TypeList<Decl, Stmt, TypeLoc
>), std::shared_ptr<llvm::Regex>>( ::clang::ast_matchers
::internal::createAndVerifyRegex( RegExp, RegexFlags, "isExpansionInFileMatching"
)); } inline ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_isExpansionInFileMatching0Matcher, void
(::clang::ast_matchers::internal::TypeList<Decl, Stmt, TypeLoc
>), std::shared_ptr<llvm::Regex>> isExpansionInFileMatching
(llvm::StringRef RegExp) { return isExpansionInFileMatching(RegExp
, llvm::Regex::NoFlags); } typedef ::clang::ast_matchers::internal
::PolymorphicMatcher< internal::matcher_isExpansionInFileMatching0Matcher
, void(::clang::ast_matchers::internal::TypeList<Decl, Stmt
, TypeLoc>), std::shared_ptr<llvm::Regex>> ( &
isExpansionInFileMatching_Type0Flags)( llvm::StringRef RegExp
, llvm::Regex::RegexFlags RegexFlags); typedef ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_isExpansionInFileMatching0Matcher
, void(::clang::ast_matchers::internal::TypeList<Decl, Stmt
, TypeLoc>), std::shared_ptr<llvm::Regex>> (&
isExpansionInFileMatching_Type0)( llvm::StringRef RegExp); template
<typename NodeType, typename ParamT> bool internal:: matcher_isExpansionInFileMatching0Matcher
<NodeType, ParamT>::matches( const NodeType &Node, ::
clang::ast_matchers::internal::ASTMatchFinder *Finder, ::clang
::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
294 TypeLoc),namespace internal { template <typename NodeType, typename
ParamT> class matcher_isExpansionInFileMatching0Matcher :
public ::clang::ast_matchers::internal::MatcherInterface<
NodeType> { public: explicit matcher_isExpansionInFileMatching0Matcher
( std::shared_ptr<llvm::Regex> RE) : RegExp(std::move(RE
)) {} bool matches(const NodeType &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const override; private: std
::shared_ptr<llvm::Regex> RegExp; }; } inline ::clang::
ast_matchers::internal::PolymorphicMatcher< internal::matcher_isExpansionInFileMatching0Matcher
, void(::clang::ast_matchers::internal::TypeList<Decl, Stmt
, TypeLoc>), std::shared_ptr<llvm::Regex>> isExpansionInFileMatching
(llvm::StringRef RegExp, llvm::Regex::RegexFlags RegexFlags) {
return ::clang::ast_matchers::internal::PolymorphicMatcher<
internal::matcher_isExpansionInFileMatching0Matcher, void(::
clang::ast_matchers::internal::TypeList<Decl, Stmt, TypeLoc
>), std::shared_ptr<llvm::Regex>>( ::clang::ast_matchers
::internal::createAndVerifyRegex( RegExp, RegexFlags, "isExpansionInFileMatching"
)); } inline ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_isExpansionInFileMatching0Matcher, void
(::clang::ast_matchers::internal::TypeList<Decl, Stmt, TypeLoc
>), std::shared_ptr<llvm::Regex>> isExpansionInFileMatching
(llvm::StringRef RegExp) { return isExpansionInFileMatching(RegExp
, llvm::Regex::NoFlags); } typedef ::clang::ast_matchers::internal
::PolymorphicMatcher< internal::matcher_isExpansionInFileMatching0Matcher
, void(::clang::ast_matchers::internal::TypeList<Decl, Stmt
, TypeLoc>), std::shared_ptr<llvm::Regex>> ( &
isExpansionInFileMatching_Type0Flags)( llvm::StringRef RegExp
, llvm::Regex::RegexFlags RegexFlags); typedef ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_isExpansionInFileMatching0Matcher
, void(::clang::ast_matchers::internal::TypeList<Decl, Stmt
, TypeLoc>), std::shared_ptr<llvm::Regex>> (&
isExpansionInFileMatching_Type0)( llvm::StringRef RegExp); template
<typename NodeType, typename ParamT> bool internal:: matcher_isExpansionInFileMatching0Matcher
<NodeType, ParamT>::matches( const NodeType &Node, ::
clang::ast_matchers::internal::ASTMatchFinder *Finder, ::clang
::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
295 RegExp)namespace internal { template <typename NodeType, typename
ParamT> class matcher_isExpansionInFileMatching0Matcher :
public ::clang::ast_matchers::internal::MatcherInterface<
NodeType> { public: explicit matcher_isExpansionInFileMatching0Matcher
( std::shared_ptr<llvm::Regex> RE) : RegExp(std::move(RE
)) {} bool matches(const NodeType &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const override; private: std
::shared_ptr<llvm::Regex> RegExp; }; } inline ::clang::
ast_matchers::internal::PolymorphicMatcher< internal::matcher_isExpansionInFileMatching0Matcher
, void(::clang::ast_matchers::internal::TypeList<Decl, Stmt
, TypeLoc>), std::shared_ptr<llvm::Regex>> isExpansionInFileMatching
(llvm::StringRef RegExp, llvm::Regex::RegexFlags RegexFlags) {
return ::clang::ast_matchers::internal::PolymorphicMatcher<
internal::matcher_isExpansionInFileMatching0Matcher, void(::
clang::ast_matchers::internal::TypeList<Decl, Stmt, TypeLoc
>), std::shared_ptr<llvm::Regex>>( ::clang::ast_matchers
::internal::createAndVerifyRegex( RegExp, RegexFlags, "isExpansionInFileMatching"
)); } inline ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_isExpansionInFileMatching0Matcher, void
(::clang::ast_matchers::internal::TypeList<Decl, Stmt, TypeLoc
>), std::shared_ptr<llvm::Regex>> isExpansionInFileMatching
(llvm::StringRef RegExp) { return isExpansionInFileMatching(RegExp
, llvm::Regex::NoFlags); } typedef ::clang::ast_matchers::internal
::PolymorphicMatcher< internal::matcher_isExpansionInFileMatching0Matcher
, void(::clang::ast_matchers::internal::TypeList<Decl, Stmt
, TypeLoc>), std::shared_ptr<llvm::Regex>> ( &
isExpansionInFileMatching_Type0Flags)( llvm::StringRef RegExp
, llvm::Regex::RegexFlags RegexFlags); typedef ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_isExpansionInFileMatching0Matcher
, void(::clang::ast_matchers::internal::TypeList<Decl, Stmt
, TypeLoc>), std::shared_ptr<llvm::Regex>> (&
isExpansionInFileMatching_Type0)( llvm::StringRef RegExp); template
<typename NodeType, typename ParamT> bool internal:: matcher_isExpansionInFileMatching0Matcher
<NodeType, ParamT>::matches( const NodeType &Node, ::
clang::ast_matchers::internal::ASTMatchFinder *Finder, ::clang
::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
{
296 auto &SourceManager = Finder->getASTContext().getSourceManager();
297 auto ExpansionLoc = SourceManager.getExpansionLoc(Node.getBeginLoc());
298 if (ExpansionLoc.isInvalid()) {
299 return false;
300 }
301 auto FileEntry =
302 SourceManager.getFileEntryForID(SourceManager.getFileID(ExpansionLoc));
303 if (!FileEntry) {
304 return false;
305 }
306
307 auto Filename = FileEntry->getName();
308 return RegExp->match(Filename);
309}
310
311/// Matches statements that are (transitively) expanded from the named macro.
312/// Does not match if only part of the statement is expanded from that macro or
313/// if different parts of the statement are expanded from different
314/// appearances of the macro.
315AST_POLYMORPHIC_MATCHER_P(isExpandedFromMacro,namespace internal { template <typename NodeType, typename
ParamT> class matcher_isExpandedFromMacro0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<NodeType
> { public: explicit matcher_isExpandedFromMacro0Matcher( std
::string const &AMacroName) : MacroName(AMacroName) {} bool
matches(const NodeType &Node, ::clang::ast_matchers::internal
::ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: std::string MacroName; };
} inline ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_isExpandedFromMacro0Matcher, void(::clang
::ast_matchers::internal::TypeList<Decl, Stmt, TypeLoc>
), std::string> isExpandedFromMacro(std::string const &
MacroName) { return ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_isExpandedFromMacro0Matcher, void(::clang
::ast_matchers::internal::TypeList<Decl, Stmt, TypeLoc>
), std::string>(MacroName); } typedef ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_isExpandedFromMacro0Matcher
, void(::clang::ast_matchers::internal::TypeList<Decl, Stmt
, TypeLoc>), std::string> (&isExpandedFromMacro_Type0
)(std::string const &MacroName); template <typename NodeType
, typename ParamT> bool internal:: matcher_isExpandedFromMacro0Matcher
<NodeType, ParamT>::matches( const NodeType &Node, ::
clang::ast_matchers::internal::ASTMatchFinder *Finder, ::clang
::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
316 AST_POLYMORPHIC_SUPPORTED_TYPES(Decl, Stmt, TypeLoc),namespace internal { template <typename NodeType, typename
ParamT> class matcher_isExpandedFromMacro0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<NodeType
> { public: explicit matcher_isExpandedFromMacro0Matcher( std
::string const &AMacroName) : MacroName(AMacroName) {} bool
matches(const NodeType &Node, ::clang::ast_matchers::internal
::ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: std::string MacroName; };
} inline ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_isExpandedFromMacro0Matcher, void(::clang
::ast_matchers::internal::TypeList<Decl, Stmt, TypeLoc>
), std::string> isExpandedFromMacro(std::string const &
MacroName) { return ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_isExpandedFromMacro0Matcher, void(::clang
::ast_matchers::internal::TypeList<Decl, Stmt, TypeLoc>
), std::string>(MacroName); } typedef ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_isExpandedFromMacro0Matcher
, void(::clang::ast_matchers::internal::TypeList<Decl, Stmt
, TypeLoc>), std::string> (&isExpandedFromMacro_Type0
)(std::string const &MacroName); template <typename NodeType
, typename ParamT> bool internal:: matcher_isExpandedFromMacro0Matcher
<NodeType, ParamT>::matches( const NodeType &Node, ::
clang::ast_matchers::internal::ASTMatchFinder *Finder, ::clang
::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
317 std::string, MacroName)namespace internal { template <typename NodeType, typename
ParamT> class matcher_isExpandedFromMacro0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<NodeType
> { public: explicit matcher_isExpandedFromMacro0Matcher( std
::string const &AMacroName) : MacroName(AMacroName) {} bool
matches(const NodeType &Node, ::clang::ast_matchers::internal
::ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: std::string MacroName; };
} inline ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_isExpandedFromMacro0Matcher, void(::clang
::ast_matchers::internal::TypeList<Decl, Stmt, TypeLoc>
), std::string> isExpandedFromMacro(std::string const &
MacroName) { return ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_isExpandedFromMacro0Matcher, void(::clang
::ast_matchers::internal::TypeList<Decl, Stmt, TypeLoc>
), std::string>(MacroName); } typedef ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_isExpandedFromMacro0Matcher
, void(::clang::ast_matchers::internal::TypeList<Decl, Stmt
, TypeLoc>), std::string> (&isExpandedFromMacro_Type0
)(std::string const &MacroName); template <typename NodeType
, typename ParamT> bool internal:: matcher_isExpandedFromMacro0Matcher
<NodeType, ParamT>::matches( const NodeType &Node, ::
clang::ast_matchers::internal::ASTMatchFinder *Finder, ::clang
::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
{
318 // Verifies that the statement' beginning and ending are both expanded from
319 // the same instance of the given macro.
320 auto& Context = Finder->getASTContext();
321 std::optional<SourceLocation> B =
322 internal::getExpansionLocOfMacro(MacroName, Node.getBeginLoc(), Context);
323 if (!B) return false;
324 std::optional<SourceLocation> E =
325 internal::getExpansionLocOfMacro(MacroName, Node.getEndLoc(), Context);
326 if (!E) return false;
327 return *B == *E;
328}
329
330/// Matches declarations.
331///
332/// Examples matches \c X, \c C, and the friend declaration inside \c C;
333/// \code
334/// void X();
335/// class C {
336/// friend X;
337/// };
338/// \endcode
339extern const internal::VariadicAllOfMatcher<Decl> decl;
340
341/// Matches decomposition-declarations.
342///
343/// Examples matches the declaration node with \c foo and \c bar, but not
344/// \c number.
345/// (matcher = declStmt(has(decompositionDecl())))
346///
347/// \code
348/// int number = 42;
349/// auto [foo, bar] = std::make_pair{42, 42};
350/// \endcode
351extern const internal::VariadicDynCastAllOfMatcher<Decl, DecompositionDecl>
352 decompositionDecl;
353
354/// Matches binding declarations
355/// Example matches \c foo and \c bar
356/// (matcher = bindingDecl()
357///
358/// \code
359/// auto [foo, bar] = std::make_pair{42, 42};
360/// \endcode
361extern const internal::VariadicDynCastAllOfMatcher<Decl, BindingDecl>
362 bindingDecl;
363
364/// Matches a declaration of a linkage specification.
365///
366/// Given
367/// \code
368/// extern "C" {}
369/// \endcode
370/// linkageSpecDecl()
371/// matches "extern "C" {}"
372extern const internal::VariadicDynCastAllOfMatcher<Decl, LinkageSpecDecl>
373 linkageSpecDecl;
374
375/// Matches a declaration of anything that could have a name.
376///
377/// Example matches \c X, \c S, the anonymous union type, \c i, and \c U;
378/// \code
379/// typedef int X;
380/// struct S {
381/// union {
382/// int i;
383/// } U;
384/// };
385/// \endcode
386extern const internal::VariadicDynCastAllOfMatcher<Decl, NamedDecl> namedDecl;
387
388/// Matches a declaration of label.
389///
390/// Given
391/// \code
392/// goto FOO;
393/// FOO: bar();
394/// \endcode
395/// labelDecl()
396/// matches 'FOO:'
397extern const internal::VariadicDynCastAllOfMatcher<Decl, LabelDecl> labelDecl;
398
399/// Matches a declaration of a namespace.
400///
401/// Given
402/// \code
403/// namespace {}
404/// namespace test {}
405/// \endcode
406/// namespaceDecl()
407/// matches "namespace {}" and "namespace test {}"
408extern const internal::VariadicDynCastAllOfMatcher<Decl, NamespaceDecl>
409 namespaceDecl;
410
411/// Matches a declaration of a namespace alias.
412///
413/// Given
414/// \code
415/// namespace test {}
416/// namespace alias = ::test;
417/// \endcode
418/// namespaceAliasDecl()
419/// matches "namespace alias" but not "namespace test"
420extern const internal::VariadicDynCastAllOfMatcher<Decl, NamespaceAliasDecl>
421 namespaceAliasDecl;
422
423/// Matches class, struct, and union declarations.
424///
425/// Example matches \c X, \c Z, \c U, and \c S
426/// \code
427/// class X;
428/// template<class T> class Z {};
429/// struct S {};
430/// union U {};
431/// \endcode
432extern const internal::VariadicDynCastAllOfMatcher<Decl, RecordDecl> recordDecl;
433
434/// Matches C++ class declarations.
435///
436/// Example matches \c X, \c Z
437/// \code
438/// class X;
439/// template<class T> class Z {};
440/// \endcode
441extern const internal::VariadicDynCastAllOfMatcher<Decl, CXXRecordDecl>
442 cxxRecordDecl;
443
444/// Matches C++ class template declarations.
445///
446/// Example matches \c Z
447/// \code
448/// template<class T> class Z {};
449/// \endcode
450extern const internal::VariadicDynCastAllOfMatcher<Decl, ClassTemplateDecl>
451 classTemplateDecl;
452
453/// Matches C++ class template specializations.
454///
455/// Given
456/// \code
457/// template<typename T> class A {};
458/// template<> class A<double> {};
459/// A<int> a;
460/// \endcode
461/// classTemplateSpecializationDecl()
462/// matches the specializations \c A<int> and \c A<double>
463extern const internal::VariadicDynCastAllOfMatcher<
464 Decl, ClassTemplateSpecializationDecl>
465 classTemplateSpecializationDecl;
466
467/// Matches C++ class template partial specializations.
468///
469/// Given
470/// \code
471/// template<class T1, class T2, int I>
472/// class A {};
473///
474/// template<class T, int I>
475/// class A<T, T*, I> {};
476///
477/// template<>
478/// class A<int, int, 1> {};
479/// \endcode
480/// classTemplatePartialSpecializationDecl()
481/// matches the specialization \c A<T,T*,I> but not \c A<int,int,1>
482extern const internal::VariadicDynCastAllOfMatcher<
483 Decl, ClassTemplatePartialSpecializationDecl>
484 classTemplatePartialSpecializationDecl;
485
486/// Matches declarator declarations (field, variable, function
487/// and non-type template parameter declarations).
488///
489/// Given
490/// \code
491/// class X { int y; };
492/// \endcode
493/// declaratorDecl()
494/// matches \c int y.
495extern const internal::VariadicDynCastAllOfMatcher<Decl, DeclaratorDecl>
496 declaratorDecl;
497
498/// Matches parameter variable declarations.
499///
500/// Given
501/// \code
502/// void f(int x);
503/// \endcode
504/// parmVarDecl()
505/// matches \c int x.
506extern const internal::VariadicDynCastAllOfMatcher<Decl, ParmVarDecl>
507 parmVarDecl;
508
509/// Matches C++ access specifier declarations.
510///
511/// Given
512/// \code
513/// class C {
514/// public:
515/// int a;
516/// };
517/// \endcode
518/// accessSpecDecl()
519/// matches 'public:'
520extern const internal::VariadicDynCastAllOfMatcher<Decl, AccessSpecDecl>
521 accessSpecDecl;
522
523/// Matches class bases.
524///
525/// Examples matches \c public virtual B.
526/// \code
527/// class B {};
528/// class C : public virtual B {};
529/// \endcode
530extern const internal::VariadicAllOfMatcher<CXXBaseSpecifier> cxxBaseSpecifier;
531
532/// Matches constructor initializers.
533///
534/// Examples matches \c i(42).
535/// \code
536/// class C {
537/// C() : i(42) {}
538/// int i;
539/// };
540/// \endcode
541extern const internal::VariadicAllOfMatcher<CXXCtorInitializer>
542 cxxCtorInitializer;
543
544/// Matches template arguments.
545///
546/// Given
547/// \code
548/// template <typename T> struct C {};
549/// C<int> c;
550/// \endcode
551/// templateArgument()
552/// matches 'int' in C<int>.
553extern const internal::VariadicAllOfMatcher<TemplateArgument> templateArgument;
554
555/// Matches template arguments (with location info).
556///
557/// Given
558/// \code
559/// template <typename T> struct C {};
560/// C<int> c;
561/// \endcode
562/// templateArgumentLoc()
563/// matches 'int' in C<int>.
564extern const internal::VariadicAllOfMatcher<TemplateArgumentLoc>
565 templateArgumentLoc;
566
567/// Matches template name.
568///
569/// Given
570/// \code
571/// template <typename T> class X { };
572/// X<int> xi;
573/// \endcode
574/// templateName()
575/// matches 'X' in X<int>.
576extern const internal::VariadicAllOfMatcher<TemplateName> templateName;
577
578/// Matches non-type template parameter declarations.
579///
580/// Given
581/// \code
582/// template <typename T, int N> struct C {};
583/// \endcode
584/// nonTypeTemplateParmDecl()
585/// matches 'N', but not 'T'.
586extern const internal::VariadicDynCastAllOfMatcher<Decl,
587 NonTypeTemplateParmDecl>
588 nonTypeTemplateParmDecl;
589
590/// Matches template type parameter declarations.
591///
592/// Given
593/// \code
594/// template <typename T, int N> struct C {};
595/// \endcode
596/// templateTypeParmDecl()
597/// matches 'T', but not 'N'.
598extern const internal::VariadicDynCastAllOfMatcher<Decl, TemplateTypeParmDecl>
599 templateTypeParmDecl;
600
601/// Matches template template parameter declarations.
602///
603/// Given
604/// \code
605/// template <template <typename> class Z, int N> struct C {};
606/// \endcode
607/// templateTypeParmDecl()
608/// matches 'Z', but not 'N'.
609extern const internal::VariadicDynCastAllOfMatcher<Decl,
610 TemplateTemplateParmDecl>
611 templateTemplateParmDecl;
612
613/// Matches public C++ declarations and C++ base specifers that specify public
614/// inheritance.
615///
616/// Examples:
617/// \code
618/// class C {
619/// public: int a; // fieldDecl(isPublic()) matches 'a'
620/// protected: int b;
621/// private: int c;
622/// };
623/// \endcode
624///
625/// \code
626/// class Base {};
627/// class Derived1 : public Base {}; // matches 'Base'
628/// struct Derived2 : Base {}; // matches 'Base'
629/// \endcode
630AST_POLYMORPHIC_MATCHER(isPublic,namespace internal { template <typename NodeType> class
matcher_isPublicMatcher : public ::clang::ast_matchers::internal
::MatcherInterface<NodeType> { public: bool matches(const
NodeType &Node, ::clang::ast_matchers::internal::ASTMatchFinder
*Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; }; } inline ::clang::ast_matchers::
internal::PolymorphicMatcher< internal::matcher_isPublicMatcher
, void(::clang::ast_matchers::internal::TypeList<Decl, CXXBaseSpecifier
>)> isPublic() { return ::clang::ast_matchers::internal
::PolymorphicMatcher< internal::matcher_isPublicMatcher, void
(::clang::ast_matchers::internal::TypeList<Decl, CXXBaseSpecifier
>)>(); } template <typename NodeType> bool internal
::matcher_isPublicMatcher<NodeType>::matches( const NodeType
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
631 AST_POLYMORPHIC_SUPPORTED_TYPES(Decl,namespace internal { template <typename NodeType> class
matcher_isPublicMatcher : public ::clang::ast_matchers::internal
::MatcherInterface<NodeType> { public: bool matches(const
NodeType &Node, ::clang::ast_matchers::internal::ASTMatchFinder
*Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; }; } inline ::clang::ast_matchers::
internal::PolymorphicMatcher< internal::matcher_isPublicMatcher
, void(::clang::ast_matchers::internal::TypeList<Decl, CXXBaseSpecifier
>)> isPublic() { return ::clang::ast_matchers::internal
::PolymorphicMatcher< internal::matcher_isPublicMatcher, void
(::clang::ast_matchers::internal::TypeList<Decl, CXXBaseSpecifier
>)>(); } template <typename NodeType> bool internal
::matcher_isPublicMatcher<NodeType>::matches( const NodeType
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
632 CXXBaseSpecifier))namespace internal { template <typename NodeType> class
matcher_isPublicMatcher : public ::clang::ast_matchers::internal
::MatcherInterface<NodeType> { public: bool matches(const
NodeType &Node, ::clang::ast_matchers::internal::ASTMatchFinder
*Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; }; } inline ::clang::ast_matchers::
internal::PolymorphicMatcher< internal::matcher_isPublicMatcher
, void(::clang::ast_matchers::internal::TypeList<Decl, CXXBaseSpecifier
>)> isPublic() { return ::clang::ast_matchers::internal
::PolymorphicMatcher< internal::matcher_isPublicMatcher, void
(::clang::ast_matchers::internal::TypeList<Decl, CXXBaseSpecifier
>)>(); } template <typename NodeType> bool internal
::matcher_isPublicMatcher<NodeType>::matches( const NodeType
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
633 return getAccessSpecifier(Node) == AS_public;
634}
635
636/// Matches protected C++ declarations and C++ base specifers that specify
637/// protected inheritance.
638///
639/// Examples:
640/// \code
641/// class C {
642/// public: int a;
643/// protected: int b; // fieldDecl(isProtected()) matches 'b'
644/// private: int c;
645/// };
646/// \endcode
647///
648/// \code
649/// class Base {};
650/// class Derived : protected Base {}; // matches 'Base'
651/// \endcode
652AST_POLYMORPHIC_MATCHER(isProtected,namespace internal { template <typename NodeType> class
matcher_isProtectedMatcher : public ::clang::ast_matchers::internal
::MatcherInterface<NodeType> { public: bool matches(const
NodeType &Node, ::clang::ast_matchers::internal::ASTMatchFinder
*Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; }; } inline ::clang::ast_matchers::
internal::PolymorphicMatcher< internal::matcher_isProtectedMatcher
, void(::clang::ast_matchers::internal::TypeList<Decl, CXXBaseSpecifier
>)> isProtected() { return ::clang::ast_matchers::internal
::PolymorphicMatcher< internal::matcher_isProtectedMatcher
, void(::clang::ast_matchers::internal::TypeList<Decl, CXXBaseSpecifier
>)>(); } template <typename NodeType> bool internal
::matcher_isProtectedMatcher<NodeType>::matches( const NodeType
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
653 AST_POLYMORPHIC_SUPPORTED_TYPES(Decl,namespace internal { template <typename NodeType> class
matcher_isProtectedMatcher : public ::clang::ast_matchers::internal
::MatcherInterface<NodeType> { public: bool matches(const
NodeType &Node, ::clang::ast_matchers::internal::ASTMatchFinder
*Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; }; } inline ::clang::ast_matchers::
internal::PolymorphicMatcher< internal::matcher_isProtectedMatcher
, void(::clang::ast_matchers::internal::TypeList<Decl, CXXBaseSpecifier
>)> isProtected() { return ::clang::ast_matchers::internal
::PolymorphicMatcher< internal::matcher_isProtectedMatcher
, void(::clang::ast_matchers::internal::TypeList<Decl, CXXBaseSpecifier
>)>(); } template <typename NodeType> bool internal
::matcher_isProtectedMatcher<NodeType>::matches( const NodeType
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
654 CXXBaseSpecifier))namespace internal { template <typename NodeType> class
matcher_isProtectedMatcher : public ::clang::ast_matchers::internal
::MatcherInterface<NodeType> { public: bool matches(const
NodeType &Node, ::clang::ast_matchers::internal::ASTMatchFinder
*Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; }; } inline ::clang::ast_matchers::
internal::PolymorphicMatcher< internal::matcher_isProtectedMatcher
, void(::clang::ast_matchers::internal::TypeList<Decl, CXXBaseSpecifier
>)> isProtected() { return ::clang::ast_matchers::internal
::PolymorphicMatcher< internal::matcher_isProtectedMatcher
, void(::clang::ast_matchers::internal::TypeList<Decl, CXXBaseSpecifier
>)>(); } template <typename NodeType> bool internal
::matcher_isProtectedMatcher<NodeType>::matches( const NodeType
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
655 return getAccessSpecifier(Node) == AS_protected;
656}
657
658/// Matches private C++ declarations and C++ base specifers that specify private
659/// inheritance.
660///
661/// Examples:
662/// \code
663/// class C {
664/// public: int a;
665/// protected: int b;
666/// private: int c; // fieldDecl(isPrivate()) matches 'c'
667/// };
668/// \endcode
669///
670/// \code
671/// struct Base {};
672/// struct Derived1 : private Base {}; // matches 'Base'
673/// class Derived2 : Base {}; // matches 'Base'
674/// \endcode
675AST_POLYMORPHIC_MATCHER(isPrivate,namespace internal { template <typename NodeType> class
matcher_isPrivateMatcher : public ::clang::ast_matchers::internal
::MatcherInterface<NodeType> { public: bool matches(const
NodeType &Node, ::clang::ast_matchers::internal::ASTMatchFinder
*Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; }; } inline ::clang::ast_matchers::
internal::PolymorphicMatcher< internal::matcher_isPrivateMatcher
, void(::clang::ast_matchers::internal::TypeList<Decl, CXXBaseSpecifier
>)> isPrivate() { return ::clang::ast_matchers::internal
::PolymorphicMatcher< internal::matcher_isPrivateMatcher, void
(::clang::ast_matchers::internal::TypeList<Decl, CXXBaseSpecifier
>)>(); } template <typename NodeType> bool internal
::matcher_isPrivateMatcher<NodeType>::matches( const NodeType
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
676 AST_POLYMORPHIC_SUPPORTED_TYPES(Decl,namespace internal { template <typename NodeType> class
matcher_isPrivateMatcher : public ::clang::ast_matchers::internal
::MatcherInterface<NodeType> { public: bool matches(const
NodeType &Node, ::clang::ast_matchers::internal::ASTMatchFinder
*Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; }; } inline ::clang::ast_matchers::
internal::PolymorphicMatcher< internal::matcher_isPrivateMatcher
, void(::clang::ast_matchers::internal::TypeList<Decl, CXXBaseSpecifier
>)> isPrivate() { return ::clang::ast_matchers::internal
::PolymorphicMatcher< internal::matcher_isPrivateMatcher, void
(::clang::ast_matchers::internal::TypeList<Decl, CXXBaseSpecifier
>)>(); } template <typename NodeType> bool internal
::matcher_isPrivateMatcher<NodeType>::matches( const NodeType
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
677 CXXBaseSpecifier))namespace internal { template <typename NodeType> class
matcher_isPrivateMatcher : public ::clang::ast_matchers::internal
::MatcherInterface<NodeType> { public: bool matches(const
NodeType &Node, ::clang::ast_matchers::internal::ASTMatchFinder
*Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; }; } inline ::clang::ast_matchers::
internal::PolymorphicMatcher< internal::matcher_isPrivateMatcher
, void(::clang::ast_matchers::internal::TypeList<Decl, CXXBaseSpecifier
>)> isPrivate() { return ::clang::ast_matchers::internal
::PolymorphicMatcher< internal::matcher_isPrivateMatcher, void
(::clang::ast_matchers::internal::TypeList<Decl, CXXBaseSpecifier
>)>(); } template <typename NodeType> bool internal
::matcher_isPrivateMatcher<NodeType>::matches( const NodeType
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
678 return getAccessSpecifier(Node) == AS_private;
679}
680
681/// Matches non-static data members that are bit-fields.
682///
683/// Given
684/// \code
685/// class C {
686/// int a : 2;
687/// int b;
688/// };
689/// \endcode
690/// fieldDecl(isBitField())
691/// matches 'int a;' but not 'int b;'.
692AST_MATCHER(FieldDecl, isBitField)namespace internal { class matcher_isBitFieldMatcher : public
::clang::ast_matchers::internal::MatcherInterface<FieldDecl
> { public: explicit matcher_isBitFieldMatcher() = default
; bool matches(const FieldDecl &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const override; }; } inline
::clang::ast_matchers::internal::Matcher<FieldDecl> isBitField
() { return ::clang::ast_matchers::internal::makeMatcher( new
internal::matcher_isBitFieldMatcher()); } inline bool internal
::matcher_isBitFieldMatcher::matches( const FieldDecl &Node
, ::clang::ast_matchers::internal::ASTMatchFinder *Finder, ::
clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder
) const
{
693 return Node.isBitField();
694}
695
696/// Matches non-static data members that are bit-fields of the specified
697/// bit width.
698///
699/// Given
700/// \code
701/// class C {
702/// int a : 2;
703/// int b : 4;
704/// int c : 2;
705/// };
706/// \endcode
707/// fieldDecl(hasBitWidth(2))
708/// matches 'int a;' and 'int c;' but not 'int b;'.
709AST_MATCHER_P(FieldDecl, hasBitWidth, unsigned, Width)namespace internal { class matcher_hasBitWidth0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<FieldDecl
> { public: explicit matcher_hasBitWidth0Matcher( unsigned
const &AWidth) : Width(AWidth) {} bool matches(const FieldDecl
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: unsigned Width; }; } inline
::clang::ast_matchers::internal::Matcher<FieldDecl> hasBitWidth
( unsigned const &Width) { return ::clang::ast_matchers::
internal::makeMatcher( new internal::matcher_hasBitWidth0Matcher
(Width)); } typedef ::clang::ast_matchers::internal::Matcher<
FieldDecl> ( &hasBitWidth_Type0)(unsigned const &Width
); inline bool internal::matcher_hasBitWidth0Matcher::matches
( const FieldDecl &Node, ::clang::ast_matchers::internal::
ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
710 return Node.isBitField() &&
711 Node.getBitWidthValue(Finder->getASTContext()) == Width;
712}
713
714/// Matches non-static data members that have an in-class initializer.
715///
716/// Given
717/// \code
718/// class C {
719/// int a = 2;
720/// int b = 3;
721/// int c;
722/// };
723/// \endcode
724/// fieldDecl(hasInClassInitializer(integerLiteral(equals(2))))
725/// matches 'int a;' but not 'int b;'.
726/// fieldDecl(hasInClassInitializer(anything()))
727/// matches 'int a;' and 'int b;' but not 'int c;'.
728AST_MATCHER_P(FieldDecl, hasInClassInitializer, internal::Matcher<Expr>,namespace internal { class matcher_hasInClassInitializer0Matcher
: public ::clang::ast_matchers::internal::MatcherInterface<
FieldDecl> { public: explicit matcher_hasInClassInitializer0Matcher
( internal::Matcher<Expr> const &AInnerMatcher) : InnerMatcher
(AInnerMatcher) {} bool matches(const FieldDecl &Node, ::
clang::ast_matchers::internal::ASTMatchFinder *Finder, ::clang
::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
override; private: internal::Matcher<Expr> InnerMatcher
; }; } inline ::clang::ast_matchers::internal::Matcher<FieldDecl
> hasInClassInitializer( internal::Matcher<Expr> const
&InnerMatcher) { return ::clang::ast_matchers::internal::
makeMatcher( new internal::matcher_hasInClassInitializer0Matcher
(InnerMatcher)); } typedef ::clang::ast_matchers::internal::Matcher
<FieldDecl> ( &hasInClassInitializer_Type0)(internal
::Matcher<Expr> const &InnerMatcher); inline bool internal
::matcher_hasInClassInitializer0Matcher::matches( const FieldDecl
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
729 InnerMatcher)namespace internal { class matcher_hasInClassInitializer0Matcher
: public ::clang::ast_matchers::internal::MatcherInterface<
FieldDecl> { public: explicit matcher_hasInClassInitializer0Matcher
( internal::Matcher<Expr> const &AInnerMatcher) : InnerMatcher
(AInnerMatcher) {} bool matches(const FieldDecl &Node, ::
clang::ast_matchers::internal::ASTMatchFinder *Finder, ::clang
::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
override; private: internal::Matcher<Expr> InnerMatcher
; }; } inline ::clang::ast_matchers::internal::Matcher<FieldDecl
> hasInClassInitializer( internal::Matcher<Expr> const
&InnerMatcher) { return ::clang::ast_matchers::internal::
makeMatcher( new internal::matcher_hasInClassInitializer0Matcher
(InnerMatcher)); } typedef ::clang::ast_matchers::internal::Matcher
<FieldDecl> ( &hasInClassInitializer_Type0)(internal
::Matcher<Expr> const &InnerMatcher); inline bool internal
::matcher_hasInClassInitializer0Matcher::matches( const FieldDecl
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
730 const Expr *Initializer = Node.getInClassInitializer();
731 return (Initializer != nullptr &&
732 InnerMatcher.matches(*Initializer, Finder, Builder));
733}
734
735/// Determines whether the function is "main", which is the entry point
736/// into an executable program.
737AST_MATCHER(FunctionDecl, isMain)namespace internal { class matcher_isMainMatcher : public ::clang
::ast_matchers::internal::MatcherInterface<FunctionDecl>
{ public: explicit matcher_isMainMatcher() = default; bool matches
(const FunctionDecl &Node, ::clang::ast_matchers::internal
::ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; }; } inline ::clang::ast_matchers::
internal::Matcher<FunctionDecl> isMain() { return ::clang
::ast_matchers::internal::makeMatcher( new internal::matcher_isMainMatcher
()); } inline bool internal::matcher_isMainMatcher::matches( const
FunctionDecl &Node, ::clang::ast_matchers::internal::ASTMatchFinder
*Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
738 return Node.isMain();
739}
740
741/// Matches the specialized template of a specialization declaration.
742///
743/// Given
744/// \code
745/// template<typename T> class A {}; #1
746/// template<> class A<int> {}; #2
747/// \endcode
748/// classTemplateSpecializationDecl(hasSpecializedTemplate(classTemplateDecl()))
749/// matches '#2' with classTemplateDecl() matching the class template
750/// declaration of 'A' at #1.
751AST_MATCHER_P(ClassTemplateSpecializationDecl, hasSpecializedTemplate,namespace internal { class matcher_hasSpecializedTemplate0Matcher
: public ::clang::ast_matchers::internal::MatcherInterface<
ClassTemplateSpecializationDecl> { public: explicit matcher_hasSpecializedTemplate0Matcher
( internal::Matcher<ClassTemplateDecl> const &AInnerMatcher
) : InnerMatcher(AInnerMatcher) {} bool matches(const ClassTemplateSpecializationDecl
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: internal::Matcher<ClassTemplateDecl
> InnerMatcher; }; } inline ::clang::ast_matchers::internal
::Matcher<ClassTemplateSpecializationDecl> hasSpecializedTemplate
( internal::Matcher<ClassTemplateDecl> const &InnerMatcher
) { return ::clang::ast_matchers::internal::makeMatcher( new internal
::matcher_hasSpecializedTemplate0Matcher(InnerMatcher)); } typedef
::clang::ast_matchers::internal::Matcher<ClassTemplateSpecializationDecl
> ( &hasSpecializedTemplate_Type0)(internal::Matcher<
ClassTemplateDecl> const &InnerMatcher); inline bool internal
::matcher_hasSpecializedTemplate0Matcher::matches( const ClassTemplateSpecializationDecl
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
752 internal::Matcher<ClassTemplateDecl>, InnerMatcher)namespace internal { class matcher_hasSpecializedTemplate0Matcher
: public ::clang::ast_matchers::internal::MatcherInterface<
ClassTemplateSpecializationDecl> { public: explicit matcher_hasSpecializedTemplate0Matcher
( internal::Matcher<ClassTemplateDecl> const &AInnerMatcher
) : InnerMatcher(AInnerMatcher) {} bool matches(const ClassTemplateSpecializationDecl
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: internal::Matcher<ClassTemplateDecl
> InnerMatcher; }; } inline ::clang::ast_matchers::internal
::Matcher<ClassTemplateSpecializationDecl> hasSpecializedTemplate
( internal::Matcher<ClassTemplateDecl> const &InnerMatcher
) { return ::clang::ast_matchers::internal::makeMatcher( new internal
::matcher_hasSpecializedTemplate0Matcher(InnerMatcher)); } typedef
::clang::ast_matchers::internal::Matcher<ClassTemplateSpecializationDecl
> ( &hasSpecializedTemplate_Type0)(internal::Matcher<
ClassTemplateDecl> const &InnerMatcher); inline bool internal
::matcher_hasSpecializedTemplate0Matcher::matches( const ClassTemplateSpecializationDecl
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
753 const ClassTemplateDecl* Decl = Node.getSpecializedTemplate();
754 return (Decl != nullptr &&
755 InnerMatcher.matches(*Decl, Finder, Builder));
756}
757
758/// Matches an entity that has been implicitly added by the compiler (e.g.
759/// implicit default/copy constructors).
760AST_POLYMORPHIC_MATCHER(isImplicit,namespace internal { template <typename NodeType> class
matcher_isImplicitMatcher : public ::clang::ast_matchers::internal
::MatcherInterface<NodeType> { public: bool matches(const
NodeType &Node, ::clang::ast_matchers::internal::ASTMatchFinder
*Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; }; } inline ::clang::ast_matchers::
internal::PolymorphicMatcher< internal::matcher_isImplicitMatcher
, void(::clang::ast_matchers::internal::TypeList<Decl, Attr
, LambdaCapture>)> isImplicit() { return ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_isImplicitMatcher
, void(::clang::ast_matchers::internal::TypeList<Decl, Attr
, LambdaCapture>)>(); } template <typename NodeType>
bool internal::matcher_isImplicitMatcher<NodeType>::matches
( const NodeType &Node, ::clang::ast_matchers::internal::
ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
761 AST_POLYMORPHIC_SUPPORTED_TYPES(Decl, Attr,namespace internal { template <typename NodeType> class
matcher_isImplicitMatcher : public ::clang::ast_matchers::internal
::MatcherInterface<NodeType> { public: bool matches(const
NodeType &Node, ::clang::ast_matchers::internal::ASTMatchFinder
*Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; }; } inline ::clang::ast_matchers::
internal::PolymorphicMatcher< internal::matcher_isImplicitMatcher
, void(::clang::ast_matchers::internal::TypeList<Decl, Attr
, LambdaCapture>)> isImplicit() { return ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_isImplicitMatcher
, void(::clang::ast_matchers::internal::TypeList<Decl, Attr
, LambdaCapture>)>(); } template <typename NodeType>
bool internal::matcher_isImplicitMatcher<NodeType>::matches
( const NodeType &Node, ::clang::ast_matchers::internal::
ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
762 LambdaCapture))namespace internal { template <typename NodeType> class
matcher_isImplicitMatcher : public ::clang::ast_matchers::internal
::MatcherInterface<NodeType> { public: bool matches(const
NodeType &Node, ::clang::ast_matchers::internal::ASTMatchFinder
*Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; }; } inline ::clang::ast_matchers::
internal::PolymorphicMatcher< internal::matcher_isImplicitMatcher
, void(::clang::ast_matchers::internal::TypeList<Decl, Attr
, LambdaCapture>)> isImplicit() { return ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_isImplicitMatcher
, void(::clang::ast_matchers::internal::TypeList<Decl, Attr
, LambdaCapture>)>(); } template <typename NodeType>
bool internal::matcher_isImplicitMatcher<NodeType>::matches
( const NodeType &Node, ::clang::ast_matchers::internal::
ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
763 return Node.isImplicit();
764}
765
766/// Matches classTemplateSpecializations, templateSpecializationType and
767/// functionDecl that have at least one TemplateArgument matching the given
768/// InnerMatcher.
769///
770/// Given
771/// \code
772/// template<typename T> class A {};
773/// template<> class A<double> {};
774/// A<int> a;
775///
776/// template<typename T> f() {};
777/// void func() { f<int>(); };
778/// \endcode
779///
780/// \endcode
781/// classTemplateSpecializationDecl(hasAnyTemplateArgument(
782/// refersToType(asString("int"))))
783/// matches the specialization \c A<int>
784///
785/// functionDecl(hasAnyTemplateArgument(refersToType(asString("int"))))
786/// matches the specialization \c f<int>
787AST_POLYMORPHIC_MATCHER_P(namespace internal { template <typename NodeType, typename
ParamT> class matcher_hasAnyTemplateArgument0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<NodeType
> { public: explicit matcher_hasAnyTemplateArgument0Matcher
( internal::Matcher<TemplateArgument> const &AInnerMatcher
) : InnerMatcher(AInnerMatcher) {} bool matches(const NodeType
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: internal::Matcher<TemplateArgument
> InnerMatcher; }; } inline ::clang::ast_matchers::internal
::PolymorphicMatcher< internal::matcher_hasAnyTemplateArgument0Matcher
, void(::clang::ast_matchers::internal::TypeList<ClassTemplateSpecializationDecl
, TemplateSpecializationType, FunctionDecl>), internal::Matcher
<TemplateArgument> > hasAnyTemplateArgument(internal
::Matcher<TemplateArgument> const &InnerMatcher) { return
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_hasAnyTemplateArgument0Matcher, void(::clang::ast_matchers
::internal::TypeList<ClassTemplateSpecializationDecl, TemplateSpecializationType
, FunctionDecl>), internal::Matcher<TemplateArgument>
>(InnerMatcher); } typedef ::clang::ast_matchers::internal
::PolymorphicMatcher< internal::matcher_hasAnyTemplateArgument0Matcher
, void(::clang::ast_matchers::internal::TypeList<ClassTemplateSpecializationDecl
, TemplateSpecializationType, FunctionDecl>), internal::Matcher
<TemplateArgument> > (&hasAnyTemplateArgument_Type0
)(internal::Matcher<TemplateArgument> const &InnerMatcher
); template <typename NodeType, typename ParamT> bool internal
:: matcher_hasAnyTemplateArgument0Matcher<NodeType, ParamT
>::matches( const NodeType &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
788 hasAnyTemplateArgument,namespace internal { template <typename NodeType, typename
ParamT> class matcher_hasAnyTemplateArgument0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<NodeType
> { public: explicit matcher_hasAnyTemplateArgument0Matcher
( internal::Matcher<TemplateArgument> const &AInnerMatcher
) : InnerMatcher(AInnerMatcher) {} bool matches(const NodeType
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: internal::Matcher<TemplateArgument
> InnerMatcher; }; } inline ::clang::ast_matchers::internal
::PolymorphicMatcher< internal::matcher_hasAnyTemplateArgument0Matcher
, void(::clang::ast_matchers::internal::TypeList<ClassTemplateSpecializationDecl
, TemplateSpecializationType, FunctionDecl>), internal::Matcher
<TemplateArgument> > hasAnyTemplateArgument(internal
::Matcher<TemplateArgument> const &InnerMatcher) { return
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_hasAnyTemplateArgument0Matcher, void(::clang::ast_matchers
::internal::TypeList<ClassTemplateSpecializationDecl, TemplateSpecializationType
, FunctionDecl>), internal::Matcher<TemplateArgument>
>(InnerMatcher); } typedef ::clang::ast_matchers::internal
::PolymorphicMatcher< internal::matcher_hasAnyTemplateArgument0Matcher
, void(::clang::ast_matchers::internal::TypeList<ClassTemplateSpecializationDecl
, TemplateSpecializationType, FunctionDecl>), internal::Matcher
<TemplateArgument> > (&hasAnyTemplateArgument_Type0
)(internal::Matcher<TemplateArgument> const &InnerMatcher
); template <typename NodeType, typename ParamT> bool internal
:: matcher_hasAnyTemplateArgument0Matcher<NodeType, ParamT
>::matches( const NodeType &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
789 AST_POLYMORPHIC_SUPPORTED_TYPES(ClassTemplateSpecializationDecl,namespace internal { template <typename NodeType, typename
ParamT> class matcher_hasAnyTemplateArgument0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<NodeType
> { public: explicit matcher_hasAnyTemplateArgument0Matcher
( internal::Matcher<TemplateArgument> const &AInnerMatcher
) : InnerMatcher(AInnerMatcher) {} bool matches(const NodeType
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: internal::Matcher<TemplateArgument
> InnerMatcher; }; } inline ::clang::ast_matchers::internal
::PolymorphicMatcher< internal::matcher_hasAnyTemplateArgument0Matcher
, void(::clang::ast_matchers::internal::TypeList<ClassTemplateSpecializationDecl
, TemplateSpecializationType, FunctionDecl>), internal::Matcher
<TemplateArgument> > hasAnyTemplateArgument(internal
::Matcher<TemplateArgument> const &InnerMatcher) { return
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_hasAnyTemplateArgument0Matcher, void(::clang::ast_matchers
::internal::TypeList<ClassTemplateSpecializationDecl, TemplateSpecializationType
, FunctionDecl>), internal::Matcher<TemplateArgument>
>(InnerMatcher); } typedef ::clang::ast_matchers::internal
::PolymorphicMatcher< internal::matcher_hasAnyTemplateArgument0Matcher
, void(::clang::ast_matchers::internal::TypeList<ClassTemplateSpecializationDecl
, TemplateSpecializationType, FunctionDecl>), internal::Matcher
<TemplateArgument> > (&hasAnyTemplateArgument_Type0
)(internal::Matcher<TemplateArgument> const &InnerMatcher
); template <typename NodeType, typename ParamT> bool internal
:: matcher_hasAnyTemplateArgument0Matcher<NodeType, ParamT
>::matches( const NodeType &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
790 TemplateSpecializationType,namespace internal { template <typename NodeType, typename
ParamT> class matcher_hasAnyTemplateArgument0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<NodeType
> { public: explicit matcher_hasAnyTemplateArgument0Matcher
( internal::Matcher<TemplateArgument> const &AInnerMatcher
) : InnerMatcher(AInnerMatcher) {} bool matches(const NodeType
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: internal::Matcher<TemplateArgument
> InnerMatcher; }; } inline ::clang::ast_matchers::internal
::PolymorphicMatcher< internal::matcher_hasAnyTemplateArgument0Matcher
, void(::clang::ast_matchers::internal::TypeList<ClassTemplateSpecializationDecl
, TemplateSpecializationType, FunctionDecl>), internal::Matcher
<TemplateArgument> > hasAnyTemplateArgument(internal
::Matcher<TemplateArgument> const &InnerMatcher) { return
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_hasAnyTemplateArgument0Matcher, void(::clang::ast_matchers
::internal::TypeList<ClassTemplateSpecializationDecl, TemplateSpecializationType
, FunctionDecl>), internal::Matcher<TemplateArgument>
>(InnerMatcher); } typedef ::clang::ast_matchers::internal
::PolymorphicMatcher< internal::matcher_hasAnyTemplateArgument0Matcher
, void(::clang::ast_matchers::internal::TypeList<ClassTemplateSpecializationDecl
, TemplateSpecializationType, FunctionDecl>), internal::Matcher
<TemplateArgument> > (&hasAnyTemplateArgument_Type0
)(internal::Matcher<TemplateArgument> const &InnerMatcher
); template <typename NodeType, typename ParamT> bool internal
:: matcher_hasAnyTemplateArgument0Matcher<NodeType, ParamT
>::matches( const NodeType &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
791 FunctionDecl),namespace internal { template <typename NodeType, typename
ParamT> class matcher_hasAnyTemplateArgument0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<NodeType
> { public: explicit matcher_hasAnyTemplateArgument0Matcher
( internal::Matcher<TemplateArgument> const &AInnerMatcher
) : InnerMatcher(AInnerMatcher) {} bool matches(const NodeType
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: internal::Matcher<TemplateArgument
> InnerMatcher; }; } inline ::clang::ast_matchers::internal
::PolymorphicMatcher< internal::matcher_hasAnyTemplateArgument0Matcher
, void(::clang::ast_matchers::internal::TypeList<ClassTemplateSpecializationDecl
, TemplateSpecializationType, FunctionDecl>), internal::Matcher
<TemplateArgument> > hasAnyTemplateArgument(internal
::Matcher<TemplateArgument> const &InnerMatcher) { return
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_hasAnyTemplateArgument0Matcher, void(::clang::ast_matchers
::internal::TypeList<ClassTemplateSpecializationDecl, TemplateSpecializationType
, FunctionDecl>), internal::Matcher<TemplateArgument>
>(InnerMatcher); } typedef ::clang::ast_matchers::internal
::PolymorphicMatcher< internal::matcher_hasAnyTemplateArgument0Matcher
, void(::clang::ast_matchers::internal::TypeList<ClassTemplateSpecializationDecl
, TemplateSpecializationType, FunctionDecl>), internal::Matcher
<TemplateArgument> > (&hasAnyTemplateArgument_Type0
)(internal::Matcher<TemplateArgument> const &InnerMatcher
); template <typename NodeType, typename ParamT> bool internal
:: matcher_hasAnyTemplateArgument0Matcher<NodeType, ParamT
>::matches( const NodeType &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
792 internal::Matcher<TemplateArgument>, InnerMatcher)namespace internal { template <typename NodeType, typename
ParamT> class matcher_hasAnyTemplateArgument0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<NodeType
> { public: explicit matcher_hasAnyTemplateArgument0Matcher
( internal::Matcher<TemplateArgument> const &AInnerMatcher
) : InnerMatcher(AInnerMatcher) {} bool matches(const NodeType
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: internal::Matcher<TemplateArgument
> InnerMatcher; }; } inline ::clang::ast_matchers::internal
::PolymorphicMatcher< internal::matcher_hasAnyTemplateArgument0Matcher
, void(::clang::ast_matchers::internal::TypeList<ClassTemplateSpecializationDecl
, TemplateSpecializationType, FunctionDecl>), internal::Matcher
<TemplateArgument> > hasAnyTemplateArgument(internal
::Matcher<TemplateArgument> const &InnerMatcher) { return
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_hasAnyTemplateArgument0Matcher, void(::clang::ast_matchers
::internal::TypeList<ClassTemplateSpecializationDecl, TemplateSpecializationType
, FunctionDecl>), internal::Matcher<TemplateArgument>
>(InnerMatcher); } typedef ::clang::ast_matchers::internal
::PolymorphicMatcher< internal::matcher_hasAnyTemplateArgument0Matcher
, void(::clang::ast_matchers::internal::TypeList<ClassTemplateSpecializationDecl
, TemplateSpecializationType, FunctionDecl>), internal::Matcher
<TemplateArgument> > (&hasAnyTemplateArgument_Type0
)(internal::Matcher<TemplateArgument> const &InnerMatcher
); template <typename NodeType, typename ParamT> bool internal
:: matcher_hasAnyTemplateArgument0Matcher<NodeType, ParamT
>::matches( const NodeType &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
{
793 ArrayRef<TemplateArgument> List =
794 internal::getTemplateSpecializationArgs(Node);
795 return matchesFirstInRange(InnerMatcher, List.begin(), List.end(), Finder,
796 Builder) != List.end();
797}
798
799/// Causes all nested matchers to be matched with the specified traversal kind.
800///
801/// Given
802/// \code
803/// void foo()
804/// {
805/// int i = 3.0;
806/// }
807/// \endcode
808/// The matcher
809/// \code
810/// traverse(TK_IgnoreUnlessSpelledInSource,
811/// varDecl(hasInitializer(floatLiteral().bind("init")))
812/// )
813/// \endcode
814/// matches the variable declaration with "init" bound to the "3.0".
815template <typename T>
816internal::Matcher<T> traverse(TraversalKind TK,
817 const internal::Matcher<T> &InnerMatcher) {
818 return internal::DynTypedMatcher::constructRestrictedWrapper(
819 new internal::TraversalMatcher<T>(TK, InnerMatcher),
820 InnerMatcher.getID().first)
821 .template unconditionalConvertTo<T>();
822}
823
824template <typename T>
825internal::BindableMatcher<T>
826traverse(TraversalKind TK, const internal::BindableMatcher<T> &InnerMatcher) {
827 return internal::BindableMatcher<T>(
828 internal::DynTypedMatcher::constructRestrictedWrapper(
829 new internal::TraversalMatcher<T>(TK, InnerMatcher),
830 InnerMatcher.getID().first)
831 .template unconditionalConvertTo<T>());
832}
833
834template <typename... T>
835internal::TraversalWrapper<internal::VariadicOperatorMatcher<T...>>
836traverse(TraversalKind TK,
837 const internal::VariadicOperatorMatcher<T...> &InnerMatcher) {
838 return internal::TraversalWrapper<internal::VariadicOperatorMatcher<T...>>(
839 TK, InnerMatcher);
840}
841
842template <template <typename ToArg, typename FromArg> class ArgumentAdapterT,
843 typename T, typename ToTypes>
844internal::TraversalWrapper<
845 internal::ArgumentAdaptingMatcherFuncAdaptor<ArgumentAdapterT, T, ToTypes>>
846traverse(TraversalKind TK, const internal::ArgumentAdaptingMatcherFuncAdaptor<
847 ArgumentAdapterT, T, ToTypes> &InnerMatcher) {
848 return internal::TraversalWrapper<
849 internal::ArgumentAdaptingMatcherFuncAdaptor<ArgumentAdapterT, T,
850 ToTypes>>(TK, InnerMatcher);
851}
852
853template <template <typename T, typename... P> class MatcherT, typename... P,
854 typename ReturnTypesF>
855internal::TraversalWrapper<
856 internal::PolymorphicMatcher<MatcherT, ReturnTypesF, P...>>
857traverse(TraversalKind TK,
858 const internal::PolymorphicMatcher<MatcherT, ReturnTypesF, P...>
859 &InnerMatcher) {
860 return internal::TraversalWrapper<
861 internal::PolymorphicMatcher<MatcherT, ReturnTypesF, P...>>(TK,
862 InnerMatcher);
863}
864
865template <typename... T>
866internal::Matcher<typename internal::GetClade<T...>::Type>
867traverse(TraversalKind TK, const internal::MapAnyOfHelper<T...> &InnerMatcher) {
868 return traverse(TK, InnerMatcher.with());
869}
870
871/// Matches expressions that match InnerMatcher after any implicit AST
872/// nodes are stripped off.
873///
874/// Parentheses and explicit casts are not discarded.
875/// Given
876/// \code
877/// class C {};
878/// C a = C();
879/// C b;
880/// C c = b;
881/// \endcode
882/// The matchers
883/// \code
884/// varDecl(hasInitializer(ignoringImplicit(cxxConstructExpr())))
885/// \endcode
886/// would match the declarations for a, b, and c.
887/// While
888/// \code
889/// varDecl(hasInitializer(cxxConstructExpr()))
890/// \endcode
891/// only match the declarations for b and c.
892AST_MATCHER_P(Expr, ignoringImplicit, internal::Matcher<Expr>,namespace internal { class matcher_ignoringImplicit0Matcher :
public ::clang::ast_matchers::internal::MatcherInterface<
Expr> { public: explicit matcher_ignoringImplicit0Matcher(
internal::Matcher<Expr> const &AInnerMatcher) : InnerMatcher
(AInnerMatcher) {} bool matches(const Expr &Node, ::clang
::ast_matchers::internal::ASTMatchFinder *Finder, ::clang::ast_matchers
::internal::BoundNodesTreeBuilder *Builder) const override; private
: internal::Matcher<Expr> InnerMatcher; }; } inline ::clang
::ast_matchers::internal::Matcher<Expr> ignoringImplicit
( internal::Matcher<Expr> const &InnerMatcher) { return
::clang::ast_matchers::internal::makeMatcher( new internal::
matcher_ignoringImplicit0Matcher(InnerMatcher)); } typedef ::
clang::ast_matchers::internal::Matcher<Expr> ( &ignoringImplicit_Type0
)(internal::Matcher<Expr> const &InnerMatcher); inline
bool internal::matcher_ignoringImplicit0Matcher::matches( const
Expr &Node, ::clang::ast_matchers::internal::ASTMatchFinder
*Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
893 InnerMatcher)namespace internal { class matcher_ignoringImplicit0Matcher :
public ::clang::ast_matchers::internal::MatcherInterface<
Expr> { public: explicit matcher_ignoringImplicit0Matcher(
internal::Matcher<Expr> const &AInnerMatcher) : InnerMatcher
(AInnerMatcher) {} bool matches(const Expr &Node, ::clang
::ast_matchers::internal::ASTMatchFinder *Finder, ::clang::ast_matchers
::internal::BoundNodesTreeBuilder *Builder) const override; private
: internal::Matcher<Expr> InnerMatcher; }; } inline ::clang
::ast_matchers::internal::Matcher<Expr> ignoringImplicit
( internal::Matcher<Expr> const &InnerMatcher) { return
::clang::ast_matchers::internal::makeMatcher( new internal::
matcher_ignoringImplicit0Matcher(InnerMatcher)); } typedef ::
clang::ast_matchers::internal::Matcher<Expr> ( &ignoringImplicit_Type0
)(internal::Matcher<Expr> const &InnerMatcher); inline
bool internal::matcher_ignoringImplicit0Matcher::matches( const
Expr &Node, ::clang::ast_matchers::internal::ASTMatchFinder
*Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
894 return InnerMatcher.matches(*Node.IgnoreImplicit(), Finder, Builder);
895}
896
897/// Matches expressions that match InnerMatcher after any implicit casts
898/// are stripped off.
899///
900/// Parentheses and explicit casts are not discarded.
901/// Given
902/// \code
903/// int arr[5];
904/// int a = 0;
905/// char b = 0;
906/// const int c = a;
907/// int *d = arr;
908/// long e = (long) 0l;
909/// \endcode
910/// The matchers
911/// \code
912/// varDecl(hasInitializer(ignoringImpCasts(integerLiteral())))
913/// varDecl(hasInitializer(ignoringImpCasts(declRefExpr())))
914/// \endcode
915/// would match the declarations for a, b, c, and d, but not e.
916/// While
917/// \code
918/// varDecl(hasInitializer(integerLiteral()))
919/// varDecl(hasInitializer(declRefExpr()))
920/// \endcode
921/// only match the declarations for a.
922AST_MATCHER_P(Expr, ignoringImpCasts,namespace internal { class matcher_ignoringImpCasts0Matcher :
public ::clang::ast_matchers::internal::MatcherInterface<
Expr> { public: explicit matcher_ignoringImpCasts0Matcher(
internal::Matcher<Expr> const &AInnerMatcher) : InnerMatcher
(AInnerMatcher) {} bool matches(const Expr &Node, ::clang
::ast_matchers::internal::ASTMatchFinder *Finder, ::clang::ast_matchers
::internal::BoundNodesTreeBuilder *Builder) const override; private
: internal::Matcher<Expr> InnerMatcher; }; } inline ::clang
::ast_matchers::internal::Matcher<Expr> ignoringImpCasts
( internal::Matcher<Expr> const &InnerMatcher) { return
::clang::ast_matchers::internal::makeMatcher( new internal::
matcher_ignoringImpCasts0Matcher(InnerMatcher)); } typedef ::
clang::ast_matchers::internal::Matcher<Expr> ( &ignoringImpCasts_Type0
)(internal::Matcher<Expr> const &InnerMatcher); inline
bool internal::matcher_ignoringImpCasts0Matcher::matches( const
Expr &Node, ::clang::ast_matchers::internal::ASTMatchFinder
*Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
923 internal::Matcher<Expr>, InnerMatcher)namespace internal { class matcher_ignoringImpCasts0Matcher :
public ::clang::ast_matchers::internal::MatcherInterface<
Expr> { public: explicit matcher_ignoringImpCasts0Matcher(
internal::Matcher<Expr> const &AInnerMatcher) : InnerMatcher
(AInnerMatcher) {} bool matches(const Expr &Node, ::clang
::ast_matchers::internal::ASTMatchFinder *Finder, ::clang::ast_matchers
::internal::BoundNodesTreeBuilder *Builder) const override; private
: internal::Matcher<Expr> InnerMatcher; }; } inline ::clang
::ast_matchers::internal::Matcher<Expr> ignoringImpCasts
( internal::Matcher<Expr> const &InnerMatcher) { return
::clang::ast_matchers::internal::makeMatcher( new internal::
matcher_ignoringImpCasts0Matcher(InnerMatcher)); } typedef ::
clang::ast_matchers::internal::Matcher<Expr> ( &ignoringImpCasts_Type0
)(internal::Matcher<Expr> const &InnerMatcher); inline
bool internal::matcher_ignoringImpCasts0Matcher::matches( const
Expr &Node, ::clang::ast_matchers::internal::ASTMatchFinder
*Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
924 return InnerMatcher.matches(*Node.IgnoreImpCasts(), Finder, Builder);
925}
926
927/// Matches expressions that match InnerMatcher after parentheses and
928/// casts are stripped off.
929///
930/// Implicit and non-C Style casts are also discarded.
931/// Given
932/// \code
933/// int a = 0;
934/// char b = (0);
935/// void* c = reinterpret_cast<char*>(0);
936/// char d = char(0);
937/// \endcode
938/// The matcher
939/// varDecl(hasInitializer(ignoringParenCasts(integerLiteral())))
940/// would match the declarations for a, b, c, and d.
941/// while
942/// varDecl(hasInitializer(integerLiteral()))
943/// only match the declaration for a.
944AST_MATCHER_P(Expr, ignoringParenCasts, internal::Matcher<Expr>, InnerMatcher)namespace internal { class matcher_ignoringParenCasts0Matcher
: public ::clang::ast_matchers::internal::MatcherInterface<
Expr> { public: explicit matcher_ignoringParenCasts0Matcher
( internal::Matcher<Expr> const &AInnerMatcher) : InnerMatcher
(AInnerMatcher) {} bool matches(const Expr &Node, ::clang
::ast_matchers::internal::ASTMatchFinder *Finder, ::clang::ast_matchers
::internal::BoundNodesTreeBuilder *Builder) const override; private
: internal::Matcher<Expr> InnerMatcher; }; } inline ::clang
::ast_matchers::internal::Matcher<Expr> ignoringParenCasts
( internal::Matcher<Expr> const &InnerMatcher) { return
::clang::ast_matchers::internal::makeMatcher( new internal::
matcher_ignoringParenCasts0Matcher(InnerMatcher)); } typedef ::
clang::ast_matchers::internal::Matcher<Expr> ( &ignoringParenCasts_Type0
)(internal::Matcher<Expr> const &InnerMatcher); inline
bool internal::matcher_ignoringParenCasts0Matcher::matches( const
Expr &Node, ::clang::ast_matchers::internal::ASTMatchFinder
*Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
945 return InnerMatcher.matches(*Node.IgnoreParenCasts(), Finder, Builder);
946}
947
948/// Matches expressions that match InnerMatcher after implicit casts and
949/// parentheses are stripped off.
950///
951/// Explicit casts are not discarded.
952/// Given
953/// \code
954/// int arr[5];
955/// int a = 0;
956/// char b = (0);
957/// const int c = a;
958/// int *d = (arr);
959/// long e = ((long) 0l);
960/// \endcode
961/// The matchers
962/// varDecl(hasInitializer(ignoringParenImpCasts(integerLiteral())))
963/// varDecl(hasInitializer(ignoringParenImpCasts(declRefExpr())))
964/// would match the declarations for a, b, c, and d, but not e.
965/// while
966/// varDecl(hasInitializer(integerLiteral()))
967/// varDecl(hasInitializer(declRefExpr()))
968/// would only match the declaration for a.
969AST_MATCHER_P(Expr, ignoringParenImpCasts,namespace internal { class matcher_ignoringParenImpCasts0Matcher
: public ::clang::ast_matchers::internal::MatcherInterface<
Expr> { public: explicit matcher_ignoringParenImpCasts0Matcher
( internal::Matcher<Expr> const &AInnerMatcher) : InnerMatcher
(AInnerMatcher) {} bool matches(const Expr &Node, ::clang
::ast_matchers::internal::ASTMatchFinder *Finder, ::clang::ast_matchers
::internal::BoundNodesTreeBuilder *Builder) const override; private
: internal::Matcher<Expr> InnerMatcher; }; } inline ::clang
::ast_matchers::internal::Matcher<Expr> ignoringParenImpCasts
( internal::Matcher<Expr> const &InnerMatcher) { return
::clang::ast_matchers::internal::makeMatcher( new internal::
matcher_ignoringParenImpCasts0Matcher(InnerMatcher)); } typedef
::clang::ast_matchers::internal::Matcher<Expr> ( &
ignoringParenImpCasts_Type0)(internal::Matcher<Expr> const
&InnerMatcher); inline bool internal::matcher_ignoringParenImpCasts0Matcher
::matches( const Expr &Node, ::clang::ast_matchers::internal
::ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
970 internal::Matcher<Expr>, InnerMatcher)namespace internal { class matcher_ignoringParenImpCasts0Matcher
: public ::clang::ast_matchers::internal::MatcherInterface<
Expr> { public: explicit matcher_ignoringParenImpCasts0Matcher
( internal::Matcher<Expr> const &AInnerMatcher) : InnerMatcher
(AInnerMatcher) {} bool matches(const Expr &Node, ::clang
::ast_matchers::internal::ASTMatchFinder *Finder, ::clang::ast_matchers
::internal::BoundNodesTreeBuilder *Builder) const override; private
: internal::Matcher<Expr> InnerMatcher; }; } inline ::clang
::ast_matchers::internal::Matcher<Expr> ignoringParenImpCasts
( internal::Matcher<Expr> const &InnerMatcher) { return
::clang::ast_matchers::internal::makeMatcher( new internal::
matcher_ignoringParenImpCasts0Matcher(InnerMatcher)); } typedef
::clang::ast_matchers::internal::Matcher<Expr> ( &
ignoringParenImpCasts_Type0)(internal::Matcher<Expr> const
&InnerMatcher); inline bool internal::matcher_ignoringParenImpCasts0Matcher
::matches( const Expr &Node, ::clang::ast_matchers::internal
::ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
971 return InnerMatcher.matches(*Node.IgnoreParenImpCasts(), Finder, Builder);
972}
973
974/// Matches types that match InnerMatcher after any parens are stripped.
975///
976/// Given
977/// \code
978/// void (*fp)(void);
979/// \endcode
980/// The matcher
981/// \code
982/// varDecl(hasType(pointerType(pointee(ignoringParens(functionType())))))
983/// \endcode
984/// would match the declaration for fp.
985AST_MATCHER_P_OVERLOAD(QualType, ignoringParens, internal::Matcher<QualType>,namespace internal { class matcher_ignoringParens0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<QualType
> { public: explicit matcher_ignoringParens0Matcher( internal
::Matcher<QualType> const &AInnerMatcher) : InnerMatcher
(AInnerMatcher) {} bool matches(const QualType &Node, ::clang
::ast_matchers::internal::ASTMatchFinder *Finder, ::clang::ast_matchers
::internal::BoundNodesTreeBuilder *Builder) const override; private
: internal::Matcher<QualType> InnerMatcher; }; } inline
::clang::ast_matchers::internal::Matcher<QualType> ignoringParens
( internal::Matcher<QualType> const &InnerMatcher) {
return ::clang::ast_matchers::internal::makeMatcher( new internal
::matcher_ignoringParens0Matcher(InnerMatcher)); } typedef ::
clang::ast_matchers::internal::Matcher<QualType> ( &
ignoringParens_Type0)(internal::Matcher<QualType> const
&InnerMatcher); inline bool internal::matcher_ignoringParens0Matcher
::matches( const QualType &Node, ::clang::ast_matchers::internal
::ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
986 InnerMatcher, 0)namespace internal { class matcher_ignoringParens0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<QualType
> { public: explicit matcher_ignoringParens0Matcher( internal
::Matcher<QualType> const &AInnerMatcher) : InnerMatcher
(AInnerMatcher) {} bool matches(const QualType &Node, ::clang
::ast_matchers::internal::ASTMatchFinder *Finder, ::clang::ast_matchers
::internal::BoundNodesTreeBuilder *Builder) const override; private
: internal::Matcher<QualType> InnerMatcher; }; } inline
::clang::ast_matchers::internal::Matcher<QualType> ignoringParens
( internal::Matcher<QualType> const &InnerMatcher) {
return ::clang::ast_matchers::internal::makeMatcher( new internal
::matcher_ignoringParens0Matcher(InnerMatcher)); } typedef ::
clang::ast_matchers::internal::Matcher<QualType> ( &
ignoringParens_Type0)(internal::Matcher<QualType> const
&InnerMatcher); inline bool internal::matcher_ignoringParens0Matcher
::matches( const QualType &Node, ::clang::ast_matchers::internal
::ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
987 return InnerMatcher.matches(Node.IgnoreParens(), Finder, Builder);
988}
989
990/// Overload \c ignoringParens for \c Expr.
991///
992/// Given
993/// \code
994/// const char* str = ("my-string");
995/// \endcode
996/// The matcher
997/// \code
998/// implicitCastExpr(hasSourceExpression(ignoringParens(stringLiteral())))
999/// \endcode
1000/// would match the implicit cast resulting from the assignment.
1001AST_MATCHER_P_OVERLOAD(Expr, ignoringParens, internal::Matcher<Expr>,namespace internal { class matcher_ignoringParens1Matcher : public
::clang::ast_matchers::internal::MatcherInterface<Expr>
{ public: explicit matcher_ignoringParens1Matcher( internal::
Matcher<Expr> const &AInnerMatcher) : InnerMatcher(
AInnerMatcher) {} bool matches(const Expr &Node, ::clang::
ast_matchers::internal::ASTMatchFinder *Finder, ::clang::ast_matchers
::internal::BoundNodesTreeBuilder *Builder) const override; private
: internal::Matcher<Expr> InnerMatcher; }; } inline ::clang
::ast_matchers::internal::Matcher<Expr> ignoringParens(
internal::Matcher<Expr> const &InnerMatcher) { return
::clang::ast_matchers::internal::makeMatcher( new internal::
matcher_ignoringParens1Matcher(InnerMatcher)); } typedef ::clang
::ast_matchers::internal::Matcher<Expr> ( &ignoringParens_Type1
)(internal::Matcher<Expr> const &InnerMatcher); inline
bool internal::matcher_ignoringParens1Matcher::matches( const
Expr &Node, ::clang::ast_matchers::internal::ASTMatchFinder
*Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
1002 InnerMatcher, 1)namespace internal { class matcher_ignoringParens1Matcher : public
::clang::ast_matchers::internal::MatcherInterface<Expr>
{ public: explicit matcher_ignoringParens1Matcher( internal::
Matcher<Expr> const &AInnerMatcher) : InnerMatcher(
AInnerMatcher) {} bool matches(const Expr &Node, ::clang::
ast_matchers::internal::ASTMatchFinder *Finder, ::clang::ast_matchers
::internal::BoundNodesTreeBuilder *Builder) const override; private
: internal::Matcher<Expr> InnerMatcher; }; } inline ::clang
::ast_matchers::internal::Matcher<Expr> ignoringParens(
internal::Matcher<Expr> const &InnerMatcher) { return
::clang::ast_matchers::internal::makeMatcher( new internal::
matcher_ignoringParens1Matcher(InnerMatcher)); } typedef ::clang
::ast_matchers::internal::Matcher<Expr> ( &ignoringParens_Type1
)(internal::Matcher<Expr> const &InnerMatcher); inline
bool internal::matcher_ignoringParens1Matcher::matches( const
Expr &Node, ::clang::ast_matchers::internal::ASTMatchFinder
*Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
1003 const Expr *E = Node.IgnoreParens();
1004 return InnerMatcher.matches(*E, Finder, Builder);
1005}
1006
1007/// Matches expressions that are instantiation-dependent even if it is
1008/// neither type- nor value-dependent.
1009///
1010/// In the following example, the expression sizeof(sizeof(T() + T()))
1011/// is instantiation-dependent (since it involves a template parameter T),
1012/// but is neither type- nor value-dependent, since the type of the inner
1013/// sizeof is known (std::size_t) and therefore the size of the outer
1014/// sizeof is known.
1015/// \code
1016/// template<typename T>
1017/// void f(T x, T y) { sizeof(sizeof(T() + T()); }
1018/// \endcode
1019/// expr(isInstantiationDependent()) matches sizeof(sizeof(T() + T())
1020AST_MATCHER(Expr, isInstantiationDependent)namespace internal { class matcher_isInstantiationDependentMatcher
: public ::clang::ast_matchers::internal::MatcherInterface<
Expr> { public: explicit matcher_isInstantiationDependentMatcher
() = default; bool matches(const Expr &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const override; }; } inline
::clang::ast_matchers::internal::Matcher<Expr> isInstantiationDependent
() { return ::clang::ast_matchers::internal::makeMatcher( new
internal::matcher_isInstantiationDependentMatcher()); } inline
bool internal::matcher_isInstantiationDependentMatcher::matches
( const Expr &Node, ::clang::ast_matchers::internal::ASTMatchFinder
*Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
1021 return Node.isInstantiationDependent();
1022}
1023
1024/// Matches expressions that are type-dependent because the template type
1025/// is not yet instantiated.
1026///
1027/// For example, the expressions "x" and "x + y" are type-dependent in
1028/// the following code, but "y" is not type-dependent:
1029/// \code
1030/// template<typename T>
1031/// void add(T x, int y) {
1032/// x + y;
1033/// }
1034/// \endcode
1035/// expr(isTypeDependent()) matches x + y
1036AST_MATCHER(Expr, isTypeDependent)namespace internal { class matcher_isTypeDependentMatcher : public
::clang::ast_matchers::internal::MatcherInterface<Expr>
{ public: explicit matcher_isTypeDependentMatcher() = default
; bool matches(const Expr &Node, ::clang::ast_matchers::internal
::ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; }; } inline ::clang::ast_matchers::
internal::Matcher<Expr> isTypeDependent() { return ::clang
::ast_matchers::internal::makeMatcher( new internal::matcher_isTypeDependentMatcher
()); } inline bool internal::matcher_isTypeDependentMatcher::
matches( const Expr &Node, ::clang::ast_matchers::internal
::ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{ return Node.isTypeDependent(); }
1037
1038/// Matches expression that are value-dependent because they contain a
1039/// non-type template parameter.
1040///
1041/// For example, the array bound of "Chars" in the following example is
1042/// value-dependent.
1043/// \code
1044/// template<int Size> int f() { return Size; }
1045/// \endcode
1046/// expr(isValueDependent()) matches return Size
1047AST_MATCHER(Expr, isValueDependent)namespace internal { class matcher_isValueDependentMatcher : public
::clang::ast_matchers::internal::MatcherInterface<Expr>
{ public: explicit matcher_isValueDependentMatcher() = default
; bool matches(const Expr &Node, ::clang::ast_matchers::internal
::ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; }; } inline ::clang::ast_matchers::
internal::Matcher<Expr> isValueDependent() { return ::clang
::ast_matchers::internal::makeMatcher( new internal::matcher_isValueDependentMatcher
()); } inline bool internal::matcher_isValueDependentMatcher::
matches( const Expr &Node, ::clang::ast_matchers::internal
::ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{ return Node.isValueDependent(); }
1048
1049/// Matches classTemplateSpecializations, templateSpecializationType and
1050/// functionDecl where the n'th TemplateArgument matches the given InnerMatcher.
1051///
1052/// Given
1053/// \code
1054/// template<typename T, typename U> class A {};
1055/// A<bool, int> b;
1056/// A<int, bool> c;
1057///
1058/// template<typename T> void f() {}
1059/// void func() { f<int>(); };
1060/// \endcode
1061/// classTemplateSpecializationDecl(hasTemplateArgument(
1062/// 1, refersToType(asString("int"))))
1063/// matches the specialization \c A<bool, int>
1064///
1065/// functionDecl(hasTemplateArgument(0, refersToType(asString("int"))))
1066/// matches the specialization \c f<int>
1067AST_POLYMORPHIC_MATCHER_P2(namespace internal { template <typename NodeType, typename
ParamT1, typename ParamT2> class matcher_hasTemplateArgument0Matcher
: public ::clang::ast_matchers::internal::MatcherInterface<
NodeType> { public: matcher_hasTemplateArgument0Matcher(unsigned
const &AN, internal::Matcher<TemplateArgument> const
&AInnerMatcher) : N(AN), InnerMatcher(AInnerMatcher) {} bool
matches(const NodeType &Node, ::clang::ast_matchers::internal
::ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: unsigned N; internal::Matcher
<TemplateArgument> InnerMatcher; }; } inline ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_hasTemplateArgument0Matcher
, void(::clang::ast_matchers::internal::TypeList<ClassTemplateSpecializationDecl
, TemplateSpecializationType, FunctionDecl>), unsigned, internal
::Matcher<TemplateArgument> > hasTemplateArgument(unsigned
const &N, internal::Matcher<TemplateArgument> const
&InnerMatcher) { return ::clang::ast_matchers::internal::
PolymorphicMatcher< internal::matcher_hasTemplateArgument0Matcher
, void(::clang::ast_matchers::internal::TypeList<ClassTemplateSpecializationDecl
, TemplateSpecializationType, FunctionDecl>), unsigned, internal
::Matcher<TemplateArgument> >(N, InnerMatcher); } typedef
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_hasTemplateArgument0Matcher, void(::clang::ast_matchers
::internal::TypeList<ClassTemplateSpecializationDecl, TemplateSpecializationType
, FunctionDecl>), unsigned, internal::Matcher<TemplateArgument
> > (&hasTemplateArgument_Type0)( unsigned const &
N, internal::Matcher<TemplateArgument> const &InnerMatcher
); template <typename NodeType, typename ParamT1, typename
ParamT2> bool internal::matcher_hasTemplateArgument0Matcher
< NodeType, ParamT1, ParamT2>:: matches(const NodeType &
Node, ::clang::ast_matchers::internal::ASTMatchFinder *Finder
, ::clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder
) const
1068 hasTemplateArgument,namespace internal { template <typename NodeType, typename
ParamT1, typename ParamT2> class matcher_hasTemplateArgument0Matcher
: public ::clang::ast_matchers::internal::MatcherInterface<
NodeType> { public: matcher_hasTemplateArgument0Matcher(unsigned
const &AN, internal::Matcher<TemplateArgument> const
&AInnerMatcher) : N(AN), InnerMatcher(AInnerMatcher) {} bool
matches(const NodeType &Node, ::clang::ast_matchers::internal
::ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: unsigned N; internal::Matcher
<TemplateArgument> InnerMatcher; }; } inline ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_hasTemplateArgument0Matcher
, void(::clang::ast_matchers::internal::TypeList<ClassTemplateSpecializationDecl
, TemplateSpecializationType, FunctionDecl>), unsigned, internal
::Matcher<TemplateArgument> > hasTemplateArgument(unsigned
const &N, internal::Matcher<TemplateArgument> const
&InnerMatcher) { return ::clang::ast_matchers::internal::
PolymorphicMatcher< internal::matcher_hasTemplateArgument0Matcher
, void(::clang::ast_matchers::internal::TypeList<ClassTemplateSpecializationDecl
, TemplateSpecializationType, FunctionDecl>), unsigned, internal
::Matcher<TemplateArgument> >(N, InnerMatcher); } typedef
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_hasTemplateArgument0Matcher, void(::clang::ast_matchers
::internal::TypeList<ClassTemplateSpecializationDecl, TemplateSpecializationType
, FunctionDecl>), unsigned, internal::Matcher<TemplateArgument
> > (&hasTemplateArgument_Type0)( unsigned const &
N, internal::Matcher<TemplateArgument> const &InnerMatcher
); template <typename NodeType, typename ParamT1, typename
ParamT2> bool internal::matcher_hasTemplateArgument0Matcher
< NodeType, ParamT1, ParamT2>:: matches(const NodeType &
Node, ::clang::ast_matchers::internal::ASTMatchFinder *Finder
, ::clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder
) const
1069 AST_POLYMORPHIC_SUPPORTED_TYPES(ClassTemplateSpecializationDecl,namespace internal { template <typename NodeType, typename
ParamT1, typename ParamT2> class matcher_hasTemplateArgument0Matcher
: public ::clang::ast_matchers::internal::MatcherInterface<
NodeType> { public: matcher_hasTemplateArgument0Matcher(unsigned
const &AN, internal::Matcher<TemplateArgument> const
&AInnerMatcher) : N(AN), InnerMatcher(AInnerMatcher) {} bool
matches(const NodeType &Node, ::clang::ast_matchers::internal
::ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: unsigned N; internal::Matcher
<TemplateArgument> InnerMatcher; }; } inline ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_hasTemplateArgument0Matcher
, void(::clang::ast_matchers::internal::TypeList<ClassTemplateSpecializationDecl
, TemplateSpecializationType, FunctionDecl>), unsigned, internal
::Matcher<TemplateArgument> > hasTemplateArgument(unsigned
const &N, internal::Matcher<TemplateArgument> const
&InnerMatcher) { return ::clang::ast_matchers::internal::
PolymorphicMatcher< internal::matcher_hasTemplateArgument0Matcher
, void(::clang::ast_matchers::internal::TypeList<ClassTemplateSpecializationDecl
, TemplateSpecializationType, FunctionDecl>), unsigned, internal
::Matcher<TemplateArgument> >(N, InnerMatcher); } typedef
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_hasTemplateArgument0Matcher, void(::clang::ast_matchers
::internal::TypeList<ClassTemplateSpecializationDecl, TemplateSpecializationType
, FunctionDecl>), unsigned, internal::Matcher<TemplateArgument
> > (&hasTemplateArgument_Type0)( unsigned const &
N, internal::Matcher<TemplateArgument> const &InnerMatcher
); template <typename NodeType, typename ParamT1, typename
ParamT2> bool internal::matcher_hasTemplateArgument0Matcher
< NodeType, ParamT1, ParamT2>:: matches(const NodeType &
Node, ::clang::ast_matchers::internal::ASTMatchFinder *Finder
, ::clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder
) const
1070 TemplateSpecializationType,namespace internal { template <typename NodeType, typename
ParamT1, typename ParamT2> class matcher_hasTemplateArgument0Matcher
: public ::clang::ast_matchers::internal::MatcherInterface<
NodeType> { public: matcher_hasTemplateArgument0Matcher(unsigned
const &AN, internal::Matcher<TemplateArgument> const
&AInnerMatcher) : N(AN), InnerMatcher(AInnerMatcher) {} bool
matches(const NodeType &Node, ::clang::ast_matchers::internal
::ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: unsigned N; internal::Matcher
<TemplateArgument> InnerMatcher; }; } inline ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_hasTemplateArgument0Matcher
, void(::clang::ast_matchers::internal::TypeList<ClassTemplateSpecializationDecl
, TemplateSpecializationType, FunctionDecl>), unsigned, internal
::Matcher<TemplateArgument> > hasTemplateArgument(unsigned
const &N, internal::Matcher<TemplateArgument> const
&InnerMatcher) { return ::clang::ast_matchers::internal::
PolymorphicMatcher< internal::matcher_hasTemplateArgument0Matcher
, void(::clang::ast_matchers::internal::TypeList<ClassTemplateSpecializationDecl
, TemplateSpecializationType, FunctionDecl>), unsigned, internal
::Matcher<TemplateArgument> >(N, InnerMatcher); } typedef
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_hasTemplateArgument0Matcher, void(::clang::ast_matchers
::internal::TypeList<ClassTemplateSpecializationDecl, TemplateSpecializationType
, FunctionDecl>), unsigned, internal::Matcher<TemplateArgument
> > (&hasTemplateArgument_Type0)( unsigned const &
N, internal::Matcher<TemplateArgument> const &InnerMatcher
); template <typename NodeType, typename ParamT1, typename
ParamT2> bool internal::matcher_hasTemplateArgument0Matcher
< NodeType, ParamT1, ParamT2>:: matches(const NodeType &
Node, ::clang::ast_matchers::internal::ASTMatchFinder *Finder
, ::clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder
) const
1071 FunctionDecl),namespace internal { template <typename NodeType, typename
ParamT1, typename ParamT2> class matcher_hasTemplateArgument0Matcher
: public ::clang::ast_matchers::internal::MatcherInterface<
NodeType> { public: matcher_hasTemplateArgument0Matcher(unsigned
const &AN, internal::Matcher<TemplateArgument> const
&AInnerMatcher) : N(AN), InnerMatcher(AInnerMatcher) {} bool
matches(const NodeType &Node, ::clang::ast_matchers::internal
::ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: unsigned N; internal::Matcher
<TemplateArgument> InnerMatcher; }; } inline ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_hasTemplateArgument0Matcher
, void(::clang::ast_matchers::internal::TypeList<ClassTemplateSpecializationDecl
, TemplateSpecializationType, FunctionDecl>), unsigned, internal
::Matcher<TemplateArgument> > hasTemplateArgument(unsigned
const &N, internal::Matcher<TemplateArgument> const
&InnerMatcher) { return ::clang::ast_matchers::internal::
PolymorphicMatcher< internal::matcher_hasTemplateArgument0Matcher
, void(::clang::ast_matchers::internal::TypeList<ClassTemplateSpecializationDecl
, TemplateSpecializationType, FunctionDecl>), unsigned, internal
::Matcher<TemplateArgument> >(N, InnerMatcher); } typedef
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_hasTemplateArgument0Matcher, void(::clang::ast_matchers
::internal::TypeList<ClassTemplateSpecializationDecl, TemplateSpecializationType
, FunctionDecl>), unsigned, internal::Matcher<TemplateArgument
> > (&hasTemplateArgument_Type0)( unsigned const &
N, internal::Matcher<TemplateArgument> const &InnerMatcher
); template <typename NodeType, typename ParamT1, typename
ParamT2> bool internal::matcher_hasTemplateArgument0Matcher
< NodeType, ParamT1, ParamT2>:: matches(const NodeType &
Node, ::clang::ast_matchers::internal::ASTMatchFinder *Finder
, ::clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder
) const
1072 unsigned, N, internal::Matcher<TemplateArgument>, InnerMatcher)namespace internal { template <typename NodeType, typename
ParamT1, typename ParamT2> class matcher_hasTemplateArgument0Matcher
: public ::clang::ast_matchers::internal::MatcherInterface<
NodeType> { public: matcher_hasTemplateArgument0Matcher(unsigned
const &AN, internal::Matcher<TemplateArgument> const
&AInnerMatcher) : N(AN), InnerMatcher(AInnerMatcher) {} bool
matches(const NodeType &Node, ::clang::ast_matchers::internal
::ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: unsigned N; internal::Matcher
<TemplateArgument> InnerMatcher; }; } inline ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_hasTemplateArgument0Matcher
, void(::clang::ast_matchers::internal::TypeList<ClassTemplateSpecializationDecl
, TemplateSpecializationType, FunctionDecl>), unsigned, internal
::Matcher<TemplateArgument> > hasTemplateArgument(unsigned
const &N, internal::Matcher<TemplateArgument> const
&InnerMatcher) { return ::clang::ast_matchers::internal::
PolymorphicMatcher< internal::matcher_hasTemplateArgument0Matcher
, void(::clang::ast_matchers::internal::TypeList<ClassTemplateSpecializationDecl
, TemplateSpecializationType, FunctionDecl>), unsigned, internal
::Matcher<TemplateArgument> >(N, InnerMatcher); } typedef
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_hasTemplateArgument0Matcher, void(::clang::ast_matchers
::internal::TypeList<ClassTemplateSpecializationDecl, TemplateSpecializationType
, FunctionDecl>), unsigned, internal::Matcher<TemplateArgument
> > (&hasTemplateArgument_Type0)( unsigned const &
N, internal::Matcher<TemplateArgument> const &InnerMatcher
); template <typename NodeType, typename ParamT1, typename
ParamT2> bool internal::matcher_hasTemplateArgument0Matcher
< NodeType, ParamT1, ParamT2>:: matches(const NodeType &
Node, ::clang::ast_matchers::internal::ASTMatchFinder *Finder
, ::clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder
) const
{
1073 ArrayRef<TemplateArgument> List =
1074 internal::getTemplateSpecializationArgs(Node);
1075 if (List.size() <= N)
1076 return false;
1077 return InnerMatcher.matches(List[N], Finder, Builder);
1078}
1079
1080/// Matches if the number of template arguments equals \p N.
1081///
1082/// Given
1083/// \code
1084/// template<typename T> struct C {};
1085/// C<int> c;
1086/// \endcode
1087/// classTemplateSpecializationDecl(templateArgumentCountIs(1))
1088/// matches C<int>.
1089AST_POLYMORPHIC_MATCHER_P(namespace internal { template <typename NodeType, typename
ParamT> class matcher_templateArgumentCountIs0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<NodeType
> { public: explicit matcher_templateArgumentCountIs0Matcher
( unsigned const &AN) : N(AN) {} bool matches(const NodeType
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: unsigned N; }; } inline ::
clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_templateArgumentCountIs0Matcher, void(::clang::ast_matchers
::internal::TypeList<ClassTemplateSpecializationDecl, TemplateSpecializationType
>), unsigned> templateArgumentCountIs(unsigned const &
N) { return ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_templateArgumentCountIs0Matcher, void(
::clang::ast_matchers::internal::TypeList<ClassTemplateSpecializationDecl
, TemplateSpecializationType>), unsigned>(N); } typedef
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_templateArgumentCountIs0Matcher, void(::clang::ast_matchers
::internal::TypeList<ClassTemplateSpecializationDecl, TemplateSpecializationType
>), unsigned> (&templateArgumentCountIs_Type0)(unsigned
const &N); template <typename NodeType, typename ParamT
> bool internal:: matcher_templateArgumentCountIs0Matcher<
NodeType, ParamT>::matches( const NodeType &Node, ::clang
::ast_matchers::internal::ASTMatchFinder *Finder, ::clang::ast_matchers
::internal::BoundNodesTreeBuilder *Builder) const
1090 templateArgumentCountIs,namespace internal { template <typename NodeType, typename
ParamT> class matcher_templateArgumentCountIs0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<NodeType
> { public: explicit matcher_templateArgumentCountIs0Matcher
( unsigned const &AN) : N(AN) {} bool matches(const NodeType
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: unsigned N; }; } inline ::
clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_templateArgumentCountIs0Matcher, void(::clang::ast_matchers
::internal::TypeList<ClassTemplateSpecializationDecl, TemplateSpecializationType
>), unsigned> templateArgumentCountIs(unsigned const &
N) { return ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_templateArgumentCountIs0Matcher, void(
::clang::ast_matchers::internal::TypeList<ClassTemplateSpecializationDecl
, TemplateSpecializationType>), unsigned>(N); } typedef
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_templateArgumentCountIs0Matcher, void(::clang::ast_matchers
::internal::TypeList<ClassTemplateSpecializationDecl, TemplateSpecializationType
>), unsigned> (&templateArgumentCountIs_Type0)(unsigned
const &N); template <typename NodeType, typename ParamT
> bool internal:: matcher_templateArgumentCountIs0Matcher<
NodeType, ParamT>::matches( const NodeType &Node, ::clang
::ast_matchers::internal::ASTMatchFinder *Finder, ::clang::ast_matchers
::internal::BoundNodesTreeBuilder *Builder) const
1091 AST_POLYMORPHIC_SUPPORTED_TYPES(ClassTemplateSpecializationDecl,namespace internal { template <typename NodeType, typename
ParamT> class matcher_templateArgumentCountIs0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<NodeType
> { public: explicit matcher_templateArgumentCountIs0Matcher
( unsigned const &AN) : N(AN) {} bool matches(const NodeType
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: unsigned N; }; } inline ::
clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_templateArgumentCountIs0Matcher, void(::clang::ast_matchers
::internal::TypeList<ClassTemplateSpecializationDecl, TemplateSpecializationType
>), unsigned> templateArgumentCountIs(unsigned const &
N) { return ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_templateArgumentCountIs0Matcher, void(
::clang::ast_matchers::internal::TypeList<ClassTemplateSpecializationDecl
, TemplateSpecializationType>), unsigned>(N); } typedef
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_templateArgumentCountIs0Matcher, void(::clang::ast_matchers
::internal::TypeList<ClassTemplateSpecializationDecl, TemplateSpecializationType
>), unsigned> (&templateArgumentCountIs_Type0)(unsigned
const &N); template <typename NodeType, typename ParamT
> bool internal:: matcher_templateArgumentCountIs0Matcher<
NodeType, ParamT>::matches( const NodeType &Node, ::clang
::ast_matchers::internal::ASTMatchFinder *Finder, ::clang::ast_matchers
::internal::BoundNodesTreeBuilder *Builder) const
1092 TemplateSpecializationType),namespace internal { template <typename NodeType, typename
ParamT> class matcher_templateArgumentCountIs0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<NodeType
> { public: explicit matcher_templateArgumentCountIs0Matcher
( unsigned const &AN) : N(AN) {} bool matches(const NodeType
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: unsigned N; }; } inline ::
clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_templateArgumentCountIs0Matcher, void(::clang::ast_matchers
::internal::TypeList<ClassTemplateSpecializationDecl, TemplateSpecializationType
>), unsigned> templateArgumentCountIs(unsigned const &
N) { return ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_templateArgumentCountIs0Matcher, void(
::clang::ast_matchers::internal::TypeList<ClassTemplateSpecializationDecl
, TemplateSpecializationType>), unsigned>(N); } typedef
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_templateArgumentCountIs0Matcher, void(::clang::ast_matchers
::internal::TypeList<ClassTemplateSpecializationDecl, TemplateSpecializationType
>), unsigned> (&templateArgumentCountIs_Type0)(unsigned
const &N); template <typename NodeType, typename ParamT
> bool internal:: matcher_templateArgumentCountIs0Matcher<
NodeType, ParamT>::matches( const NodeType &Node, ::clang
::ast_matchers::internal::ASTMatchFinder *Finder, ::clang::ast_matchers
::internal::BoundNodesTreeBuilder *Builder) const
1093 unsigned, N)namespace internal { template <typename NodeType, typename
ParamT> class matcher_templateArgumentCountIs0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<NodeType
> { public: explicit matcher_templateArgumentCountIs0Matcher
( unsigned const &AN) : N(AN) {} bool matches(const NodeType
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: unsigned N; }; } inline ::
clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_templateArgumentCountIs0Matcher, void(::clang::ast_matchers
::internal::TypeList<ClassTemplateSpecializationDecl, TemplateSpecializationType
>), unsigned> templateArgumentCountIs(unsigned const &
N) { return ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_templateArgumentCountIs0Matcher, void(
::clang::ast_matchers::internal::TypeList<ClassTemplateSpecializationDecl
, TemplateSpecializationType>), unsigned>(N); } typedef
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_templateArgumentCountIs0Matcher, void(::clang::ast_matchers
::internal::TypeList<ClassTemplateSpecializationDecl, TemplateSpecializationType
>), unsigned> (&templateArgumentCountIs_Type0)(unsigned
const &N); template <typename NodeType, typename ParamT
> bool internal:: matcher_templateArgumentCountIs0Matcher<
NodeType, ParamT>::matches( const NodeType &Node, ::clang
::ast_matchers::internal::ASTMatchFinder *Finder, ::clang::ast_matchers
::internal::BoundNodesTreeBuilder *Builder) const
{
1094 return internal::getTemplateSpecializationArgs(Node).size() == N;
1095}
1096
1097/// Matches a TemplateArgument that refers to a certain type.
1098///
1099/// Given
1100/// \code
1101/// struct X {};
1102/// template<typename T> struct A {};
1103/// A<X> a;
1104/// \endcode
1105/// classTemplateSpecializationDecl(hasAnyTemplateArgument(refersToType(
1106/// recordType(hasDeclaration(recordDecl(hasName("X")))))))
1107/// matches the specialization of \c struct A generated by \c A<X>.
1108AST_MATCHER_P(TemplateArgument, refersToType,namespace internal { class matcher_refersToType0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<TemplateArgument
> { public: explicit matcher_refersToType0Matcher( internal
::Matcher<QualType> const &AInnerMatcher) : InnerMatcher
(AInnerMatcher) {} bool matches(const TemplateArgument &Node
, ::clang::ast_matchers::internal::ASTMatchFinder *Finder, ::
clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder
) const override; private: internal::Matcher<QualType> InnerMatcher
; }; } inline ::clang::ast_matchers::internal::Matcher<TemplateArgument
> refersToType( internal::Matcher<QualType> const &
InnerMatcher) { return ::clang::ast_matchers::internal::makeMatcher
( new internal::matcher_refersToType0Matcher(InnerMatcher)); }
typedef ::clang::ast_matchers::internal::Matcher<TemplateArgument
> ( &refersToType_Type0)(internal::Matcher<QualType
> const &InnerMatcher); inline bool internal::matcher_refersToType0Matcher
::matches( const TemplateArgument &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
1109 internal::Matcher<QualType>, InnerMatcher)namespace internal { class matcher_refersToType0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<TemplateArgument
> { public: explicit matcher_refersToType0Matcher( internal
::Matcher<QualType> const &AInnerMatcher) : InnerMatcher
(AInnerMatcher) {} bool matches(const TemplateArgument &Node
, ::clang::ast_matchers::internal::ASTMatchFinder *Finder, ::
clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder
) const override; private: internal::Matcher<QualType> InnerMatcher
; }; } inline ::clang::ast_matchers::internal::Matcher<TemplateArgument
> refersToType( internal::Matcher<QualType> const &
InnerMatcher) { return ::clang::ast_matchers::internal::makeMatcher
( new internal::matcher_refersToType0Matcher(InnerMatcher)); }
typedef ::clang::ast_matchers::internal::Matcher<TemplateArgument
> ( &refersToType_Type0)(internal::Matcher<QualType
> const &InnerMatcher); inline bool internal::matcher_refersToType0Matcher
::matches( const TemplateArgument &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
{
1110 if (Node.getKind() != TemplateArgument::Type)
1111 return false;
1112 return InnerMatcher.matches(Node.getAsType(), Finder, Builder);
1113}
1114
1115/// Matches a TemplateArgument that refers to a certain template.
1116///
1117/// Given
1118/// \code
1119/// template<template <typename> class S> class X {};
1120/// template<typename T> class Y {};
1121/// X<Y> xi;
1122/// \endcode
1123/// classTemplateSpecializationDecl(hasAnyTemplateArgument(
1124/// refersToTemplate(templateName())))
1125/// matches the specialization \c X<Y>
1126AST_MATCHER_P(TemplateArgument, refersToTemplate,namespace internal { class matcher_refersToTemplate0Matcher :
public ::clang::ast_matchers::internal::MatcherInterface<
TemplateArgument> { public: explicit matcher_refersToTemplate0Matcher
( internal::Matcher<TemplateName> const &AInnerMatcher
) : InnerMatcher(AInnerMatcher) {} bool matches(const TemplateArgument
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: internal::Matcher<TemplateName
> InnerMatcher; }; } inline ::clang::ast_matchers::internal
::Matcher<TemplateArgument> refersToTemplate( internal::
Matcher<TemplateName> const &InnerMatcher) { return
::clang::ast_matchers::internal::makeMatcher( new internal::
matcher_refersToTemplate0Matcher(InnerMatcher)); } typedef ::
clang::ast_matchers::internal::Matcher<TemplateArgument>
( &refersToTemplate_Type0)(internal::Matcher<TemplateName
> const &InnerMatcher); inline bool internal::matcher_refersToTemplate0Matcher
::matches( const TemplateArgument &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
1127 internal::Matcher<TemplateName>, InnerMatcher)namespace internal { class matcher_refersToTemplate0Matcher :
public ::clang::ast_matchers::internal::MatcherInterface<
TemplateArgument> { public: explicit matcher_refersToTemplate0Matcher
( internal::Matcher<TemplateName> const &AInnerMatcher
) : InnerMatcher(AInnerMatcher) {} bool matches(const TemplateArgument
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: internal::Matcher<TemplateName
> InnerMatcher; }; } inline ::clang::ast_matchers::internal
::Matcher<TemplateArgument> refersToTemplate( internal::
Matcher<TemplateName> const &InnerMatcher) { return
::clang::ast_matchers::internal::makeMatcher( new internal::
matcher_refersToTemplate0Matcher(InnerMatcher)); } typedef ::
clang::ast_matchers::internal::Matcher<TemplateArgument>
( &refersToTemplate_Type0)(internal::Matcher<TemplateName
> const &InnerMatcher); inline bool internal::matcher_refersToTemplate0Matcher
::matches( const TemplateArgument &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
{
1128 if (Node.getKind() != TemplateArgument::Template)
1129 return false;
1130 return InnerMatcher.matches(Node.getAsTemplate(), Finder, Builder);
1131}
1132
1133/// Matches a canonical TemplateArgument that refers to a certain
1134/// declaration.
1135///
1136/// Given
1137/// \code
1138/// struct B { int next; };
1139/// template<int(B::*next_ptr)> struct A {};
1140/// A<&B::next> a;
1141/// \endcode
1142/// classTemplateSpecializationDecl(hasAnyTemplateArgument(
1143/// refersToDeclaration(fieldDecl(hasName("next")))))
1144/// matches the specialization \c A<&B::next> with \c fieldDecl(...) matching
1145/// \c B::next
1146AST_MATCHER_P(TemplateArgument, refersToDeclaration,namespace internal { class matcher_refersToDeclaration0Matcher
: public ::clang::ast_matchers::internal::MatcherInterface<
TemplateArgument> { public: explicit matcher_refersToDeclaration0Matcher
( internal::Matcher<Decl> const &AInnerMatcher) : InnerMatcher
(AInnerMatcher) {} bool matches(const TemplateArgument &Node
, ::clang::ast_matchers::internal::ASTMatchFinder *Finder, ::
clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder
) const override; private: internal::Matcher<Decl> InnerMatcher
; }; } inline ::clang::ast_matchers::internal::Matcher<TemplateArgument
> refersToDeclaration( internal::Matcher<Decl> const
&InnerMatcher) { return ::clang::ast_matchers::internal::
makeMatcher( new internal::matcher_refersToDeclaration0Matcher
(InnerMatcher)); } typedef ::clang::ast_matchers::internal::Matcher
<TemplateArgument> ( &refersToDeclaration_Type0)(internal
::Matcher<Decl> const &InnerMatcher); inline bool internal
::matcher_refersToDeclaration0Matcher::matches( const TemplateArgument
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
1147 internal::Matcher<Decl>, InnerMatcher)namespace internal { class matcher_refersToDeclaration0Matcher
: public ::clang::ast_matchers::internal::MatcherInterface<
TemplateArgument> { public: explicit matcher_refersToDeclaration0Matcher
( internal::Matcher<Decl> const &AInnerMatcher) : InnerMatcher
(AInnerMatcher) {} bool matches(const TemplateArgument &Node
, ::clang::ast_matchers::internal::ASTMatchFinder *Finder, ::
clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder
) const override; private: internal::Matcher<Decl> InnerMatcher
; }; } inline ::clang::ast_matchers::internal::Matcher<TemplateArgument
> refersToDeclaration( internal::Matcher<Decl> const
&InnerMatcher) { return ::clang::ast_matchers::internal::
makeMatcher( new internal::matcher_refersToDeclaration0Matcher
(InnerMatcher)); } typedef ::clang::ast_matchers::internal::Matcher
<TemplateArgument> ( &refersToDeclaration_Type0)(internal
::Matcher<Decl> const &InnerMatcher); inline bool internal
::matcher_refersToDeclaration0Matcher::matches( const TemplateArgument
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
1148 if (Node.getKind() == TemplateArgument::Declaration)
1149 return InnerMatcher.matches(*Node.getAsDecl(), Finder, Builder);
1150 return false;
1151}
1152
1153/// Matches a sugar TemplateArgument that refers to a certain expression.
1154///
1155/// Given
1156/// \code
1157/// struct B { int next; };
1158/// template<int(B::*next_ptr)> struct A {};
1159/// A<&B::next> a;
1160/// \endcode
1161/// templateSpecializationType(hasAnyTemplateArgument(
1162/// isExpr(hasDescendant(declRefExpr(to(fieldDecl(hasName("next"))))))))
1163/// matches the specialization \c A<&B::next> with \c fieldDecl(...) matching
1164/// \c B::next
1165AST_MATCHER_P(TemplateArgument, isExpr, internal::Matcher<Expr>, InnerMatcher)namespace internal { class matcher_isExpr0Matcher : public ::
clang::ast_matchers::internal::MatcherInterface<TemplateArgument
> { public: explicit matcher_isExpr0Matcher( internal::Matcher
<Expr> const &AInnerMatcher) : InnerMatcher(AInnerMatcher
) {} bool matches(const TemplateArgument &Node, ::clang::
ast_matchers::internal::ASTMatchFinder *Finder, ::clang::ast_matchers
::internal::BoundNodesTreeBuilder *Builder) const override; private
: internal::Matcher<Expr> InnerMatcher; }; } inline ::clang
::ast_matchers::internal::Matcher<TemplateArgument> isExpr
( internal::Matcher<Expr> const &InnerMatcher) { return
::clang::ast_matchers::internal::makeMatcher( new internal::
matcher_isExpr0Matcher(InnerMatcher)); } typedef ::clang::ast_matchers
::internal::Matcher<TemplateArgument> ( &isExpr_Type0
)(internal::Matcher<Expr> const &InnerMatcher); inline
bool internal::matcher_isExpr0Matcher::matches( const TemplateArgument
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
1166 if (Node.getKind() == TemplateArgument::Expression)
1167 return InnerMatcher.matches(*Node.getAsExpr(), Finder, Builder);
1168 return false;
1169}
1170
1171/// Matches a TemplateArgument that is an integral value.
1172///
1173/// Given
1174/// \code
1175/// template<int T> struct C {};
1176/// C<42> c;
1177/// \endcode
1178/// classTemplateSpecializationDecl(
1179/// hasAnyTemplateArgument(isIntegral()))
1180/// matches the implicit instantiation of C in C<42>
1181/// with isIntegral() matching 42.
1182AST_MATCHER(TemplateArgument, isIntegral)namespace internal { class matcher_isIntegralMatcher : public
::clang::ast_matchers::internal::MatcherInterface<TemplateArgument
> { public: explicit matcher_isIntegralMatcher() = default
; bool matches(const TemplateArgument &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const override; }; } inline
::clang::ast_matchers::internal::Matcher<TemplateArgument
> isIntegral() { return ::clang::ast_matchers::internal::makeMatcher
( new internal::matcher_isIntegralMatcher()); } inline bool internal
::matcher_isIntegralMatcher::matches( const TemplateArgument &
Node, ::clang::ast_matchers::internal::ASTMatchFinder *Finder
, ::clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder
) const
{
1183 return Node.getKind() == TemplateArgument::Integral;
1184}
1185
1186/// Matches a TemplateArgument that refers to an integral type.
1187///
1188/// Given
1189/// \code
1190/// template<int T> struct C {};
1191/// C<42> c;
1192/// \endcode
1193/// classTemplateSpecializationDecl(
1194/// hasAnyTemplateArgument(refersToIntegralType(asString("int"))))
1195/// matches the implicit instantiation of C in C<42>.
1196AST_MATCHER_P(TemplateArgument, refersToIntegralType,namespace internal { class matcher_refersToIntegralType0Matcher
: public ::clang::ast_matchers::internal::MatcherInterface<
TemplateArgument> { public: explicit matcher_refersToIntegralType0Matcher
( internal::Matcher<QualType> const &AInnerMatcher)
: InnerMatcher(AInnerMatcher) {} bool matches(const TemplateArgument
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: internal::Matcher<QualType
> InnerMatcher; }; } inline ::clang::ast_matchers::internal
::Matcher<TemplateArgument> refersToIntegralType( internal
::Matcher<QualType> const &InnerMatcher) { return ::
clang::ast_matchers::internal::makeMatcher( new internal::matcher_refersToIntegralType0Matcher
(InnerMatcher)); } typedef ::clang::ast_matchers::internal::Matcher
<TemplateArgument> ( &refersToIntegralType_Type0)(internal
::Matcher<QualType> const &InnerMatcher); inline bool
internal::matcher_refersToIntegralType0Matcher::matches( const
TemplateArgument &Node, ::clang::ast_matchers::internal::
ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
1197 internal::Matcher<QualType>, InnerMatcher)namespace internal { class matcher_refersToIntegralType0Matcher
: public ::clang::ast_matchers::internal::MatcherInterface<
TemplateArgument> { public: explicit matcher_refersToIntegralType0Matcher
( internal::Matcher<QualType> const &AInnerMatcher)
: InnerMatcher(AInnerMatcher) {} bool matches(const TemplateArgument
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: internal::Matcher<QualType
> InnerMatcher; }; } inline ::clang::ast_matchers::internal
::Matcher<TemplateArgument> refersToIntegralType( internal
::Matcher<QualType> const &InnerMatcher) { return ::
clang::ast_matchers::internal::makeMatcher( new internal::matcher_refersToIntegralType0Matcher
(InnerMatcher)); } typedef ::clang::ast_matchers::internal::Matcher
<TemplateArgument> ( &refersToIntegralType_Type0)(internal
::Matcher<QualType> const &InnerMatcher); inline bool
internal::matcher_refersToIntegralType0Matcher::matches( const
TemplateArgument &Node, ::clang::ast_matchers::internal::
ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
1198 if (Node.getKind() != TemplateArgument::Integral)
1199 return false;
1200 return InnerMatcher.matches(Node.getIntegralType(), Finder, Builder);
1201}
1202
1203/// Matches a TemplateArgument of integral type with a given value.
1204///
1205/// Note that 'Value' is a string as the template argument's value is
1206/// an arbitrary precision integer. 'Value' must be euqal to the canonical
1207/// representation of that integral value in base 10.
1208///
1209/// Given
1210/// \code
1211/// template<int T> struct C {};
1212/// C<42> c;
1213/// \endcode
1214/// classTemplateSpecializationDecl(
1215/// hasAnyTemplateArgument(equalsIntegralValue("42")))
1216/// matches the implicit instantiation of C in C<42>.
1217AST_MATCHER_P(TemplateArgument, equalsIntegralValue,namespace internal { class matcher_equalsIntegralValue0Matcher
: public ::clang::ast_matchers::internal::MatcherInterface<
TemplateArgument> { public: explicit matcher_equalsIntegralValue0Matcher
( std::string const &AValue) : Value(AValue) {} bool matches
(const TemplateArgument &Node, ::clang::ast_matchers::internal
::ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: std::string Value; }; } inline
::clang::ast_matchers::internal::Matcher<TemplateArgument
> equalsIntegralValue( std::string const &Value) { return
::clang::ast_matchers::internal::makeMatcher( new internal::
matcher_equalsIntegralValue0Matcher(Value)); } typedef ::clang
::ast_matchers::internal::Matcher<TemplateArgument> ( &
equalsIntegralValue_Type0)(std::string const &Value); inline
bool internal::matcher_equalsIntegralValue0Matcher::matches(
const TemplateArgument &Node, ::clang::ast_matchers::internal
::ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
1218 std::string, Value)namespace internal { class matcher_equalsIntegralValue0Matcher
: public ::clang::ast_matchers::internal::MatcherInterface<
TemplateArgument> { public: explicit matcher_equalsIntegralValue0Matcher
( std::string const &AValue) : Value(AValue) {} bool matches
(const TemplateArgument &Node, ::clang::ast_matchers::internal
::ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: std::string Value; }; } inline
::clang::ast_matchers::internal::Matcher<TemplateArgument
> equalsIntegralValue( std::string const &Value) { return
::clang::ast_matchers::internal::makeMatcher( new internal::
matcher_equalsIntegralValue0Matcher(Value)); } typedef ::clang
::ast_matchers::internal::Matcher<TemplateArgument> ( &
equalsIntegralValue_Type0)(std::string const &Value); inline
bool internal::matcher_equalsIntegralValue0Matcher::matches(
const TemplateArgument &Node, ::clang::ast_matchers::internal
::ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
1219 if (Node.getKind() != TemplateArgument::Integral)
1220 return false;
1221 return toString(Node.getAsIntegral(), 10) == Value;
1222}
1223
1224/// Matches an Objective-C autorelease pool statement.
1225///
1226/// Given
1227/// \code
1228/// @autoreleasepool {
1229/// int x = 0;
1230/// }
1231/// \endcode
1232/// autoreleasePoolStmt(stmt()) matches the declaration of "x"
1233/// inside the autorelease pool.
1234extern const internal::VariadicDynCastAllOfMatcher<Stmt,
1235 ObjCAutoreleasePoolStmt> autoreleasePoolStmt;
1236
1237/// Matches any value declaration.
1238///
1239/// Example matches A, B, C and F
1240/// \code
1241/// enum X { A, B, C };
1242/// void F();
1243/// \endcode
1244extern const internal::VariadicDynCastAllOfMatcher<Decl, ValueDecl> valueDecl;
1245
1246/// Matches C++ constructor declarations.
1247///
1248/// Example matches Foo::Foo() and Foo::Foo(int)
1249/// \code
1250/// class Foo {
1251/// public:
1252/// Foo();
1253/// Foo(int);
1254/// int DoSomething();
1255/// };
1256/// \endcode
1257extern const internal::VariadicDynCastAllOfMatcher<Decl, CXXConstructorDecl>
1258 cxxConstructorDecl;
1259
1260/// Matches explicit C++ destructor declarations.
1261///
1262/// Example matches Foo::~Foo()
1263/// \code
1264/// class Foo {
1265/// public:
1266/// virtual ~Foo();
1267/// };
1268/// \endcode
1269extern const internal::VariadicDynCastAllOfMatcher<Decl, CXXDestructorDecl>
1270 cxxDestructorDecl;
1271
1272/// Matches enum declarations.
1273///
1274/// Example matches X
1275/// \code
1276/// enum X {
1277/// A, B, C
1278/// };
1279/// \endcode
1280extern const internal::VariadicDynCastAllOfMatcher<Decl, EnumDecl> enumDecl;
1281
1282/// Matches enum constants.
1283///
1284/// Example matches A, B, C
1285/// \code
1286/// enum X {
1287/// A, B, C
1288/// };
1289/// \endcode
1290extern const internal::VariadicDynCastAllOfMatcher<Decl, EnumConstantDecl>
1291 enumConstantDecl;
1292
1293/// Matches tag declarations.
1294///
1295/// Example matches X, Z, U, S, E
1296/// \code
1297/// class X;
1298/// template<class T> class Z {};
1299/// struct S {};
1300/// union U {};
1301/// enum E {
1302/// A, B, C
1303/// };
1304/// \endcode
1305extern const internal::VariadicDynCastAllOfMatcher<Decl, TagDecl> tagDecl;
1306
1307/// Matches method declarations.
1308///
1309/// Example matches y
1310/// \code
1311/// class X { void y(); };
1312/// \endcode
1313extern const internal::VariadicDynCastAllOfMatcher<Decl, CXXMethodDecl>
1314 cxxMethodDecl;
1315
1316/// Matches conversion operator declarations.
1317///
1318/// Example matches the operator.
1319/// \code
1320/// class X { operator int() const; };
1321/// \endcode
1322extern const internal::VariadicDynCastAllOfMatcher<Decl, CXXConversionDecl>
1323 cxxConversionDecl;
1324
1325/// Matches user-defined and implicitly generated deduction guide.
1326///
1327/// Example matches the deduction guide.
1328/// \code
1329/// template<typename T>
1330/// class X { X(int) };
1331/// X(int) -> X<int>;
1332/// \endcode
1333extern const internal::VariadicDynCastAllOfMatcher<Decl, CXXDeductionGuideDecl>
1334 cxxDeductionGuideDecl;
1335
1336/// Matches variable declarations.
1337///
1338/// Note: this does not match declarations of member variables, which are
1339/// "field" declarations in Clang parlance.
1340///
1341/// Example matches a
1342/// \code
1343/// int a;
1344/// \endcode
1345extern const internal::VariadicDynCastAllOfMatcher<Decl, VarDecl> varDecl;
1346
1347/// Matches field declarations.
1348///
1349/// Given
1350/// \code
1351/// class X { int m; };
1352/// \endcode
1353/// fieldDecl()
1354/// matches 'm'.
1355extern const internal::VariadicDynCastAllOfMatcher<Decl, FieldDecl> fieldDecl;
1356
1357/// Matches indirect field declarations.
1358///
1359/// Given
1360/// \code
1361/// struct X { struct { int a; }; };
1362/// \endcode
1363/// indirectFieldDecl()
1364/// matches 'a'.
1365extern const internal::VariadicDynCastAllOfMatcher<Decl, IndirectFieldDecl>
1366 indirectFieldDecl;
1367
1368/// Matches function declarations.
1369///
1370/// Example matches f
1371/// \code
1372/// void f();
1373/// \endcode
1374extern const internal::VariadicDynCastAllOfMatcher<Decl, FunctionDecl>
1375 functionDecl;
1376
1377/// Matches C++ function template declarations.
1378///
1379/// Example matches f
1380/// \code
1381/// template<class T> void f(T t) {}
1382/// \endcode
1383extern const internal::VariadicDynCastAllOfMatcher<Decl, FunctionTemplateDecl>
1384 functionTemplateDecl;
1385
1386/// Matches friend declarations.
1387///
1388/// Given
1389/// \code
1390/// class X { friend void foo(); };
1391/// \endcode
1392/// friendDecl()
1393/// matches 'friend void foo()'.
1394extern const internal::VariadicDynCastAllOfMatcher<Decl, FriendDecl> friendDecl;
1395
1396/// Matches statements.
1397///
1398/// Given
1399/// \code
1400/// { ++a; }
1401/// \endcode
1402/// stmt()
1403/// matches both the compound statement '{ ++a; }' and '++a'.
1404extern const internal::VariadicAllOfMatcher<Stmt> stmt;
1405
1406/// Matches declaration statements.
1407///
1408/// Given
1409/// \code
1410/// int a;
1411/// \endcode
1412/// declStmt()
1413/// matches 'int a'.
1414extern const internal::VariadicDynCastAllOfMatcher<Stmt, DeclStmt> declStmt;
1415
1416/// Matches member expressions.
1417///
1418/// Given
1419/// \code
1420/// class Y {
1421/// void x() { this->x(); x(); Y y; y.x(); a; this->b; Y::b; }
1422/// int a; static int b;
1423/// };
1424/// \endcode
1425/// memberExpr()
1426/// matches this->x, x, y.x, a, this->b
1427extern const internal::VariadicDynCastAllOfMatcher<Stmt, MemberExpr> memberExpr;
1428
1429/// Matches unresolved member expressions.
1430///
1431/// Given
1432/// \code
1433/// struct X {
1434/// template <class T> void f();
1435/// void g();
1436/// };
1437/// template <class T> void h() { X x; x.f<T>(); x.g(); }
1438/// \endcode
1439/// unresolvedMemberExpr()
1440/// matches x.f<T>
1441extern const internal::VariadicDynCastAllOfMatcher<Stmt, UnresolvedMemberExpr>
1442 unresolvedMemberExpr;
1443
1444/// Matches member expressions where the actual member referenced could not be
1445/// resolved because the base expression or the member name was dependent.
1446///
1447/// Given
1448/// \code
1449/// template <class T> void f() { T t; t.g(); }
1450/// \endcode
1451/// cxxDependentScopeMemberExpr()
1452/// matches t.g
1453extern const internal::VariadicDynCastAllOfMatcher<Stmt,
1454 CXXDependentScopeMemberExpr>
1455 cxxDependentScopeMemberExpr;
1456
1457/// Matches call expressions.
1458///
1459/// Example matches x.y() and y()
1460/// \code
1461/// X x;
1462/// x.y();
1463/// y();
1464/// \endcode
1465extern const internal::VariadicDynCastAllOfMatcher<Stmt, CallExpr> callExpr;
1466
1467/// Matches call expressions which were resolved using ADL.
1468///
1469/// Example matches y(x) but not y(42) or NS::y(x).
1470/// \code
1471/// namespace NS {
1472/// struct X {};
1473/// void y(X);
1474/// }
1475///
1476/// void y(...);
1477///
1478/// void test() {
1479/// NS::X x;
1480/// y(x); // Matches
1481/// NS::y(x); // Doesn't match
1482/// y(42); // Doesn't match
1483/// using NS::y;
1484/// y(x); // Found by both unqualified lookup and ADL, doesn't match
1485// }
1486/// \endcode
1487AST_MATCHER(CallExpr, usesADL)namespace internal { class matcher_usesADLMatcher : public ::
clang::ast_matchers::internal::MatcherInterface<CallExpr>
{ public: explicit matcher_usesADLMatcher() = default; bool matches
(const CallExpr &Node, ::clang::ast_matchers::internal::ASTMatchFinder
*Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; }; } inline ::clang::ast_matchers::
internal::Matcher<CallExpr> usesADL() { return ::clang::
ast_matchers::internal::makeMatcher( new internal::matcher_usesADLMatcher
()); } inline bool internal::matcher_usesADLMatcher::matches(
const CallExpr &Node, ::clang::ast_matchers::internal::ASTMatchFinder
*Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{ return Node.usesADL(); }
1488
1489/// Matches lambda expressions.
1490///
1491/// Example matches [&](){return 5;}
1492/// \code
1493/// [&](){return 5;}
1494/// \endcode
1495extern const internal::VariadicDynCastAllOfMatcher<Stmt, LambdaExpr> lambdaExpr;
1496
1497/// Matches member call expressions.
1498///
1499/// Example matches x.y()
1500/// \code
1501/// X x;
1502/// x.y();
1503/// \endcode
1504extern const internal::VariadicDynCastAllOfMatcher<Stmt, CXXMemberCallExpr>
1505 cxxMemberCallExpr;
1506
1507/// Matches ObjectiveC Message invocation expressions.
1508///
1509/// The innermost message send invokes the "alloc" class method on the
1510/// NSString class, while the outermost message send invokes the
1511/// "initWithString" instance method on the object returned from
1512/// NSString's "alloc". This matcher should match both message sends.
1513/// \code
1514/// [[NSString alloc] initWithString:@"Hello"]
1515/// \endcode
1516extern const internal::VariadicDynCastAllOfMatcher<Stmt, ObjCMessageExpr>
1517 objcMessageExpr;
1518
1519/// Matches ObjectiveC String literal expressions.
1520///
1521/// Example matches @"abcd"
1522/// \code
1523/// NSString *s = @"abcd";
1524/// \endcode
1525extern const internal::VariadicDynCastAllOfMatcher<Stmt, ObjCStringLiteral>
1526 objcStringLiteral;
1527
1528/// Matches Objective-C interface declarations.
1529///
1530/// Example matches Foo
1531/// \code
1532/// @interface Foo
1533/// @end
1534/// \endcode
1535extern const internal::VariadicDynCastAllOfMatcher<Decl, ObjCInterfaceDecl>
1536 objcInterfaceDecl;
1537
1538/// Matches Objective-C implementation declarations.
1539///
1540/// Example matches Foo
1541/// \code
1542/// @implementation Foo
1543/// @end
1544/// \endcode
1545extern const internal::VariadicDynCastAllOfMatcher<Decl, ObjCImplementationDecl>
1546 objcImplementationDecl;
1547
1548/// Matches Objective-C protocol declarations.
1549///
1550/// Example matches FooDelegate
1551/// \code
1552/// @protocol FooDelegate
1553/// @end
1554/// \endcode
1555extern const internal::VariadicDynCastAllOfMatcher<Decl, ObjCProtocolDecl>
1556 objcProtocolDecl;
1557
1558/// Matches Objective-C category declarations.
1559///
1560/// Example matches Foo (Additions)
1561/// \code
1562/// @interface Foo (Additions)
1563/// @end
1564/// \endcode
1565extern const internal::VariadicDynCastAllOfMatcher<Decl, ObjCCategoryDecl>
1566 objcCategoryDecl;
1567
1568/// Matches Objective-C category definitions.
1569///
1570/// Example matches Foo (Additions)
1571/// \code
1572/// @implementation Foo (Additions)
1573/// @end
1574/// \endcode
1575extern const internal::VariadicDynCastAllOfMatcher<Decl, ObjCCategoryImplDecl>
1576 objcCategoryImplDecl;
1577
1578/// Matches Objective-C method declarations.
1579///
1580/// Example matches both declaration and definition of -[Foo method]
1581/// \code
1582/// @interface Foo
1583/// - (void)method;
1584/// @end
1585///
1586/// @implementation Foo
1587/// - (void)method {}
1588/// @end
1589/// \endcode
1590extern const internal::VariadicDynCastAllOfMatcher<Decl, ObjCMethodDecl>
1591 objcMethodDecl;
1592
1593/// Matches block declarations.
1594///
1595/// Example matches the declaration of the nameless block printing an input
1596/// integer.
1597///
1598/// \code
1599/// myFunc(^(int p) {
1600/// printf("%d", p);
1601/// })
1602/// \endcode
1603extern const internal::VariadicDynCastAllOfMatcher<Decl, BlockDecl>
1604 blockDecl;
1605
1606/// Matches Objective-C instance variable declarations.
1607///
1608/// Example matches _enabled
1609/// \code
1610/// @implementation Foo {
1611/// BOOL _enabled;
1612/// }
1613/// @end
1614/// \endcode
1615extern const internal::VariadicDynCastAllOfMatcher<Decl, ObjCIvarDecl>
1616 objcIvarDecl;
1617
1618/// Matches Objective-C property declarations.
1619///
1620/// Example matches enabled
1621/// \code
1622/// @interface Foo
1623/// @property BOOL enabled;
1624/// @end
1625/// \endcode
1626extern const internal::VariadicDynCastAllOfMatcher<Decl, ObjCPropertyDecl>
1627 objcPropertyDecl;
1628
1629/// Matches Objective-C \@throw statements.
1630///
1631/// Example matches \@throw
1632/// \code
1633/// @throw obj;
1634/// \endcode
1635extern const internal::VariadicDynCastAllOfMatcher<Stmt, ObjCAtThrowStmt>
1636 objcThrowStmt;
1637
1638/// Matches Objective-C @try statements.
1639///
1640/// Example matches @try
1641/// \code
1642/// @try {}
1643/// @catch (...) {}
1644/// \endcode
1645extern const internal::VariadicDynCastAllOfMatcher<Stmt, ObjCAtTryStmt>
1646 objcTryStmt;
1647
1648/// Matches Objective-C @catch statements.
1649///
1650/// Example matches @catch
1651/// \code
1652/// @try {}
1653/// @catch (...) {}
1654/// \endcode
1655extern const internal::VariadicDynCastAllOfMatcher<Stmt, ObjCAtCatchStmt>
1656 objcCatchStmt;
1657
1658/// Matches Objective-C @finally statements.
1659///
1660/// Example matches @finally
1661/// \code
1662/// @try {}
1663/// @finally {}
1664/// \endcode
1665extern const internal::VariadicDynCastAllOfMatcher<Stmt, ObjCAtFinallyStmt>
1666 objcFinallyStmt;
1667
1668/// Matches expressions that introduce cleanups to be run at the end
1669/// of the sub-expression's evaluation.
1670///
1671/// Example matches std::string()
1672/// \code
1673/// const std::string str = std::string();
1674/// \endcode
1675extern const internal::VariadicDynCastAllOfMatcher<Stmt, ExprWithCleanups>
1676 exprWithCleanups;
1677
1678/// Matches init list expressions.
1679///
1680/// Given
1681/// \code
1682/// int a[] = { 1, 2 };
1683/// struct B { int x, y; };
1684/// B b = { 5, 6 };
1685/// \endcode
1686/// initListExpr()
1687/// matches "{ 1, 2 }" and "{ 5, 6 }"
1688extern const internal::VariadicDynCastAllOfMatcher<Stmt, InitListExpr>
1689 initListExpr;
1690
1691/// Matches the syntactic form of init list expressions
1692/// (if expression have it).
1693AST_MATCHER_P(InitListExpr, hasSyntacticForm,namespace internal { class matcher_hasSyntacticForm0Matcher :
public ::clang::ast_matchers::internal::MatcherInterface<
InitListExpr> { public: explicit matcher_hasSyntacticForm0Matcher
( internal::Matcher<Expr> const &AInnerMatcher) : InnerMatcher
(AInnerMatcher) {} bool matches(const InitListExpr &Node,
::clang::ast_matchers::internal::ASTMatchFinder *Finder, ::clang
::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
override; private: internal::Matcher<Expr> InnerMatcher
; }; } inline ::clang::ast_matchers::internal::Matcher<InitListExpr
> hasSyntacticForm( internal::Matcher<Expr> const &
InnerMatcher) { return ::clang::ast_matchers::internal::makeMatcher
( new internal::matcher_hasSyntacticForm0Matcher(InnerMatcher
)); } typedef ::clang::ast_matchers::internal::Matcher<InitListExpr
> ( &hasSyntacticForm_Type0)(internal::Matcher<Expr
> const &InnerMatcher); inline bool internal::matcher_hasSyntacticForm0Matcher
::matches( const InitListExpr &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
1694 internal::Matcher<Expr>, InnerMatcher)namespace internal { class matcher_hasSyntacticForm0Matcher :
public ::clang::ast_matchers::internal::MatcherInterface<
InitListExpr> { public: explicit matcher_hasSyntacticForm0Matcher
( internal::Matcher<Expr> const &AInnerMatcher) : InnerMatcher
(AInnerMatcher) {} bool matches(const InitListExpr &Node,
::clang::ast_matchers::internal::ASTMatchFinder *Finder, ::clang
::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
override; private: internal::Matcher<Expr> InnerMatcher
; }; } inline ::clang::ast_matchers::internal::Matcher<InitListExpr
> hasSyntacticForm( internal::Matcher<Expr> const &
InnerMatcher) { return ::clang::ast_matchers::internal::makeMatcher
( new internal::matcher_hasSyntacticForm0Matcher(InnerMatcher
)); } typedef ::clang::ast_matchers::internal::Matcher<InitListExpr
> ( &hasSyntacticForm_Type0)(internal::Matcher<Expr
> const &InnerMatcher); inline bool internal::matcher_hasSyntacticForm0Matcher
::matches( const InitListExpr &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
{
1695 const Expr *SyntForm = Node.getSyntacticForm();
1696 return (SyntForm != nullptr &&
1697 InnerMatcher.matches(*SyntForm, Finder, Builder));
1698}
1699
1700/// Matches C++ initializer list expressions.
1701///
1702/// Given
1703/// \code
1704/// std::vector<int> a({ 1, 2, 3 });
1705/// std::vector<int> b = { 4, 5 };
1706/// int c[] = { 6, 7 };
1707/// std::pair<int, int> d = { 8, 9 };
1708/// \endcode
1709/// cxxStdInitializerListExpr()
1710/// matches "{ 1, 2, 3 }" and "{ 4, 5 }"
1711extern const internal::VariadicDynCastAllOfMatcher<Stmt,
1712 CXXStdInitializerListExpr>
1713 cxxStdInitializerListExpr;
1714
1715/// Matches implicit initializers of init list expressions.
1716///
1717/// Given
1718/// \code
1719/// point ptarray[10] = { [2].y = 1.0, [2].x = 2.0, [0].x = 1.0 };
1720/// \endcode
1721/// implicitValueInitExpr()
1722/// matches "[0].y" (implicitly)
1723extern const internal::VariadicDynCastAllOfMatcher<Stmt, ImplicitValueInitExpr>
1724 implicitValueInitExpr;
1725
1726/// Matches paren list expressions.
1727/// ParenListExprs don't have a predefined type and are used for late parsing.
1728/// In the final AST, they can be met in template declarations.
1729///
1730/// Given
1731/// \code
1732/// template<typename T> class X {
1733/// void f() {
1734/// X x(*this);
1735/// int a = 0, b = 1; int i = (a, b);
1736/// }
1737/// };
1738/// \endcode
1739/// parenListExpr() matches "*this" but NOT matches (a, b) because (a, b)
1740/// has a predefined type and is a ParenExpr, not a ParenListExpr.
1741extern const internal::VariadicDynCastAllOfMatcher<Stmt, ParenListExpr>
1742 parenListExpr;
1743
1744/// Matches substitutions of non-type template parameters.
1745///
1746/// Given
1747/// \code
1748/// template <int N>
1749/// struct A { static const int n = N; };
1750/// struct B : public A<42> {};
1751/// \endcode
1752/// substNonTypeTemplateParmExpr()
1753/// matches "N" in the right-hand side of "static const int n = N;"
1754extern const internal::VariadicDynCastAllOfMatcher<Stmt,
1755 SubstNonTypeTemplateParmExpr>
1756 substNonTypeTemplateParmExpr;
1757
1758/// Matches using declarations.
1759///
1760/// Given
1761/// \code
1762/// namespace X { int x; }
1763/// using X::x;
1764/// \endcode
1765/// usingDecl()
1766/// matches \code using X::x \endcode
1767extern const internal::VariadicDynCastAllOfMatcher<Decl, UsingDecl> usingDecl;
1768
1769/// Matches using-enum declarations.
1770///
1771/// Given
1772/// \code
1773/// namespace X { enum x {...}; }
1774/// using enum X::x;
1775/// \endcode
1776/// usingEnumDecl()
1777/// matches \code using enum X::x \endcode
1778extern const internal::VariadicDynCastAllOfMatcher<Decl, UsingEnumDecl>
1779 usingEnumDecl;
1780
1781/// Matches using namespace declarations.
1782///
1783/// Given
1784/// \code
1785/// namespace X { int x; }
1786/// using namespace X;
1787/// \endcode
1788/// usingDirectiveDecl()
1789/// matches \code using namespace X \endcode
1790extern const internal::VariadicDynCastAllOfMatcher<Decl, UsingDirectiveDecl>
1791 usingDirectiveDecl;
1792
1793/// Matches reference to a name that can be looked up during parsing
1794/// but could not be resolved to a specific declaration.
1795///
1796/// Given
1797/// \code
1798/// template<typename T>
1799/// T foo() { T a; return a; }
1800/// template<typename T>
1801/// void bar() {
1802/// foo<T>();
1803/// }
1804/// \endcode
1805/// unresolvedLookupExpr()
1806/// matches \code foo<T>() \endcode
1807extern const internal::VariadicDynCastAllOfMatcher<Stmt, UnresolvedLookupExpr>
1808 unresolvedLookupExpr;
1809
1810/// Matches unresolved using value declarations.
1811///
1812/// Given
1813/// \code
1814/// template<typename X>
1815/// class C : private X {
1816/// using X::x;
1817/// };
1818/// \endcode
1819/// unresolvedUsingValueDecl()
1820/// matches \code using X::x \endcode
1821extern const internal::VariadicDynCastAllOfMatcher<Decl,
1822 UnresolvedUsingValueDecl>
1823 unresolvedUsingValueDecl;
1824
1825/// Matches unresolved using value declarations that involve the
1826/// typename.
1827///
1828/// Given
1829/// \code
1830/// template <typename T>
1831/// struct Base { typedef T Foo; };
1832///
1833/// template<typename T>
1834/// struct S : private Base<T> {
1835/// using typename Base<T>::Foo;
1836/// };
1837/// \endcode
1838/// unresolvedUsingTypenameDecl()
1839/// matches \code using Base<T>::Foo \endcode
1840extern const internal::VariadicDynCastAllOfMatcher<Decl,
1841 UnresolvedUsingTypenameDecl>
1842 unresolvedUsingTypenameDecl;
1843
1844/// Matches a constant expression wrapper.
1845///
1846/// Example matches the constant in the case statement:
1847/// (matcher = constantExpr())
1848/// \code
1849/// switch (a) {
1850/// case 37: break;
1851/// }
1852/// \endcode
1853extern const internal::VariadicDynCastAllOfMatcher<Stmt, ConstantExpr>
1854 constantExpr;
1855
1856/// Matches parentheses used in expressions.
1857///
1858/// Example matches (foo() + 1)
1859/// \code
1860/// int foo() { return 1; }
1861/// int a = (foo() + 1);
1862/// \endcode
1863extern const internal::VariadicDynCastAllOfMatcher<Stmt, ParenExpr> parenExpr;
1864
1865/// Matches constructor call expressions (including implicit ones).
1866///
1867/// Example matches string(ptr, n) and ptr within arguments of f
1868/// (matcher = cxxConstructExpr())
1869/// \code
1870/// void f(const string &a, const string &b);
1871/// char *ptr;
1872/// int n;
1873/// f(string(ptr, n), ptr);
1874/// \endcode
1875extern const internal::VariadicDynCastAllOfMatcher<Stmt, CXXConstructExpr>
1876 cxxConstructExpr;
1877
1878/// Matches unresolved constructor call expressions.
1879///
1880/// Example matches T(t) in return statement of f
1881/// (matcher = cxxUnresolvedConstructExpr())
1882/// \code
1883/// template <typename T>
1884/// void f(const T& t) { return T(t); }
1885/// \endcode
1886extern const internal::VariadicDynCastAllOfMatcher<Stmt,
1887 CXXUnresolvedConstructExpr>
1888 cxxUnresolvedConstructExpr;
1889
1890/// Matches implicit and explicit this expressions.
1891///
1892/// Example matches the implicit this expression in "return i".
1893/// (matcher = cxxThisExpr())
1894/// \code
1895/// struct foo {
1896/// int i;
1897/// int f() { return i; }
1898/// };
1899/// \endcode
1900extern const internal::VariadicDynCastAllOfMatcher<Stmt, CXXThisExpr>
1901 cxxThisExpr;
1902
1903/// Matches nodes where temporaries are created.
1904///
1905/// Example matches FunctionTakesString(GetStringByValue())
1906/// (matcher = cxxBindTemporaryExpr())
1907/// \code
1908/// FunctionTakesString(GetStringByValue());
1909/// FunctionTakesStringByPointer(GetStringPointer());
1910/// \endcode
1911extern const internal::VariadicDynCastAllOfMatcher<Stmt, CXXBindTemporaryExpr>
1912 cxxBindTemporaryExpr;
1913
1914/// Matches nodes where temporaries are materialized.
1915///
1916/// Example: Given
1917/// \code
1918/// struct T {void func();};
1919/// T f();
1920/// void g(T);
1921/// \endcode
1922/// materializeTemporaryExpr() matches 'f()' in these statements
1923/// \code
1924/// T u(f());
1925/// g(f());
1926/// f().func();
1927/// \endcode
1928/// but does not match
1929/// \code
1930/// f();
1931/// \endcode
1932extern const internal::VariadicDynCastAllOfMatcher<Stmt,
1933 MaterializeTemporaryExpr>
1934 materializeTemporaryExpr;
1935
1936/// Matches new expressions.
1937///
1938/// Given
1939/// \code
1940/// new X;
1941/// \endcode
1942/// cxxNewExpr()
1943/// matches 'new X'.
1944extern const internal::VariadicDynCastAllOfMatcher<Stmt, CXXNewExpr> cxxNewExpr;
1945
1946/// Matches delete expressions.
1947///
1948/// Given
1949/// \code
1950/// delete X;
1951/// \endcode
1952/// cxxDeleteExpr()
1953/// matches 'delete X'.
1954extern const internal::VariadicDynCastAllOfMatcher<Stmt, CXXDeleteExpr>
1955 cxxDeleteExpr;
1956
1957/// Matches noexcept expressions.
1958///
1959/// Given
1960/// \code
1961/// bool a() noexcept;
1962/// bool b() noexcept(true);
1963/// bool c() noexcept(false);
1964/// bool d() noexcept(noexcept(a()));
1965/// bool e = noexcept(b()) || noexcept(c());
1966/// \endcode
1967/// cxxNoexceptExpr()
1968/// matches `noexcept(a())`, `noexcept(b())` and `noexcept(c())`.
1969/// doesn't match the noexcept specifier in the declarations a, b, c or d.
1970extern const internal::VariadicDynCastAllOfMatcher<Stmt, CXXNoexceptExpr>
1971 cxxNoexceptExpr;
1972
1973/// Matches array subscript expressions.
1974///
1975/// Given
1976/// \code
1977/// int i = a[1];
1978/// \endcode
1979/// arraySubscriptExpr()
1980/// matches "a[1]"
1981extern const internal::VariadicDynCastAllOfMatcher<Stmt, ArraySubscriptExpr>
1982 arraySubscriptExpr;
1983
1984/// Matches the value of a default argument at the call site.
1985///
1986/// Example matches the CXXDefaultArgExpr placeholder inserted for the
1987/// default value of the second parameter in the call expression f(42)
1988/// (matcher = cxxDefaultArgExpr())
1989/// \code
1990/// void f(int x, int y = 0);
1991/// f(42);
1992/// \endcode
1993extern const internal::VariadicDynCastAllOfMatcher<Stmt, CXXDefaultArgExpr>
1994 cxxDefaultArgExpr;
1995
1996/// Matches overloaded operator calls.
1997///
1998/// Note that if an operator isn't overloaded, it won't match. Instead, use
1999/// binaryOperator matcher.
2000/// Currently it does not match operators such as new delete.
2001/// FIXME: figure out why these do not match?
2002///
2003/// Example matches both operator<<((o << b), c) and operator<<(o, b)
2004/// (matcher = cxxOperatorCallExpr())
2005/// \code
2006/// ostream &operator<< (ostream &out, int i) { };
2007/// ostream &o; int b = 1, c = 1;
2008/// o << b << c;
2009/// \endcode
2010/// See also the binaryOperation() matcher for more-general matching of binary
2011/// uses of this AST node.
2012extern const internal::VariadicDynCastAllOfMatcher<Stmt, CXXOperatorCallExpr>
2013 cxxOperatorCallExpr;
2014
2015/// Matches rewritten binary operators
2016///
2017/// Example matches use of "<":
2018/// \code
2019/// #include <compare>
2020/// struct HasSpaceshipMem {
2021/// int a;
2022/// constexpr auto operator<=>(const HasSpaceshipMem&) const = default;
2023/// };
2024/// void compare() {
2025/// HasSpaceshipMem hs1, hs2;
2026/// if (hs1 < hs2)
2027/// return;
2028/// }
2029/// \endcode
2030/// See also the binaryOperation() matcher for more-general matching
2031/// of this AST node.
2032extern const internal::VariadicDynCastAllOfMatcher<Stmt,
2033 CXXRewrittenBinaryOperator>
2034 cxxRewrittenBinaryOperator;
2035
2036/// Matches expressions.
2037///
2038/// Example matches x()
2039/// \code
2040/// void f() { x(); }
2041/// \endcode
2042extern const internal::VariadicDynCastAllOfMatcher<Stmt, Expr> expr;
2043
2044/// Matches expressions that refer to declarations.
2045///
2046/// Example matches x in if (x)
2047/// \code
2048/// bool x;
2049/// if (x) {}
2050/// \endcode
2051extern const internal::VariadicDynCastAllOfMatcher<Stmt, DeclRefExpr>
2052 declRefExpr;
2053
2054/// Matches a reference to an ObjCIvar.
2055///
2056/// Example: matches "a" in "init" method:
2057/// \code
2058/// @implementation A {
2059/// NSString *a;
2060/// }
2061/// - (void) init {
2062/// a = @"hello";
2063/// }
2064/// \endcode
2065extern const internal::VariadicDynCastAllOfMatcher<Stmt, ObjCIvarRefExpr>
2066 objcIvarRefExpr;
2067
2068/// Matches a reference to a block.
2069///
2070/// Example: matches "^{}":
2071/// \code
2072/// void f() { ^{}(); }
2073/// \endcode
2074extern const internal::VariadicDynCastAllOfMatcher<Stmt, BlockExpr> blockExpr;
2075
2076/// Matches if statements.
2077///
2078/// Example matches 'if (x) {}'
2079/// \code
2080/// if (x) {}
2081/// \endcode
2082extern const internal::VariadicDynCastAllOfMatcher<Stmt, IfStmt> ifStmt;
2083
2084/// Matches for statements.
2085///
2086/// Example matches 'for (;;) {}'
2087/// \code
2088/// for (;;) {}
2089/// int i[] = {1, 2, 3}; for (auto a : i);
2090/// \endcode
2091extern const internal::VariadicDynCastAllOfMatcher<Stmt, ForStmt> forStmt;
2092
2093/// Matches the increment statement of a for loop.
2094///
2095/// Example:
2096/// forStmt(hasIncrement(unaryOperator(hasOperatorName("++"))))
2097/// matches '++x' in
2098/// \code
2099/// for (x; x < N; ++x) { }
2100/// \endcode
2101AST_MATCHER_P(ForStmt, hasIncrement, internal::Matcher<Stmt>,namespace internal { class matcher_hasIncrement0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<ForStmt
> { public: explicit matcher_hasIncrement0Matcher( internal
::Matcher<Stmt> const &AInnerMatcher) : InnerMatcher
(AInnerMatcher) {} bool matches(const ForStmt &Node, ::clang
::ast_matchers::internal::ASTMatchFinder *Finder, ::clang::ast_matchers
::internal::BoundNodesTreeBuilder *Builder) const override; private
: internal::Matcher<Stmt> InnerMatcher; }; } inline ::clang
::ast_matchers::internal::Matcher<ForStmt> hasIncrement
( internal::Matcher<Stmt> const &InnerMatcher) { return
::clang::ast_matchers::internal::makeMatcher( new internal::
matcher_hasIncrement0Matcher(InnerMatcher)); } typedef ::clang
::ast_matchers::internal::Matcher<ForStmt> ( &hasIncrement_Type0
)(internal::Matcher<Stmt> const &InnerMatcher); inline
bool internal::matcher_hasIncrement0Matcher::matches( const ForStmt
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
2102 InnerMatcher)namespace internal { class matcher_hasIncrement0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<ForStmt
> { public: explicit matcher_hasIncrement0Matcher( internal
::Matcher<Stmt> const &AInnerMatcher) : InnerMatcher
(AInnerMatcher) {} bool matches(const ForStmt &Node, ::clang
::ast_matchers::internal::ASTMatchFinder *Finder, ::clang::ast_matchers
::internal::BoundNodesTreeBuilder *Builder) const override; private
: internal::Matcher<Stmt> InnerMatcher; }; } inline ::clang
::ast_matchers::internal::Matcher<ForStmt> hasIncrement
( internal::Matcher<Stmt> const &InnerMatcher) { return
::clang::ast_matchers::internal::makeMatcher( new internal::
matcher_hasIncrement0Matcher(InnerMatcher)); } typedef ::clang
::ast_matchers::internal::Matcher<ForStmt> ( &hasIncrement_Type0
)(internal::Matcher<Stmt> const &InnerMatcher); inline
bool internal::matcher_hasIncrement0Matcher::matches( const ForStmt
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
2103 const Stmt *const Increment = Node.getInc();
2104 return (Increment != nullptr &&
2105 InnerMatcher.matches(*Increment, Finder, Builder));
2106}
2107
2108/// Matches the initialization statement of a for loop.
2109///
2110/// Example:
2111/// forStmt(hasLoopInit(declStmt()))
2112/// matches 'int x = 0' in
2113/// \code
2114/// for (int x = 0; x < N; ++x) { }
2115/// \endcode
2116AST_MATCHER_P(ForStmt, hasLoopInit, internal::Matcher<Stmt>,namespace internal { class matcher_hasLoopInit0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<ForStmt
> { public: explicit matcher_hasLoopInit0Matcher( internal
::Matcher<Stmt> const &AInnerMatcher) : InnerMatcher
(AInnerMatcher) {} bool matches(const ForStmt &Node, ::clang
::ast_matchers::internal::ASTMatchFinder *Finder, ::clang::ast_matchers
::internal::BoundNodesTreeBuilder *Builder) const override; private
: internal::Matcher<Stmt> InnerMatcher; }; } inline ::clang
::ast_matchers::internal::Matcher<ForStmt> hasLoopInit(
internal::Matcher<Stmt> const &InnerMatcher) { return
::clang::ast_matchers::internal::makeMatcher( new internal::
matcher_hasLoopInit0Matcher(InnerMatcher)); } typedef ::clang
::ast_matchers::internal::Matcher<ForStmt> ( &hasLoopInit_Type0
)(internal::Matcher<Stmt> const &InnerMatcher); inline
bool internal::matcher_hasLoopInit0Matcher::matches( const ForStmt
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
2117 InnerMatcher)namespace internal { class matcher_hasLoopInit0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<ForStmt
> { public: explicit matcher_hasLoopInit0Matcher( internal
::Matcher<Stmt> const &AInnerMatcher) : InnerMatcher
(AInnerMatcher) {} bool matches(const ForStmt &Node, ::clang
::ast_matchers::internal::ASTMatchFinder *Finder, ::clang::ast_matchers
::internal::BoundNodesTreeBuilder *Builder) const override; private
: internal::Matcher<Stmt> InnerMatcher; }; } inline ::clang
::ast_matchers::internal::Matcher<ForStmt> hasLoopInit(
internal::Matcher<Stmt> const &InnerMatcher) { return
::clang::ast_matchers::internal::makeMatcher( new internal::
matcher_hasLoopInit0Matcher(InnerMatcher)); } typedef ::clang
::ast_matchers::internal::Matcher<ForStmt> ( &hasLoopInit_Type0
)(internal::Matcher<Stmt> const &InnerMatcher); inline
bool internal::matcher_hasLoopInit0Matcher::matches( const ForStmt
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
2118 const Stmt *const Init = Node.getInit();
2119 return (Init != nullptr && InnerMatcher.matches(*Init, Finder, Builder));
2120}
2121
2122/// Matches range-based for statements.
2123///
2124/// cxxForRangeStmt() matches 'for (auto a : i)'
2125/// \code
2126/// int i[] = {1, 2, 3}; for (auto a : i);
2127/// for(int j = 0; j < 5; ++j);
2128/// \endcode
2129extern const internal::VariadicDynCastAllOfMatcher<Stmt, CXXForRangeStmt>
2130 cxxForRangeStmt;
2131
2132/// Matches the initialization statement of a for loop.
2133///
2134/// Example:
2135/// forStmt(hasLoopVariable(anything()))
2136/// matches 'int x' in
2137/// \code
2138/// for (int x : a) { }
2139/// \endcode
2140AST_MATCHER_P(CXXForRangeStmt, hasLoopVariable, internal::Matcher<VarDecl>,namespace internal { class matcher_hasLoopVariable0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<CXXForRangeStmt
> { public: explicit matcher_hasLoopVariable0Matcher( internal
::Matcher<VarDecl> const &AInnerMatcher) : InnerMatcher
(AInnerMatcher) {} bool matches(const CXXForRangeStmt &Node
, ::clang::ast_matchers::internal::ASTMatchFinder *Finder, ::
clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder
) const override; private: internal::Matcher<VarDecl> InnerMatcher
; }; } inline ::clang::ast_matchers::internal::Matcher<CXXForRangeStmt
> hasLoopVariable( internal::Matcher<VarDecl> const &
InnerMatcher) { return ::clang::ast_matchers::internal::makeMatcher
( new internal::matcher_hasLoopVariable0Matcher(InnerMatcher)
); } typedef ::clang::ast_matchers::internal::Matcher<CXXForRangeStmt
> ( &hasLoopVariable_Type0)(internal::Matcher<VarDecl
> const &InnerMatcher); inline bool internal::matcher_hasLoopVariable0Matcher
::matches( const CXXForRangeStmt &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
2141 InnerMatcher)namespace internal { class matcher_hasLoopVariable0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<CXXForRangeStmt
> { public: explicit matcher_hasLoopVariable0Matcher( internal
::Matcher<VarDecl> const &AInnerMatcher) : InnerMatcher
(AInnerMatcher) {} bool matches(const CXXForRangeStmt &Node
, ::clang::ast_matchers::internal::ASTMatchFinder *Finder, ::
clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder
) const override; private: internal::Matcher<VarDecl> InnerMatcher
; }; } inline ::clang::ast_matchers::internal::Matcher<CXXForRangeStmt
> hasLoopVariable( internal::Matcher<VarDecl> const &
InnerMatcher) { return ::clang::ast_matchers::internal::makeMatcher
( new internal::matcher_hasLoopVariable0Matcher(InnerMatcher)
); } typedef ::clang::ast_matchers::internal::Matcher<CXXForRangeStmt
> ( &hasLoopVariable_Type0)(internal::Matcher<VarDecl
> const &InnerMatcher); inline bool internal::matcher_hasLoopVariable0Matcher
::matches( const CXXForRangeStmt &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
{
2142 const VarDecl *const Var = Node.getLoopVariable();
2143 return (Var != nullptr && InnerMatcher.matches(*Var, Finder, Builder));
2144}
2145
2146/// Matches the range initialization statement of a for loop.
2147///
2148/// Example:
2149/// forStmt(hasRangeInit(anything()))
2150/// matches 'a' in
2151/// \code
2152/// for (int x : a) { }
2153/// \endcode
2154AST_MATCHER_P(CXXForRangeStmt, hasRangeInit, internal::Matcher<Expr>,namespace internal { class matcher_hasRangeInit0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<CXXForRangeStmt
> { public: explicit matcher_hasRangeInit0Matcher( internal
::Matcher<Expr> const &AInnerMatcher) : InnerMatcher
(AInnerMatcher) {} bool matches(const CXXForRangeStmt &Node
, ::clang::ast_matchers::internal::ASTMatchFinder *Finder, ::
clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder
) const override; private: internal::Matcher<Expr> InnerMatcher
; }; } inline ::clang::ast_matchers::internal::Matcher<CXXForRangeStmt
> hasRangeInit( internal::Matcher<Expr> const &InnerMatcher
) { return ::clang::ast_matchers::internal::makeMatcher( new internal
::matcher_hasRangeInit0Matcher(InnerMatcher)); } typedef ::clang
::ast_matchers::internal::Matcher<CXXForRangeStmt> ( &
hasRangeInit_Type0)(internal::Matcher<Expr> const &
InnerMatcher); inline bool internal::matcher_hasRangeInit0Matcher
::matches( const CXXForRangeStmt &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
2155 InnerMatcher)namespace internal { class matcher_hasRangeInit0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<CXXForRangeStmt
> { public: explicit matcher_hasRangeInit0Matcher( internal
::Matcher<Expr> const &AInnerMatcher) : InnerMatcher
(AInnerMatcher) {} bool matches(const CXXForRangeStmt &Node
, ::clang::ast_matchers::internal::ASTMatchFinder *Finder, ::
clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder
) const override; private: internal::Matcher<Expr> InnerMatcher
; }; } inline ::clang::ast_matchers::internal::Matcher<CXXForRangeStmt
> hasRangeInit( internal::Matcher<Expr> const &InnerMatcher
) { return ::clang::ast_matchers::internal::makeMatcher( new internal
::matcher_hasRangeInit0Matcher(InnerMatcher)); } typedef ::clang
::ast_matchers::internal::Matcher<CXXForRangeStmt> ( &
hasRangeInit_Type0)(internal::Matcher<Expr> const &
InnerMatcher); inline bool internal::matcher_hasRangeInit0Matcher
::matches( const CXXForRangeStmt &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
{
2156 const Expr *const Init = Node.getRangeInit();
2157 return (Init != nullptr && InnerMatcher.matches(*Init, Finder, Builder));
2158}
2159
2160/// Matches while statements.
2161///
2162/// Given
2163/// \code
2164/// while (true) {}
2165/// \endcode
2166/// whileStmt()
2167/// matches 'while (true) {}'.
2168extern const internal::VariadicDynCastAllOfMatcher<Stmt, WhileStmt> whileStmt;
2169
2170/// Matches do statements.
2171///
2172/// Given
2173/// \code
2174/// do {} while (true);
2175/// \endcode
2176/// doStmt()
2177/// matches 'do {} while(true)'
2178extern const internal::VariadicDynCastAllOfMatcher<Stmt, DoStmt> doStmt;
2179
2180/// Matches break statements.
2181///
2182/// Given
2183/// \code
2184/// while (true) { break; }
2185/// \endcode
2186/// breakStmt()
2187/// matches 'break'
2188extern const internal::VariadicDynCastAllOfMatcher<Stmt, BreakStmt> breakStmt;
2189
2190/// Matches continue statements.
2191///
2192/// Given
2193/// \code
2194/// while (true) { continue; }
2195/// \endcode
2196/// continueStmt()
2197/// matches 'continue'
2198extern const internal::VariadicDynCastAllOfMatcher<Stmt, ContinueStmt>
2199 continueStmt;
2200
2201/// Matches co_return statements.
2202///
2203/// Given
2204/// \code
2205/// while (true) { co_return; }
2206/// \endcode
2207/// coreturnStmt()
2208/// matches 'co_return'
2209extern const internal::VariadicDynCastAllOfMatcher<Stmt, CoreturnStmt>
2210 coreturnStmt;
2211
2212/// Matches return statements.
2213///
2214/// Given
2215/// \code
2216/// return 1;
2217/// \endcode
2218/// returnStmt()
2219/// matches 'return 1'
2220extern const internal::VariadicDynCastAllOfMatcher<Stmt, ReturnStmt> returnStmt;
2221
2222/// Matches goto statements.
2223///
2224/// Given
2225/// \code
2226/// goto FOO;
2227/// FOO: bar();
2228/// \endcode
2229/// gotoStmt()
2230/// matches 'goto FOO'
2231extern const internal::VariadicDynCastAllOfMatcher<Stmt, GotoStmt> gotoStmt;
2232
2233/// Matches label statements.
2234///
2235/// Given
2236/// \code
2237/// goto FOO;
2238/// FOO: bar();
2239/// \endcode
2240/// labelStmt()
2241/// matches 'FOO:'
2242extern const internal::VariadicDynCastAllOfMatcher<Stmt, LabelStmt> labelStmt;
2243
2244/// Matches address of label statements (GNU extension).
2245///
2246/// Given
2247/// \code
2248/// FOO: bar();
2249/// void *ptr = &&FOO;
2250/// goto *bar;
2251/// \endcode
2252/// addrLabelExpr()
2253/// matches '&&FOO'
2254extern const internal::VariadicDynCastAllOfMatcher<Stmt, AddrLabelExpr>
2255 addrLabelExpr;
2256
2257/// Matches switch statements.
2258///
2259/// Given
2260/// \code
2261/// switch(a) { case 42: break; default: break; }
2262/// \endcode
2263/// switchStmt()
2264/// matches 'switch(a)'.
2265extern const internal::VariadicDynCastAllOfMatcher<Stmt, SwitchStmt> switchStmt;
2266
2267/// Matches case and default statements inside switch statements.
2268///
2269/// Given
2270/// \code
2271/// switch(a) { case 42: break; default: break; }
2272/// \endcode
2273/// switchCase()
2274/// matches 'case 42:' and 'default:'.
2275extern const internal::VariadicDynCastAllOfMatcher<Stmt, SwitchCase> switchCase;
2276
2277/// Matches case statements inside switch statements.
2278///
2279/// Given
2280/// \code
2281/// switch(a) { case 42: break; default: break; }
2282/// \endcode
2283/// caseStmt()
2284/// matches 'case 42:'.
2285extern const internal::VariadicDynCastAllOfMatcher<Stmt, CaseStmt> caseStmt;
2286
2287/// Matches default statements inside switch statements.
2288///
2289/// Given
2290/// \code
2291/// switch(a) { case 42: break; default: break; }
2292/// \endcode
2293/// defaultStmt()
2294/// matches 'default:'.
2295extern const internal::VariadicDynCastAllOfMatcher<Stmt, DefaultStmt>
2296 defaultStmt;
2297
2298/// Matches compound statements.
2299///
2300/// Example matches '{}' and '{{}}' in 'for (;;) {{}}'
2301/// \code
2302/// for (;;) {{}}
2303/// \endcode
2304extern const internal::VariadicDynCastAllOfMatcher<Stmt, CompoundStmt>
2305 compoundStmt;
2306
2307/// Matches catch statements.
2308///
2309/// \code
2310/// try {} catch(int i) {}
2311/// \endcode
2312/// cxxCatchStmt()
2313/// matches 'catch(int i)'
2314extern const internal::VariadicDynCastAllOfMatcher<Stmt, CXXCatchStmt>
2315 cxxCatchStmt;
2316
2317/// Matches try statements.
2318///
2319/// \code
2320/// try {} catch(int i) {}
2321/// \endcode
2322/// cxxTryStmt()
2323/// matches 'try {}'
2324extern const internal::VariadicDynCastAllOfMatcher<Stmt, CXXTryStmt> cxxTryStmt;
2325
2326/// Matches throw expressions.
2327///
2328/// \code
2329/// try { throw 5; } catch(int i) {}
2330/// \endcode
2331/// cxxThrowExpr()
2332/// matches 'throw 5'
2333extern const internal::VariadicDynCastAllOfMatcher<Stmt, CXXThrowExpr>
2334 cxxThrowExpr;
2335
2336/// Matches null statements.
2337///
2338/// \code
2339/// foo();;
2340/// \endcode
2341/// nullStmt()
2342/// matches the second ';'
2343extern const internal::VariadicDynCastAllOfMatcher<Stmt, NullStmt> nullStmt;
2344
2345/// Matches asm statements.
2346///
2347/// \code
2348/// int i = 100;
2349/// __asm("mov al, 2");
2350/// \endcode
2351/// asmStmt()
2352/// matches '__asm("mov al, 2")'
2353extern const internal::VariadicDynCastAllOfMatcher<Stmt, AsmStmt> asmStmt;
2354
2355/// Matches bool literals.
2356///
2357/// Example matches true
2358/// \code
2359/// true
2360/// \endcode
2361extern const internal::VariadicDynCastAllOfMatcher<Stmt, CXXBoolLiteralExpr>
2362 cxxBoolLiteral;
2363
2364/// Matches string literals (also matches wide string literals).
2365///
2366/// Example matches "abcd", L"abcd"
2367/// \code
2368/// char *s = "abcd";
2369/// wchar_t *ws = L"abcd";
2370/// \endcode
2371extern const internal::VariadicDynCastAllOfMatcher<Stmt, StringLiteral>
2372 stringLiteral;
2373
2374/// Matches character literals (also matches wchar_t).
2375///
2376/// Not matching Hex-encoded chars (e.g. 0x1234, which is a IntegerLiteral),
2377/// though.
2378///
2379/// Example matches 'a', L'a'
2380/// \code
2381/// char ch = 'a';
2382/// wchar_t chw = L'a';
2383/// \endcode
2384extern const internal::VariadicDynCastAllOfMatcher<Stmt, CharacterLiteral>
2385 characterLiteral;
2386
2387/// Matches integer literals of all sizes / encodings, e.g.
2388/// 1, 1L, 0x1 and 1U.
2389///
2390/// Does not match character-encoded integers such as L'a'.
2391extern const internal::VariadicDynCastAllOfMatcher<Stmt, IntegerLiteral>
2392 integerLiteral;
2393
2394/// Matches float literals of all sizes / encodings, e.g.
2395/// 1.0, 1.0f, 1.0L and 1e10.
2396///
2397/// Does not match implicit conversions such as
2398/// \code
2399/// float a = 10;
2400/// \endcode
2401extern const internal::VariadicDynCastAllOfMatcher<Stmt, FloatingLiteral>
2402 floatLiteral;
2403
2404/// Matches imaginary literals, which are based on integer and floating
2405/// point literals e.g.: 1i, 1.0i
2406extern const internal::VariadicDynCastAllOfMatcher<Stmt, ImaginaryLiteral>
2407 imaginaryLiteral;
2408
2409/// Matches fixed point literals
2410extern const internal::VariadicDynCastAllOfMatcher<Stmt, FixedPointLiteral>
2411 fixedPointLiteral;
2412
2413/// Matches user defined literal operator call.
2414///
2415/// Example match: "foo"_suffix
2416extern const internal::VariadicDynCastAllOfMatcher<Stmt, UserDefinedLiteral>
2417 userDefinedLiteral;
2418
2419/// Matches compound (i.e. non-scalar) literals
2420///
2421/// Example match: {1}, (1, 2)
2422/// \code
2423/// int array[4] = {1};
2424/// vector int myvec = (vector int)(1, 2);
2425/// \endcode
2426extern const internal::VariadicDynCastAllOfMatcher<Stmt, CompoundLiteralExpr>
2427 compoundLiteralExpr;
2428
2429/// Matches co_await expressions.
2430///
2431/// Given
2432/// \code
2433/// co_await 1;
2434/// \endcode
2435/// coawaitExpr()
2436/// matches 'co_await 1'
2437extern const internal::VariadicDynCastAllOfMatcher<Stmt, CoawaitExpr>
2438 coawaitExpr;
2439/// Matches co_await expressions where the type of the promise is dependent
2440extern const internal::VariadicDynCastAllOfMatcher<Stmt, DependentCoawaitExpr>
2441 dependentCoawaitExpr;
2442/// Matches co_yield expressions.
2443///
2444/// Given
2445/// \code
2446/// co_yield 1;
2447/// \endcode
2448/// coyieldExpr()
2449/// matches 'co_yield 1'
2450extern const internal::VariadicDynCastAllOfMatcher<Stmt, CoyieldExpr>
2451 coyieldExpr;
2452
2453/// Matches coroutine body statements.
2454///
2455/// coroutineBodyStmt() matches the coroutine below
2456/// \code
2457/// generator<int> gen() {
2458/// co_return;
2459/// }
2460/// \endcode
2461extern const internal::VariadicDynCastAllOfMatcher<Stmt, CoroutineBodyStmt>
2462 coroutineBodyStmt;
2463
2464/// Matches nullptr literal.
2465extern const internal::VariadicDynCastAllOfMatcher<Stmt, CXXNullPtrLiteralExpr>
2466 cxxNullPtrLiteralExpr;
2467
2468/// Matches GNU __builtin_choose_expr.
2469extern const internal::VariadicDynCastAllOfMatcher<Stmt, ChooseExpr>
2470 chooseExpr;
2471
2472/// Matches GNU __null expression.
2473extern const internal::VariadicDynCastAllOfMatcher<Stmt, GNUNullExpr>
2474 gnuNullExpr;
2475
2476/// Matches C11 _Generic expression.
2477extern const internal::VariadicDynCastAllOfMatcher<Stmt, GenericSelectionExpr>
2478 genericSelectionExpr;
2479
2480/// Matches atomic builtins.
2481/// Example matches __atomic_load_n(ptr, 1)
2482/// \code
2483/// void foo() { int *ptr; __atomic_load_n(ptr, 1); }
2484/// \endcode
2485extern const internal::VariadicDynCastAllOfMatcher<Stmt, AtomicExpr> atomicExpr;
2486
2487/// Matches statement expression (GNU extension).
2488///
2489/// Example match: ({ int X = 4; X; })
2490/// \code
2491/// int C = ({ int X = 4; X; });
2492/// \endcode
2493extern const internal::VariadicDynCastAllOfMatcher<Stmt, StmtExpr> stmtExpr;
2494
2495/// Matches binary operator expressions.
2496///
2497/// Example matches a || b
2498/// \code
2499/// !(a || b)
2500/// \endcode
2501/// See also the binaryOperation() matcher for more-general matching.
2502extern const internal::VariadicDynCastAllOfMatcher<Stmt, BinaryOperator>
2503 binaryOperator;
2504
2505/// Matches unary operator expressions.
2506///
2507/// Example matches !a
2508/// \code
2509/// !a || b
2510/// \endcode
2511extern const internal::VariadicDynCastAllOfMatcher<Stmt, UnaryOperator>
2512 unaryOperator;
2513
2514/// Matches conditional operator expressions.
2515///
2516/// Example matches a ? b : c
2517/// \code
2518/// (a ? b : c) + 42
2519/// \endcode
2520extern const internal::VariadicDynCastAllOfMatcher<Stmt, ConditionalOperator>
2521 conditionalOperator;
2522
2523/// Matches binary conditional operator expressions (GNU extension).
2524///
2525/// Example matches a ?: b
2526/// \code
2527/// (a ?: b) + 42;
2528/// \endcode
2529extern const internal::VariadicDynCastAllOfMatcher<Stmt,
2530 BinaryConditionalOperator>
2531 binaryConditionalOperator;
2532
2533/// Matches opaque value expressions. They are used as helpers
2534/// to reference another expressions and can be met
2535/// in BinaryConditionalOperators, for example.
2536///
2537/// Example matches 'a'
2538/// \code
2539/// (a ?: c) + 42;
2540/// \endcode
2541extern const internal::VariadicDynCastAllOfMatcher<Stmt, OpaqueValueExpr>
2542 opaqueValueExpr;
2543
2544/// Matches a C++ static_assert declaration.
2545///
2546/// Example:
2547/// staticAssertDecl()
2548/// matches
2549/// static_assert(sizeof(S) == sizeof(int))
2550/// in
2551/// \code
2552/// struct S {
2553/// int x;
2554/// };
2555/// static_assert(sizeof(S) == sizeof(int));
2556/// \endcode
2557extern const internal::VariadicDynCastAllOfMatcher<Decl, StaticAssertDecl>
2558 staticAssertDecl;
2559
2560/// Matches a reinterpret_cast expression.
2561///
2562/// Either the source expression or the destination type can be matched
2563/// using has(), but hasDestinationType() is more specific and can be
2564/// more readable.
2565///
2566/// Example matches reinterpret_cast<char*>(&p) in
2567/// \code
2568/// void* p = reinterpret_cast<char*>(&p);
2569/// \endcode
2570extern const internal::VariadicDynCastAllOfMatcher<Stmt, CXXReinterpretCastExpr>
2571 cxxReinterpretCastExpr;
2572
2573/// Matches a C++ static_cast expression.
2574///
2575/// \see hasDestinationType
2576/// \see reinterpretCast
2577///
2578/// Example:
2579/// cxxStaticCastExpr()
2580/// matches
2581/// static_cast<long>(8)
2582/// in
2583/// \code
2584/// long eight(static_cast<long>(8));
2585/// \endcode
2586extern const internal::VariadicDynCastAllOfMatcher<Stmt, CXXStaticCastExpr>
2587 cxxStaticCastExpr;
2588
2589/// Matches a dynamic_cast expression.
2590///
2591/// Example:
2592/// cxxDynamicCastExpr()
2593/// matches
2594/// dynamic_cast<D*>(&b);
2595/// in
2596/// \code
2597/// struct B { virtual ~B() {} }; struct D : B {};
2598/// B b;
2599/// D* p = dynamic_cast<D*>(&b);
2600/// \endcode
2601extern const internal::VariadicDynCastAllOfMatcher<Stmt, CXXDynamicCastExpr>
2602 cxxDynamicCastExpr;
2603
2604/// Matches a const_cast expression.
2605///
2606/// Example: Matches const_cast<int*>(&r) in
2607/// \code
2608/// int n = 42;
2609/// const int &r(n);
2610/// int* p = const_cast<int*>(&r);
2611/// \endcode
2612extern const internal::VariadicDynCastAllOfMatcher<Stmt, CXXConstCastExpr>
2613 cxxConstCastExpr;
2614
2615/// Matches a C-style cast expression.
2616///
2617/// Example: Matches (int) 2.2f in
2618/// \code
2619/// int i = (int) 2.2f;
2620/// \endcode
2621extern const internal::VariadicDynCastAllOfMatcher<Stmt, CStyleCastExpr>
2622 cStyleCastExpr;
2623
2624/// Matches explicit cast expressions.
2625///
2626/// Matches any cast expression written in user code, whether it be a
2627/// C-style cast, a functional-style cast, or a keyword cast.
2628///
2629/// Does not match implicit conversions.
2630///
2631/// Note: the name "explicitCast" is chosen to match Clang's terminology, as
2632/// Clang uses the term "cast" to apply to implicit conversions as well as to
2633/// actual cast expressions.
2634///
2635/// \see hasDestinationType.
2636///
2637/// Example: matches all five of the casts in
2638/// \code
2639/// int((int)(reinterpret_cast<int>(static_cast<int>(const_cast<int>(42)))))
2640/// \endcode
2641/// but does not match the implicit conversion in
2642/// \code
2643/// long ell = 42;
2644/// \endcode
2645extern const internal::VariadicDynCastAllOfMatcher<Stmt, ExplicitCastExpr>
2646 explicitCastExpr;
2647
2648/// Matches the implicit cast nodes of Clang's AST.
2649///
2650/// This matches many different places, including function call return value
2651/// eliding, as well as any type conversions.
2652extern const internal::VariadicDynCastAllOfMatcher<Stmt, ImplicitCastExpr>
2653 implicitCastExpr;
2654
2655/// Matches any cast nodes of Clang's AST.
2656///
2657/// Example: castExpr() matches each of the following:
2658/// \code
2659/// (int) 3;
2660/// const_cast<Expr *>(SubExpr);
2661/// char c = 0;
2662/// \endcode
2663/// but does not match
2664/// \code
2665/// int i = (0);
2666/// int k = 0;
2667/// \endcode
2668extern const internal::VariadicDynCastAllOfMatcher<Stmt, CastExpr> castExpr;
2669
2670/// Matches functional cast expressions
2671///
2672/// Example: Matches Foo(bar);
2673/// \code
2674/// Foo f = bar;
2675/// Foo g = (Foo) bar;
2676/// Foo h = Foo(bar);
2677/// \endcode
2678extern const internal::VariadicDynCastAllOfMatcher<Stmt, CXXFunctionalCastExpr>
2679 cxxFunctionalCastExpr;
2680
2681/// Matches functional cast expressions having N != 1 arguments
2682///
2683/// Example: Matches Foo(bar, bar)
2684/// \code
2685/// Foo h = Foo(bar, bar);
2686/// \endcode
2687extern const internal::VariadicDynCastAllOfMatcher<Stmt, CXXTemporaryObjectExpr>
2688 cxxTemporaryObjectExpr;
2689
2690/// Matches predefined identifier expressions [C99 6.4.2.2].
2691///
2692/// Example: Matches __func__
2693/// \code
2694/// printf("%s", __func__);
2695/// \endcode
2696extern const internal::VariadicDynCastAllOfMatcher<Stmt, PredefinedExpr>
2697 predefinedExpr;
2698
2699/// Matches C99 designated initializer expressions [C99 6.7.8].
2700///
2701/// Example: Matches { [2].y = 1.0, [0].x = 1.0 }
2702/// \code
2703/// point ptarray[10] = { [2].y = 1.0, [0].x = 1.0 };
2704/// \endcode
2705extern const internal::VariadicDynCastAllOfMatcher<Stmt, DesignatedInitExpr>
2706 designatedInitExpr;
2707
2708/// Matches designated initializer expressions that contain
2709/// a specific number of designators.
2710///
2711/// Example: Given
2712/// \code
2713/// point ptarray[10] = { [2].y = 1.0, [0].x = 1.0 };
2714/// point ptarray2[10] = { [2].y = 1.0, [2].x = 0.0, [0].x = 1.0 };
2715/// \endcode
2716/// designatorCountIs(2)
2717/// matches '{ [2].y = 1.0, [0].x = 1.0 }',
2718/// but not '{ [2].y = 1.0, [2].x = 0.0, [0].x = 1.0 }'.
2719AST_MATCHER_P(DesignatedInitExpr, designatorCountIs, unsigned, N)namespace internal { class matcher_designatorCountIs0Matcher :
public ::clang::ast_matchers::internal::MatcherInterface<
DesignatedInitExpr> { public: explicit matcher_designatorCountIs0Matcher
( unsigned const &AN) : N(AN) {} bool matches(const DesignatedInitExpr
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: unsigned N; }; } inline ::
clang::ast_matchers::internal::Matcher<DesignatedInitExpr>
designatorCountIs( unsigned const &N) { return ::clang::
ast_matchers::internal::makeMatcher( new internal::matcher_designatorCountIs0Matcher
(N)); } typedef ::clang::ast_matchers::internal::Matcher<DesignatedInitExpr
> ( &designatorCountIs_Type0)(unsigned const &N); inline
bool internal::matcher_designatorCountIs0Matcher::matches( const
DesignatedInitExpr &Node, ::clang::ast_matchers::internal
::ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
2720 return Node.size() == N;
2721}
2722
2723/// Matches \c QualTypes in the clang AST.
2724extern const internal::VariadicAllOfMatcher<QualType> qualType;
2725
2726/// Matches \c Types in the clang AST.
2727extern const internal::VariadicAllOfMatcher<Type> type;
2728
2729/// Matches \c TypeLocs in the clang AST.
2730extern const internal::VariadicAllOfMatcher<TypeLoc> typeLoc;
2731
2732/// Matches if any of the given matchers matches.
2733///
2734/// Unlike \c anyOf, \c eachOf will generate a match result for each
2735/// matching submatcher.
2736///
2737/// For example, in:
2738/// \code
2739/// class A { int a; int b; };
2740/// \endcode
2741/// The matcher:
2742/// \code
2743/// cxxRecordDecl(eachOf(has(fieldDecl(hasName("a")).bind("v")),
2744/// has(fieldDecl(hasName("b")).bind("v"))))
2745/// \endcode
2746/// will generate two results binding "v", the first of which binds
2747/// the field declaration of \c a, the second the field declaration of
2748/// \c b.
2749///
2750/// Usable as: Any Matcher
2751extern const internal::VariadicOperatorMatcherFunc<
2752 2, std::numeric_limits<unsigned>::max()>
2753 eachOf;
2754
2755/// Matches if any of the given matchers matches.
2756///
2757/// Usable as: Any Matcher
2758extern const internal::VariadicOperatorMatcherFunc<
2759 2, std::numeric_limits<unsigned>::max()>
2760 anyOf;
2761
2762/// Matches if all given matchers match.
2763///
2764/// Usable as: Any Matcher
2765extern const internal::VariadicOperatorMatcherFunc<
2766 2, std::numeric_limits<unsigned>::max()>
2767 allOf;
2768
2769/// Matches any node regardless of the submatcher.
2770///
2771/// However, \c optionally will retain any bindings generated by the submatcher.
2772/// Useful when additional information which may or may not present about a main
2773/// matching node is desired.
2774///
2775/// For example, in:
2776/// \code
2777/// class Foo {
2778/// int bar;
2779/// }
2780/// \endcode
2781/// The matcher:
2782/// \code
2783/// cxxRecordDecl(
2784/// optionally(has(
2785/// fieldDecl(hasName("bar")).bind("var")
2786/// ))).bind("record")
2787/// \endcode
2788/// will produce a result binding for both "record" and "var".
2789/// The matcher will produce a "record" binding for even if there is no data
2790/// member named "bar" in that class.
2791///
2792/// Usable as: Any Matcher
2793extern const internal::VariadicOperatorMatcherFunc<1, 1> optionally;
2794
2795/// Matches sizeof (C99), alignof (C++11) and vec_step (OpenCL)
2796///
2797/// Given
2798/// \code
2799/// Foo x = bar;
2800/// int y = sizeof(x) + alignof(x);
2801/// \endcode
2802/// unaryExprOrTypeTraitExpr()
2803/// matches \c sizeof(x) and \c alignof(x)
2804extern const internal::VariadicDynCastAllOfMatcher<Stmt,
2805 UnaryExprOrTypeTraitExpr>
2806 unaryExprOrTypeTraitExpr;
2807
2808/// Matches any of the \p NodeMatchers with InnerMatchers nested within
2809///
2810/// Given
2811/// \code
2812/// if (true);
2813/// for (; true; );
2814/// \endcode
2815/// with the matcher
2816/// \code
2817/// mapAnyOf(ifStmt, forStmt).with(
2818/// hasCondition(cxxBoolLiteralExpr(equals(true)))
2819/// ).bind("trueCond")
2820/// \endcode
2821/// matches the \c if and the \c for. It is equivalent to:
2822/// \code
2823/// auto trueCond = hasCondition(cxxBoolLiteralExpr(equals(true)));
2824/// anyOf(
2825/// ifStmt(trueCond).bind("trueCond"),
2826/// forStmt(trueCond).bind("trueCond")
2827/// );
2828/// \endcode
2829///
2830/// The with() chain-call accepts zero or more matchers which are combined
2831/// as-if with allOf() in each of the node matchers.
2832/// Usable as: Any Matcher
2833template <typename T, typename... U>
2834auto mapAnyOf(internal::VariadicDynCastAllOfMatcher<T, U> const &...) {
2835 return internal::MapAnyOfHelper<U...>();
2836}
2837
2838/// Matches nodes which can be used with binary operators.
2839///
2840/// The code
2841/// \code
2842/// var1 != var2;
2843/// \endcode
2844/// might be represented in the clang AST as a binaryOperator, a
2845/// cxxOperatorCallExpr or a cxxRewrittenBinaryOperator, depending on
2846///
2847/// * whether the types of var1 and var2 are fundamental (binaryOperator) or at
2848/// least one is a class type (cxxOperatorCallExpr)
2849/// * whether the code appears in a template declaration, if at least one of the
2850/// vars is a dependent-type (binaryOperator)
2851/// * whether the code relies on a rewritten binary operator, such as a
2852/// spaceship operator or an inverted equality operator
2853/// (cxxRewrittenBinaryOperator)
2854///
2855/// This matcher elides details in places where the matchers for the nodes are
2856/// compatible.
2857///
2858/// Given
2859/// \code
2860/// binaryOperation(
2861/// hasOperatorName("!="),
2862/// hasLHS(expr().bind("lhs")),
2863/// hasRHS(expr().bind("rhs"))
2864/// )
2865/// \endcode
2866/// matches each use of "!=" in:
2867/// \code
2868/// struct S{
2869/// bool operator!=(const S&) const;
2870/// };
2871///
2872/// void foo()
2873/// {
2874/// 1 != 2;
2875/// S() != S();
2876/// }
2877///
2878/// template<typename T>
2879/// void templ()
2880/// {
2881/// 1 != 2;
2882/// T() != S();
2883/// }
2884/// struct HasOpEq
2885/// {
2886/// bool operator==(const HasOpEq &) const;
2887/// };
2888///
2889/// void inverse()
2890/// {
2891/// HasOpEq s1;
2892/// HasOpEq s2;
2893/// if (s1 != s2)
2894/// return;
2895/// }
2896///
2897/// struct HasSpaceship
2898/// {
2899/// bool operator<=>(const HasOpEq &) const;
2900/// };
2901///
2902/// void use_spaceship()
2903/// {
2904/// HasSpaceship s1;
2905/// HasSpaceship s2;
2906/// if (s1 != s2)
2907/// return;
2908/// }
2909/// \endcode
2910extern const internal::MapAnyOfMatcher<BinaryOperator, CXXOperatorCallExpr,
2911 CXXRewrittenBinaryOperator>
2912 binaryOperation;
2913
2914/// Matches function calls and constructor calls
2915///
2916/// Because CallExpr and CXXConstructExpr do not share a common
2917/// base class with API accessing arguments etc, AST Matchers for code
2918/// which should match both are typically duplicated. This matcher
2919/// removes the need for duplication.
2920///
2921/// Given code
2922/// \code
2923/// struct ConstructorTakesInt
2924/// {
2925/// ConstructorTakesInt(int i) {}
2926/// };
2927///
2928/// void callTakesInt(int i)
2929/// {
2930/// }
2931///
2932/// void doCall()
2933/// {
2934/// callTakesInt(42);
2935/// }
2936///
2937/// void doConstruct()
2938/// {
2939/// ConstructorTakesInt cti(42);
2940/// }
2941/// \endcode
2942///
2943/// The matcher
2944/// \code
2945/// invocation(hasArgument(0, integerLiteral(equals(42))))
2946/// \endcode
2947/// matches the expression in both doCall and doConstruct
2948extern const internal::MapAnyOfMatcher<CallExpr, CXXConstructExpr> invocation;
2949
2950/// Matches unary expressions that have a specific type of argument.
2951///
2952/// Given
2953/// \code
2954/// int a, c; float b; int s = sizeof(a) + sizeof(b) + alignof(c);
2955/// \endcode
2956/// unaryExprOrTypeTraitExpr(hasArgumentOfType(asString("int"))
2957/// matches \c sizeof(a) and \c alignof(c)
2958AST_MATCHER_P(UnaryExprOrTypeTraitExpr, hasArgumentOfType,namespace internal { class matcher_hasArgumentOfType0Matcher :
public ::clang::ast_matchers::internal::MatcherInterface<
UnaryExprOrTypeTraitExpr> { public: explicit matcher_hasArgumentOfType0Matcher
( internal::Matcher<QualType> const &AInnerMatcher)
: InnerMatcher(AInnerMatcher) {} bool matches(const UnaryExprOrTypeTraitExpr
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: internal::Matcher<QualType
> InnerMatcher; }; } inline ::clang::ast_matchers::internal
::Matcher<UnaryExprOrTypeTraitExpr> hasArgumentOfType( internal
::Matcher<QualType> const &InnerMatcher) { return ::
clang::ast_matchers::internal::makeMatcher( new internal::matcher_hasArgumentOfType0Matcher
(InnerMatcher)); } typedef ::clang::ast_matchers::internal::Matcher
<UnaryExprOrTypeTraitExpr> ( &hasArgumentOfType_Type0
)(internal::Matcher<QualType> const &InnerMatcher);
inline bool internal::matcher_hasArgumentOfType0Matcher::matches
( const UnaryExprOrTypeTraitExpr &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
2959 internal::Matcher<QualType>, InnerMatcher)namespace internal { class matcher_hasArgumentOfType0Matcher :
public ::clang::ast_matchers::internal::MatcherInterface<
UnaryExprOrTypeTraitExpr> { public: explicit matcher_hasArgumentOfType0Matcher
( internal::Matcher<QualType> const &AInnerMatcher)
: InnerMatcher(AInnerMatcher) {} bool matches(const UnaryExprOrTypeTraitExpr
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: internal::Matcher<QualType
> InnerMatcher; }; } inline ::clang::ast_matchers::internal
::Matcher<UnaryExprOrTypeTraitExpr> hasArgumentOfType( internal
::Matcher<QualType> const &InnerMatcher) { return ::
clang::ast_matchers::internal::makeMatcher( new internal::matcher_hasArgumentOfType0Matcher
(InnerMatcher)); } typedef ::clang::ast_matchers::internal::Matcher
<UnaryExprOrTypeTraitExpr> ( &hasArgumentOfType_Type0
)(internal::Matcher<QualType> const &InnerMatcher);
inline bool internal::matcher_hasArgumentOfType0Matcher::matches
( const UnaryExprOrTypeTraitExpr &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
{
2960 const QualType ArgumentType = Node.getTypeOfArgument();
2961 return InnerMatcher.matches(ArgumentType, Finder, Builder);
2962}
2963
2964/// Matches unary expressions of a certain kind.
2965///
2966/// Given
2967/// \code
2968/// int x;
2969/// int s = sizeof(x) + alignof(x)
2970/// \endcode
2971/// unaryExprOrTypeTraitExpr(ofKind(UETT_SizeOf))
2972/// matches \c sizeof(x)
2973///
2974/// If the matcher is use from clang-query, UnaryExprOrTypeTrait parameter
2975/// should be passed as a quoted string. e.g., ofKind("UETT_SizeOf").
2976AST_MATCHER_P(UnaryExprOrTypeTraitExpr, ofKind, UnaryExprOrTypeTrait, Kind)namespace internal { class matcher_ofKind0Matcher : public ::
clang::ast_matchers::internal::MatcherInterface<UnaryExprOrTypeTraitExpr
> { public: explicit matcher_ofKind0Matcher( UnaryExprOrTypeTrait
const &AKind) : Kind(AKind) {} bool matches(const UnaryExprOrTypeTraitExpr
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: UnaryExprOrTypeTrait Kind
; }; } inline ::clang::ast_matchers::internal::Matcher<UnaryExprOrTypeTraitExpr
> ofKind( UnaryExprOrTypeTrait const &Kind) { return ::
clang::ast_matchers::internal::makeMatcher( new internal::matcher_ofKind0Matcher
(Kind)); } typedef ::clang::ast_matchers::internal::Matcher<
UnaryExprOrTypeTraitExpr> ( &ofKind_Type0)(UnaryExprOrTypeTrait
const &Kind); inline bool internal::matcher_ofKind0Matcher
::matches( const UnaryExprOrTypeTraitExpr &Node, ::clang::
ast_matchers::internal::ASTMatchFinder *Finder, ::clang::ast_matchers
::internal::BoundNodesTreeBuilder *Builder) const
{
2977 return Node.getKind() == Kind;
2978}
2979
2980/// Same as unaryExprOrTypeTraitExpr, but only matching
2981/// alignof.
2982inline internal::BindableMatcher<Stmt> alignOfExpr(
2983 const internal::Matcher<UnaryExprOrTypeTraitExpr> &InnerMatcher) {
2984 return stmt(unaryExprOrTypeTraitExpr(
2985 allOf(anyOf(ofKind(UETT_AlignOf), ofKind(UETT_PreferredAlignOf)),
2986 InnerMatcher)));
2987}
2988
2989/// Same as unaryExprOrTypeTraitExpr, but only matching
2990/// sizeof.
2991inline internal::BindableMatcher<Stmt> sizeOfExpr(
2992 const internal::Matcher<UnaryExprOrTypeTraitExpr> &InnerMatcher) {
2993 return stmt(unaryExprOrTypeTraitExpr(
2994 allOf(ofKind(UETT_SizeOf), InnerMatcher)));
2995}
2996
2997/// Matches NamedDecl nodes that have the specified name.
2998///
2999/// Supports specifying enclosing namespaces or classes by prefixing the name
3000/// with '<enclosing>::'.
3001/// Does not match typedefs of an underlying type with the given name.
3002///
3003/// Example matches X (Name == "X")
3004/// \code
3005/// class X;
3006/// \endcode
3007///
3008/// Example matches X (Name is one of "::a::b::X", "a::b::X", "b::X", "X")
3009/// \code
3010/// namespace a { namespace b { class X; } }
3011/// \endcode
3012inline internal::Matcher<NamedDecl> hasName(StringRef Name) {
3013 return internal::Matcher<NamedDecl>(
3014 new internal::HasNameMatcher({std::string(Name)}));
3015}
3016
3017/// Matches NamedDecl nodes that have any of the specified names.
3018///
3019/// This matcher is only provided as a performance optimization of hasName.
3020/// \code
3021/// hasAnyName(a, b, c)
3022/// \endcode
3023/// is equivalent to, but faster than
3024/// \code
3025/// anyOf(hasName(a), hasName(b), hasName(c))
3026/// \endcode
3027extern const internal::VariadicFunction<internal::Matcher<NamedDecl>, StringRef,
3028 internal::hasAnyNameFunc>
3029 hasAnyName;
3030
3031/// Matches NamedDecl nodes whose fully qualified names contain
3032/// a substring matched by the given RegExp.
3033///
3034/// Supports specifying enclosing namespaces or classes by
3035/// prefixing the name with '<enclosing>::'. Does not match typedefs
3036/// of an underlying type with the given name.
3037///
3038/// Example matches X (regexp == "::X")
3039/// \code
3040/// class X;
3041/// \endcode
3042///
3043/// Example matches X (regexp is one of "::X", "^foo::.*X", among others)
3044/// \code
3045/// namespace foo { namespace bar { class X; } }
3046/// \endcode
3047AST_MATCHER_REGEX(NamedDecl, matchesName, RegExp)namespace internal { class matcher_matchesName0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<NamedDecl
> { public: explicit matcher_matchesName0Matcher( std::shared_ptr
<llvm::Regex> RE) : RegExp(std::move(RE)) {} bool matches
(const NamedDecl &Node, ::clang::ast_matchers::internal::
ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: std::shared_ptr<llvm::
Regex> RegExp; }; } inline ::clang::ast_matchers::internal
::Matcher<NamedDecl> matchesName( llvm::StringRef RegExp
, llvm::Regex::RegexFlags RegexFlags) { return ::clang::ast_matchers
::internal::makeMatcher( new internal::matcher_matchesName0Matcher
( ::clang::ast_matchers::internal::createAndVerifyRegex( RegExp
, RegexFlags, "matchesName"))); } inline ::clang::ast_matchers
::internal::Matcher<NamedDecl> matchesName( llvm::StringRef
RegExp) { return matchesName(RegExp, llvm::Regex::NoFlags); }
typedef ::clang::ast_matchers::internal::Matcher<NamedDecl
> ( &matchesName_Type0Flags)(llvm::StringRef, llvm::Regex
::RegexFlags); typedef ::clang::ast_matchers::internal::Matcher
<NamedDecl> ( &matchesName_Type0)(llvm::StringRef);
inline bool internal::matcher_matchesName0Matcher::matches( const
NamedDecl &Node, ::clang::ast_matchers::internal::ASTMatchFinder
*Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
3048 std::string FullNameString = "::" + Node.getQualifiedNameAsString();
3049 return RegExp->match(FullNameString);
3050}
3051
3052/// Matches overloaded operator names.
3053///
3054/// Matches overloaded operator names specified in strings without the
3055/// "operator" prefix: e.g. "<<".
3056///
3057/// Given:
3058/// \code
3059/// class A { int operator*(); };
3060/// const A &operator<<(const A &a, const A &b);
3061/// A a;
3062/// a << a; // <-- This matches
3063/// \endcode
3064///
3065/// \c cxxOperatorCallExpr(hasOverloadedOperatorName("<<"))) matches the
3066/// specified line and
3067/// \c cxxRecordDecl(hasMethod(hasOverloadedOperatorName("*")))
3068/// matches the declaration of \c A.
3069///
3070/// Usable as: Matcher<CXXOperatorCallExpr>, Matcher<FunctionDecl>
3071inline internal::PolymorphicMatcher<
3072 internal::HasOverloadedOperatorNameMatcher,
3073 AST_POLYMORPHIC_SUPPORTED_TYPES(CXXOperatorCallExpr, FunctionDecl)void(::clang::ast_matchers::internal::TypeList<CXXOperatorCallExpr
, FunctionDecl>)
,
3074 std::vector<std::string>>
3075hasOverloadedOperatorName(StringRef Name) {
3076 return internal::PolymorphicMatcher<
3077 internal::HasOverloadedOperatorNameMatcher,
3078 AST_POLYMORPHIC_SUPPORTED_TYPES(CXXOperatorCallExpr, FunctionDecl)void(::clang::ast_matchers::internal::TypeList<CXXOperatorCallExpr
, FunctionDecl>)
,
3079 std::vector<std::string>>({std::string(Name)});
3080}
3081
3082/// Matches overloaded operator names.
3083///
3084/// Matches overloaded operator names specified in strings without the
3085/// "operator" prefix: e.g. "<<".
3086///
3087/// hasAnyOverloadedOperatorName("+", "-")
3088/// Is equivalent to
3089/// anyOf(hasOverloadedOperatorName("+"), hasOverloadedOperatorName("-"))
3090extern const internal::VariadicFunction<
3091 internal::PolymorphicMatcher<internal::HasOverloadedOperatorNameMatcher,
3092 AST_POLYMORPHIC_SUPPORTED_TYPES(void(::clang::ast_matchers::internal::TypeList<CXXOperatorCallExpr
, FunctionDecl>)
3093 CXXOperatorCallExpr, FunctionDecl)void(::clang::ast_matchers::internal::TypeList<CXXOperatorCallExpr
, FunctionDecl>)
,
3094 std::vector<std::string>>,
3095 StringRef, internal::hasAnyOverloadedOperatorNameFunc>
3096 hasAnyOverloadedOperatorName;
3097
3098/// Matches template-dependent, but known, member names.
3099///
3100/// In template declarations, dependent members are not resolved and so can
3101/// not be matched to particular named declarations.
3102///
3103/// This matcher allows to match on the known name of members.
3104///
3105/// Given
3106/// \code
3107/// template <typename T>
3108/// struct S {
3109/// void mem();
3110/// };
3111/// template <typename T>
3112/// void x() {
3113/// S<T> s;
3114/// s.mem();
3115/// }
3116/// \endcode
3117/// \c cxxDependentScopeMemberExpr(hasMemberName("mem")) matches `s.mem()`
3118AST_MATCHER_P(CXXDependentScopeMemberExpr, hasMemberName, std::string, N)namespace internal { class matcher_hasMemberName0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<CXXDependentScopeMemberExpr
> { public: explicit matcher_hasMemberName0Matcher( std::string
const &AN) : N(AN) {} bool matches(const CXXDependentScopeMemberExpr
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: std::string N; }; } inline
::clang::ast_matchers::internal::Matcher<CXXDependentScopeMemberExpr
> hasMemberName( std::string const &N) { return ::clang
::ast_matchers::internal::makeMatcher( new internal::matcher_hasMemberName0Matcher
(N)); } typedef ::clang::ast_matchers::internal::Matcher<CXXDependentScopeMemberExpr
> ( &hasMemberName_Type0)(std::string const &N); inline
bool internal::matcher_hasMemberName0Matcher::matches( const
CXXDependentScopeMemberExpr &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
{
3119 return Node.getMember().getAsString() == N;
3120}
3121
3122/// Matches template-dependent, but known, member names against an already-bound
3123/// node
3124///
3125/// In template declarations, dependent members are not resolved and so can
3126/// not be matched to particular named declarations.
3127///
3128/// This matcher allows to match on the name of already-bound VarDecl, FieldDecl
3129/// and CXXMethodDecl nodes.
3130///
3131/// Given
3132/// \code
3133/// template <typename T>
3134/// struct S {
3135/// void mem();
3136/// };
3137/// template <typename T>
3138/// void x() {
3139/// S<T> s;
3140/// s.mem();
3141/// }
3142/// \endcode
3143/// The matcher
3144/// @code
3145/// \c cxxDependentScopeMemberExpr(
3146/// hasObjectExpression(declRefExpr(hasType(templateSpecializationType(
3147/// hasDeclaration(classTemplateDecl(has(cxxRecordDecl(has(
3148/// cxxMethodDecl(hasName("mem")).bind("templMem")
3149/// )))))
3150/// )))),
3151/// memberHasSameNameAsBoundNode("templMem")
3152/// )
3153/// @endcode
3154/// first matches and binds the @c mem member of the @c S template, then
3155/// compares its name to the usage in @c s.mem() in the @c x function template
3156AST_MATCHER_P(CXXDependentScopeMemberExpr, memberHasSameNameAsBoundNode,namespace internal { class matcher_memberHasSameNameAsBoundNode0Matcher
: public ::clang::ast_matchers::internal::MatcherInterface<
CXXDependentScopeMemberExpr> { public: explicit matcher_memberHasSameNameAsBoundNode0Matcher
( std::string const &ABindingID) : BindingID(ABindingID) {
} bool matches(const CXXDependentScopeMemberExpr &Node, ::
clang::ast_matchers::internal::ASTMatchFinder *Finder, ::clang
::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
override; private: std::string BindingID; }; } inline ::clang
::ast_matchers::internal::Matcher<CXXDependentScopeMemberExpr
> memberHasSameNameAsBoundNode( std::string const &BindingID
) { return ::clang::ast_matchers::internal::makeMatcher( new internal
::matcher_memberHasSameNameAsBoundNode0Matcher(BindingID)); }
typedef ::clang::ast_matchers::internal::Matcher<CXXDependentScopeMemberExpr
> ( &memberHasSameNameAsBoundNode_Type0)(std::string const
&BindingID); inline bool internal::matcher_memberHasSameNameAsBoundNode0Matcher
::matches( const CXXDependentScopeMemberExpr &Node, ::clang
::ast_matchers::internal::ASTMatchFinder *Finder, ::clang::ast_matchers
::internal::BoundNodesTreeBuilder *Builder) const
3157 std::string, BindingID)namespace internal { class matcher_memberHasSameNameAsBoundNode0Matcher
: public ::clang::ast_matchers::internal::MatcherInterface<
CXXDependentScopeMemberExpr> { public: explicit matcher_memberHasSameNameAsBoundNode0Matcher
( std::string const &ABindingID) : BindingID(ABindingID) {
} bool matches(const CXXDependentScopeMemberExpr &Node, ::
clang::ast_matchers::internal::ASTMatchFinder *Finder, ::clang
::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
override; private: std::string BindingID; }; } inline ::clang
::ast_matchers::internal::Matcher<CXXDependentScopeMemberExpr
> memberHasSameNameAsBoundNode( std::string const &BindingID
) { return ::clang::ast_matchers::internal::makeMatcher( new internal
::matcher_memberHasSameNameAsBoundNode0Matcher(BindingID)); }
typedef ::clang::ast_matchers::internal::Matcher<CXXDependentScopeMemberExpr
> ( &memberHasSameNameAsBoundNode_Type0)(std::string const
&BindingID); inline bool internal::matcher_memberHasSameNameAsBoundNode0Matcher
::matches( const CXXDependentScopeMemberExpr &Node, ::clang
::ast_matchers::internal::ASTMatchFinder *Finder, ::clang::ast_matchers
::internal::BoundNodesTreeBuilder *Builder) const
{
3158 auto MemberName = Node.getMember().getAsString();
3159
3160 return Builder->removeBindings(
3161 [this, MemberName](const BoundNodesMap &Nodes) {
3162 const auto &BN = Nodes.getNode(this->BindingID);
3163 if (const auto *ND = BN.get<NamedDecl>()) {
3164 if (!isa<FieldDecl, CXXMethodDecl, VarDecl>(ND))
3165 return true;
3166 return ND->getName() != MemberName;
3167 }
3168 return true;
3169 });
3170}
3171
3172/// Matches C++ classes that are directly or indirectly derived from a class
3173/// matching \c Base, or Objective-C classes that directly or indirectly
3174/// subclass a class matching \c Base.
3175///
3176/// Note that a class is not considered to be derived from itself.
3177///
3178/// Example matches Y, Z, C (Base == hasName("X"))
3179/// \code
3180/// class X;
3181/// class Y : public X {}; // directly derived
3182/// class Z : public Y {}; // indirectly derived
3183/// typedef X A;
3184/// typedef A B;
3185/// class C : public B {}; // derived from a typedef of X
3186/// \endcode
3187///
3188/// In the following example, Bar matches isDerivedFrom(hasName("X")):
3189/// \code
3190/// class Foo;
3191/// typedef Foo X;
3192/// class Bar : public Foo {}; // derived from a type that X is a typedef of
3193/// \endcode
3194///
3195/// In the following example, Bar matches isDerivedFrom(hasName("NSObject"))
3196/// \code
3197/// @interface NSObject @end
3198/// @interface Bar : NSObject @end
3199/// \endcode
3200///
3201/// Usable as: Matcher<CXXRecordDecl>, Matcher<ObjCInterfaceDecl>
3202AST_POLYMORPHIC_MATCHER_P(namespace internal { template <typename NodeType, typename
ParamT> class matcher_isDerivedFrom0Matcher : public ::clang
::ast_matchers::internal::MatcherInterface<NodeType> { public
: explicit matcher_isDerivedFrom0Matcher( internal::Matcher<
NamedDecl> const &ABase) : Base(ABase) {} bool matches
(const NodeType &Node, ::clang::ast_matchers::internal::ASTMatchFinder
*Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: internal::Matcher<NamedDecl
> Base; }; } inline ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_isDerivedFrom0Matcher, void(::clang::ast_matchers
::internal::TypeList<CXXRecordDecl, ObjCInterfaceDecl>)
, internal::Matcher<NamedDecl> > isDerivedFrom(internal
::Matcher<NamedDecl> const &Base) { return ::clang::
ast_matchers::internal::PolymorphicMatcher< internal::matcher_isDerivedFrom0Matcher
, void(::clang::ast_matchers::internal::TypeList<CXXRecordDecl
, ObjCInterfaceDecl>), internal::Matcher<NamedDecl> >
(Base); } typedef ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_isDerivedFrom0Matcher, void(::clang::ast_matchers
::internal::TypeList<CXXRecordDecl, ObjCInterfaceDecl>)
, internal::Matcher<NamedDecl> > (&isDerivedFrom_Type0
)(internal::Matcher<NamedDecl> const &Base); template
<typename NodeType, typename ParamT> bool internal:: matcher_isDerivedFrom0Matcher
<NodeType, ParamT>::matches( const NodeType &Node, ::
clang::ast_matchers::internal::ASTMatchFinder *Finder, ::clang
::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
3203 isDerivedFrom,namespace internal { template <typename NodeType, typename
ParamT> class matcher_isDerivedFrom0Matcher : public ::clang
::ast_matchers::internal::MatcherInterface<NodeType> { public
: explicit matcher_isDerivedFrom0Matcher( internal::Matcher<
NamedDecl> const &ABase) : Base(ABase) {} bool matches
(const NodeType &Node, ::clang::ast_matchers::internal::ASTMatchFinder
*Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: internal::Matcher<NamedDecl
> Base; }; } inline ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_isDerivedFrom0Matcher, void(::clang::ast_matchers
::internal::TypeList<CXXRecordDecl, ObjCInterfaceDecl>)
, internal::Matcher<NamedDecl> > isDerivedFrom(internal
::Matcher<NamedDecl> const &Base) { return ::clang::
ast_matchers::internal::PolymorphicMatcher< internal::matcher_isDerivedFrom0Matcher
, void(::clang::ast_matchers::internal::TypeList<CXXRecordDecl
, ObjCInterfaceDecl>), internal::Matcher<NamedDecl> >
(Base); } typedef ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_isDerivedFrom0Matcher, void(::clang::ast_matchers
::internal::TypeList<CXXRecordDecl, ObjCInterfaceDecl>)
, internal::Matcher<NamedDecl> > (&isDerivedFrom_Type0
)(internal::Matcher<NamedDecl> const &Base); template
<typename NodeType, typename ParamT> bool internal:: matcher_isDerivedFrom0Matcher
<NodeType, ParamT>::matches( const NodeType &Node, ::
clang::ast_matchers::internal::ASTMatchFinder *Finder, ::clang
::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
3204 AST_POLYMORPHIC_SUPPORTED_TYPES(CXXRecordDecl, ObjCInterfaceDecl),namespace internal { template <typename NodeType, typename
ParamT> class matcher_isDerivedFrom0Matcher : public ::clang
::ast_matchers::internal::MatcherInterface<NodeType> { public
: explicit matcher_isDerivedFrom0Matcher( internal::Matcher<
NamedDecl> const &ABase) : Base(ABase) {} bool matches
(const NodeType &Node, ::clang::ast_matchers::internal::ASTMatchFinder
*Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: internal::Matcher<NamedDecl
> Base; }; } inline ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_isDerivedFrom0Matcher, void(::clang::ast_matchers
::internal::TypeList<CXXRecordDecl, ObjCInterfaceDecl>)
, internal::Matcher<NamedDecl> > isDerivedFrom(internal
::Matcher<NamedDecl> const &Base) { return ::clang::
ast_matchers::internal::PolymorphicMatcher< internal::matcher_isDerivedFrom0Matcher
, void(::clang::ast_matchers::internal::TypeList<CXXRecordDecl
, ObjCInterfaceDecl>), internal::Matcher<NamedDecl> >
(Base); } typedef ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_isDerivedFrom0Matcher, void(::clang::ast_matchers
::internal::TypeList<CXXRecordDecl, ObjCInterfaceDecl>)
, internal::Matcher<NamedDecl> > (&isDerivedFrom_Type0
)(internal::Matcher<NamedDecl> const &Base); template
<typename NodeType, typename ParamT> bool internal:: matcher_isDerivedFrom0Matcher
<NodeType, ParamT>::matches( const NodeType &Node, ::
clang::ast_matchers::internal::ASTMatchFinder *Finder, ::clang
::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
3205 internal::Matcher<NamedDecl>, Base)namespace internal { template <typename NodeType, typename
ParamT> class matcher_isDerivedFrom0Matcher : public ::clang
::ast_matchers::internal::MatcherInterface<NodeType> { public
: explicit matcher_isDerivedFrom0Matcher( internal::Matcher<
NamedDecl> const &ABase) : Base(ABase) {} bool matches
(const NodeType &Node, ::clang::ast_matchers::internal::ASTMatchFinder
*Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: internal::Matcher<NamedDecl
> Base; }; } inline ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_isDerivedFrom0Matcher, void(::clang::ast_matchers
::internal::TypeList<CXXRecordDecl, ObjCInterfaceDecl>)
, internal::Matcher<NamedDecl> > isDerivedFrom(internal
::Matcher<NamedDecl> const &Base) { return ::clang::
ast_matchers::internal::PolymorphicMatcher< internal::matcher_isDerivedFrom0Matcher
, void(::clang::ast_matchers::internal::TypeList<CXXRecordDecl
, ObjCInterfaceDecl>), internal::Matcher<NamedDecl> >
(Base); } typedef ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_isDerivedFrom0Matcher, void(::clang::ast_matchers
::internal::TypeList<CXXRecordDecl, ObjCInterfaceDecl>)
, internal::Matcher<NamedDecl> > (&isDerivedFrom_Type0
)(internal::Matcher<NamedDecl> const &Base); template
<typename NodeType, typename ParamT> bool internal:: matcher_isDerivedFrom0Matcher
<NodeType, ParamT>::matches( const NodeType &Node, ::
clang::ast_matchers::internal::ASTMatchFinder *Finder, ::clang
::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
{
3206 // Check if the node is a C++ struct/union/class.
3207 if (const auto *RD = dyn_cast<CXXRecordDecl>(&Node))
3208 return Finder->classIsDerivedFrom(RD, Base, Builder, /*Directly=*/false);
3209
3210 // The node must be an Objective-C class.
3211 const auto *InterfaceDecl = cast<ObjCInterfaceDecl>(&Node);
3212 return Finder->objcClassIsDerivedFrom(InterfaceDecl, Base, Builder,
3213 /*Directly=*/false);
3214}
3215
3216/// Overloaded method as shortcut for \c isDerivedFrom(hasName(...)).
3217AST_POLYMORPHIC_MATCHER_P_OVERLOAD(namespace internal { template <typename NodeType, typename
ParamT> class matcher_isDerivedFrom1Matcher : public ::clang
::ast_matchers::internal::MatcherInterface<NodeType> { public
: explicit matcher_isDerivedFrom1Matcher( std::string const &
ABaseName) : BaseName(ABaseName) {} bool matches(const NodeType
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: std::string BaseName; }; }
inline ::clang::ast_matchers::internal::PolymorphicMatcher<
internal::matcher_isDerivedFrom1Matcher, void(::clang::ast_matchers
::internal::TypeList<CXXRecordDecl, ObjCInterfaceDecl>)
, std::string> isDerivedFrom(std::string const &BaseName
) { return ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_isDerivedFrom1Matcher, void(::clang::ast_matchers
::internal::TypeList<CXXRecordDecl, ObjCInterfaceDecl>)
, std::string>(BaseName); } typedef ::clang::ast_matchers::
internal::PolymorphicMatcher< internal::matcher_isDerivedFrom1Matcher
, void(::clang::ast_matchers::internal::TypeList<CXXRecordDecl
, ObjCInterfaceDecl>), std::string> (&isDerivedFrom_Type1
)(std::string const &BaseName); template <typename NodeType
, typename ParamT> bool internal:: matcher_isDerivedFrom1Matcher
<NodeType, ParamT>::matches( const NodeType &Node, ::
clang::ast_matchers::internal::ASTMatchFinder *Finder, ::clang
::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
3218 isDerivedFrom,namespace internal { template <typename NodeType, typename
ParamT> class matcher_isDerivedFrom1Matcher : public ::clang
::ast_matchers::internal::MatcherInterface<NodeType> { public
: explicit matcher_isDerivedFrom1Matcher( std::string const &
ABaseName) : BaseName(ABaseName) {} bool matches(const NodeType
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: std::string BaseName; }; }
inline ::clang::ast_matchers::internal::PolymorphicMatcher<
internal::matcher_isDerivedFrom1Matcher, void(::clang::ast_matchers
::internal::TypeList<CXXRecordDecl, ObjCInterfaceDecl>)
, std::string> isDerivedFrom(std::string const &BaseName
) { return ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_isDerivedFrom1Matcher, void(::clang::ast_matchers
::internal::TypeList<CXXRecordDecl, ObjCInterfaceDecl>)
, std::string>(BaseName); } typedef ::clang::ast_matchers::
internal::PolymorphicMatcher< internal::matcher_isDerivedFrom1Matcher
, void(::clang::ast_matchers::internal::TypeList<CXXRecordDecl
, ObjCInterfaceDecl>), std::string> (&isDerivedFrom_Type1
)(std::string const &BaseName); template <typename NodeType
, typename ParamT> bool internal:: matcher_isDerivedFrom1Matcher
<NodeType, ParamT>::matches( const NodeType &Node, ::
clang::ast_matchers::internal::ASTMatchFinder *Finder, ::clang
::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
3219 AST_POLYMORPHIC_SUPPORTED_TYPES(CXXRecordDecl, ObjCInterfaceDecl),namespace internal { template <typename NodeType, typename
ParamT> class matcher_isDerivedFrom1Matcher : public ::clang
::ast_matchers::internal::MatcherInterface<NodeType> { public
: explicit matcher_isDerivedFrom1Matcher( std::string const &
ABaseName) : BaseName(ABaseName) {} bool matches(const NodeType
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: std::string BaseName; }; }
inline ::clang::ast_matchers::internal::PolymorphicMatcher<
internal::matcher_isDerivedFrom1Matcher, void(::clang::ast_matchers
::internal::TypeList<CXXRecordDecl, ObjCInterfaceDecl>)
, std::string> isDerivedFrom(std::string const &BaseName
) { return ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_isDerivedFrom1Matcher, void(::clang::ast_matchers
::internal::TypeList<CXXRecordDecl, ObjCInterfaceDecl>)
, std::string>(BaseName); } typedef ::clang::ast_matchers::
internal::PolymorphicMatcher< internal::matcher_isDerivedFrom1Matcher
, void(::clang::ast_matchers::internal::TypeList<CXXRecordDecl
, ObjCInterfaceDecl>), std::string> (&isDerivedFrom_Type1
)(std::string const &BaseName); template <typename NodeType
, typename ParamT> bool internal:: matcher_isDerivedFrom1Matcher
<NodeType, ParamT>::matches( const NodeType &Node, ::
clang::ast_matchers::internal::ASTMatchFinder *Finder, ::clang
::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
3220 std::string, BaseName, 1)namespace internal { template <typename NodeType, typename
ParamT> class matcher_isDerivedFrom1Matcher : public ::clang
::ast_matchers::internal::MatcherInterface<NodeType> { public
: explicit matcher_isDerivedFrom1Matcher( std::string const &
ABaseName) : BaseName(ABaseName) {} bool matches(const NodeType
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: std::string BaseName; }; }
inline ::clang::ast_matchers::internal::PolymorphicMatcher<
internal::matcher_isDerivedFrom1Matcher, void(::clang::ast_matchers
::internal::TypeList<CXXRecordDecl, ObjCInterfaceDecl>)
, std::string> isDerivedFrom(std::string const &BaseName
) { return ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_isDerivedFrom1Matcher, void(::clang::ast_matchers
::internal::TypeList<CXXRecordDecl, ObjCInterfaceDecl>)
, std::string>(BaseName); } typedef ::clang::ast_matchers::
internal::PolymorphicMatcher< internal::matcher_isDerivedFrom1Matcher
, void(::clang::ast_matchers::internal::TypeList<CXXRecordDecl
, ObjCInterfaceDecl>), std::string> (&isDerivedFrom_Type1
)(std::string const &BaseName); template <typename NodeType
, typename ParamT> bool internal:: matcher_isDerivedFrom1Matcher
<NodeType, ParamT>::matches( const NodeType &Node, ::
clang::ast_matchers::internal::ASTMatchFinder *Finder, ::clang
::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
{
3221 if (BaseName.empty())
3222 return false;
3223
3224 const auto M = isDerivedFrom(hasName(BaseName));
3225
3226 if (const auto *RD = dyn_cast<CXXRecordDecl>(&Node))
3227 return Matcher<CXXRecordDecl>(M).matches(*RD, Finder, Builder);
3228
3229 const auto *InterfaceDecl = cast<ObjCInterfaceDecl>(&Node);
3230 return Matcher<ObjCInterfaceDecl>(M).matches(*InterfaceDecl, Finder, Builder);
3231}
3232
3233/// Matches C++ classes that have a direct or indirect base matching \p
3234/// BaseSpecMatcher.
3235///
3236/// Example:
3237/// matcher hasAnyBase(hasType(cxxRecordDecl(hasName("SpecialBase"))))
3238/// \code
3239/// class Foo;
3240/// class Bar : Foo {};
3241/// class Baz : Bar {};
3242/// class SpecialBase;
3243/// class Proxy : SpecialBase {}; // matches Proxy
3244/// class IndirectlyDerived : Proxy {}; //matches IndirectlyDerived
3245/// \endcode
3246///
3247// FIXME: Refactor this and isDerivedFrom to reuse implementation.
3248AST_MATCHER_P(CXXRecordDecl, hasAnyBase, internal::Matcher<CXXBaseSpecifier>,namespace internal { class matcher_hasAnyBase0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<CXXRecordDecl
> { public: explicit matcher_hasAnyBase0Matcher( internal::
Matcher<CXXBaseSpecifier> const &ABaseSpecMatcher) :
BaseSpecMatcher(ABaseSpecMatcher) {} bool matches(const CXXRecordDecl
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: internal::Matcher<CXXBaseSpecifier
> BaseSpecMatcher; }; } inline ::clang::ast_matchers::internal
::Matcher<CXXRecordDecl> hasAnyBase( internal::Matcher<
CXXBaseSpecifier> const &BaseSpecMatcher) { return ::clang
::ast_matchers::internal::makeMatcher( new internal::matcher_hasAnyBase0Matcher
(BaseSpecMatcher)); } typedef ::clang::ast_matchers::internal
::Matcher<CXXRecordDecl> ( &hasAnyBase_Type0)(internal
::Matcher<CXXBaseSpecifier> const &BaseSpecMatcher)
; inline bool internal::matcher_hasAnyBase0Matcher::matches( const
CXXRecordDecl &Node, ::clang::ast_matchers::internal::ASTMatchFinder
*Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
3249 BaseSpecMatcher)namespace internal { class matcher_hasAnyBase0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<CXXRecordDecl
> { public: explicit matcher_hasAnyBase0Matcher( internal::
Matcher<CXXBaseSpecifier> const &ABaseSpecMatcher) :
BaseSpecMatcher(ABaseSpecMatcher) {} bool matches(const CXXRecordDecl
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: internal::Matcher<CXXBaseSpecifier
> BaseSpecMatcher; }; } inline ::clang::ast_matchers::internal
::Matcher<CXXRecordDecl> hasAnyBase( internal::Matcher<
CXXBaseSpecifier> const &BaseSpecMatcher) { return ::clang
::ast_matchers::internal::makeMatcher( new internal::matcher_hasAnyBase0Matcher
(BaseSpecMatcher)); } typedef ::clang::ast_matchers::internal
::Matcher<CXXRecordDecl> ( &hasAnyBase_Type0)(internal
::Matcher<CXXBaseSpecifier> const &BaseSpecMatcher)
; inline bool internal::matcher_hasAnyBase0Matcher::matches( const
CXXRecordDecl &Node, ::clang::ast_matchers::internal::ASTMatchFinder
*Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
3250 return internal::matchesAnyBase(Node, BaseSpecMatcher, Finder, Builder);
3251}
3252
3253/// Matches C++ classes that have a direct base matching \p BaseSpecMatcher.
3254///
3255/// Example:
3256/// matcher hasDirectBase(hasType(cxxRecordDecl(hasName("SpecialBase"))))
3257/// \code
3258/// class Foo;
3259/// class Bar : Foo {};
3260/// class Baz : Bar {};
3261/// class SpecialBase;
3262/// class Proxy : SpecialBase {}; // matches Proxy
3263/// class IndirectlyDerived : Proxy {}; // doesn't match
3264/// \endcode
3265AST_MATCHER_P(CXXRecordDecl, hasDirectBase, internal::Matcher<CXXBaseSpecifier>,namespace internal { class matcher_hasDirectBase0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<CXXRecordDecl
> { public: explicit matcher_hasDirectBase0Matcher( internal
::Matcher<CXXBaseSpecifier> const &ABaseSpecMatcher
) : BaseSpecMatcher(ABaseSpecMatcher) {} bool matches(const CXXRecordDecl
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: internal::Matcher<CXXBaseSpecifier
> BaseSpecMatcher; }; } inline ::clang::ast_matchers::internal
::Matcher<CXXRecordDecl> hasDirectBase( internal::Matcher
<CXXBaseSpecifier> const &BaseSpecMatcher) { return
::clang::ast_matchers::internal::makeMatcher( new internal::
matcher_hasDirectBase0Matcher(BaseSpecMatcher)); } typedef ::
clang::ast_matchers::internal::Matcher<CXXRecordDecl> (
&hasDirectBase_Type0)(internal::Matcher<CXXBaseSpecifier
> const &BaseSpecMatcher); inline bool internal::matcher_hasDirectBase0Matcher
::matches( const CXXRecordDecl &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
3266 BaseSpecMatcher)namespace internal { class matcher_hasDirectBase0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<CXXRecordDecl
> { public: explicit matcher_hasDirectBase0Matcher( internal
::Matcher<CXXBaseSpecifier> const &ABaseSpecMatcher
) : BaseSpecMatcher(ABaseSpecMatcher) {} bool matches(const CXXRecordDecl
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: internal::Matcher<CXXBaseSpecifier
> BaseSpecMatcher; }; } inline ::clang::ast_matchers::internal
::Matcher<CXXRecordDecl> hasDirectBase( internal::Matcher
<CXXBaseSpecifier> const &BaseSpecMatcher) { return
::clang::ast_matchers::internal::makeMatcher( new internal::
matcher_hasDirectBase0Matcher(BaseSpecMatcher)); } typedef ::
clang::ast_matchers::internal::Matcher<CXXRecordDecl> (
&hasDirectBase_Type0)(internal::Matcher<CXXBaseSpecifier
> const &BaseSpecMatcher); inline bool internal::matcher_hasDirectBase0Matcher
::matches( const CXXRecordDecl &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
{
3267 return Node.hasDefinition() &&
3268 llvm::any_of(Node.bases(), [&](const CXXBaseSpecifier &Base) {
3269 return BaseSpecMatcher.matches(Base, Finder, Builder);
3270 });
3271}
3272
3273/// Similar to \c isDerivedFrom(), but also matches classes that directly
3274/// match \c Base.
3275AST_POLYMORPHIC_MATCHER_P_OVERLOAD(namespace internal { template <typename NodeType, typename
ParamT> class matcher_isSameOrDerivedFrom0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<NodeType
> { public: explicit matcher_isSameOrDerivedFrom0Matcher( internal
::Matcher<NamedDecl> const &ABase) : Base(ABase) {}
bool matches(const NodeType &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const override; private: internal
::Matcher<NamedDecl> Base; }; } inline ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_isSameOrDerivedFrom0Matcher
, void(::clang::ast_matchers::internal::TypeList<CXXRecordDecl
, ObjCInterfaceDecl>), internal::Matcher<NamedDecl> >
isSameOrDerivedFrom(internal::Matcher<NamedDecl> const
&Base) { return ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_isSameOrDerivedFrom0Matcher, void(::clang
::ast_matchers::internal::TypeList<CXXRecordDecl, ObjCInterfaceDecl
>), internal::Matcher<NamedDecl> >(Base); } typedef
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_isSameOrDerivedFrom0Matcher, void(::clang::ast_matchers
::internal::TypeList<CXXRecordDecl, ObjCInterfaceDecl>)
, internal::Matcher<NamedDecl> > (&isSameOrDerivedFrom_Type0
)(internal::Matcher<NamedDecl> const &Base); template
<typename NodeType, typename ParamT> bool internal:: matcher_isSameOrDerivedFrom0Matcher
<NodeType, ParamT>::matches( const NodeType &Node, ::
clang::ast_matchers::internal::ASTMatchFinder *Finder, ::clang
::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
3276 isSameOrDerivedFrom,namespace internal { template <typename NodeType, typename
ParamT> class matcher_isSameOrDerivedFrom0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<NodeType
> { public: explicit matcher_isSameOrDerivedFrom0Matcher( internal
::Matcher<NamedDecl> const &ABase) : Base(ABase) {}
bool matches(const NodeType &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const override; private: internal
::Matcher<NamedDecl> Base; }; } inline ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_isSameOrDerivedFrom0Matcher
, void(::clang::ast_matchers::internal::TypeList<CXXRecordDecl
, ObjCInterfaceDecl>), internal::Matcher<NamedDecl> >
isSameOrDerivedFrom(internal::Matcher<NamedDecl> const
&Base) { return ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_isSameOrDerivedFrom0Matcher, void(::clang
::ast_matchers::internal::TypeList<CXXRecordDecl, ObjCInterfaceDecl
>), internal::Matcher<NamedDecl> >(Base); } typedef
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_isSameOrDerivedFrom0Matcher, void(::clang::ast_matchers
::internal::TypeList<CXXRecordDecl, ObjCInterfaceDecl>)
, internal::Matcher<NamedDecl> > (&isSameOrDerivedFrom_Type0
)(internal::Matcher<NamedDecl> const &Base); template
<typename NodeType, typename ParamT> bool internal:: matcher_isSameOrDerivedFrom0Matcher
<NodeType, ParamT>::matches( const NodeType &Node, ::
clang::ast_matchers::internal::ASTMatchFinder *Finder, ::clang
::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
3277 AST_POLYMORPHIC_SUPPORTED_TYPES(CXXRecordDecl, ObjCInterfaceDecl),namespace internal { template <typename NodeType, typename
ParamT> class matcher_isSameOrDerivedFrom0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<NodeType
> { public: explicit matcher_isSameOrDerivedFrom0Matcher( internal
::Matcher<NamedDecl> const &ABase) : Base(ABase) {}
bool matches(const NodeType &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const override; private: internal
::Matcher<NamedDecl> Base; }; } inline ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_isSameOrDerivedFrom0Matcher
, void(::clang::ast_matchers::internal::TypeList<CXXRecordDecl
, ObjCInterfaceDecl>), internal::Matcher<NamedDecl> >
isSameOrDerivedFrom(internal::Matcher<NamedDecl> const
&Base) { return ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_isSameOrDerivedFrom0Matcher, void(::clang
::ast_matchers::internal::TypeList<CXXRecordDecl, ObjCInterfaceDecl
>), internal::Matcher<NamedDecl> >(Base); } typedef
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_isSameOrDerivedFrom0Matcher, void(::clang::ast_matchers
::internal::TypeList<CXXRecordDecl, ObjCInterfaceDecl>)
, internal::Matcher<NamedDecl> > (&isSameOrDerivedFrom_Type0
)(internal::Matcher<NamedDecl> const &Base); template
<typename NodeType, typename ParamT> bool internal:: matcher_isSameOrDerivedFrom0Matcher
<NodeType, ParamT>::matches( const NodeType &Node, ::
clang::ast_matchers::internal::ASTMatchFinder *Finder, ::clang
::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
3278 internal::Matcher<NamedDecl>, Base, 0)namespace internal { template <typename NodeType, typename
ParamT> class matcher_isSameOrDerivedFrom0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<NodeType
> { public: explicit matcher_isSameOrDerivedFrom0Matcher( internal
::Matcher<NamedDecl> const &ABase) : Base(ABase) {}
bool matches(const NodeType &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const override; private: internal
::Matcher<NamedDecl> Base; }; } inline ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_isSameOrDerivedFrom0Matcher
, void(::clang::ast_matchers::internal::TypeList<CXXRecordDecl
, ObjCInterfaceDecl>), internal::Matcher<NamedDecl> >
isSameOrDerivedFrom(internal::Matcher<NamedDecl> const
&Base) { return ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_isSameOrDerivedFrom0Matcher, void(::clang
::ast_matchers::internal::TypeList<CXXRecordDecl, ObjCInterfaceDecl
>), internal::Matcher<NamedDecl> >(Base); } typedef
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_isSameOrDerivedFrom0Matcher, void(::clang::ast_matchers
::internal::TypeList<CXXRecordDecl, ObjCInterfaceDecl>)
, internal::Matcher<NamedDecl> > (&isSameOrDerivedFrom_Type0
)(internal::Matcher<NamedDecl> const &Base); template
<typename NodeType, typename ParamT> bool internal:: matcher_isSameOrDerivedFrom0Matcher
<NodeType, ParamT>::matches( const NodeType &Node, ::
clang::ast_matchers::internal::ASTMatchFinder *Finder, ::clang
::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
{
3279 const auto M = anyOf(Base, isDerivedFrom(Base));
3280
3281 if (const auto *RD = dyn_cast<CXXRecordDecl>(&Node))
3282 return Matcher<CXXRecordDecl>(M).matches(*RD, Finder, Builder);
3283
3284 const auto *InterfaceDecl = cast<ObjCInterfaceDecl>(&Node);
3285 return Matcher<ObjCInterfaceDecl>(M).matches(*InterfaceDecl, Finder, Builder);
3286}
3287
3288/// Overloaded method as shortcut for
3289/// \c isSameOrDerivedFrom(hasName(...)).
3290AST_POLYMORPHIC_MATCHER_P_OVERLOAD(namespace internal { template <typename NodeType, typename
ParamT> class matcher_isSameOrDerivedFrom1Matcher : public
::clang::ast_matchers::internal::MatcherInterface<NodeType
> { public: explicit matcher_isSameOrDerivedFrom1Matcher( std
::string const &ABaseName) : BaseName(ABaseName) {} bool matches
(const NodeType &Node, ::clang::ast_matchers::internal::ASTMatchFinder
*Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: std::string BaseName; }; }
inline ::clang::ast_matchers::internal::PolymorphicMatcher<
internal::matcher_isSameOrDerivedFrom1Matcher, void(::clang::
ast_matchers::internal::TypeList<CXXRecordDecl, ObjCInterfaceDecl
>), std::string> isSameOrDerivedFrom(std::string const &
BaseName) { return ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_isSameOrDerivedFrom1Matcher, void(::clang
::ast_matchers::internal::TypeList<CXXRecordDecl, ObjCInterfaceDecl
>), std::string>(BaseName); } typedef ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_isSameOrDerivedFrom1Matcher
, void(::clang::ast_matchers::internal::TypeList<CXXRecordDecl
, ObjCInterfaceDecl>), std::string> (&isSameOrDerivedFrom_Type1
)(std::string const &BaseName); template <typename NodeType
, typename ParamT> bool internal:: matcher_isSameOrDerivedFrom1Matcher
<NodeType, ParamT>::matches( const NodeType &Node, ::
clang::ast_matchers::internal::ASTMatchFinder *Finder, ::clang
::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
3291 isSameOrDerivedFrom,namespace internal { template <typename NodeType, typename
ParamT> class matcher_isSameOrDerivedFrom1Matcher : public
::clang::ast_matchers::internal::MatcherInterface<NodeType
> { public: explicit matcher_isSameOrDerivedFrom1Matcher( std
::string const &ABaseName) : BaseName(ABaseName) {} bool matches
(const NodeType &Node, ::clang::ast_matchers::internal::ASTMatchFinder
*Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: std::string BaseName; }; }
inline ::clang::ast_matchers::internal::PolymorphicMatcher<
internal::matcher_isSameOrDerivedFrom1Matcher, void(::clang::
ast_matchers::internal::TypeList<CXXRecordDecl, ObjCInterfaceDecl
>), std::string> isSameOrDerivedFrom(std::string const &
BaseName) { return ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_isSameOrDerivedFrom1Matcher, void(::clang
::ast_matchers::internal::TypeList<CXXRecordDecl, ObjCInterfaceDecl
>), std::string>(BaseName); } typedef ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_isSameOrDerivedFrom1Matcher
, void(::clang::ast_matchers::internal::TypeList<CXXRecordDecl
, ObjCInterfaceDecl>), std::string> (&isSameOrDerivedFrom_Type1
)(std::string const &BaseName); template <typename NodeType
, typename ParamT> bool internal:: matcher_isSameOrDerivedFrom1Matcher
<NodeType, ParamT>::matches( const NodeType &Node, ::
clang::ast_matchers::internal::ASTMatchFinder *Finder, ::clang
::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
3292 AST_POLYMORPHIC_SUPPORTED_TYPES(CXXRecordDecl, ObjCInterfaceDecl),namespace internal { template <typename NodeType, typename
ParamT> class matcher_isSameOrDerivedFrom1Matcher : public
::clang::ast_matchers::internal::MatcherInterface<NodeType
> { public: explicit matcher_isSameOrDerivedFrom1Matcher( std
::string const &ABaseName) : BaseName(ABaseName) {} bool matches
(const NodeType &Node, ::clang::ast_matchers::internal::ASTMatchFinder
*Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: std::string BaseName; }; }
inline ::clang::ast_matchers::internal::PolymorphicMatcher<
internal::matcher_isSameOrDerivedFrom1Matcher, void(::clang::
ast_matchers::internal::TypeList<CXXRecordDecl, ObjCInterfaceDecl
>), std::string> isSameOrDerivedFrom(std::string const &
BaseName) { return ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_isSameOrDerivedFrom1Matcher, void(::clang
::ast_matchers::internal::TypeList<CXXRecordDecl, ObjCInterfaceDecl
>), std::string>(BaseName); } typedef ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_isSameOrDerivedFrom1Matcher
, void(::clang::ast_matchers::internal::TypeList<CXXRecordDecl
, ObjCInterfaceDecl>), std::string> (&isSameOrDerivedFrom_Type1
)(std::string const &BaseName); template <typename NodeType
, typename ParamT> bool internal:: matcher_isSameOrDerivedFrom1Matcher
<NodeType, ParamT>::matches( const NodeType &Node, ::
clang::ast_matchers::internal::ASTMatchFinder *Finder, ::clang
::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
3293 std::string, BaseName, 1)namespace internal { template <typename NodeType, typename
ParamT> class matcher_isSameOrDerivedFrom1Matcher : public
::clang::ast_matchers::internal::MatcherInterface<NodeType
> { public: explicit matcher_isSameOrDerivedFrom1Matcher( std
::string const &ABaseName) : BaseName(ABaseName) {} bool matches
(const NodeType &Node, ::clang::ast_matchers::internal::ASTMatchFinder
*Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: std::string BaseName; }; }
inline ::clang::ast_matchers::internal::PolymorphicMatcher<
internal::matcher_isSameOrDerivedFrom1Matcher, void(::clang::
ast_matchers::internal::TypeList<CXXRecordDecl, ObjCInterfaceDecl
>), std::string> isSameOrDerivedFrom(std::string const &
BaseName) { return ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_isSameOrDerivedFrom1Matcher, void(::clang
::ast_matchers::internal::TypeList<CXXRecordDecl, ObjCInterfaceDecl
>), std::string>(BaseName); } typedef ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_isSameOrDerivedFrom1Matcher
, void(::clang::ast_matchers::internal::TypeList<CXXRecordDecl
, ObjCInterfaceDecl>), std::string> (&isSameOrDerivedFrom_Type1
)(std::string const &BaseName); template <typename NodeType
, typename ParamT> bool internal:: matcher_isSameOrDerivedFrom1Matcher
<NodeType, ParamT>::matches( const NodeType &Node, ::
clang::ast_matchers::internal::ASTMatchFinder *Finder, ::clang
::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
{
3294 if (BaseName.empty())
3295 return false;
3296
3297 const auto M = isSameOrDerivedFrom(hasName(BaseName));
3298
3299 if (const auto *RD = dyn_cast<CXXRecordDecl>(&Node))
3300 return Matcher<CXXRecordDecl>(M).matches(*RD, Finder, Builder);
3301
3302 const auto *InterfaceDecl = cast<ObjCInterfaceDecl>(&Node);
3303 return Matcher<ObjCInterfaceDecl>(M).matches(*InterfaceDecl, Finder, Builder);
3304}
3305
3306/// Matches C++ or Objective-C classes that are directly derived from a class
3307/// matching \c Base.
3308///
3309/// Note that a class is not considered to be derived from itself.
3310///
3311/// Example matches Y, C (Base == hasName("X"))
3312/// \code
3313/// class X;
3314/// class Y : public X {}; // directly derived
3315/// class Z : public Y {}; // indirectly derived
3316/// typedef X A;
3317/// typedef A B;
3318/// class C : public B {}; // derived from a typedef of X
3319/// \endcode
3320///
3321/// In the following example, Bar matches isDerivedFrom(hasName("X")):
3322/// \code
3323/// class Foo;
3324/// typedef Foo X;
3325/// class Bar : public Foo {}; // derived from a type that X is a typedef of
3326/// \endcode
3327AST_POLYMORPHIC_MATCHER_P_OVERLOAD(namespace internal { template <typename NodeType, typename
ParamT> class matcher_isDirectlyDerivedFrom0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<NodeType
> { public: explicit matcher_isDirectlyDerivedFrom0Matcher
( internal::Matcher<NamedDecl> const &ABase) : Base
(ABase) {} bool matches(const NodeType &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const override; private: internal
::Matcher<NamedDecl> Base; }; } inline ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_isDirectlyDerivedFrom0Matcher
, void(::clang::ast_matchers::internal::TypeList<CXXRecordDecl
, ObjCInterfaceDecl>), internal::Matcher<NamedDecl> >
isDirectlyDerivedFrom(internal::Matcher<NamedDecl> const
&Base) { return ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_isDirectlyDerivedFrom0Matcher, void(::
clang::ast_matchers::internal::TypeList<CXXRecordDecl, ObjCInterfaceDecl
>), internal::Matcher<NamedDecl> >(Base); } typedef
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_isDirectlyDerivedFrom0Matcher, void(::clang::ast_matchers
::internal::TypeList<CXXRecordDecl, ObjCInterfaceDecl>)
, internal::Matcher<NamedDecl> > (&isDirectlyDerivedFrom_Type0
)(internal::Matcher<NamedDecl> const &Base); template
<typename NodeType, typename ParamT> bool internal:: matcher_isDirectlyDerivedFrom0Matcher
<NodeType, ParamT>::matches( const NodeType &Node, ::
clang::ast_matchers::internal::ASTMatchFinder *Finder, ::clang
::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
3328 isDirectlyDerivedFrom,namespace internal { template <typename NodeType, typename
ParamT> class matcher_isDirectlyDerivedFrom0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<NodeType
> { public: explicit matcher_isDirectlyDerivedFrom0Matcher
( internal::Matcher<NamedDecl> const &ABase) : Base
(ABase) {} bool matches(const NodeType &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const override; private: internal
::Matcher<NamedDecl> Base; }; } inline ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_isDirectlyDerivedFrom0Matcher
, void(::clang::ast_matchers::internal::TypeList<CXXRecordDecl
, ObjCInterfaceDecl>), internal::Matcher<NamedDecl> >
isDirectlyDerivedFrom(internal::Matcher<NamedDecl> const
&Base) { return ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_isDirectlyDerivedFrom0Matcher, void(::
clang::ast_matchers::internal::TypeList<CXXRecordDecl, ObjCInterfaceDecl
>), internal::Matcher<NamedDecl> >(Base); } typedef
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_isDirectlyDerivedFrom0Matcher, void(::clang::ast_matchers
::internal::TypeList<CXXRecordDecl, ObjCInterfaceDecl>)
, internal::Matcher<NamedDecl> > (&isDirectlyDerivedFrom_Type0
)(internal::Matcher<NamedDecl> const &Base); template
<typename NodeType, typename ParamT> bool internal:: matcher_isDirectlyDerivedFrom0Matcher
<NodeType, ParamT>::matches( const NodeType &Node, ::
clang::ast_matchers::internal::ASTMatchFinder *Finder, ::clang
::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
3329 AST_POLYMORPHIC_SUPPORTED_TYPES(CXXRecordDecl, ObjCInterfaceDecl),namespace internal { template <typename NodeType, typename
ParamT> class matcher_isDirectlyDerivedFrom0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<NodeType
> { public: explicit matcher_isDirectlyDerivedFrom0Matcher
( internal::Matcher<NamedDecl> const &ABase) : Base
(ABase) {} bool matches(const NodeType &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const override; private: internal
::Matcher<NamedDecl> Base; }; } inline ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_isDirectlyDerivedFrom0Matcher
, void(::clang::ast_matchers::internal::TypeList<CXXRecordDecl
, ObjCInterfaceDecl>), internal::Matcher<NamedDecl> >
isDirectlyDerivedFrom(internal::Matcher<NamedDecl> const
&Base) { return ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_isDirectlyDerivedFrom0Matcher, void(::
clang::ast_matchers::internal::TypeList<CXXRecordDecl, ObjCInterfaceDecl
>), internal::Matcher<NamedDecl> >(Base); } typedef
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_isDirectlyDerivedFrom0Matcher, void(::clang::ast_matchers
::internal::TypeList<CXXRecordDecl, ObjCInterfaceDecl>)
, internal::Matcher<NamedDecl> > (&isDirectlyDerivedFrom_Type0
)(internal::Matcher<NamedDecl> const &Base); template
<typename NodeType, typename ParamT> bool internal:: matcher_isDirectlyDerivedFrom0Matcher
<NodeType, ParamT>::matches( const NodeType &Node, ::
clang::ast_matchers::internal::ASTMatchFinder *Finder, ::clang
::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
3330 internal::Matcher<NamedDecl>, Base, 0)namespace internal { template <typename NodeType, typename
ParamT> class matcher_isDirectlyDerivedFrom0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<NodeType
> { public: explicit matcher_isDirectlyDerivedFrom0Matcher
( internal::Matcher<NamedDecl> const &ABase) : Base
(ABase) {} bool matches(const NodeType &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const override; private: internal
::Matcher<NamedDecl> Base; }; } inline ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_isDirectlyDerivedFrom0Matcher
, void(::clang::ast_matchers::internal::TypeList<CXXRecordDecl
, ObjCInterfaceDecl>), internal::Matcher<NamedDecl> >
isDirectlyDerivedFrom(internal::Matcher<NamedDecl> const
&Base) { return ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_isDirectlyDerivedFrom0Matcher, void(::
clang::ast_matchers::internal::TypeList<CXXRecordDecl, ObjCInterfaceDecl
>), internal::Matcher<NamedDecl> >(Base); } typedef
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_isDirectlyDerivedFrom0Matcher, void(::clang::ast_matchers
::internal::TypeList<CXXRecordDecl, ObjCInterfaceDecl>)
, internal::Matcher<NamedDecl> > (&isDirectlyDerivedFrom_Type0
)(internal::Matcher<NamedDecl> const &Base); template
<typename NodeType, typename ParamT> bool internal:: matcher_isDirectlyDerivedFrom0Matcher
<NodeType, ParamT>::matches( const NodeType &Node, ::
clang::ast_matchers::internal::ASTMatchFinder *Finder, ::clang
::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
{
3331 // Check if the node is a C++ struct/union/class.
3332 if (const auto *RD = dyn_cast<CXXRecordDecl>(&Node))
3333 return Finder->classIsDerivedFrom(RD, Base, Builder, /*Directly=*/true);
3334
3335 // The node must be an Objective-C class.
3336 const auto *InterfaceDecl = cast<ObjCInterfaceDecl>(&Node);
3337 return Finder->objcClassIsDerivedFrom(InterfaceDecl, Base, Builder,
3338 /*Directly=*/true);
3339}
3340
3341/// Overloaded method as shortcut for \c isDirectlyDerivedFrom(hasName(...)).
3342AST_POLYMORPHIC_MATCHER_P_OVERLOAD(namespace internal { template <typename NodeType, typename
ParamT> class matcher_isDirectlyDerivedFrom1Matcher : public
::clang::ast_matchers::internal::MatcherInterface<NodeType
> { public: explicit matcher_isDirectlyDerivedFrom1Matcher
( std::string const &ABaseName) : BaseName(ABaseName) {} bool
matches(const NodeType &Node, ::clang::ast_matchers::internal
::ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: std::string BaseName; }; }
inline ::clang::ast_matchers::internal::PolymorphicMatcher<
internal::matcher_isDirectlyDerivedFrom1Matcher, void(::clang
::ast_matchers::internal::TypeList<CXXRecordDecl, ObjCInterfaceDecl
>), std::string> isDirectlyDerivedFrom(std::string const
&BaseName) { return ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_isDirectlyDerivedFrom1Matcher, void(::
clang::ast_matchers::internal::TypeList<CXXRecordDecl, ObjCInterfaceDecl
>), std::string>(BaseName); } typedef ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_isDirectlyDerivedFrom1Matcher
, void(::clang::ast_matchers::internal::TypeList<CXXRecordDecl
, ObjCInterfaceDecl>), std::string> (&isDirectlyDerivedFrom_Type1
)(std::string const &BaseName); template <typename NodeType
, typename ParamT> bool internal:: matcher_isDirectlyDerivedFrom1Matcher
<NodeType, ParamT>::matches( const NodeType &Node, ::
clang::ast_matchers::internal::ASTMatchFinder *Finder, ::clang
::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
3343 isDirectlyDerivedFrom,namespace internal { template <typename NodeType, typename
ParamT> class matcher_isDirectlyDerivedFrom1Matcher : public
::clang::ast_matchers::internal::MatcherInterface<NodeType
> { public: explicit matcher_isDirectlyDerivedFrom1Matcher
( std::string const &ABaseName) : BaseName(ABaseName) {} bool
matches(const NodeType &Node, ::clang::ast_matchers::internal
::ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: std::string BaseName; }; }
inline ::clang::ast_matchers::internal::PolymorphicMatcher<
internal::matcher_isDirectlyDerivedFrom1Matcher, void(::clang
::ast_matchers::internal::TypeList<CXXRecordDecl, ObjCInterfaceDecl
>), std::string> isDirectlyDerivedFrom(std::string const
&BaseName) { return ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_isDirectlyDerivedFrom1Matcher, void(::
clang::ast_matchers::internal::TypeList<CXXRecordDecl, ObjCInterfaceDecl
>), std::string>(BaseName); } typedef ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_isDirectlyDerivedFrom1Matcher
, void(::clang::ast_matchers::internal::TypeList<CXXRecordDecl
, ObjCInterfaceDecl>), std::string> (&isDirectlyDerivedFrom_Type1
)(std::string const &BaseName); template <typename NodeType
, typename ParamT> bool internal:: matcher_isDirectlyDerivedFrom1Matcher
<NodeType, ParamT>::matches( const NodeType &Node, ::
clang::ast_matchers::internal::ASTMatchFinder *Finder, ::clang
::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
3344 AST_POLYMORPHIC_SUPPORTED_TYPES(CXXRecordDecl, ObjCInterfaceDecl),namespace internal { template <typename NodeType, typename
ParamT> class matcher_isDirectlyDerivedFrom1Matcher : public
::clang::ast_matchers::internal::MatcherInterface<NodeType
> { public: explicit matcher_isDirectlyDerivedFrom1Matcher
( std::string const &ABaseName) : BaseName(ABaseName) {} bool
matches(const NodeType &Node, ::clang::ast_matchers::internal
::ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: std::string BaseName; }; }
inline ::clang::ast_matchers::internal::PolymorphicMatcher<
internal::matcher_isDirectlyDerivedFrom1Matcher, void(::clang
::ast_matchers::internal::TypeList<CXXRecordDecl, ObjCInterfaceDecl
>), std::string> isDirectlyDerivedFrom(std::string const
&BaseName) { return ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_isDirectlyDerivedFrom1Matcher, void(::
clang::ast_matchers::internal::TypeList<CXXRecordDecl, ObjCInterfaceDecl
>), std::string>(BaseName); } typedef ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_isDirectlyDerivedFrom1Matcher
, void(::clang::ast_matchers::internal::TypeList<CXXRecordDecl
, ObjCInterfaceDecl>), std::string> (&isDirectlyDerivedFrom_Type1
)(std::string const &BaseName); template <typename NodeType
, typename ParamT> bool internal:: matcher_isDirectlyDerivedFrom1Matcher
<NodeType, ParamT>::matches( const NodeType &Node, ::
clang::ast_matchers::internal::ASTMatchFinder *Finder, ::clang
::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
3345 std::string, BaseName, 1)namespace internal { template <typename NodeType, typename
ParamT> class matcher_isDirectlyDerivedFrom1Matcher : public
::clang::ast_matchers::internal::MatcherInterface<NodeType
> { public: explicit matcher_isDirectlyDerivedFrom1Matcher
( std::string const &ABaseName) : BaseName(ABaseName) {} bool
matches(const NodeType &Node, ::clang::ast_matchers::internal
::ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: std::string BaseName; }; }
inline ::clang::ast_matchers::internal::PolymorphicMatcher<
internal::matcher_isDirectlyDerivedFrom1Matcher, void(::clang
::ast_matchers::internal::TypeList<CXXRecordDecl, ObjCInterfaceDecl
>), std::string> isDirectlyDerivedFrom(std::string const
&BaseName) { return ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_isDirectlyDerivedFrom1Matcher, void(::
clang::ast_matchers::internal::TypeList<CXXRecordDecl, ObjCInterfaceDecl
>), std::string>(BaseName); } typedef ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_isDirectlyDerivedFrom1Matcher
, void(::clang::ast_matchers::internal::TypeList<CXXRecordDecl
, ObjCInterfaceDecl>), std::string> (&isDirectlyDerivedFrom_Type1
)(std::string const &BaseName); template <typename NodeType
, typename ParamT> bool internal:: matcher_isDirectlyDerivedFrom1Matcher
<NodeType, ParamT>::matches( const NodeType &Node, ::
clang::ast_matchers::internal::ASTMatchFinder *Finder, ::clang
::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
{
3346 if (BaseName.empty())
3347 return false;
3348 const auto M = isDirectlyDerivedFrom(hasName(BaseName));
3349
3350 if (const auto *RD = dyn_cast<CXXRecordDecl>(&Node))
3351 return Matcher<CXXRecordDecl>(M).matches(*RD, Finder, Builder);
3352
3353 const auto *InterfaceDecl = cast<ObjCInterfaceDecl>(&Node);
3354 return Matcher<ObjCInterfaceDecl>(M).matches(*InterfaceDecl, Finder, Builder);
3355}
3356/// Matches the first method of a class or struct that satisfies \c
3357/// InnerMatcher.
3358///
3359/// Given:
3360/// \code
3361/// class A { void func(); };
3362/// class B { void member(); };
3363/// \endcode
3364///
3365/// \c cxxRecordDecl(hasMethod(hasName("func"))) matches the declaration of
3366/// \c A but not \c B.
3367AST_MATCHER_P(CXXRecordDecl, hasMethod, internal::Matcher<CXXMethodDecl>,namespace internal { class matcher_hasMethod0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<CXXRecordDecl
> { public: explicit matcher_hasMethod0Matcher( internal::
Matcher<CXXMethodDecl> const &AInnerMatcher) : InnerMatcher
(AInnerMatcher) {} bool matches(const CXXRecordDecl &Node
, ::clang::ast_matchers::internal::ASTMatchFinder *Finder, ::
clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder
) const override; private: internal::Matcher<CXXMethodDecl
> InnerMatcher; }; } inline ::clang::ast_matchers::internal
::Matcher<CXXRecordDecl> hasMethod( internal::Matcher<
CXXMethodDecl> const &InnerMatcher) { return ::clang::
ast_matchers::internal::makeMatcher( new internal::matcher_hasMethod0Matcher
(InnerMatcher)); } typedef ::clang::ast_matchers::internal::Matcher
<CXXRecordDecl> ( &hasMethod_Type0)(internal::Matcher
<CXXMethodDecl> const &InnerMatcher); inline bool internal
::matcher_hasMethod0Matcher::matches( const CXXRecordDecl &
Node, ::clang::ast_matchers::internal::ASTMatchFinder *Finder
, ::clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder
) const
3368 InnerMatcher)namespace internal { class matcher_hasMethod0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<CXXRecordDecl
> { public: explicit matcher_hasMethod0Matcher( internal::
Matcher<CXXMethodDecl> const &AInnerMatcher) : InnerMatcher
(AInnerMatcher) {} bool matches(const CXXRecordDecl &Node
, ::clang::ast_matchers::internal::ASTMatchFinder *Finder, ::
clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder
) const override; private: internal::Matcher<CXXMethodDecl
> InnerMatcher; }; } inline ::clang::ast_matchers::internal
::Matcher<CXXRecordDecl> hasMethod( internal::Matcher<
CXXMethodDecl> const &InnerMatcher) { return ::clang::
ast_matchers::internal::makeMatcher( new internal::matcher_hasMethod0Matcher
(InnerMatcher)); } typedef ::clang::ast_matchers::internal::Matcher
<CXXRecordDecl> ( &hasMethod_Type0)(internal::Matcher
<CXXMethodDecl> const &InnerMatcher); inline bool internal
::matcher_hasMethod0Matcher::matches( const CXXRecordDecl &
Node, ::clang::ast_matchers::internal::ASTMatchFinder *Finder
, ::clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder
) const
{
3369 BoundNodesTreeBuilder Result(*Builder);
3370 auto MatchIt = matchesFirstInPointerRange(InnerMatcher, Node.method_begin(),
3371 Node.method_end(), Finder, &Result);
3372 if (MatchIt == Node.method_end())
3373 return false;
3374
3375 if (Finder->isTraversalIgnoringImplicitNodes() && (*MatchIt)->isImplicit())
3376 return false;
3377 *Builder = std::move(Result);
3378 return true;
3379}
3380
3381/// Matches the generated class of lambda expressions.
3382///
3383/// Given:
3384/// \code
3385/// auto x = []{};
3386/// \endcode
3387///
3388/// \c cxxRecordDecl(isLambda()) matches the implicit class declaration of
3389/// \c decltype(x)
3390AST_MATCHER(CXXRecordDecl, isLambda)namespace internal { class matcher_isLambdaMatcher : public ::
clang::ast_matchers::internal::MatcherInterface<CXXRecordDecl
> { public: explicit matcher_isLambdaMatcher() = default; bool
matches(const CXXRecordDecl &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const override; }; } inline
::clang::ast_matchers::internal::Matcher<CXXRecordDecl>
isLambda() { return ::clang::ast_matchers::internal::makeMatcher
( new internal::matcher_isLambdaMatcher()); } inline bool internal
::matcher_isLambdaMatcher::matches( const CXXRecordDecl &
Node, ::clang::ast_matchers::internal::ASTMatchFinder *Finder
, ::clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder
) const
{
3391 return Node.isLambda();
3392}
3393
3394/// Matches AST nodes that have child AST nodes that match the
3395/// provided matcher.
3396///
3397/// Example matches X, Y
3398/// (matcher = cxxRecordDecl(has(cxxRecordDecl(hasName("X")))
3399/// \code
3400/// class X {}; // Matches X, because X::X is a class of name X inside X.
3401/// class Y { class X {}; };
3402/// class Z { class Y { class X {}; }; }; // Does not match Z.
3403/// \endcode
3404///
3405/// ChildT must be an AST base type.
3406///
3407/// Usable as: Any Matcher
3408/// Note that has is direct matcher, so it also matches things like implicit
3409/// casts and paren casts. If you are matching with expr then you should
3410/// probably consider using ignoringParenImpCasts like:
3411/// has(ignoringParenImpCasts(expr())).
3412extern const internal::ArgumentAdaptingMatcherFunc<internal::HasMatcher> has;
3413
3414/// Matches AST nodes that have descendant AST nodes that match the
3415/// provided matcher.
3416///
3417/// Example matches X, Y, Z
3418/// (matcher = cxxRecordDecl(hasDescendant(cxxRecordDecl(hasName("X")))))
3419/// \code
3420/// class X {}; // Matches X, because X::X is a class of name X inside X.
3421/// class Y { class X {}; };
3422/// class Z { class Y { class X {}; }; };
3423/// \endcode
3424///
3425/// DescendantT must be an AST base type.
3426///
3427/// Usable as: Any Matcher
3428extern const internal::ArgumentAdaptingMatcherFunc<
3429 internal::HasDescendantMatcher>
3430 hasDescendant;
3431
3432/// Matches AST nodes that have child AST nodes that match the
3433/// provided matcher.
3434///
3435/// Example matches X, Y, Y::X, Z::Y, Z::Y::X
3436/// (matcher = cxxRecordDecl(forEach(cxxRecordDecl(hasName("X")))
3437/// \code
3438/// class X {};
3439/// class Y { class X {}; }; // Matches Y, because Y::X is a class of name X
3440/// // inside Y.
3441/// class Z { class Y { class X {}; }; }; // Does not match Z.
3442/// \endcode
3443///
3444/// ChildT must be an AST base type.
3445///
3446/// As opposed to 'has', 'forEach' will cause a match for each result that
3447/// matches instead of only on the first one.
3448///
3449/// Usable as: Any Matcher
3450extern const internal::ArgumentAdaptingMatcherFunc<internal::ForEachMatcher>
3451 forEach;
3452
3453/// Matches AST nodes that have descendant AST nodes that match the
3454/// provided matcher.
3455///
3456/// Example matches X, A, A::X, B, B::C, B::C::X
3457/// (matcher = cxxRecordDecl(forEachDescendant(cxxRecordDecl(hasName("X")))))
3458/// \code
3459/// class X {};
3460/// class A { class X {}; }; // Matches A, because A::X is a class of name
3461/// // X inside A.
3462/// class B { class C { class X {}; }; };
3463/// \endcode
3464///
3465/// DescendantT must be an AST base type.
3466///
3467/// As opposed to 'hasDescendant', 'forEachDescendant' will cause a match for
3468/// each result that matches instead of only on the first one.
3469///
3470/// Note: Recursively combined ForEachDescendant can cause many matches:
3471/// cxxRecordDecl(forEachDescendant(cxxRecordDecl(
3472/// forEachDescendant(cxxRecordDecl())
3473/// )))
3474/// will match 10 times (plus injected class name matches) on:
3475/// \code
3476/// class A { class B { class C { class D { class E {}; }; }; }; };
3477/// \endcode
3478///
3479/// Usable as: Any Matcher
3480extern const internal::ArgumentAdaptingMatcherFunc<
3481 internal::ForEachDescendantMatcher>
3482 forEachDescendant;
3483
3484/// Matches if the node or any descendant matches.
3485///
3486/// Generates results for each match.
3487///
3488/// For example, in:
3489/// \code
3490/// class A { class B {}; class C {}; };
3491/// \endcode
3492/// The matcher:
3493/// \code
3494/// cxxRecordDecl(hasName("::A"),
3495/// findAll(cxxRecordDecl(isDefinition()).bind("m")))
3496/// \endcode
3497/// will generate results for \c A, \c B and \c C.
3498///
3499/// Usable as: Any Matcher
3500template <typename T>
3501internal::Matcher<T> findAll(const internal::Matcher<T> &Matcher) {
3502 return eachOf(Matcher, forEachDescendant(Matcher));
3503}
3504
3505/// Matches AST nodes that have a parent that matches the provided
3506/// matcher.
3507///
3508/// Given
3509/// \code
3510/// void f() { for (;;) { int x = 42; if (true) { int x = 43; } } }
3511/// \endcode
3512/// \c compoundStmt(hasParent(ifStmt())) matches "{ int x = 43; }".
3513///
3514/// Usable as: Any Matcher
3515extern const internal::ArgumentAdaptingMatcherFunc<
3516 internal::HasParentMatcher,
3517 internal::TypeList<Decl, NestedNameSpecifierLoc, Stmt, TypeLoc, Attr>,
3518 internal::TypeList<Decl, NestedNameSpecifierLoc, Stmt, TypeLoc, Attr>>
3519 hasParent;
3520
3521/// Matches AST nodes that have an ancestor that matches the provided
3522/// matcher.
3523///
3524/// Given
3525/// \code
3526/// void f() { if (true) { int x = 42; } }
3527/// void g() { for (;;) { int x = 43; } }
3528/// \endcode
3529/// \c expr(integerLiteral(hasAncestor(ifStmt()))) matches \c 42, but not 43.
3530///
3531/// Usable as: Any Matcher
3532extern const internal::ArgumentAdaptingMatcherFunc<
3533 internal::HasAncestorMatcher,
3534 internal::TypeList<Decl, NestedNameSpecifierLoc, Stmt, TypeLoc, Attr>,
3535 internal::TypeList<Decl, NestedNameSpecifierLoc, Stmt, TypeLoc, Attr>>
3536 hasAncestor;
3537
3538/// Matches if the provided matcher does not match.
3539///
3540/// Example matches Y (matcher = cxxRecordDecl(unless(hasName("X"))))
3541/// \code
3542/// class X {};
3543/// class Y {};
3544/// \endcode
3545///
3546/// Usable as: Any Matcher
3547extern const internal::VariadicOperatorMatcherFunc<1, 1> unless;
3548
3549/// Matches a node if the declaration associated with that node
3550/// matches the given matcher.
3551///
3552/// The associated declaration is:
3553/// - for type nodes, the declaration of the underlying type
3554/// - for CallExpr, the declaration of the callee
3555/// - for MemberExpr, the declaration of the referenced member
3556/// - for CXXConstructExpr, the declaration of the constructor
3557/// - for CXXNewExpr, the declaration of the operator new
3558/// - for ObjCIvarExpr, the declaration of the ivar
3559///
3560/// For type nodes, hasDeclaration will generally match the declaration of the
3561/// sugared type. Given
3562/// \code
3563/// class X {};
3564/// typedef X Y;
3565/// Y y;
3566/// \endcode
3567/// in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
3568/// typedefDecl. A common use case is to match the underlying, desugared type.
3569/// This can be achieved by using the hasUnqualifiedDesugaredType matcher:
3570/// \code
3571/// varDecl(hasType(hasUnqualifiedDesugaredType(
3572/// recordType(hasDeclaration(decl())))))
3573/// \endcode
3574/// In this matcher, the decl will match the CXXRecordDecl of class X.
3575///
3576/// Usable as: Matcher<AddrLabelExpr>, Matcher<CallExpr>,
3577/// Matcher<CXXConstructExpr>, Matcher<CXXNewExpr>, Matcher<DeclRefExpr>,
3578/// Matcher<EnumType>, Matcher<InjectedClassNameType>, Matcher<LabelStmt>,
3579/// Matcher<MemberExpr>, Matcher<QualType>, Matcher<RecordType>,
3580/// Matcher<TagType>, Matcher<TemplateSpecializationType>,
3581/// Matcher<TemplateTypeParmType>, Matcher<TypedefType>,
3582/// Matcher<UnresolvedUsingType>
3583inline internal::PolymorphicMatcher<
3584 internal::HasDeclarationMatcher,
3585 void(internal::HasDeclarationSupportedTypes), internal::Matcher<Decl>>
3586hasDeclaration(const internal::Matcher<Decl> &InnerMatcher) {
3587 return internal::PolymorphicMatcher<
3588 internal::HasDeclarationMatcher,
3589 void(internal::HasDeclarationSupportedTypes), internal::Matcher<Decl>>(
3590 InnerMatcher);
3591}
3592
3593/// Matches a \c NamedDecl whose underlying declaration matches the given
3594/// matcher.
3595///
3596/// Given
3597/// \code
3598/// namespace N { template<class T> void f(T t); }
3599/// template <class T> void g() { using N::f; f(T()); }
3600/// \endcode
3601/// \c unresolvedLookupExpr(hasAnyDeclaration(
3602/// namedDecl(hasUnderlyingDecl(hasName("::N::f")))))
3603/// matches the use of \c f in \c g() .
3604AST_MATCHER_P(NamedDecl, hasUnderlyingDecl, internal::Matcher<NamedDecl>,namespace internal { class matcher_hasUnderlyingDecl0Matcher :
public ::clang::ast_matchers::internal::MatcherInterface<
NamedDecl> { public: explicit matcher_hasUnderlyingDecl0Matcher
( internal::Matcher<NamedDecl> const &AInnerMatcher
) : InnerMatcher(AInnerMatcher) {} bool matches(const NamedDecl
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: internal::Matcher<NamedDecl
> InnerMatcher; }; } inline ::clang::ast_matchers::internal
::Matcher<NamedDecl> hasUnderlyingDecl( internal::Matcher
<NamedDecl> const &InnerMatcher) { return ::clang::
ast_matchers::internal::makeMatcher( new internal::matcher_hasUnderlyingDecl0Matcher
(InnerMatcher)); } typedef ::clang::ast_matchers::internal::Matcher
<NamedDecl> ( &hasUnderlyingDecl_Type0)(internal::Matcher
<NamedDecl> const &InnerMatcher); inline bool internal
::matcher_hasUnderlyingDecl0Matcher::matches( const NamedDecl
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
3605 InnerMatcher)namespace internal { class matcher_hasUnderlyingDecl0Matcher :
public ::clang::ast_matchers::internal::MatcherInterface<
NamedDecl> { public: explicit matcher_hasUnderlyingDecl0Matcher
( internal::Matcher<NamedDecl> const &AInnerMatcher
) : InnerMatcher(AInnerMatcher) {} bool matches(const NamedDecl
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: internal::Matcher<NamedDecl
> InnerMatcher; }; } inline ::clang::ast_matchers::internal
::Matcher<NamedDecl> hasUnderlyingDecl( internal::Matcher
<NamedDecl> const &InnerMatcher) { return ::clang::
ast_matchers::internal::makeMatcher( new internal::matcher_hasUnderlyingDecl0Matcher
(InnerMatcher)); } typedef ::clang::ast_matchers::internal::Matcher
<NamedDecl> ( &hasUnderlyingDecl_Type0)(internal::Matcher
<NamedDecl> const &InnerMatcher); inline bool internal
::matcher_hasUnderlyingDecl0Matcher::matches( const NamedDecl
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
3606 const NamedDecl *UnderlyingDecl = Node.getUnderlyingDecl();
3607
3608 return UnderlyingDecl != nullptr &&
3609 InnerMatcher.matches(*UnderlyingDecl, Finder, Builder);
3610}
3611
3612/// Matches on the implicit object argument of a member call expression, after
3613/// stripping off any parentheses or implicit casts.
3614///
3615/// Given
3616/// \code
3617/// class Y { public: void m(); };
3618/// Y g();
3619/// class X : public Y {};
3620/// void z(Y y, X x) { y.m(); (g()).m(); x.m(); }
3621/// \endcode
3622/// cxxMemberCallExpr(on(hasType(cxxRecordDecl(hasName("Y")))))
3623/// matches `y.m()` and `(g()).m()`.
3624/// cxxMemberCallExpr(on(hasType(cxxRecordDecl(hasName("X")))))
3625/// matches `x.m()`.
3626/// cxxMemberCallExpr(on(callExpr()))
3627/// matches `(g()).m()`.
3628///
3629/// FIXME: Overload to allow directly matching types?
3630AST_MATCHER_P(CXXMemberCallExpr, on, internal::Matcher<Expr>,namespace internal { class matcher_on0Matcher : public ::clang
::ast_matchers::internal::MatcherInterface<CXXMemberCallExpr
> { public: explicit matcher_on0Matcher( internal::Matcher
<Expr> const &AInnerMatcher) : InnerMatcher(AInnerMatcher
) {} bool matches(const CXXMemberCallExpr &Node, ::clang::
ast_matchers::internal::ASTMatchFinder *Finder, ::clang::ast_matchers
::internal::BoundNodesTreeBuilder *Builder) const override; private
: internal::Matcher<Expr> InnerMatcher; }; } inline ::clang
::ast_matchers::internal::Matcher<CXXMemberCallExpr> on
( internal::Matcher<Expr> const &InnerMatcher) { return
::clang::ast_matchers::internal::makeMatcher( new internal::
matcher_on0Matcher(InnerMatcher)); } typedef ::clang::ast_matchers
::internal::Matcher<CXXMemberCallExpr> ( &on_Type0)
(internal::Matcher<Expr> const &InnerMatcher); inline
bool internal::matcher_on0Matcher::matches( const CXXMemberCallExpr
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
3631 InnerMatcher)namespace internal { class matcher_on0Matcher : public ::clang
::ast_matchers::internal::MatcherInterface<CXXMemberCallExpr
> { public: explicit matcher_on0Matcher( internal::Matcher
<Expr> const &AInnerMatcher) : InnerMatcher(AInnerMatcher
) {} bool matches(const CXXMemberCallExpr &Node, ::clang::
ast_matchers::internal::ASTMatchFinder *Finder, ::clang::ast_matchers
::internal::BoundNodesTreeBuilder *Builder) const override; private
: internal::Matcher<Expr> InnerMatcher; }; } inline ::clang
::ast_matchers::internal::Matcher<CXXMemberCallExpr> on
( internal::Matcher<Expr> const &InnerMatcher) { return
::clang::ast_matchers::internal::makeMatcher( new internal::
matcher_on0Matcher(InnerMatcher)); } typedef ::clang::ast_matchers
::internal::Matcher<CXXMemberCallExpr> ( &on_Type0)
(internal::Matcher<Expr> const &InnerMatcher); inline
bool internal::matcher_on0Matcher::matches( const CXXMemberCallExpr
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
3632 const Expr *ExprNode = Node.getImplicitObjectArgument()
3633 ->IgnoreParenImpCasts();
3634 return (ExprNode != nullptr &&
3635 InnerMatcher.matches(*ExprNode, Finder, Builder));
3636}
3637
3638
3639/// Matches on the receiver of an ObjectiveC Message expression.
3640///
3641/// Example
3642/// matcher = objCMessageExpr(hasReceiverType(asString("UIWebView *")));
3643/// matches the [webView ...] message invocation.
3644/// \code
3645/// NSString *webViewJavaScript = ...
3646/// UIWebView *webView = ...
3647/// [webView stringByEvaluatingJavaScriptFromString:webViewJavascript];
3648/// \endcode
3649AST_MATCHER_P(ObjCMessageExpr, hasReceiverType, internal::Matcher<QualType>,namespace internal { class matcher_hasReceiverType0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<ObjCMessageExpr
> { public: explicit matcher_hasReceiverType0Matcher( internal
::Matcher<QualType> const &AInnerMatcher) : InnerMatcher
(AInnerMatcher) {} bool matches(const ObjCMessageExpr &Node
, ::clang::ast_matchers::internal::ASTMatchFinder *Finder, ::
clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder
) const override; private: internal::Matcher<QualType> InnerMatcher
; }; } inline ::clang::ast_matchers::internal::Matcher<ObjCMessageExpr
> hasReceiverType( internal::Matcher<QualType> const
&InnerMatcher) { return ::clang::ast_matchers::internal::
makeMatcher( new internal::matcher_hasReceiverType0Matcher(InnerMatcher
)); } typedef ::clang::ast_matchers::internal::Matcher<ObjCMessageExpr
> ( &hasReceiverType_Type0)(internal::Matcher<QualType
> const &InnerMatcher); inline bool internal::matcher_hasReceiverType0Matcher
::matches( const ObjCMessageExpr &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
3650 InnerMatcher)namespace internal { class matcher_hasReceiverType0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<ObjCMessageExpr
> { public: explicit matcher_hasReceiverType0Matcher( internal
::Matcher<QualType> const &AInnerMatcher) : InnerMatcher
(AInnerMatcher) {} bool matches(const ObjCMessageExpr &Node
, ::clang::ast_matchers::internal::ASTMatchFinder *Finder, ::
clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder
) const override; private: internal::Matcher<QualType> InnerMatcher
; }; } inline ::clang::ast_matchers::internal::Matcher<ObjCMessageExpr
> hasReceiverType( internal::Matcher<QualType> const
&InnerMatcher) { return ::clang::ast_matchers::internal::
makeMatcher( new internal::matcher_hasReceiverType0Matcher(InnerMatcher
)); } typedef ::clang::ast_matchers::internal::Matcher<ObjCMessageExpr
> ( &hasReceiverType_Type0)(internal::Matcher<QualType
> const &InnerMatcher); inline bool internal::matcher_hasReceiverType0Matcher
::matches( const ObjCMessageExpr &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
{
3651 const QualType TypeDecl = Node.getReceiverType();
3652 return InnerMatcher.matches(TypeDecl, Finder, Builder);
3653}
3654
3655/// Returns true when the Objective-C method declaration is a class method.
3656///
3657/// Example
3658/// matcher = objcMethodDecl(isClassMethod())
3659/// matches
3660/// \code
3661/// @interface I + (void)foo; @end
3662/// \endcode
3663/// but not
3664/// \code
3665/// @interface I - (void)bar; @end
3666/// \endcode
3667AST_MATCHER(ObjCMethodDecl, isClassMethod)namespace internal { class matcher_isClassMethodMatcher : public
::clang::ast_matchers::internal::MatcherInterface<ObjCMethodDecl
> { public: explicit matcher_isClassMethodMatcher() = default
; bool matches(const ObjCMethodDecl &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const override; }; } inline
::clang::ast_matchers::internal::Matcher<ObjCMethodDecl>
isClassMethod() { return ::clang::ast_matchers::internal::makeMatcher
( new internal::matcher_isClassMethodMatcher()); } inline bool
internal::matcher_isClassMethodMatcher::matches( const ObjCMethodDecl
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
3668 return Node.isClassMethod();
3669}
3670
3671/// Returns true when the Objective-C method declaration is an instance method.
3672///
3673/// Example
3674/// matcher = objcMethodDecl(isInstanceMethod())
3675/// matches
3676/// \code
3677/// @interface I - (void)bar; @end
3678/// \endcode
3679/// but not
3680/// \code
3681/// @interface I + (void)foo; @end
3682/// \endcode
3683AST_MATCHER(ObjCMethodDecl, isInstanceMethod)namespace internal { class matcher_isInstanceMethodMatcher : public
::clang::ast_matchers::internal::MatcherInterface<ObjCMethodDecl
> { public: explicit matcher_isInstanceMethodMatcher() = default
; bool matches(const ObjCMethodDecl &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const override; }; } inline
::clang::ast_matchers::internal::Matcher<ObjCMethodDecl>
isInstanceMethod() { return ::clang::ast_matchers::internal::
makeMatcher( new internal::matcher_isInstanceMethodMatcher())
; } inline bool internal::matcher_isInstanceMethodMatcher::matches
( const ObjCMethodDecl &Node, ::clang::ast_matchers::internal
::ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
3684 return Node.isInstanceMethod();
3685}
3686
3687/// Returns true when the Objective-C message is sent to a class.
3688///
3689/// Example
3690/// matcher = objcMessageExpr(isClassMessage())
3691/// matches
3692/// \code
3693/// [NSString stringWithFormat:@"format"];
3694/// \endcode
3695/// but not
3696/// \code
3697/// NSString *x = @"hello";
3698/// [x containsString:@"h"];
3699/// \endcode
3700AST_MATCHER(ObjCMessageExpr, isClassMessage)namespace internal { class matcher_isClassMessageMatcher : public
::clang::ast_matchers::internal::MatcherInterface<ObjCMessageExpr
> { public: explicit matcher_isClassMessageMatcher() = default
; bool matches(const ObjCMessageExpr &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const override; }; } inline
::clang::ast_matchers::internal::Matcher<ObjCMessageExpr>
isClassMessage() { return ::clang::ast_matchers::internal::makeMatcher
( new internal::matcher_isClassMessageMatcher()); } inline bool
internal::matcher_isClassMessageMatcher::matches( const ObjCMessageExpr
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
3701 return Node.isClassMessage();
3702}
3703
3704/// Returns true when the Objective-C message is sent to an instance.
3705///
3706/// Example
3707/// matcher = objcMessageExpr(isInstanceMessage())
3708/// matches
3709/// \code
3710/// NSString *x = @"hello";
3711/// [x containsString:@"h"];
3712/// \endcode
3713/// but not
3714/// \code
3715/// [NSString stringWithFormat:@"format"];
3716/// \endcode
3717AST_MATCHER(ObjCMessageExpr, isInstanceMessage)namespace internal { class matcher_isInstanceMessageMatcher :
public ::clang::ast_matchers::internal::MatcherInterface<
ObjCMessageExpr> { public: explicit matcher_isInstanceMessageMatcher
() = default; bool matches(const ObjCMessageExpr &Node, ::
clang::ast_matchers::internal::ASTMatchFinder *Finder, ::clang
::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
override; }; } inline ::clang::ast_matchers::internal::Matcher
<ObjCMessageExpr> isInstanceMessage() { return ::clang::
ast_matchers::internal::makeMatcher( new internal::matcher_isInstanceMessageMatcher
()); } inline bool internal::matcher_isInstanceMessageMatcher
::matches( const ObjCMessageExpr &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
{
3718 return Node.isInstanceMessage();
3719}
3720
3721/// Matches if the Objective-C message is sent to an instance,
3722/// and the inner matcher matches on that instance.
3723///
3724/// For example the method call in
3725/// \code
3726/// NSString *x = @"hello";
3727/// [x containsString:@"h"];
3728/// \endcode
3729/// is matched by
3730/// objcMessageExpr(hasReceiver(declRefExpr(to(varDecl(hasName("x"))))))
3731AST_MATCHER_P(ObjCMessageExpr, hasReceiver, internal::Matcher<Expr>,namespace internal { class matcher_hasReceiver0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<ObjCMessageExpr
> { public: explicit matcher_hasReceiver0Matcher( internal
::Matcher<Expr> const &AInnerMatcher) : InnerMatcher
(AInnerMatcher) {} bool matches(const ObjCMessageExpr &Node
, ::clang::ast_matchers::internal::ASTMatchFinder *Finder, ::
clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder
) const override; private: internal::Matcher<Expr> InnerMatcher
; }; } inline ::clang::ast_matchers::internal::Matcher<ObjCMessageExpr
> hasReceiver( internal::Matcher<Expr> const &InnerMatcher
) { return ::clang::ast_matchers::internal::makeMatcher( new internal
::matcher_hasReceiver0Matcher(InnerMatcher)); } typedef ::clang
::ast_matchers::internal::Matcher<ObjCMessageExpr> ( &
hasReceiver_Type0)(internal::Matcher<Expr> const &InnerMatcher
); inline bool internal::matcher_hasReceiver0Matcher::matches
( const ObjCMessageExpr &Node, ::clang::ast_matchers::internal
::ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
3732 InnerMatcher)namespace internal { class matcher_hasReceiver0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<ObjCMessageExpr
> { public: explicit matcher_hasReceiver0Matcher( internal
::Matcher<Expr> const &AInnerMatcher) : InnerMatcher
(AInnerMatcher) {} bool matches(const ObjCMessageExpr &Node
, ::clang::ast_matchers::internal::ASTMatchFinder *Finder, ::
clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder
) const override; private: internal::Matcher<Expr> InnerMatcher
; }; } inline ::clang::ast_matchers::internal::Matcher<ObjCMessageExpr
> hasReceiver( internal::Matcher<Expr> const &InnerMatcher
) { return ::clang::ast_matchers::internal::makeMatcher( new internal
::matcher_hasReceiver0Matcher(InnerMatcher)); } typedef ::clang
::ast_matchers::internal::Matcher<ObjCMessageExpr> ( &
hasReceiver_Type0)(internal::Matcher<Expr> const &InnerMatcher
); inline bool internal::matcher_hasReceiver0Matcher::matches
( const ObjCMessageExpr &Node, ::clang::ast_matchers::internal
::ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
3733 const Expr *ReceiverNode = Node.getInstanceReceiver();
3734 return (ReceiverNode != nullptr &&
3735 InnerMatcher.matches(*ReceiverNode->IgnoreParenImpCasts(), Finder,
3736 Builder));
3737}
3738
3739/// Matches when BaseName == Selector.getAsString()
3740///
3741/// matcher = objCMessageExpr(hasSelector("loadHTMLString:baseURL:"));
3742/// matches the outer message expr in the code below, but NOT the message
3743/// invocation for self.bodyView.
3744/// \code
3745/// [self.bodyView loadHTMLString:html baseURL:NULL];
3746/// \endcode
3747AST_MATCHER_P(ObjCMessageExpr, hasSelector, std::string, BaseName)namespace internal { class matcher_hasSelector0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<ObjCMessageExpr
> { public: explicit matcher_hasSelector0Matcher( std::string
const &ABaseName) : BaseName(ABaseName) {} bool matches(
const ObjCMessageExpr &Node, ::clang::ast_matchers::internal
::ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: std::string BaseName; }; }
inline ::clang::ast_matchers::internal::Matcher<ObjCMessageExpr
> hasSelector( std::string const &BaseName) { return ::
clang::ast_matchers::internal::makeMatcher( new internal::matcher_hasSelector0Matcher
(BaseName)); } typedef ::clang::ast_matchers::internal::Matcher
<ObjCMessageExpr> ( &hasSelector_Type0)(std::string
const &BaseName); inline bool internal::matcher_hasSelector0Matcher
::matches( const ObjCMessageExpr &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
{
3748 Selector Sel = Node.getSelector();
3749 return BaseName == Sel.getAsString();
3750}
3751
3752/// Matches when at least one of the supplied string equals to the
3753/// Selector.getAsString()
3754///
3755/// matcher = objCMessageExpr(hasSelector("methodA:", "methodB:"));
3756/// matches both of the expressions below:
3757/// \code
3758/// [myObj methodA:argA];
3759/// [myObj methodB:argB];
3760/// \endcode
3761extern const internal::VariadicFunction<internal::Matcher<ObjCMessageExpr>,
3762 StringRef,
3763 internal::hasAnySelectorFunc>
3764 hasAnySelector;
3765
3766/// Matches ObjC selectors whose name contains
3767/// a substring matched by the given RegExp.
3768/// matcher = objCMessageExpr(matchesSelector("loadHTMLString\:baseURL?"));
3769/// matches the outer message expr in the code below, but NOT the message
3770/// invocation for self.bodyView.
3771/// \code
3772/// [self.bodyView loadHTMLString:html baseURL:NULL];
3773/// \endcode
3774AST_MATCHER_REGEX(ObjCMessageExpr, matchesSelector, RegExp)namespace internal { class matcher_matchesSelector0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<ObjCMessageExpr
> { public: explicit matcher_matchesSelector0Matcher( std::
shared_ptr<llvm::Regex> RE) : RegExp(std::move(RE)) {} bool
matches(const ObjCMessageExpr &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const override; private: std
::shared_ptr<llvm::Regex> RegExp; }; } inline ::clang::
ast_matchers::internal::Matcher<ObjCMessageExpr> matchesSelector
( llvm::StringRef RegExp, llvm::Regex::RegexFlags RegexFlags)
{ return ::clang::ast_matchers::internal::makeMatcher( new internal
::matcher_matchesSelector0Matcher( ::clang::ast_matchers::internal
::createAndVerifyRegex( RegExp, RegexFlags, "matchesSelector"
))); } inline ::clang::ast_matchers::internal::Matcher<ObjCMessageExpr
> matchesSelector( llvm::StringRef RegExp) { return matchesSelector
(RegExp, llvm::Regex::NoFlags); } typedef ::clang::ast_matchers
::internal::Matcher<ObjCMessageExpr> ( &matchesSelector_Type0Flags
)(llvm::StringRef, llvm::Regex::RegexFlags); typedef ::clang::
ast_matchers::internal::Matcher<ObjCMessageExpr> ( &
matchesSelector_Type0)(llvm::StringRef); inline bool internal
::matcher_matchesSelector0Matcher::matches( const ObjCMessageExpr
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
3775 std::string SelectorString = Node.getSelector().getAsString();
3776 return RegExp->match(SelectorString);
3777}
3778
3779/// Matches when the selector is the empty selector
3780///
3781/// Matches only when the selector of the objCMessageExpr is NULL. This may
3782/// represent an error condition in the tree!
3783AST_MATCHER(ObjCMessageExpr, hasNullSelector)namespace internal { class matcher_hasNullSelectorMatcher : public
::clang::ast_matchers::internal::MatcherInterface<ObjCMessageExpr
> { public: explicit matcher_hasNullSelectorMatcher() = default
; bool matches(const ObjCMessageExpr &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const override; }; } inline
::clang::ast_matchers::internal::Matcher<ObjCMessageExpr>
hasNullSelector() { return ::clang::ast_matchers::internal::
makeMatcher( new internal::matcher_hasNullSelectorMatcher());
} inline bool internal::matcher_hasNullSelectorMatcher::matches
( const ObjCMessageExpr &Node, ::clang::ast_matchers::internal
::ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
3784 return Node.getSelector().isNull();
3785}
3786
3787/// Matches when the selector is a Unary Selector
3788///
3789/// matcher = objCMessageExpr(matchesSelector(hasUnarySelector());
3790/// matches self.bodyView in the code below, but NOT the outer message
3791/// invocation of "loadHTMLString:baseURL:".
3792/// \code
3793/// [self.bodyView loadHTMLString:html baseURL:NULL];
3794/// \endcode
3795AST_MATCHER(ObjCMessageExpr, hasUnarySelector)namespace internal { class matcher_hasUnarySelectorMatcher : public
::clang::ast_matchers::internal::MatcherInterface<ObjCMessageExpr
> { public: explicit matcher_hasUnarySelectorMatcher() = default
; bool matches(const ObjCMessageExpr &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const override; }; } inline
::clang::ast_matchers::internal::Matcher<ObjCMessageExpr>
hasUnarySelector() { return ::clang::ast_matchers::internal::
makeMatcher( new internal::matcher_hasUnarySelectorMatcher())
; } inline bool internal::matcher_hasUnarySelectorMatcher::matches
( const ObjCMessageExpr &Node, ::clang::ast_matchers::internal
::ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
3796 return Node.getSelector().isUnarySelector();
3797}
3798
3799/// Matches when the selector is a keyword selector
3800///
3801/// objCMessageExpr(hasKeywordSelector()) matches the generated setFrame
3802/// message expression in
3803///
3804/// \code
3805/// UIWebView *webView = ...;
3806/// CGRect bodyFrame = webView.frame;
3807/// bodyFrame.size.height = self.bodyContentHeight;
3808/// webView.frame = bodyFrame;
3809/// // ^---- matches here
3810/// \endcode
3811AST_MATCHER(ObjCMessageExpr, hasKeywordSelector)namespace internal { class matcher_hasKeywordSelectorMatcher :
public ::clang::ast_matchers::internal::MatcherInterface<
ObjCMessageExpr> { public: explicit matcher_hasKeywordSelectorMatcher
() = default; bool matches(const ObjCMessageExpr &Node, ::
clang::ast_matchers::internal::ASTMatchFinder *Finder, ::clang
::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
override; }; } inline ::clang::ast_matchers::internal::Matcher
<ObjCMessageExpr> hasKeywordSelector() { return ::clang
::ast_matchers::internal::makeMatcher( new internal::matcher_hasKeywordSelectorMatcher
()); } inline bool internal::matcher_hasKeywordSelectorMatcher
::matches( const ObjCMessageExpr &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
{
3812 return Node.getSelector().isKeywordSelector();
3813}
3814
3815/// Matches when the selector has the specified number of arguments
3816///
3817/// matcher = objCMessageExpr(numSelectorArgs(0));
3818/// matches self.bodyView in the code below
3819///
3820/// matcher = objCMessageExpr(numSelectorArgs(2));
3821/// matches the invocation of "loadHTMLString:baseURL:" but not that
3822/// of self.bodyView
3823/// \code
3824/// [self.bodyView loadHTMLString:html baseURL:NULL];
3825/// \endcode
3826AST_MATCHER_P(ObjCMessageExpr, numSelectorArgs, unsigned, N)namespace internal { class matcher_numSelectorArgs0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<ObjCMessageExpr
> { public: explicit matcher_numSelectorArgs0Matcher( unsigned
const &AN) : N(AN) {} bool matches(const ObjCMessageExpr
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: unsigned N; }; } inline ::
clang::ast_matchers::internal::Matcher<ObjCMessageExpr>
numSelectorArgs( unsigned const &N) { return ::clang::ast_matchers
::internal::makeMatcher( new internal::matcher_numSelectorArgs0Matcher
(N)); } typedef ::clang::ast_matchers::internal::Matcher<ObjCMessageExpr
> ( &numSelectorArgs_Type0)(unsigned const &N); inline
bool internal::matcher_numSelectorArgs0Matcher::matches( const
ObjCMessageExpr &Node, ::clang::ast_matchers::internal::
ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
3827 return Node.getSelector().getNumArgs() == N;
3828}
3829
3830/// Matches if the call expression's callee expression matches.
3831///
3832/// Given
3833/// \code
3834/// class Y { void x() { this->x(); x(); Y y; y.x(); } };
3835/// void f() { f(); }
3836/// \endcode
3837/// callExpr(callee(expr()))
3838/// matches this->x(), x(), y.x(), f()
3839/// with callee(...)
3840/// matching this->x, x, y.x, f respectively
3841///
3842/// Note: Callee cannot take the more general internal::Matcher<Expr>
3843/// because this introduces ambiguous overloads with calls to Callee taking a
3844/// internal::Matcher<Decl>, as the matcher hierarchy is purely
3845/// implemented in terms of implicit casts.
3846AST_MATCHER_P(CallExpr, callee, internal::Matcher<Stmt>,namespace internal { class matcher_callee0Matcher : public ::
clang::ast_matchers::internal::MatcherInterface<CallExpr>
{ public: explicit matcher_callee0Matcher( internal::Matcher
<Stmt> const &AInnerMatcher) : InnerMatcher(AInnerMatcher
) {} bool matches(const CallExpr &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const override; private: internal
::Matcher<Stmt> InnerMatcher; }; } inline ::clang::ast_matchers
::internal::Matcher<CallExpr> callee( internal::Matcher
<Stmt> const &InnerMatcher) { return ::clang::ast_matchers
::internal::makeMatcher( new internal::matcher_callee0Matcher
(InnerMatcher)); } typedef ::clang::ast_matchers::internal::Matcher
<CallExpr> ( &callee_Type0)(internal::Matcher<Stmt
> const &InnerMatcher); inline bool internal::matcher_callee0Matcher
::matches( const CallExpr &Node, ::clang::ast_matchers::internal
::ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
3847 InnerMatcher)namespace internal { class matcher_callee0Matcher : public ::
clang::ast_matchers::internal::MatcherInterface<CallExpr>
{ public: explicit matcher_callee0Matcher( internal::Matcher
<Stmt> const &AInnerMatcher) : InnerMatcher(AInnerMatcher
) {} bool matches(const CallExpr &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const override; private: internal
::Matcher<Stmt> InnerMatcher; }; } inline ::clang::ast_matchers
::internal::Matcher<CallExpr> callee( internal::Matcher
<Stmt> const &InnerMatcher) { return ::clang::ast_matchers
::internal::makeMatcher( new internal::matcher_callee0Matcher
(InnerMatcher)); } typedef ::clang::ast_matchers::internal::Matcher
<CallExpr> ( &callee_Type0)(internal::Matcher<Stmt
> const &InnerMatcher); inline bool internal::matcher_callee0Matcher
::matches( const CallExpr &Node, ::clang::ast_matchers::internal
::ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
3848 const Expr *ExprNode = Node.getCallee();
3849 return (ExprNode != nullptr &&
3850 InnerMatcher.matches(*ExprNode, Finder, Builder));
3851}
3852
3853/// Matches 1) if the call expression's callee's declaration matches the
3854/// given matcher; or 2) if the Obj-C message expression's callee's method
3855/// declaration matches the given matcher.
3856///
3857/// Example matches y.x() (matcher = callExpr(callee(
3858/// cxxMethodDecl(hasName("x")))))
3859/// \code
3860/// class Y { public: void x(); };
3861/// void z() { Y y; y.x(); }
3862/// \endcode
3863///
3864/// Example 2. Matches [I foo] with
3865/// objcMessageExpr(callee(objcMethodDecl(hasName("foo"))))
3866///
3867/// \code
3868/// @interface I: NSObject
3869/// +(void)foo;
3870/// @end
3871/// ...
3872/// [I foo]
3873/// \endcode
3874AST_POLYMORPHIC_MATCHER_P_OVERLOAD(namespace internal { template <typename NodeType, typename
ParamT> class matcher_callee1Matcher : public ::clang::ast_matchers
::internal::MatcherInterface<NodeType> { public: explicit
matcher_callee1Matcher( internal::Matcher<Decl> const &
AInnerMatcher) : InnerMatcher(AInnerMatcher) {} bool matches(
const NodeType &Node, ::clang::ast_matchers::internal::ASTMatchFinder
*Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: internal::Matcher<Decl
> InnerMatcher; }; } inline ::clang::ast_matchers::internal
::PolymorphicMatcher< internal::matcher_callee1Matcher, void
(::clang::ast_matchers::internal::TypeList<ObjCMessageExpr
, CallExpr>), internal::Matcher<Decl> > callee(internal
::Matcher<Decl> const &InnerMatcher) { return ::clang
::ast_matchers::internal::PolymorphicMatcher< internal::matcher_callee1Matcher
, void(::clang::ast_matchers::internal::TypeList<ObjCMessageExpr
, CallExpr>), internal::Matcher<Decl> >(InnerMatcher
); } typedef ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_callee1Matcher, void(::clang::ast_matchers
::internal::TypeList<ObjCMessageExpr, CallExpr>), internal
::Matcher<Decl> > (&callee_Type1)(internal::Matcher
<Decl> const &InnerMatcher); template <typename NodeType
, typename ParamT> bool internal:: matcher_callee1Matcher<
NodeType, ParamT>::matches( const NodeType &Node, ::clang
::ast_matchers::internal::ASTMatchFinder *Finder, ::clang::ast_matchers
::internal::BoundNodesTreeBuilder *Builder) const
3875 callee, AST_POLYMORPHIC_SUPPORTED_TYPES(ObjCMessageExpr, CallExpr),namespace internal { template <typename NodeType, typename
ParamT> class matcher_callee1Matcher : public ::clang::ast_matchers
::internal::MatcherInterface<NodeType> { public: explicit
matcher_callee1Matcher( internal::Matcher<Decl> const &
AInnerMatcher) : InnerMatcher(AInnerMatcher) {} bool matches(
const NodeType &Node, ::clang::ast_matchers::internal::ASTMatchFinder
*Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: internal::Matcher<Decl
> InnerMatcher; }; } inline ::clang::ast_matchers::internal
::PolymorphicMatcher< internal::matcher_callee1Matcher, void
(::clang::ast_matchers::internal::TypeList<ObjCMessageExpr
, CallExpr>), internal::Matcher<Decl> > callee(internal
::Matcher<Decl> const &InnerMatcher) { return ::clang
::ast_matchers::internal::PolymorphicMatcher< internal::matcher_callee1Matcher
, void(::clang::ast_matchers::internal::TypeList<ObjCMessageExpr
, CallExpr>), internal::Matcher<Decl> >(InnerMatcher
); } typedef ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_callee1Matcher, void(::clang::ast_matchers
::internal::TypeList<ObjCMessageExpr, CallExpr>), internal
::Matcher<Decl> > (&callee_Type1)(internal::Matcher
<Decl> const &InnerMatcher); template <typename NodeType
, typename ParamT> bool internal:: matcher_callee1Matcher<
NodeType, ParamT>::matches( const NodeType &Node, ::clang
::ast_matchers::internal::ASTMatchFinder *Finder, ::clang::ast_matchers
::internal::BoundNodesTreeBuilder *Builder) const
3876 internal::Matcher<Decl>, InnerMatcher, 1)namespace internal { template <typename NodeType, typename
ParamT> class matcher_callee1Matcher : public ::clang::ast_matchers
::internal::MatcherInterface<NodeType> { public: explicit
matcher_callee1Matcher( internal::Matcher<Decl> const &
AInnerMatcher) : InnerMatcher(AInnerMatcher) {} bool matches(
const NodeType &Node, ::clang::ast_matchers::internal::ASTMatchFinder
*Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: internal::Matcher<Decl
> InnerMatcher; }; } inline ::clang::ast_matchers::internal
::PolymorphicMatcher< internal::matcher_callee1Matcher, void
(::clang::ast_matchers::internal::TypeList<ObjCMessageExpr
, CallExpr>), internal::Matcher<Decl> > callee(internal
::Matcher<Decl> const &InnerMatcher) { return ::clang
::ast_matchers::internal::PolymorphicMatcher< internal::matcher_callee1Matcher
, void(::clang::ast_matchers::internal::TypeList<ObjCMessageExpr
, CallExpr>), internal::Matcher<Decl> >(InnerMatcher
); } typedef ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_callee1Matcher, void(::clang::ast_matchers
::internal::TypeList<ObjCMessageExpr, CallExpr>), internal
::Matcher<Decl> > (&callee_Type1)(internal::Matcher
<Decl> const &InnerMatcher); template <typename NodeType
, typename ParamT> bool internal:: matcher_callee1Matcher<
NodeType, ParamT>::matches( const NodeType &Node, ::clang
::ast_matchers::internal::ASTMatchFinder *Finder, ::clang::ast_matchers
::internal::BoundNodesTreeBuilder *Builder) const
{
3877 if (const auto *CallNode = dyn_cast<CallExpr>(&Node))
3878 return callExpr(hasDeclaration(InnerMatcher))
3879 .matches(Node, Finder, Builder);
3880 else {
3881 // The dynamic cast below is guaranteed to succeed as there are only 2
3882 // supported return types.
3883 const auto *MsgNode = cast<ObjCMessageExpr>(&Node);
3884 const Decl *DeclNode = MsgNode->getMethodDecl();
3885 return (DeclNode != nullptr &&
3886 InnerMatcher.matches(*DeclNode, Finder, Builder));
3887 }
3888}
3889
3890/// Matches if the expression's or declaration's type matches a type
3891/// matcher.
3892///
3893/// Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X")))))
3894/// and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X")))))
3895/// and U (matcher = typedefDecl(hasType(asString("int")))
3896/// and friend class X (matcher = friendDecl(hasType("X"))
3897/// and public virtual X (matcher = cxxBaseSpecifier(hasType(
3898/// asString("class X")))
3899/// \code
3900/// class X {};
3901/// void y(X &x) { x; X z; }
3902/// typedef int U;
3903/// class Y { friend class X; };
3904/// class Z : public virtual X {};
3905/// \endcode
3906AST_POLYMORPHIC_MATCHER_P_OVERLOAD(namespace internal { template <typename NodeType, typename
ParamT> class matcher_hasType0Matcher : public ::clang::ast_matchers
::internal::MatcherInterface<NodeType> { public: explicit
matcher_hasType0Matcher( internal::Matcher<QualType> const
&AInnerMatcher) : InnerMatcher(AInnerMatcher) {} bool matches
(const NodeType &Node, ::clang::ast_matchers::internal::ASTMatchFinder
*Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: internal::Matcher<QualType
> InnerMatcher; }; } inline ::clang::ast_matchers::internal
::PolymorphicMatcher< internal::matcher_hasType0Matcher, void
(::clang::ast_matchers::internal::TypeList<Expr, FriendDecl
, TypedefNameDecl, ValueDecl, CXXBaseSpecifier>), internal
::Matcher<QualType> > hasType(internal::Matcher<QualType
> const &InnerMatcher) { return ::clang::ast_matchers::
internal::PolymorphicMatcher< internal::matcher_hasType0Matcher
, void(::clang::ast_matchers::internal::TypeList<Expr, FriendDecl
, TypedefNameDecl, ValueDecl, CXXBaseSpecifier>), internal
::Matcher<QualType> >(InnerMatcher); } typedef ::clang
::ast_matchers::internal::PolymorphicMatcher< internal::matcher_hasType0Matcher
, void(::clang::ast_matchers::internal::TypeList<Expr, FriendDecl
, TypedefNameDecl, ValueDecl, CXXBaseSpecifier>), internal
::Matcher<QualType> > (&hasType_Type0)(internal::
Matcher<QualType> const &InnerMatcher); template <
typename NodeType, typename ParamT> bool internal:: matcher_hasType0Matcher
<NodeType, ParamT>::matches( const NodeType &Node, ::
clang::ast_matchers::internal::ASTMatchFinder *Finder, ::clang
::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
3907 hasType,namespace internal { template <typename NodeType, typename
ParamT> class matcher_hasType0Matcher : public ::clang::ast_matchers
::internal::MatcherInterface<NodeType> { public: explicit
matcher_hasType0Matcher( internal::Matcher<QualType> const
&AInnerMatcher) : InnerMatcher(AInnerMatcher) {} bool matches
(const NodeType &Node, ::clang::ast_matchers::internal::ASTMatchFinder
*Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: internal::Matcher<QualType
> InnerMatcher; }; } inline ::clang::ast_matchers::internal
::PolymorphicMatcher< internal::matcher_hasType0Matcher, void
(::clang::ast_matchers::internal::TypeList<Expr, FriendDecl
, TypedefNameDecl, ValueDecl, CXXBaseSpecifier>), internal
::Matcher<QualType> > hasType(internal::Matcher<QualType
> const &InnerMatcher) { return ::clang::ast_matchers::
internal::PolymorphicMatcher< internal::matcher_hasType0Matcher
, void(::clang::ast_matchers::internal::TypeList<Expr, FriendDecl
, TypedefNameDecl, ValueDecl, CXXBaseSpecifier>), internal
::Matcher<QualType> >(InnerMatcher); } typedef ::clang
::ast_matchers::internal::PolymorphicMatcher< internal::matcher_hasType0Matcher
, void(::clang::ast_matchers::internal::TypeList<Expr, FriendDecl
, TypedefNameDecl, ValueDecl, CXXBaseSpecifier>), internal
::Matcher<QualType> > (&hasType_Type0)(internal::
Matcher<QualType> const &InnerMatcher); template <
typename NodeType, typename ParamT> bool internal:: matcher_hasType0Matcher
<NodeType, ParamT>::matches( const NodeType &Node, ::
clang::ast_matchers::internal::ASTMatchFinder *Finder, ::clang
::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
3908 AST_POLYMORPHIC_SUPPORTED_TYPES(Expr, FriendDecl, TypedefNameDecl,namespace internal { template <typename NodeType, typename
ParamT> class matcher_hasType0Matcher : public ::clang::ast_matchers
::internal::MatcherInterface<NodeType> { public: explicit
matcher_hasType0Matcher( internal::Matcher<QualType> const
&AInnerMatcher) : InnerMatcher(AInnerMatcher) {} bool matches
(const NodeType &Node, ::clang::ast_matchers::internal::ASTMatchFinder
*Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: internal::Matcher<QualType
> InnerMatcher; }; } inline ::clang::ast_matchers::internal
::PolymorphicMatcher< internal::matcher_hasType0Matcher, void
(::clang::ast_matchers::internal::TypeList<Expr, FriendDecl
, TypedefNameDecl, ValueDecl, CXXBaseSpecifier>), internal
::Matcher<QualType> > hasType(internal::Matcher<QualType
> const &InnerMatcher) { return ::clang::ast_matchers::
internal::PolymorphicMatcher< internal::matcher_hasType0Matcher
, void(::clang::ast_matchers::internal::TypeList<Expr, FriendDecl
, TypedefNameDecl, ValueDecl, CXXBaseSpecifier>), internal
::Matcher<QualType> >(InnerMatcher); } typedef ::clang
::ast_matchers::internal::PolymorphicMatcher< internal::matcher_hasType0Matcher
, void(::clang::ast_matchers::internal::TypeList<Expr, FriendDecl
, TypedefNameDecl, ValueDecl, CXXBaseSpecifier>), internal
::Matcher<QualType> > (&hasType_Type0)(internal::
Matcher<QualType> const &InnerMatcher); template <
typename NodeType, typename ParamT> bool internal:: matcher_hasType0Matcher
<NodeType, ParamT>::matches( const NodeType &Node, ::
clang::ast_matchers::internal::ASTMatchFinder *Finder, ::clang
::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
3909 ValueDecl, CXXBaseSpecifier),namespace internal { template <typename NodeType, typename
ParamT> class matcher_hasType0Matcher : public ::clang::ast_matchers
::internal::MatcherInterface<NodeType> { public: explicit
matcher_hasType0Matcher( internal::Matcher<QualType> const
&AInnerMatcher) : InnerMatcher(AInnerMatcher) {} bool matches
(const NodeType &Node, ::clang::ast_matchers::internal::ASTMatchFinder
*Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: internal::Matcher<QualType
> InnerMatcher; }; } inline ::clang::ast_matchers::internal
::PolymorphicMatcher< internal::matcher_hasType0Matcher, void
(::clang::ast_matchers::internal::TypeList<Expr, FriendDecl
, TypedefNameDecl, ValueDecl, CXXBaseSpecifier>), internal
::Matcher<QualType> > hasType(internal::Matcher<QualType
> const &InnerMatcher) { return ::clang::ast_matchers::
internal::PolymorphicMatcher< internal::matcher_hasType0Matcher
, void(::clang::ast_matchers::internal::TypeList<Expr, FriendDecl
, TypedefNameDecl, ValueDecl, CXXBaseSpecifier>), internal
::Matcher<QualType> >(InnerMatcher); } typedef ::clang
::ast_matchers::internal::PolymorphicMatcher< internal::matcher_hasType0Matcher
, void(::clang::ast_matchers::internal::TypeList<Expr, FriendDecl
, TypedefNameDecl, ValueDecl, CXXBaseSpecifier>), internal
::Matcher<QualType> > (&hasType_Type0)(internal::
Matcher<QualType> const &InnerMatcher); template <
typename NodeType, typename ParamT> bool internal:: matcher_hasType0Matcher
<NodeType, ParamT>::matches( const NodeType &Node, ::
clang::ast_matchers::internal::ASTMatchFinder *Finder, ::clang
::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
3910 internal::Matcher<QualType>, InnerMatcher, 0)namespace internal { template <typename NodeType, typename
ParamT> class matcher_hasType0Matcher : public ::clang::ast_matchers
::internal::MatcherInterface<NodeType> { public: explicit
matcher_hasType0Matcher( internal::Matcher<QualType> const
&AInnerMatcher) : InnerMatcher(AInnerMatcher) {} bool matches
(const NodeType &Node, ::clang::ast_matchers::internal::ASTMatchFinder
*Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: internal::Matcher<QualType
> InnerMatcher; }; } inline ::clang::ast_matchers::internal
::PolymorphicMatcher< internal::matcher_hasType0Matcher, void
(::clang::ast_matchers::internal::TypeList<Expr, FriendDecl
, TypedefNameDecl, ValueDecl, CXXBaseSpecifier>), internal
::Matcher<QualType> > hasType(internal::Matcher<QualType
> const &InnerMatcher) { return ::clang::ast_matchers::
internal::PolymorphicMatcher< internal::matcher_hasType0Matcher
, void(::clang::ast_matchers::internal::TypeList<Expr, FriendDecl
, TypedefNameDecl, ValueDecl, CXXBaseSpecifier>), internal
::Matcher<QualType> >(InnerMatcher); } typedef ::clang
::ast_matchers::internal::PolymorphicMatcher< internal::matcher_hasType0Matcher
, void(::clang::ast_matchers::internal::TypeList<Expr, FriendDecl
, TypedefNameDecl, ValueDecl, CXXBaseSpecifier>), internal
::Matcher<QualType> > (&hasType_Type0)(internal::
Matcher<QualType> const &InnerMatcher); template <
typename NodeType, typename ParamT> bool internal:: matcher_hasType0Matcher
<NodeType, ParamT>::matches( const NodeType &Node, ::
clang::ast_matchers::internal::ASTMatchFinder *Finder, ::clang
::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
{
3911 QualType QT = internal::getUnderlyingType(Node);
3912 if (!QT.isNull())
3913 return InnerMatcher.matches(QT, Finder, Builder);
3914 return false;
3915}
3916
3917/// Overloaded to match the declaration of the expression's or value
3918/// declaration's type.
3919///
3920/// In case of a value declaration (for example a variable declaration),
3921/// this resolves one layer of indirection. For example, in the value
3922/// declaration "X x;", cxxRecordDecl(hasName("X")) matches the declaration of
3923/// X, while varDecl(hasType(cxxRecordDecl(hasName("X")))) matches the
3924/// declaration of x.
3925///
3926/// Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X")))))
3927/// and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X")))))
3928/// and friend class X (matcher = friendDecl(hasType("X"))
3929/// and public virtual X (matcher = cxxBaseSpecifier(hasType(
3930/// cxxRecordDecl(hasName("X"))))
3931/// \code
3932/// class X {};
3933/// void y(X &x) { x; X z; }
3934/// class Y { friend class X; };
3935/// class Z : public virtual X {};
3936/// \endcode
3937///
3938/// Example matches class Derived
3939/// (matcher = cxxRecordDecl(hasAnyBase(hasType(cxxRecordDecl(hasName("Base"))))))
3940/// \code
3941/// class Base {};
3942/// class Derived : Base {};
3943/// \endcode
3944///
3945/// Usable as: Matcher<Expr>, Matcher<FriendDecl>, Matcher<ValueDecl>,
3946/// Matcher<CXXBaseSpecifier>
3947AST_POLYMORPHIC_MATCHER_P_OVERLOAD(namespace internal { template <typename NodeType, typename
ParamT> class matcher_hasType1Matcher : public ::clang::ast_matchers
::internal::MatcherInterface<NodeType> { public: explicit
matcher_hasType1Matcher( internal::Matcher<Decl> const
&AInnerMatcher) : InnerMatcher(AInnerMatcher) {} bool matches
(const NodeType &Node, ::clang::ast_matchers::internal::ASTMatchFinder
*Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: internal::Matcher<Decl
> InnerMatcher; }; } inline ::clang::ast_matchers::internal
::PolymorphicMatcher< internal::matcher_hasType1Matcher, void
(::clang::ast_matchers::internal::TypeList<Expr, FriendDecl
, ValueDecl, CXXBaseSpecifier>), internal::Matcher<Decl
> > hasType(internal::Matcher<Decl> const &InnerMatcher
) { return ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_hasType1Matcher, void(::clang::ast_matchers
::internal::TypeList<Expr, FriendDecl, ValueDecl, CXXBaseSpecifier
>), internal::Matcher<Decl> >(InnerMatcher); } typedef
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_hasType1Matcher, void(::clang::ast_matchers::internal
::TypeList<Expr, FriendDecl, ValueDecl, CXXBaseSpecifier>
), internal::Matcher<Decl> > (&hasType_Type1)(internal
::Matcher<Decl> const &InnerMatcher); template <
typename NodeType, typename ParamT> bool internal:: matcher_hasType1Matcher
<NodeType, ParamT>::matches( const NodeType &Node, ::
clang::ast_matchers::internal::ASTMatchFinder *Finder, ::clang
::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
3948 hasType,namespace internal { template <typename NodeType, typename
ParamT> class matcher_hasType1Matcher : public ::clang::ast_matchers
::internal::MatcherInterface<NodeType> { public: explicit
matcher_hasType1Matcher( internal::Matcher<Decl> const
&AInnerMatcher) : InnerMatcher(AInnerMatcher) {} bool matches
(const NodeType &Node, ::clang::ast_matchers::internal::ASTMatchFinder
*Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: internal::Matcher<Decl
> InnerMatcher; }; } inline ::clang::ast_matchers::internal
::PolymorphicMatcher< internal::matcher_hasType1Matcher, void
(::clang::ast_matchers::internal::TypeList<Expr, FriendDecl
, ValueDecl, CXXBaseSpecifier>), internal::Matcher<Decl
> > hasType(internal::Matcher<Decl> const &InnerMatcher
) { return ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_hasType1Matcher, void(::clang::ast_matchers
::internal::TypeList<Expr, FriendDecl, ValueDecl, CXXBaseSpecifier
>), internal::Matcher<Decl> >(InnerMatcher); } typedef
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_hasType1Matcher, void(::clang::ast_matchers::internal
::TypeList<Expr, FriendDecl, ValueDecl, CXXBaseSpecifier>
), internal::Matcher<Decl> > (&hasType_Type1)(internal
::Matcher<Decl> const &InnerMatcher); template <
typename NodeType, typename ParamT> bool internal:: matcher_hasType1Matcher
<NodeType, ParamT>::matches( const NodeType &Node, ::
clang::ast_matchers::internal::ASTMatchFinder *Finder, ::clang
::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
3949 AST_POLYMORPHIC_SUPPORTED_TYPES(Expr, FriendDecl, ValueDecl,namespace internal { template <typename NodeType, typename
ParamT> class matcher_hasType1Matcher : public ::clang::ast_matchers
::internal::MatcherInterface<NodeType> { public: explicit
matcher_hasType1Matcher( internal::Matcher<Decl> const
&AInnerMatcher) : InnerMatcher(AInnerMatcher) {} bool matches
(const NodeType &Node, ::clang::ast_matchers::internal::ASTMatchFinder
*Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: internal::Matcher<Decl
> InnerMatcher; }; } inline ::clang::ast_matchers::internal
::PolymorphicMatcher< internal::matcher_hasType1Matcher, void
(::clang::ast_matchers::internal::TypeList<Expr, FriendDecl
, ValueDecl, CXXBaseSpecifier>), internal::Matcher<Decl
> > hasType(internal::Matcher<Decl> const &InnerMatcher
) { return ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_hasType1Matcher, void(::clang::ast_matchers
::internal::TypeList<Expr, FriendDecl, ValueDecl, CXXBaseSpecifier
>), internal::Matcher<Decl> >(InnerMatcher); } typedef
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_hasType1Matcher, void(::clang::ast_matchers::internal
::TypeList<Expr, FriendDecl, ValueDecl, CXXBaseSpecifier>
), internal::Matcher<Decl> > (&hasType_Type1)(internal
::Matcher<Decl> const &InnerMatcher); template <
typename NodeType, typename ParamT> bool internal:: matcher_hasType1Matcher
<NodeType, ParamT>::matches( const NodeType &Node, ::
clang::ast_matchers::internal::ASTMatchFinder *Finder, ::clang
::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
3950 CXXBaseSpecifier),namespace internal { template <typename NodeType, typename
ParamT> class matcher_hasType1Matcher : public ::clang::ast_matchers
::internal::MatcherInterface<NodeType> { public: explicit
matcher_hasType1Matcher( internal::Matcher<Decl> const
&AInnerMatcher) : InnerMatcher(AInnerMatcher) {} bool matches
(const NodeType &Node, ::clang::ast_matchers::internal::ASTMatchFinder
*Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: internal::Matcher<Decl
> InnerMatcher; }; } inline ::clang::ast_matchers::internal
::PolymorphicMatcher< internal::matcher_hasType1Matcher, void
(::clang::ast_matchers::internal::TypeList<Expr, FriendDecl
, ValueDecl, CXXBaseSpecifier>), internal::Matcher<Decl
> > hasType(internal::Matcher<Decl> const &InnerMatcher
) { return ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_hasType1Matcher, void(::clang::ast_matchers
::internal::TypeList<Expr, FriendDecl, ValueDecl, CXXBaseSpecifier
>), internal::Matcher<Decl> >(InnerMatcher); } typedef
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_hasType1Matcher, void(::clang::ast_matchers::internal
::TypeList<Expr, FriendDecl, ValueDecl, CXXBaseSpecifier>
), internal::Matcher<Decl> > (&hasType_Type1)(internal
::Matcher<Decl> const &InnerMatcher); template <
typename NodeType, typename ParamT> bool internal:: matcher_hasType1Matcher
<NodeType, ParamT>::matches( const NodeType &Node, ::
clang::ast_matchers::internal::ASTMatchFinder *Finder, ::clang
::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
3951 internal::Matcher<Decl>, InnerMatcher, 1)namespace internal { template <typename NodeType, typename
ParamT> class matcher_hasType1Matcher : public ::clang::ast_matchers
::internal::MatcherInterface<NodeType> { public: explicit
matcher_hasType1Matcher( internal::Matcher<Decl> const
&AInnerMatcher) : InnerMatcher(AInnerMatcher) {} bool matches
(const NodeType &Node, ::clang::ast_matchers::internal::ASTMatchFinder
*Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: internal::Matcher<Decl
> InnerMatcher; }; } inline ::clang::ast_matchers::internal
::PolymorphicMatcher< internal::matcher_hasType1Matcher, void
(::clang::ast_matchers::internal::TypeList<Expr, FriendDecl
, ValueDecl, CXXBaseSpecifier>), internal::Matcher<Decl
> > hasType(internal::Matcher<Decl> const &InnerMatcher
) { return ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_hasType1Matcher, void(::clang::ast_matchers
::internal::TypeList<Expr, FriendDecl, ValueDecl, CXXBaseSpecifier
>), internal::Matcher<Decl> >(InnerMatcher); } typedef
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_hasType1Matcher, void(::clang::ast_matchers::internal
::TypeList<Expr, FriendDecl, ValueDecl, CXXBaseSpecifier>
), internal::Matcher<Decl> > (&hasType_Type1)(internal
::Matcher<Decl> const &InnerMatcher); template <
typename NodeType, typename ParamT> bool internal:: matcher_hasType1Matcher
<NodeType, ParamT>::matches( const NodeType &Node, ::
clang::ast_matchers::internal::ASTMatchFinder *Finder, ::clang
::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
{
3952 QualType QT = internal::getUnderlyingType(Node);
3953 if (!QT.isNull())
3954 return qualType(hasDeclaration(InnerMatcher)).matches(QT, Finder, Builder);
3955 return false;
3956}
3957
3958/// Matches if the type location of a node matches the inner matcher.
3959///
3960/// Examples:
3961/// \code
3962/// int x;
3963/// \endcode
3964/// declaratorDecl(hasTypeLoc(loc(asString("int"))))
3965/// matches int x
3966///
3967/// \code
3968/// auto x = int(3);
3969/// \endcode
3970/// cxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int"))))
3971/// matches int(3)
3972///
3973/// \code
3974/// struct Foo { Foo(int, int); };
3975/// auto x = Foo(1, 2);
3976/// \endcode
3977/// cxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo"))))
3978/// matches Foo(1, 2)
3979///
3980/// Usable as: Matcher<BlockDecl>, Matcher<CXXBaseSpecifier>,
3981/// Matcher<CXXCtorInitializer>, Matcher<CXXFunctionalCastExpr>,
3982/// Matcher<CXXNewExpr>, Matcher<CXXTemporaryObjectExpr>,
3983/// Matcher<CXXUnresolvedConstructExpr>,
3984/// Matcher<ClassTemplateSpecializationDecl>, Matcher<CompoundLiteralExpr>,
3985/// Matcher<DeclaratorDecl>, Matcher<ExplicitCastExpr>,
3986/// Matcher<ObjCPropertyDecl>, Matcher<TemplateArgumentLoc>,
3987/// Matcher<TypedefNameDecl>
3988AST_POLYMORPHIC_MATCHER_P(namespace internal { template <typename NodeType, typename
ParamT> class matcher_hasTypeLoc0Matcher : public ::clang
::ast_matchers::internal::MatcherInterface<NodeType> { public
: explicit matcher_hasTypeLoc0Matcher( internal::Matcher<TypeLoc
> const &AInner) : Inner(AInner) {} bool matches(const
NodeType &Node, ::clang::ast_matchers::internal::ASTMatchFinder
*Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: internal::Matcher<TypeLoc
> Inner; }; } inline ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_hasTypeLoc0Matcher, void(::clang::ast_matchers
::internal::TypeList<BlockDecl, CXXBaseSpecifier, CXXCtorInitializer
, CXXFunctionalCastExpr, CXXNewExpr, CXXTemporaryObjectExpr, CXXUnresolvedConstructExpr
, ClassTemplateSpecializationDecl, CompoundLiteralExpr, DeclaratorDecl
, ExplicitCastExpr, ObjCPropertyDecl, TemplateArgumentLoc, TypedefNameDecl
>), internal::Matcher<TypeLoc> > hasTypeLoc(internal
::Matcher<TypeLoc> const &Inner) { return ::clang::
ast_matchers::internal::PolymorphicMatcher< internal::matcher_hasTypeLoc0Matcher
, void(::clang::ast_matchers::internal::TypeList<BlockDecl
, CXXBaseSpecifier, CXXCtorInitializer, CXXFunctionalCastExpr
, CXXNewExpr, CXXTemporaryObjectExpr, CXXUnresolvedConstructExpr
, ClassTemplateSpecializationDecl, CompoundLiteralExpr, DeclaratorDecl
, ExplicitCastExpr, ObjCPropertyDecl, TemplateArgumentLoc, TypedefNameDecl
>), internal::Matcher<TypeLoc> >(Inner); } typedef
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_hasTypeLoc0Matcher, void(::clang::ast_matchers::internal
::TypeList<BlockDecl, CXXBaseSpecifier, CXXCtorInitializer
, CXXFunctionalCastExpr, CXXNewExpr, CXXTemporaryObjectExpr, CXXUnresolvedConstructExpr
, ClassTemplateSpecializationDecl, CompoundLiteralExpr, DeclaratorDecl
, ExplicitCastExpr, ObjCPropertyDecl, TemplateArgumentLoc, TypedefNameDecl
>), internal::Matcher<TypeLoc> > (&hasTypeLoc_Type0
)(internal::Matcher<TypeLoc> const &Inner); template
<typename NodeType, typename ParamT> bool internal:: matcher_hasTypeLoc0Matcher
<NodeType, ParamT>::matches( const NodeType &Node, ::
clang::ast_matchers::internal::ASTMatchFinder *Finder, ::clang
::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
3989 hasTypeLoc,namespace internal { template <typename NodeType, typename
ParamT> class matcher_hasTypeLoc0Matcher : public ::clang
::ast_matchers::internal::MatcherInterface<NodeType> { public
: explicit matcher_hasTypeLoc0Matcher( internal::Matcher<TypeLoc
> const &AInner) : Inner(AInner) {} bool matches(const
NodeType &Node, ::clang::ast_matchers::internal::ASTMatchFinder
*Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: internal::Matcher<TypeLoc
> Inner; }; } inline ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_hasTypeLoc0Matcher, void(::clang::ast_matchers
::internal::TypeList<BlockDecl, CXXBaseSpecifier, CXXCtorInitializer
, CXXFunctionalCastExpr, CXXNewExpr, CXXTemporaryObjectExpr, CXXUnresolvedConstructExpr
, ClassTemplateSpecializationDecl, CompoundLiteralExpr, DeclaratorDecl
, ExplicitCastExpr, ObjCPropertyDecl, TemplateArgumentLoc, TypedefNameDecl
>), internal::Matcher<TypeLoc> > hasTypeLoc(internal
::Matcher<TypeLoc> const &Inner) { return ::clang::
ast_matchers::internal::PolymorphicMatcher< internal::matcher_hasTypeLoc0Matcher
, void(::clang::ast_matchers::internal::TypeList<BlockDecl
, CXXBaseSpecifier, CXXCtorInitializer, CXXFunctionalCastExpr
, CXXNewExpr, CXXTemporaryObjectExpr, CXXUnresolvedConstructExpr
, ClassTemplateSpecializationDecl, CompoundLiteralExpr, DeclaratorDecl
, ExplicitCastExpr, ObjCPropertyDecl, TemplateArgumentLoc, TypedefNameDecl
>), internal::Matcher<TypeLoc> >(Inner); } typedef
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_hasTypeLoc0Matcher, void(::clang::ast_matchers::internal
::TypeList<BlockDecl, CXXBaseSpecifier, CXXCtorInitializer
, CXXFunctionalCastExpr, CXXNewExpr, CXXTemporaryObjectExpr, CXXUnresolvedConstructExpr
, ClassTemplateSpecializationDecl, CompoundLiteralExpr, DeclaratorDecl
, ExplicitCastExpr, ObjCPropertyDecl, TemplateArgumentLoc, TypedefNameDecl
>), internal::Matcher<TypeLoc> > (&hasTypeLoc_Type0
)(internal::Matcher<TypeLoc> const &Inner); template
<typename NodeType, typename ParamT> bool internal:: matcher_hasTypeLoc0Matcher
<NodeType, ParamT>::matches( const NodeType &Node, ::
clang::ast_matchers::internal::ASTMatchFinder *Finder, ::clang
::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
3990 AST_POLYMORPHIC_SUPPORTED_TYPES(namespace internal { template <typename NodeType, typename
ParamT> class matcher_hasTypeLoc0Matcher : public ::clang
::ast_matchers::internal::MatcherInterface<NodeType> { public
: explicit matcher_hasTypeLoc0Matcher( internal::Matcher<TypeLoc
> const &AInner) : Inner(AInner) {} bool matches(const
NodeType &Node, ::clang::ast_matchers::internal::ASTMatchFinder
*Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: internal::Matcher<TypeLoc
> Inner; }; } inline ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_hasTypeLoc0Matcher, void(::clang::ast_matchers
::internal::TypeList<BlockDecl, CXXBaseSpecifier, CXXCtorInitializer
, CXXFunctionalCastExpr, CXXNewExpr, CXXTemporaryObjectExpr, CXXUnresolvedConstructExpr
, ClassTemplateSpecializationDecl, CompoundLiteralExpr, DeclaratorDecl
, ExplicitCastExpr, ObjCPropertyDecl, TemplateArgumentLoc, TypedefNameDecl
>), internal::Matcher<TypeLoc> > hasTypeLoc(internal
::Matcher<TypeLoc> const &Inner) { return ::clang::
ast_matchers::internal::PolymorphicMatcher< internal::matcher_hasTypeLoc0Matcher
, void(::clang::ast_matchers::internal::TypeList<BlockDecl
, CXXBaseSpecifier, CXXCtorInitializer, CXXFunctionalCastExpr
, CXXNewExpr, CXXTemporaryObjectExpr, CXXUnresolvedConstructExpr
, ClassTemplateSpecializationDecl, CompoundLiteralExpr, DeclaratorDecl
, ExplicitCastExpr, ObjCPropertyDecl, TemplateArgumentLoc, TypedefNameDecl
>), internal::Matcher<TypeLoc> >(Inner); } typedef
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_hasTypeLoc0Matcher, void(::clang::ast_matchers::internal
::TypeList<BlockDecl, CXXBaseSpecifier, CXXCtorInitializer
, CXXFunctionalCastExpr, CXXNewExpr, CXXTemporaryObjectExpr, CXXUnresolvedConstructExpr
, ClassTemplateSpecializationDecl, CompoundLiteralExpr, DeclaratorDecl
, ExplicitCastExpr, ObjCPropertyDecl, TemplateArgumentLoc, TypedefNameDecl
>), internal::Matcher<TypeLoc> > (&hasTypeLoc_Type0
)(internal::Matcher<TypeLoc> const &Inner); template
<typename NodeType, typename ParamT> bool internal:: matcher_hasTypeLoc0Matcher
<NodeType, ParamT>::matches( const NodeType &Node, ::
clang::ast_matchers::internal::ASTMatchFinder *Finder, ::clang
::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
3991 BlockDecl, CXXBaseSpecifier, CXXCtorInitializer, CXXFunctionalCastExpr,namespace internal { template <typename NodeType, typename
ParamT> class matcher_hasTypeLoc0Matcher : public ::clang
::ast_matchers::internal::MatcherInterface<NodeType> { public
: explicit matcher_hasTypeLoc0Matcher( internal::Matcher<TypeLoc
> const &AInner) : Inner(AInner) {} bool matches(const
NodeType &Node, ::clang::ast_matchers::internal::ASTMatchFinder
*Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: internal::Matcher<TypeLoc
> Inner; }; } inline ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_hasTypeLoc0Matcher, void(::clang::ast_matchers
::internal::TypeList<BlockDecl, CXXBaseSpecifier, CXXCtorInitializer
, CXXFunctionalCastExpr, CXXNewExpr, CXXTemporaryObjectExpr, CXXUnresolvedConstructExpr
, ClassTemplateSpecializationDecl, CompoundLiteralExpr, DeclaratorDecl
, ExplicitCastExpr, ObjCPropertyDecl, TemplateArgumentLoc, TypedefNameDecl
>), internal::Matcher<TypeLoc> > hasTypeLoc(internal
::Matcher<TypeLoc> const &Inner) { return ::clang::
ast_matchers::internal::PolymorphicMatcher< internal::matcher_hasTypeLoc0Matcher
, void(::clang::ast_matchers::internal::TypeList<BlockDecl
, CXXBaseSpecifier, CXXCtorInitializer, CXXFunctionalCastExpr
, CXXNewExpr, CXXTemporaryObjectExpr, CXXUnresolvedConstructExpr
, ClassTemplateSpecializationDecl, CompoundLiteralExpr, DeclaratorDecl
, ExplicitCastExpr, ObjCPropertyDecl, TemplateArgumentLoc, TypedefNameDecl
>), internal::Matcher<TypeLoc> >(Inner); } typedef
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_hasTypeLoc0Matcher, void(::clang::ast_matchers::internal
::TypeList<BlockDecl, CXXBaseSpecifier, CXXCtorInitializer
, CXXFunctionalCastExpr, CXXNewExpr, CXXTemporaryObjectExpr, CXXUnresolvedConstructExpr
, ClassTemplateSpecializationDecl, CompoundLiteralExpr, DeclaratorDecl
, ExplicitCastExpr, ObjCPropertyDecl, TemplateArgumentLoc, TypedefNameDecl
>), internal::Matcher<TypeLoc> > (&hasTypeLoc_Type0
)(internal::Matcher<TypeLoc> const &Inner); template
<typename NodeType, typename ParamT> bool internal:: matcher_hasTypeLoc0Matcher
<NodeType, ParamT>::matches( const NodeType &Node, ::
clang::ast_matchers::internal::ASTMatchFinder *Finder, ::clang
::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
3992 CXXNewExpr, CXXTemporaryObjectExpr, CXXUnresolvedConstructExpr,namespace internal { template <typename NodeType, typename
ParamT> class matcher_hasTypeLoc0Matcher : public ::clang
::ast_matchers::internal::MatcherInterface<NodeType> { public
: explicit matcher_hasTypeLoc0Matcher( internal::Matcher<TypeLoc
> const &AInner) : Inner(AInner) {} bool matches(const
NodeType &Node, ::clang::ast_matchers::internal::ASTMatchFinder
*Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: internal::Matcher<TypeLoc
> Inner; }; } inline ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_hasTypeLoc0Matcher, void(::clang::ast_matchers
::internal::TypeList<BlockDecl, CXXBaseSpecifier, CXXCtorInitializer
, CXXFunctionalCastExpr, CXXNewExpr, CXXTemporaryObjectExpr, CXXUnresolvedConstructExpr
, ClassTemplateSpecializationDecl, CompoundLiteralExpr, DeclaratorDecl
, ExplicitCastExpr, ObjCPropertyDecl, TemplateArgumentLoc, TypedefNameDecl
>), internal::Matcher<TypeLoc> > hasTypeLoc(internal
::Matcher<TypeLoc> const &Inner) { return ::clang::
ast_matchers::internal::PolymorphicMatcher< internal::matcher_hasTypeLoc0Matcher
, void(::clang::ast_matchers::internal::TypeList<BlockDecl
, CXXBaseSpecifier, CXXCtorInitializer, CXXFunctionalCastExpr
, CXXNewExpr, CXXTemporaryObjectExpr, CXXUnresolvedConstructExpr
, ClassTemplateSpecializationDecl, CompoundLiteralExpr, DeclaratorDecl
, ExplicitCastExpr, ObjCPropertyDecl, TemplateArgumentLoc, TypedefNameDecl
>), internal::Matcher<TypeLoc> >(Inner); } typedef
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_hasTypeLoc0Matcher, void(::clang::ast_matchers::internal
::TypeList<BlockDecl, CXXBaseSpecifier, CXXCtorInitializer
, CXXFunctionalCastExpr, CXXNewExpr, CXXTemporaryObjectExpr, CXXUnresolvedConstructExpr
, ClassTemplateSpecializationDecl, CompoundLiteralExpr, DeclaratorDecl
, ExplicitCastExpr, ObjCPropertyDecl, TemplateArgumentLoc, TypedefNameDecl
>), internal::Matcher<TypeLoc> > (&hasTypeLoc_Type0
)(internal::Matcher<TypeLoc> const &Inner); template
<typename NodeType, typename ParamT> bool internal:: matcher_hasTypeLoc0Matcher
<NodeType, ParamT>::matches( const NodeType &Node, ::
clang::ast_matchers::internal::ASTMatchFinder *Finder, ::clang
::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
3993 ClassTemplateSpecializationDecl, CompoundLiteralExpr, DeclaratorDecl,namespace internal { template <typename NodeType, typename
ParamT> class matcher_hasTypeLoc0Matcher : public ::clang
::ast_matchers::internal::MatcherInterface<NodeType> { public
: explicit matcher_hasTypeLoc0Matcher( internal::Matcher<TypeLoc
> const &AInner) : Inner(AInner) {} bool matches(const
NodeType &Node, ::clang::ast_matchers::internal::ASTMatchFinder
*Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: internal::Matcher<TypeLoc
> Inner; }; } inline ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_hasTypeLoc0Matcher, void(::clang::ast_matchers
::internal::TypeList<BlockDecl, CXXBaseSpecifier, CXXCtorInitializer
, CXXFunctionalCastExpr, CXXNewExpr, CXXTemporaryObjectExpr, CXXUnresolvedConstructExpr
, ClassTemplateSpecializationDecl, CompoundLiteralExpr, DeclaratorDecl
, ExplicitCastExpr, ObjCPropertyDecl, TemplateArgumentLoc, TypedefNameDecl
>), internal::Matcher<TypeLoc> > hasTypeLoc(internal
::Matcher<TypeLoc> const &Inner) { return ::clang::
ast_matchers::internal::PolymorphicMatcher< internal::matcher_hasTypeLoc0Matcher
, void(::clang::ast_matchers::internal::TypeList<BlockDecl
, CXXBaseSpecifier, CXXCtorInitializer, CXXFunctionalCastExpr
, CXXNewExpr, CXXTemporaryObjectExpr, CXXUnresolvedConstructExpr
, ClassTemplateSpecializationDecl, CompoundLiteralExpr, DeclaratorDecl
, ExplicitCastExpr, ObjCPropertyDecl, TemplateArgumentLoc, TypedefNameDecl
>), internal::Matcher<TypeLoc> >(Inner); } typedef
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_hasTypeLoc0Matcher, void(::clang::ast_matchers::internal
::TypeList<BlockDecl, CXXBaseSpecifier, CXXCtorInitializer
, CXXFunctionalCastExpr, CXXNewExpr, CXXTemporaryObjectExpr, CXXUnresolvedConstructExpr
, ClassTemplateSpecializationDecl, CompoundLiteralExpr, DeclaratorDecl
, ExplicitCastExpr, ObjCPropertyDecl, TemplateArgumentLoc, TypedefNameDecl
>), internal::Matcher<TypeLoc> > (&hasTypeLoc_Type0
)(internal::Matcher<TypeLoc> const &Inner); template
<typename NodeType, typename ParamT> bool internal:: matcher_hasTypeLoc0Matcher
<NodeType, ParamT>::matches( const NodeType &Node, ::
clang::ast_matchers::internal::ASTMatchFinder *Finder, ::clang
::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
3994 ExplicitCastExpr, ObjCPropertyDecl, TemplateArgumentLoc,namespace internal { template <typename NodeType, typename
ParamT> class matcher_hasTypeLoc0Matcher : public ::clang
::ast_matchers::internal::MatcherInterface<NodeType> { public
: explicit matcher_hasTypeLoc0Matcher( internal::Matcher<TypeLoc
> const &AInner) : Inner(AInner) {} bool matches(const
NodeType &Node, ::clang::ast_matchers::internal::ASTMatchFinder
*Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: internal::Matcher<TypeLoc
> Inner; }; } inline ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_hasTypeLoc0Matcher, void(::clang::ast_matchers
::internal::TypeList<BlockDecl, CXXBaseSpecifier, CXXCtorInitializer
, CXXFunctionalCastExpr, CXXNewExpr, CXXTemporaryObjectExpr, CXXUnresolvedConstructExpr
, ClassTemplateSpecializationDecl, CompoundLiteralExpr, DeclaratorDecl
, ExplicitCastExpr, ObjCPropertyDecl, TemplateArgumentLoc, TypedefNameDecl
>), internal::Matcher<TypeLoc> > hasTypeLoc(internal
::Matcher<TypeLoc> const &Inner) { return ::clang::
ast_matchers::internal::PolymorphicMatcher< internal::matcher_hasTypeLoc0Matcher
, void(::clang::ast_matchers::internal::TypeList<BlockDecl
, CXXBaseSpecifier, CXXCtorInitializer, CXXFunctionalCastExpr
, CXXNewExpr, CXXTemporaryObjectExpr, CXXUnresolvedConstructExpr
, ClassTemplateSpecializationDecl, CompoundLiteralExpr, DeclaratorDecl
, ExplicitCastExpr, ObjCPropertyDecl, TemplateArgumentLoc, TypedefNameDecl
>), internal::Matcher<TypeLoc> >(Inner); } typedef
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_hasTypeLoc0Matcher, void(::clang::ast_matchers::internal
::TypeList<BlockDecl, CXXBaseSpecifier, CXXCtorInitializer
, CXXFunctionalCastExpr, CXXNewExpr, CXXTemporaryObjectExpr, CXXUnresolvedConstructExpr
, ClassTemplateSpecializationDecl, CompoundLiteralExpr, DeclaratorDecl
, ExplicitCastExpr, ObjCPropertyDecl, TemplateArgumentLoc, TypedefNameDecl
>), internal::Matcher<TypeLoc> > (&hasTypeLoc_Type0
)(internal::Matcher<TypeLoc> const &Inner); template
<typename NodeType, typename ParamT> bool internal:: matcher_hasTypeLoc0Matcher
<NodeType, ParamT>::matches( const NodeType &Node, ::
clang::ast_matchers::internal::ASTMatchFinder *Finder, ::clang
::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
3995 TypedefNameDecl),namespace internal { template <typename NodeType, typename
ParamT> class matcher_hasTypeLoc0Matcher : public ::clang
::ast_matchers::internal::MatcherInterface<NodeType> { public
: explicit matcher_hasTypeLoc0Matcher( internal::Matcher<TypeLoc
> const &AInner) : Inner(AInner) {} bool matches(const
NodeType &Node, ::clang::ast_matchers::internal::ASTMatchFinder
*Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: internal::Matcher<TypeLoc
> Inner; }; } inline ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_hasTypeLoc0Matcher, void(::clang::ast_matchers
::internal::TypeList<BlockDecl, CXXBaseSpecifier, CXXCtorInitializer
, CXXFunctionalCastExpr, CXXNewExpr, CXXTemporaryObjectExpr, CXXUnresolvedConstructExpr
, ClassTemplateSpecializationDecl, CompoundLiteralExpr, DeclaratorDecl
, ExplicitCastExpr, ObjCPropertyDecl, TemplateArgumentLoc, TypedefNameDecl
>), internal::Matcher<TypeLoc> > hasTypeLoc(internal
::Matcher<TypeLoc> const &Inner) { return ::clang::
ast_matchers::internal::PolymorphicMatcher< internal::matcher_hasTypeLoc0Matcher
, void(::clang::ast_matchers::internal::TypeList<BlockDecl
, CXXBaseSpecifier, CXXCtorInitializer, CXXFunctionalCastExpr
, CXXNewExpr, CXXTemporaryObjectExpr, CXXUnresolvedConstructExpr
, ClassTemplateSpecializationDecl, CompoundLiteralExpr, DeclaratorDecl
, ExplicitCastExpr, ObjCPropertyDecl, TemplateArgumentLoc, TypedefNameDecl
>), internal::Matcher<TypeLoc> >(Inner); } typedef
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_hasTypeLoc0Matcher, void(::clang::ast_matchers::internal
::TypeList<BlockDecl, CXXBaseSpecifier, CXXCtorInitializer
, CXXFunctionalCastExpr, CXXNewExpr, CXXTemporaryObjectExpr, CXXUnresolvedConstructExpr
, ClassTemplateSpecializationDecl, CompoundLiteralExpr, DeclaratorDecl
, ExplicitCastExpr, ObjCPropertyDecl, TemplateArgumentLoc, TypedefNameDecl
>), internal::Matcher<TypeLoc> > (&hasTypeLoc_Type0
)(internal::Matcher<TypeLoc> const &Inner); template
<typename NodeType, typename ParamT> bool internal:: matcher_hasTypeLoc0Matcher
<NodeType, ParamT>::matches( const NodeType &Node, ::
clang::ast_matchers::internal::ASTMatchFinder *Finder, ::clang
::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
3996 internal::Matcher<TypeLoc>, Inner)namespace internal { template <typename NodeType, typename
ParamT> class matcher_hasTypeLoc0Matcher : public ::clang
::ast_matchers::internal::MatcherInterface<NodeType> { public
: explicit matcher_hasTypeLoc0Matcher( internal::Matcher<TypeLoc
> const &AInner) : Inner(AInner) {} bool matches(const
NodeType &Node, ::clang::ast_matchers::internal::ASTMatchFinder
*Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: internal::Matcher<TypeLoc
> Inner; }; } inline ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_hasTypeLoc0Matcher, void(::clang::ast_matchers
::internal::TypeList<BlockDecl, CXXBaseSpecifier, CXXCtorInitializer
, CXXFunctionalCastExpr, CXXNewExpr, CXXTemporaryObjectExpr, CXXUnresolvedConstructExpr
, ClassTemplateSpecializationDecl, CompoundLiteralExpr, DeclaratorDecl
, ExplicitCastExpr, ObjCPropertyDecl, TemplateArgumentLoc, TypedefNameDecl
>), internal::Matcher<TypeLoc> > hasTypeLoc(internal
::Matcher<TypeLoc> const &Inner) { return ::clang::
ast_matchers::internal::PolymorphicMatcher< internal::matcher_hasTypeLoc0Matcher
, void(::clang::ast_matchers::internal::TypeList<BlockDecl
, CXXBaseSpecifier, CXXCtorInitializer, CXXFunctionalCastExpr
, CXXNewExpr, CXXTemporaryObjectExpr, CXXUnresolvedConstructExpr
, ClassTemplateSpecializationDecl, CompoundLiteralExpr, DeclaratorDecl
, ExplicitCastExpr, ObjCPropertyDecl, TemplateArgumentLoc, TypedefNameDecl
>), internal::Matcher<TypeLoc> >(Inner); } typedef
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_hasTypeLoc0Matcher, void(::clang::ast_matchers::internal
::TypeList<BlockDecl, CXXBaseSpecifier, CXXCtorInitializer
, CXXFunctionalCastExpr, CXXNewExpr, CXXTemporaryObjectExpr, CXXUnresolvedConstructExpr
, ClassTemplateSpecializationDecl, CompoundLiteralExpr, DeclaratorDecl
, ExplicitCastExpr, ObjCPropertyDecl, TemplateArgumentLoc, TypedefNameDecl
>), internal::Matcher<TypeLoc> > (&hasTypeLoc_Type0
)(internal::Matcher<TypeLoc> const &Inner); template
<typename NodeType, typename ParamT> bool internal:: matcher_hasTypeLoc0Matcher
<NodeType, ParamT>::matches( const NodeType &Node, ::
clang::ast_matchers::internal::ASTMatchFinder *Finder, ::clang
::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
{
3997 TypeSourceInfo *source = internal::GetTypeSourceInfo(Node);
3998 if (source == nullptr) {
3999 // This happens for example for implicit destructors.
4000 return false;
4001 }
4002 return Inner.matches(source->getTypeLoc(), Finder, Builder);
4003}
4004
4005/// Matches if the matched type is represented by the given string.
4006///
4007/// Given
4008/// \code
4009/// class Y { public: void x(); };
4010/// void z() { Y* y; y->x(); }
4011/// \endcode
4012/// cxxMemberCallExpr(on(hasType(asString("class Y *"))))
4013/// matches y->x()
4014AST_MATCHER_P(QualType, asString, std::string, Name)namespace internal { class matcher_asString0Matcher : public ::
clang::ast_matchers::internal::MatcherInterface<QualType>
{ public: explicit matcher_asString0Matcher( std::string const
&AName) : Name(AName) {} bool matches(const QualType &
Node, ::clang::ast_matchers::internal::ASTMatchFinder *Finder
, ::clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder
) const override; private: std::string Name; }; } inline ::clang
::ast_matchers::internal::Matcher<QualType> asString( std
::string const &Name) { return ::clang::ast_matchers::internal
::makeMatcher( new internal::matcher_asString0Matcher(Name));
} typedef ::clang::ast_matchers::internal::Matcher<QualType
> ( &asString_Type0)(std::string const &Name); inline
bool internal::matcher_asString0Matcher::matches( const QualType
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
4015 return Name == Node.getAsString();
4016}
4017
4018/// Matches if the matched type is a pointer type and the pointee type
4019/// matches the specified matcher.
4020///
4021/// Example matches y->x()
4022/// (matcher = cxxMemberCallExpr(on(hasType(pointsTo
4023/// cxxRecordDecl(hasName("Y")))))))
4024/// \code
4025/// class Y { public: void x(); };
4026/// void z() { Y *y; y->x(); }
4027/// \endcode
4028AST_MATCHER_P(namespace internal { class matcher_pointsTo0Matcher : public ::
clang::ast_matchers::internal::MatcherInterface<QualType>
{ public: explicit matcher_pointsTo0Matcher( internal::Matcher
<QualType> const &AInnerMatcher) : InnerMatcher(AInnerMatcher
) {} bool matches(const QualType &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const override; private: internal
::Matcher<QualType> InnerMatcher; }; } inline ::clang::
ast_matchers::internal::Matcher<QualType> pointsTo( internal
::Matcher<QualType> const &InnerMatcher) { return ::
clang::ast_matchers::internal::makeMatcher( new internal::matcher_pointsTo0Matcher
(InnerMatcher)); } typedef ::clang::ast_matchers::internal::Matcher
<QualType> ( &pointsTo_Type0)(internal::Matcher<
QualType> const &InnerMatcher); inline bool internal::
matcher_pointsTo0Matcher::matches( const QualType &Node, ::
clang::ast_matchers::internal::ASTMatchFinder *Finder, ::clang
::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
4029 QualType, pointsTo, internal::Matcher<QualType>,namespace internal { class matcher_pointsTo0Matcher : public ::
clang::ast_matchers::internal::MatcherInterface<QualType>
{ public: explicit matcher_pointsTo0Matcher( internal::Matcher
<QualType> const &AInnerMatcher) : InnerMatcher(AInnerMatcher
) {} bool matches(const QualType &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const override; private: internal
::Matcher<QualType> InnerMatcher; }; } inline ::clang::
ast_matchers::internal::Matcher<QualType> pointsTo( internal
::Matcher<QualType> const &InnerMatcher) { return ::
clang::ast_matchers::internal::makeMatcher( new internal::matcher_pointsTo0Matcher
(InnerMatcher)); } typedef ::clang::ast_matchers::internal::Matcher
<QualType> ( &pointsTo_Type0)(internal::Matcher<
QualType> const &InnerMatcher); inline bool internal::
matcher_pointsTo0Matcher::matches( const QualType &Node, ::
clang::ast_matchers::internal::ASTMatchFinder *Finder, ::clang
::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
4030 InnerMatcher)namespace internal { class matcher_pointsTo0Matcher : public ::
clang::ast_matchers::internal::MatcherInterface<QualType>
{ public: explicit matcher_pointsTo0Matcher( internal::Matcher
<QualType> const &AInnerMatcher) : InnerMatcher(AInnerMatcher
) {} bool matches(const QualType &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const override; private: internal
::Matcher<QualType> InnerMatcher; }; } inline ::clang::
ast_matchers::internal::Matcher<QualType> pointsTo( internal
::Matcher<QualType> const &InnerMatcher) { return ::
clang::ast_matchers::internal::makeMatcher( new internal::matcher_pointsTo0Matcher
(InnerMatcher)); } typedef ::clang::ast_matchers::internal::Matcher
<QualType> ( &pointsTo_Type0)(internal::Matcher<
QualType> const &InnerMatcher); inline bool internal::
matcher_pointsTo0Matcher::matches( const QualType &Node, ::
clang::ast_matchers::internal::ASTMatchFinder *Finder, ::clang
::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
{
4031 return (!Node.isNull() && Node->isAnyPointerType() &&
4032 InnerMatcher.matches(Node->getPointeeType(), Finder, Builder));
4033}
4034
4035/// Overloaded to match the pointee type's declaration.
4036AST_MATCHER_P_OVERLOAD(QualType, pointsTo, internal::Matcher<Decl>,namespace internal { class matcher_pointsTo1Matcher : public ::
clang::ast_matchers::internal::MatcherInterface<QualType>
{ public: explicit matcher_pointsTo1Matcher( internal::Matcher
<Decl> const &AInnerMatcher) : InnerMatcher(AInnerMatcher
) {} bool matches(const QualType &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const override; private: internal
::Matcher<Decl> InnerMatcher; }; } inline ::clang::ast_matchers
::internal::Matcher<QualType> pointsTo( internal::Matcher
<Decl> const &InnerMatcher) { return ::clang::ast_matchers
::internal::makeMatcher( new internal::matcher_pointsTo1Matcher
(InnerMatcher)); } typedef ::clang::ast_matchers::internal::Matcher
<QualType> ( &pointsTo_Type1)(internal::Matcher<
Decl> const &InnerMatcher); inline bool internal::matcher_pointsTo1Matcher
::matches( const QualType &Node, ::clang::ast_matchers::internal
::ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
4037 InnerMatcher, 1)namespace internal { class matcher_pointsTo1Matcher : public ::
clang::ast_matchers::internal::MatcherInterface<QualType>
{ public: explicit matcher_pointsTo1Matcher( internal::Matcher
<Decl> const &AInnerMatcher) : InnerMatcher(AInnerMatcher
) {} bool matches(const QualType &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const override; private: internal
::Matcher<Decl> InnerMatcher; }; } inline ::clang::ast_matchers
::internal::Matcher<QualType> pointsTo( internal::Matcher
<Decl> const &InnerMatcher) { return ::clang::ast_matchers
::internal::makeMatcher( new internal::matcher_pointsTo1Matcher
(InnerMatcher)); } typedef ::clang::ast_matchers::internal::Matcher
<QualType> ( &pointsTo_Type1)(internal::Matcher<
Decl> const &InnerMatcher); inline bool internal::matcher_pointsTo1Matcher
::matches( const QualType &Node, ::clang::ast_matchers::internal
::ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
4038 return pointsTo(qualType(hasDeclaration(InnerMatcher)))
4039 .matches(Node, Finder, Builder);
4040}
4041
4042/// Matches if the matched type matches the unqualified desugared
4043/// type of the matched node.
4044///
4045/// For example, in:
4046/// \code
4047/// class A {};
4048/// using B = A;
4049/// \endcode
4050/// The matcher type(hasUnqualifiedDesugaredType(recordType())) matches
4051/// both B and A.
4052AST_MATCHER_P(Type, hasUnqualifiedDesugaredType, internal::Matcher<Type>,namespace internal { class matcher_hasUnqualifiedDesugaredType0Matcher
: public ::clang::ast_matchers::internal::MatcherInterface<
Type> { public: explicit matcher_hasUnqualifiedDesugaredType0Matcher
( internal::Matcher<Type> const &AInnerMatcher) : InnerMatcher
(AInnerMatcher) {} bool matches(const Type &Node, ::clang
::ast_matchers::internal::ASTMatchFinder *Finder, ::clang::ast_matchers
::internal::BoundNodesTreeBuilder *Builder) const override; private
: internal::Matcher<Type> InnerMatcher; }; } inline ::clang
::ast_matchers::internal::Matcher<Type> hasUnqualifiedDesugaredType
( internal::Matcher<Type> const &InnerMatcher) { return
::clang::ast_matchers::internal::makeMatcher( new internal::
matcher_hasUnqualifiedDesugaredType0Matcher(InnerMatcher)); }
typedef ::clang::ast_matchers::internal::Matcher<Type>
( &hasUnqualifiedDesugaredType_Type0)(internal::Matcher<
Type> const &InnerMatcher); inline bool internal::matcher_hasUnqualifiedDesugaredType0Matcher
::matches( const Type &Node, ::clang::ast_matchers::internal
::ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
4053 InnerMatcher)namespace internal { class matcher_hasUnqualifiedDesugaredType0Matcher
: public ::clang::ast_matchers::internal::MatcherInterface<
Type> { public: explicit matcher_hasUnqualifiedDesugaredType0Matcher
( internal::Matcher<Type> const &AInnerMatcher) : InnerMatcher
(AInnerMatcher) {} bool matches(const Type &Node, ::clang
::ast_matchers::internal::ASTMatchFinder *Finder, ::clang::ast_matchers
::internal::BoundNodesTreeBuilder *Builder) const override; private
: internal::Matcher<Type> InnerMatcher; }; } inline ::clang
::ast_matchers::internal::Matcher<Type> hasUnqualifiedDesugaredType
( internal::Matcher<Type> const &InnerMatcher) { return
::clang::ast_matchers::internal::makeMatcher( new internal::
matcher_hasUnqualifiedDesugaredType0Matcher(InnerMatcher)); }
typedef ::clang::ast_matchers::internal::Matcher<Type>
( &hasUnqualifiedDesugaredType_Type0)(internal::Matcher<
Type> const &InnerMatcher); inline bool internal::matcher_hasUnqualifiedDesugaredType0Matcher
::matches( const Type &Node, ::clang::ast_matchers::internal
::ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
4054 return InnerMatcher.matches(*Node.getUnqualifiedDesugaredType(), Finder,
4055 Builder);
4056}
4057
4058/// Matches if the matched type is a reference type and the referenced
4059/// type matches the specified matcher.
4060///
4061/// Example matches X &x and const X &y
4062/// (matcher = varDecl(hasType(references(cxxRecordDecl(hasName("X"))))))
4063/// \code
4064/// class X {
4065/// void a(X b) {
4066/// X &x = b;
4067/// const X &y = b;
4068/// }
4069/// };
4070/// \endcode
4071AST_MATCHER_P(QualType, references, internal::Matcher<QualType>,namespace internal { class matcher_references0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<QualType
> { public: explicit matcher_references0Matcher( internal::
Matcher<QualType> const &AInnerMatcher) : InnerMatcher
(AInnerMatcher) {} bool matches(const QualType &Node, ::clang
::ast_matchers::internal::ASTMatchFinder *Finder, ::clang::ast_matchers
::internal::BoundNodesTreeBuilder *Builder) const override; private
: internal::Matcher<QualType> InnerMatcher; }; } inline
::clang::ast_matchers::internal::Matcher<QualType> references
( internal::Matcher<QualType> const &InnerMatcher) {
return ::clang::ast_matchers::internal::makeMatcher( new internal
::matcher_references0Matcher(InnerMatcher)); } typedef ::clang
::ast_matchers::internal::Matcher<QualType> ( &references_Type0
)(internal::Matcher<QualType> const &InnerMatcher);
inline bool internal::matcher_references0Matcher::matches( const
QualType &Node, ::clang::ast_matchers::internal::ASTMatchFinder
*Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
4072 InnerMatcher)namespace internal { class matcher_references0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<QualType
> { public: explicit matcher_references0Matcher( internal::
Matcher<QualType> const &AInnerMatcher) : InnerMatcher
(AInnerMatcher) {} bool matches(const QualType &Node, ::clang
::ast_matchers::internal::ASTMatchFinder *Finder, ::clang::ast_matchers
::internal::BoundNodesTreeBuilder *Builder) const override; private
: internal::Matcher<QualType> InnerMatcher; }; } inline
::clang::ast_matchers::internal::Matcher<QualType> references
( internal::Matcher<QualType> const &InnerMatcher) {
return ::clang::ast_matchers::internal::makeMatcher( new internal
::matcher_references0Matcher(InnerMatcher)); } typedef ::clang
::ast_matchers::internal::Matcher<QualType> ( &references_Type0
)(internal::Matcher<QualType> const &InnerMatcher);
inline bool internal::matcher_references0Matcher::matches( const
QualType &Node, ::clang::ast_matchers::internal::ASTMatchFinder
*Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
4073 return (!Node.isNull() && Node->isReferenceType() &&
4074 InnerMatcher.matches(Node->getPointeeType(), Finder, Builder));
4075}
4076
4077/// Matches QualTypes whose canonical type matches InnerMatcher.
4078///
4079/// Given:
4080/// \code
4081/// typedef int &int_ref;
4082/// int a;
4083/// int_ref b = a;
4084/// \endcode
4085///
4086/// \c varDecl(hasType(qualType(referenceType()))))) will not match the
4087/// declaration of b but \c
4088/// varDecl(hasType(qualType(hasCanonicalType(referenceType())))))) does.
4089AST_MATCHER_P(QualType, hasCanonicalType, internal::Matcher<QualType>,namespace internal { class matcher_hasCanonicalType0Matcher :
public ::clang::ast_matchers::internal::MatcherInterface<
QualType> { public: explicit matcher_hasCanonicalType0Matcher
( internal::Matcher<QualType> const &AInnerMatcher)
: InnerMatcher(AInnerMatcher) {} bool matches(const QualType
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: internal::Matcher<QualType
> InnerMatcher; }; } inline ::clang::ast_matchers::internal
::Matcher<QualType> hasCanonicalType( internal::Matcher
<QualType> const &InnerMatcher) { return ::clang::ast_matchers
::internal::makeMatcher( new internal::matcher_hasCanonicalType0Matcher
(InnerMatcher)); } typedef ::clang::ast_matchers::internal::Matcher
<QualType> ( &hasCanonicalType_Type0)(internal::Matcher
<QualType> const &InnerMatcher); inline bool internal
::matcher_hasCanonicalType0Matcher::matches( const QualType &
Node, ::clang::ast_matchers::internal::ASTMatchFinder *Finder
, ::clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder
) const
4090 InnerMatcher)namespace internal { class matcher_hasCanonicalType0Matcher :
public ::clang::ast_matchers::internal::MatcherInterface<
QualType> { public: explicit matcher_hasCanonicalType0Matcher
( internal::Matcher<QualType> const &AInnerMatcher)
: InnerMatcher(AInnerMatcher) {} bool matches(const QualType
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: internal::Matcher<QualType
> InnerMatcher; }; } inline ::clang::ast_matchers::internal
::Matcher<QualType> hasCanonicalType( internal::Matcher
<QualType> const &InnerMatcher) { return ::clang::ast_matchers
::internal::makeMatcher( new internal::matcher_hasCanonicalType0Matcher
(InnerMatcher)); } typedef ::clang::ast_matchers::internal::Matcher
<QualType> ( &hasCanonicalType_Type0)(internal::Matcher
<QualType> const &InnerMatcher); inline bool internal
::matcher_hasCanonicalType0Matcher::matches( const QualType &
Node, ::clang::ast_matchers::internal::ASTMatchFinder *Finder
, ::clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder
) const
{
4091 if (Node.isNull())
4092 return false;
4093 return InnerMatcher.matches(Node.getCanonicalType(), Finder, Builder);
4094}
4095
4096/// Overloaded to match the referenced type's declaration.
4097AST_MATCHER_P_OVERLOAD(QualType, references, internal::Matcher<Decl>,namespace internal { class matcher_references1Matcher : public
::clang::ast_matchers::internal::MatcherInterface<QualType
> { public: explicit matcher_references1Matcher( internal::
Matcher<Decl> const &AInnerMatcher) : InnerMatcher(
AInnerMatcher) {} bool matches(const QualType &Node, ::clang
::ast_matchers::internal::ASTMatchFinder *Finder, ::clang::ast_matchers
::internal::BoundNodesTreeBuilder *Builder) const override; private
: internal::Matcher<Decl> InnerMatcher; }; } inline ::clang
::ast_matchers::internal::Matcher<QualType> references(
internal::Matcher<Decl> const &InnerMatcher) { return
::clang::ast_matchers::internal::makeMatcher( new internal::
matcher_references1Matcher(InnerMatcher)); } typedef ::clang::
ast_matchers::internal::Matcher<QualType> ( &references_Type1
)(internal::Matcher<Decl> const &InnerMatcher); inline
bool internal::matcher_references1Matcher::matches( const QualType
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
4098 InnerMatcher, 1)namespace internal { class matcher_references1Matcher : public
::clang::ast_matchers::internal::MatcherInterface<QualType
> { public: explicit matcher_references1Matcher( internal::
Matcher<Decl> const &AInnerMatcher) : InnerMatcher(
AInnerMatcher) {} bool matches(const QualType &Node, ::clang
::ast_matchers::internal::ASTMatchFinder *Finder, ::clang::ast_matchers
::internal::BoundNodesTreeBuilder *Builder) const override; private
: internal::Matcher<Decl> InnerMatcher; }; } inline ::clang
::ast_matchers::internal::Matcher<QualType> references(
internal::Matcher<Decl> const &InnerMatcher) { return
::clang::ast_matchers::internal::makeMatcher( new internal::
matcher_references1Matcher(InnerMatcher)); } typedef ::clang::
ast_matchers::internal::Matcher<QualType> ( &references_Type1
)(internal::Matcher<Decl> const &InnerMatcher); inline
bool internal::matcher_references1Matcher::matches( const QualType
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
4099 return references(qualType(hasDeclaration(InnerMatcher)))
4100 .matches(Node, Finder, Builder);
4101}
4102
4103/// Matches on the implicit object argument of a member call expression. Unlike
4104/// `on`, matches the argument directly without stripping away anything.
4105///
4106/// Given
4107/// \code
4108/// class Y { public: void m(); };
4109/// Y g();
4110/// class X : public Y { void g(); };
4111/// void z(Y y, X x) { y.m(); x.m(); x.g(); (g()).m(); }
4112/// \endcode
4113/// cxxMemberCallExpr(onImplicitObjectArgument(hasType(
4114/// cxxRecordDecl(hasName("Y")))))
4115/// matches `y.m()`, `x.m()` and (g()).m(), but not `x.g()`.
4116/// cxxMemberCallExpr(on(callExpr()))
4117/// does not match `(g()).m()`, because the parens are not ignored.
4118///
4119/// FIXME: Overload to allow directly matching types?
4120AST_MATCHER_P(CXXMemberCallExpr, onImplicitObjectArgument,namespace internal { class matcher_onImplicitObjectArgument0Matcher
: public ::clang::ast_matchers::internal::MatcherInterface<
CXXMemberCallExpr> { public: explicit matcher_onImplicitObjectArgument0Matcher
( internal::Matcher<Expr> const &AInnerMatcher) : InnerMatcher
(AInnerMatcher) {} bool matches(const CXXMemberCallExpr &
Node, ::clang::ast_matchers::internal::ASTMatchFinder *Finder
, ::clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder
) const override; private: internal::Matcher<Expr> InnerMatcher
; }; } inline ::clang::ast_matchers::internal::Matcher<CXXMemberCallExpr
> onImplicitObjectArgument( internal::Matcher<Expr> const
&InnerMatcher) { return ::clang::ast_matchers::internal::
makeMatcher( new internal::matcher_onImplicitObjectArgument0Matcher
(InnerMatcher)); } typedef ::clang::ast_matchers::internal::Matcher
<CXXMemberCallExpr> ( &onImplicitObjectArgument_Type0
)(internal::Matcher<Expr> const &InnerMatcher); inline
bool internal::matcher_onImplicitObjectArgument0Matcher::matches
( const CXXMemberCallExpr &Node, ::clang::ast_matchers::internal
::ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
4121 internal::Matcher<Expr>, InnerMatcher)namespace internal { class matcher_onImplicitObjectArgument0Matcher
: public ::clang::ast_matchers::internal::MatcherInterface<
CXXMemberCallExpr> { public: explicit matcher_onImplicitObjectArgument0Matcher
( internal::Matcher<Expr> const &AInnerMatcher) : InnerMatcher
(AInnerMatcher) {} bool matches(const CXXMemberCallExpr &
Node, ::clang::ast_matchers::internal::ASTMatchFinder *Finder
, ::clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder
) const override; private: internal::Matcher<Expr> InnerMatcher
; }; } inline ::clang::ast_matchers::internal::Matcher<CXXMemberCallExpr
> onImplicitObjectArgument( internal::Matcher<Expr> const
&InnerMatcher) { return ::clang::ast_matchers::internal::
makeMatcher( new internal::matcher_onImplicitObjectArgument0Matcher
(InnerMatcher)); } typedef ::clang::ast_matchers::internal::Matcher
<CXXMemberCallExpr> ( &onImplicitObjectArgument_Type0
)(internal::Matcher<Expr> const &InnerMatcher); inline
bool internal::matcher_onImplicitObjectArgument0Matcher::matches
( const CXXMemberCallExpr &Node, ::clang::ast_matchers::internal
::ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
4122 const Expr *ExprNode = Node.getImplicitObjectArgument();
4123 return (ExprNode != nullptr &&
4124 InnerMatcher.matches(*ExprNode, Finder, Builder));
4125}
4126
4127/// Matches if the type of the expression's implicit object argument either
4128/// matches the InnerMatcher, or is a pointer to a type that matches the
4129/// InnerMatcher.
4130///
4131/// Given
4132/// \code
4133/// class Y { public: void m(); };
4134/// class X : public Y { void g(); };
4135/// void z() { Y y; y.m(); Y *p; p->m(); X x; x.m(); x.g(); }
4136/// \endcode
4137/// cxxMemberCallExpr(thisPointerType(hasDeclaration(
4138/// cxxRecordDecl(hasName("Y")))))
4139/// matches `y.m()`, `p->m()` and `x.m()`.
4140/// cxxMemberCallExpr(thisPointerType(hasDeclaration(
4141/// cxxRecordDecl(hasName("X")))))
4142/// matches `x.g()`.
4143AST_MATCHER_P_OVERLOAD(CXXMemberCallExpr, thisPointerType,namespace internal { class matcher_thisPointerType0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<CXXMemberCallExpr
> { public: explicit matcher_thisPointerType0Matcher( internal
::Matcher<QualType> const &AInnerMatcher) : InnerMatcher
(AInnerMatcher) {} bool matches(const CXXMemberCallExpr &
Node, ::clang::ast_matchers::internal::ASTMatchFinder *Finder
, ::clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder
) const override; private: internal::Matcher<QualType> InnerMatcher
; }; } inline ::clang::ast_matchers::internal::Matcher<CXXMemberCallExpr
> thisPointerType( internal::Matcher<QualType> const
&InnerMatcher) { return ::clang::ast_matchers::internal::
makeMatcher( new internal::matcher_thisPointerType0Matcher(InnerMatcher
)); } typedef ::clang::ast_matchers::internal::Matcher<CXXMemberCallExpr
> ( &thisPointerType_Type0)(internal::Matcher<QualType
> const &InnerMatcher); inline bool internal::matcher_thisPointerType0Matcher
::matches( const CXXMemberCallExpr &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
4144 internal::Matcher<QualType>, InnerMatcher, 0)namespace internal { class matcher_thisPointerType0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<CXXMemberCallExpr
> { public: explicit matcher_thisPointerType0Matcher( internal
::Matcher<QualType> const &AInnerMatcher) : InnerMatcher
(AInnerMatcher) {} bool matches(const CXXMemberCallExpr &
Node, ::clang::ast_matchers::internal::ASTMatchFinder *Finder
, ::clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder
) const override; private: internal::Matcher<QualType> InnerMatcher
; }; } inline ::clang::ast_matchers::internal::Matcher<CXXMemberCallExpr
> thisPointerType( internal::Matcher<QualType> const
&InnerMatcher) { return ::clang::ast_matchers::internal::
makeMatcher( new internal::matcher_thisPointerType0Matcher(InnerMatcher
)); } typedef ::clang::ast_matchers::internal::Matcher<CXXMemberCallExpr
> ( &thisPointerType_Type0)(internal::Matcher<QualType
> const &InnerMatcher); inline bool internal::matcher_thisPointerType0Matcher
::matches( const CXXMemberCallExpr &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
{
4145 return onImplicitObjectArgument(
4146 anyOf(hasType(InnerMatcher), hasType(pointsTo(InnerMatcher))))
4147 .matches(Node, Finder, Builder);
4148}
4149