Bug Summary

File:clang-tools-extra/clang-tidy/performance/NoexceptMoveConstructorCheck.cpp
Warning:line 43, column 35
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 NoexceptMoveConstructorCheck.cpp -analyzer-store=region -analyzer-opt-analyze-nested-blocks -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/llvm-toolchain-snapshot-15~++20220211101351+43a1756a5d53/build-llvm/tools/clang/stage2-bins -resource-dir /usr/lib/llvm-15/lib/clang/15.0.0 -D _DEBUG -D _GNU_SOURCE -D __STDC_CONSTANT_MACROS -D __STDC_FORMAT_MACROS -D __STDC_LIMIT_MACROS -I tools/clang/tools/extra/clang-tidy/performance -I /build/llvm-toolchain-snapshot-15~++20220211101351+43a1756a5d53/clang-tools-extra/clang-tidy/performance -I tools/clang/tools/extra/clang-tidy -I /build/llvm-toolchain-snapshot-15~++20220211101351+43a1756a5d53/clang/include -I tools/clang/include -I include -I /build/llvm-toolchain-snapshot-15~++20220211101351+43a1756a5d53/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-15/lib/clang/15.0.0/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/llvm-toolchain-snapshot-15~++20220211101351+43a1756a5d53/build-llvm/tools/clang/stage2-bins=build-llvm/tools/clang/stage2-bins -fmacro-prefix-map=/build/llvm-toolchain-snapshot-15~++20220211101351+43a1756a5d53/= -fcoverage-prefix-map=/build/llvm-toolchain-snapshot-15~++20220211101351+43a1756a5d53/build-llvm/tools/clang/stage2-bins=build-llvm/tools/clang/stage2-bins -fcoverage-prefix-map=/build/llvm-toolchain-snapshot-15~++20220211101351+43a1756a5d53/= -O3 -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 -std=c++14 -fdeprecated-macro -fdebug-compilation-dir=/build/llvm-toolchain-snapshot-15~++20220211101351+43a1756a5d53/build-llvm/tools/clang/stage2-bins -fdebug-prefix-map=/build/llvm-toolchain-snapshot-15~++20220211101351+43a1756a5d53/build-llvm/tools/clang/stage2-bins=build-llvm/tools/clang/stage2-bins -fdebug-prefix-map=/build/llvm-toolchain-snapshot-15~++20220211101351+43a1756a5d53/= -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-2022-02-12-012820-35430-1 -x c++ /build/llvm-toolchain-snapshot-15~++20220211101351+43a1756a5d53/clang-tools-extra/clang-tidy/performance/NoexceptMoveConstructorCheck.cpp

/build/llvm-toolchain-snapshot-15~++20220211101351+43a1756a5d53/clang-tools-extra/clang-tidy/performance/NoexceptMoveConstructorCheck.cpp

1//===--- NoexceptMoveConstructorCheck.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 "NoexceptMoveConstructorCheck.h"
10#include "clang/AST/ASTContext.h"
11#include "clang/ASTMatchers/ASTMatchFinder.h"
12#include "clang/Lex/Lexer.h"
13#include "clang/Tooling/FixIt.h"
14
15using namespace clang::ast_matchers;
16
17namespace clang {
18namespace tidy {
19namespace performance {
20
21void NoexceptMoveConstructorCheck::registerMatchers(MatchFinder *Finder) {
22 Finder->addMatcher(
23 cxxMethodDecl(anyOf(cxxConstructorDecl(), hasOverloadedOperatorName("=")),
24 unless(isImplicit()), unless(isDeleted()))
25 .bind("decl"),
26 this);
27}
28
29void NoexceptMoveConstructorCheck::check(
30 const MatchFinder::MatchResult &Result) {
31 if (const auto *Decl
19.1
'Decl' is non-null
19.1
'Decl' is non-null
19.1
'Decl' is non-null
19.1
'Decl' is non-null
19.1
'Decl' is non-null
= Result.Nodes.getNodeAs<CXXMethodDecl>("decl")) {
1
Calling 'BoundNodes::getNodeAs'
19
Returning from 'BoundNodes::getNodeAs'
20
Taking true branch
32 bool IsConstructor = false;
33 if (const auto *Ctor
21.1
'Ctor' is null
21.1
'Ctor' is null
21.1
'Ctor' is null
21.1
'Ctor' is null
21.1
'Ctor' is null
= dyn_cast<CXXConstructorDecl>(Decl)) {
21
Assuming 'Decl' is not a 'CXXConstructorDecl'
22
Taking false branch
34 if (!Ctor->isMoveConstructor())
35 return;
36 IsConstructor = true;
37 } else if (!Decl->isMoveAssignmentOperator()) {
23
Assuming the condition is false
24
Taking false branch
38 return;
39 }
40
41 const auto *ProtoType = Decl->getType()->getAs<FunctionProtoType>();
25
Assuming the object is not a 'FunctionProtoType'
26
'ProtoType' initialized to a null pointer value
42
43 if (isUnresolvedExceptionSpec(ProtoType->getExceptionSpecType()))
27
Called C++ object pointer is null
44 return;
45
46 if (!isNoexceptExceptionSpec(ProtoType->getExceptionSpecType())) {
47 auto Diag = diag(Decl->getLocation(),
48 "move %select{assignment operator|constructor}0s should "
49 "be marked noexcept")
50 << IsConstructor;
51 // Add FixIt hints.
52 SourceManager &SM = *Result.SourceManager;
53 assert(Decl->getNumParams() > 0)(static_cast <bool> (Decl->getNumParams() > 0) ? void
(0) : __assert_fail ("Decl->getNumParams() > 0", "clang-tools-extra/clang-tidy/performance/NoexceptMoveConstructorCheck.cpp"
, 53, __extension__ __PRETTY_FUNCTION__))
;
54 SourceLocation NoexceptLoc = Decl->getParamDecl(Decl->getNumParams() - 1)
55 ->getSourceRange()
56 .getEnd();
57 if (NoexceptLoc.isValid())
58 NoexceptLoc = Lexer::findLocationAfterToken(
59 NoexceptLoc, tok::r_paren, SM, Result.Context->getLangOpts(), true);
60 if (NoexceptLoc.isValid())
61 Diag << FixItHint::CreateInsertion(NoexceptLoc, " noexcept ");
62 return;
63 }
64
65 // Don't complain about nothrow(false), but complain on nothrow(expr)
66 // where expr evaluates to false.
67 if (ProtoType->canThrow() == CT_Can) {
68 Expr *E = ProtoType->getNoexceptExpr();
69 E = E->IgnoreImplicit();
70 if (!isa<CXXBoolLiteralExpr>(E)) {
71 diag(E->getExprLoc(),
72 "noexcept specifier on the move %select{assignment "
73 "operator|constructor}0 evaluates to 'false'")
74 << IsConstructor;
75 }
76 }
77 }
78}
79
80} // namespace performance
81} // namespace tidy
82} // namespace clang

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