Bug Summary

File:clang-tools-extra/clang-tidy/abseil/DurationFactoryScaleCheck.cpp
Warning:line 198, column 34
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 DurationFactoryScaleCheck.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-14~++20220119111520+da61cb019eb2/build-llvm/tools/clang/stage2-bins -resource-dir /usr/lib/llvm-14/lib/clang/14.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/abseil -I /build/llvm-toolchain-snapshot-14~++20220119111520+da61cb019eb2/clang-tools-extra/clang-tidy/abseil -I tools/clang/tools/extra/clang-tidy -I /build/llvm-toolchain-snapshot-14~++20220119111520+da61cb019eb2/clang/include -I tools/clang/include -I include -I /build/llvm-toolchain-snapshot-14~++20220119111520+da61cb019eb2/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-14/lib/clang/14.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-14~++20220119111520+da61cb019eb2/build-llvm/tools/clang/stage2-bins=build-llvm/tools/clang/stage2-bins -fmacro-prefix-map=/build/llvm-toolchain-snapshot-14~++20220119111520+da61cb019eb2/= -fcoverage-prefix-map=/build/llvm-toolchain-snapshot-14~++20220119111520+da61cb019eb2/build-llvm/tools/clang/stage2-bins=build-llvm/tools/clang/stage2-bins -fcoverage-prefix-map=/build/llvm-toolchain-snapshot-14~++20220119111520+da61cb019eb2/= -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-14~++20220119111520+da61cb019eb2/build-llvm/tools/clang/stage2-bins -fdebug-prefix-map=/build/llvm-toolchain-snapshot-14~++20220119111520+da61cb019eb2/build-llvm/tools/clang/stage2-bins=build-llvm/tools/clang/stage2-bins -fdebug-prefix-map=/build/llvm-toolchain-snapshot-14~++20220119111520+da61cb019eb2/= -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-01-19-134126-35450-1 -x c++ /build/llvm-toolchain-snapshot-14~++20220119111520+da61cb019eb2/clang-tools-extra/clang-tidy/abseil/DurationFactoryScaleCheck.cpp

/build/llvm-toolchain-snapshot-14~++20220119111520+da61cb019eb2/clang-tools-extra/clang-tidy/abseil/DurationFactoryScaleCheck.cpp

1//===--- DurationFactoryScaleCheck.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 "DurationFactoryScaleCheck.h"
10#include "DurationRewriter.h"
11#include "clang/AST/ASTContext.h"
12#include "clang/ASTMatchers/ASTMatchFinder.h"
13#include "clang/Tooling/FixIt.h"
14
15using namespace clang::ast_matchers;
16
17namespace clang {
18namespace tidy {
19namespace abseil {
20
21// Given the name of a duration factory function, return the appropriate
22// `DurationScale` for that factory. If no factory can be found for
23// `FactoryName`, return `None`.
24static llvm::Optional<DurationScale>
25getScaleForFactory(llvm::StringRef FactoryName) {
26 return llvm::StringSwitch<llvm::Optional<DurationScale>>(FactoryName)
27 .Case("Nanoseconds", DurationScale::Nanoseconds)
28 .Case("Microseconds", DurationScale::Microseconds)
29 .Case("Milliseconds", DurationScale::Milliseconds)
30 .Case("Seconds", DurationScale::Seconds)
31 .Case("Minutes", DurationScale::Minutes)
32 .Case("Hours", DurationScale::Hours)
33 .Default(llvm::None);
34}
35
36// Given either an integer or float literal, return its value.
37// One and only one of `IntLit` and `FloatLit` should be provided.
38static double getValue(const IntegerLiteral *IntLit,
39 const FloatingLiteral *FloatLit) {
40 if (IntLit)
41 return IntLit->getValue().getLimitedValue();
42
43 assert(FloatLit != nullptr && "Neither IntLit nor FloatLit set")(static_cast <bool> (FloatLit != nullptr && "Neither IntLit nor FloatLit set"
) ? void (0) : __assert_fail ("FloatLit != nullptr && \"Neither IntLit nor FloatLit set\""
, "clang-tools-extra/clang-tidy/abseil/DurationFactoryScaleCheck.cpp"
, 43, __extension__ __PRETTY_FUNCTION__))
;
44 return FloatLit->getValueAsApproximateDouble();
45}
46
47// Given the scale of a duration and a `Multiplier`, determine if `Multiplier`
48// would produce a new scale. If so, return a tuple containing the new scale
49// and a suitable Multiplier for that scale, otherwise `None`.
50static llvm::Optional<std::tuple<DurationScale, double>>
51getNewScaleSingleStep(DurationScale OldScale, double Multiplier) {
52 switch (OldScale) {
53 case DurationScale::Hours:
54 if (Multiplier <= 1.0 / 60.0)
55 return std::make_tuple(DurationScale::Minutes, Multiplier * 60.0);
56 break;
57
58 case DurationScale::Minutes:
59 if (Multiplier >= 60.0)
60 return std::make_tuple(DurationScale::Hours, Multiplier / 60.0);
61 if (Multiplier <= 1.0 / 60.0)
62 return std::make_tuple(DurationScale::Seconds, Multiplier * 60.0);
63 break;
64
65 case DurationScale::Seconds:
66 if (Multiplier >= 60.0)
67 return std::make_tuple(DurationScale::Minutes, Multiplier / 60.0);
68 if (Multiplier <= 1e-3)
69 return std::make_tuple(DurationScale::Milliseconds, Multiplier * 1e3);
70 break;
71
72 case DurationScale::Milliseconds:
73 if (Multiplier >= 1e3)
74 return std::make_tuple(DurationScale::Seconds, Multiplier / 1e3);
75 if (Multiplier <= 1e-3)
76 return std::make_tuple(DurationScale::Microseconds, Multiplier * 1e3);
77 break;
78
79 case DurationScale::Microseconds:
80 if (Multiplier >= 1e3)
81 return std::make_tuple(DurationScale::Milliseconds, Multiplier / 1e3);
82 if (Multiplier <= 1e-3)
83 return std::make_tuple(DurationScale::Nanoseconds, Multiplier * 1e-3);
84 break;
85
86 case DurationScale::Nanoseconds:
87 if (Multiplier >= 1e3)
88 return std::make_tuple(DurationScale::Microseconds, Multiplier / 1e3);
89 break;
90 }
91
92 return llvm::None;
93}
94
95// Given the scale of a duration and a `Multiplier`, determine if `Multiplier`
96// would produce a new scale. If so, return it, otherwise `None`.
97static llvm::Optional<DurationScale> getNewScale(DurationScale OldScale,
98 double Multiplier) {
99 while (Multiplier != 1.0) {
100 llvm::Optional<std::tuple<DurationScale, double>> Result =
101 getNewScaleSingleStep(OldScale, Multiplier);
102 if (!Result)
103 break;
104 if (std::get<1>(*Result) == 1.0)
105 return std::get<0>(*Result);
106 Multiplier = std::get<1>(*Result);
107 OldScale = std::get<0>(*Result);
108 }
109
110 return llvm::None;
111}
112
113void DurationFactoryScaleCheck::registerMatchers(MatchFinder *Finder) {
114 Finder->addMatcher(
115 callExpr(
116 callee(functionDecl(DurationFactoryFunction()).bind("call_decl")),
117 hasArgument(
118 0,
119 ignoringImpCasts(anyOf(
120 cxxFunctionalCastExpr(
121 hasDestinationType(
122 anyOf(isInteger(), realFloatingPointType())),
123 hasSourceExpression(initListExpr())),
124 integerLiteral(equals(0)), floatLiteral(equals(0.0)),
125 binaryOperator(hasOperatorName("*"),
126 hasEitherOperand(ignoringImpCasts(
127 anyOf(integerLiteral(), floatLiteral()))))
128 .bind("mult_binop"),
129 binaryOperator(hasOperatorName("/"), hasRHS(floatLiteral()))
130 .bind("div_binop")))))
131 .bind("call"),
132 this);
133}
134
135void DurationFactoryScaleCheck::check(const MatchFinder::MatchResult &Result) {
136 const auto *Call = Result.Nodes.getNodeAs<CallExpr>("call");
137
138 // Don't try to replace things inside of macro definitions.
139 if (Call->getExprLoc().isMacroID())
1
Calling 'SourceLocation::isMacroID'
4
Returning from 'SourceLocation::isMacroID'
5
Taking false branch
140 return;
141
142 const Expr *Arg = Call->getArg(0)->IgnoreParenImpCasts();
143 // Arguments which are macros are ignored.
144 if (Arg->getBeginLoc().isMacroID())
6
Calling 'SourceLocation::isMacroID'
9
Returning from 'SourceLocation::isMacroID'
10
Taking false branch
145 return;
146
147 // We first handle the cases of literal zero (both float and integer).
148 if (isLiteralZero(Result, *Arg)) {
11
Assuming the condition is false
12
Taking false branch
149 diag(Call->getBeginLoc(),
150 "use ZeroDuration() for zero-length time intervals")
151 << FixItHint::CreateReplacement(Call->getSourceRange(),
152 "absl::ZeroDuration()");
153 return;
154 }
155
156 const auto *CallDecl = Result.Nodes.getNodeAs<FunctionDecl>("call_decl");
157 llvm::Optional<DurationScale> MaybeScale =
158 getScaleForFactory(CallDecl->getName());
159 if (!MaybeScale)
13
Calling 'Optional::operator bool'
21
Returning from 'Optional::operator bool'
22
Taking false branch
160 return;
161
162 DurationScale Scale = *MaybeScale;
163 const Expr *Remainder;
164 llvm::Optional<DurationScale> NewScale;
165
166 // We next handle the cases of multiplication and division.
167 if (const auto *MultBinOp
33.1
'MultBinOp' is null
33.1
'MultBinOp' is null
33.1
'MultBinOp' is null
33.1
'MultBinOp' is null
33.1
'MultBinOp' is null
33.1
'MultBinOp' is null
33.1
'MultBinOp' is null
=
34
Taking false branch
168 Result.Nodes.getNodeAs<BinaryOperator>("mult_binop")) {
23
Calling 'BoundNodes::getNodeAs'
33
Returning from 'BoundNodes::getNodeAs'
169 // For multiplication, we need to look at both operands, and consider the
170 // cases where a user is multiplying by something such as 1e-3.
171
172 // First check the LHS
173 const auto *IntLit = llvm::dyn_cast<IntegerLiteral>(MultBinOp->getLHS());
174 const auto *FloatLit = llvm::dyn_cast<FloatingLiteral>(MultBinOp->getLHS());
175 if (IntLit || FloatLit) {
176 NewScale = getNewScale(Scale, getValue(IntLit, FloatLit));
177 if (NewScale)
178 Remainder = MultBinOp->getRHS();
179 }
180
181 // If we weren't able to scale based on the LHS, check the RHS
182 if (!NewScale) {
183 IntLit = llvm::dyn_cast<IntegerLiteral>(MultBinOp->getRHS());
184 FloatLit = llvm::dyn_cast<FloatingLiteral>(MultBinOp->getRHS());
185 if (IntLit || FloatLit) {
186 NewScale = getNewScale(Scale, getValue(IntLit, FloatLit));
187 if (NewScale)
188 Remainder = MultBinOp->getLHS();
189 }
190 }
191 } else if (const auto *DivBinOp
53.1
'DivBinOp' is non-null
53.1
'DivBinOp' is non-null
53.1
'DivBinOp' is non-null
53.1
'DivBinOp' is non-null
53.1
'DivBinOp' is non-null
53.1
'DivBinOp' is non-null
53.1
'DivBinOp' is non-null
=
54
Taking true branch
192 Result.Nodes.getNodeAs<BinaryOperator>("div_binop")) {
35
Calling 'BoundNodes::getNodeAs'
53
Returning from 'BoundNodes::getNodeAs'
193 // We next handle division.
194 // For division, we only check the RHS.
195 const auto *FloatLit = llvm::dyn_cast<FloatingLiteral>(DivBinOp->getRHS());
55
Assuming the object is not a 'FloatingLiteral'
56
'FloatLit' initialized to a null pointer value
196
197 llvm::Optional<DurationScale> NewScale =
198 getNewScale(Scale, 1.0 / FloatLit->getValueAsApproximateDouble());
57
Called C++ object pointer is null
199 if (NewScale) {
200 const Expr *Remainder = DivBinOp->getLHS();
201
202 // We've found an appropriate scaling factor and the new scale, so output
203 // the relevant fix.
204 diag(Call->getBeginLoc(), "internal duration scaling can be removed")
205 << FixItHint::CreateReplacement(
206 Call->getSourceRange(),
207 (llvm::Twine(getDurationFactoryForScale(*NewScale)) + "(" +
208 tooling::fixit::getText(*Remainder, *Result.Context) + ")")
209 .str());
210 }
211 }
212
213 if (NewScale) {
214 assert(Remainder && "No remainder found")(static_cast <bool> (Remainder && "No remainder found"
) ? void (0) : __assert_fail ("Remainder && \"No remainder found\""
, "clang-tools-extra/clang-tidy/abseil/DurationFactoryScaleCheck.cpp"
, 214, __extension__ __PRETTY_FUNCTION__))
;
215 // We've found an appropriate scaling factor and the new scale, so output
216 // the relevant fix.
217 diag(Call->getBeginLoc(), "internal duration scaling can be removed")
218 << FixItHint::CreateReplacement(
219 Call->getSourceRange(),
220 (llvm::Twine(getDurationFactoryForScale(*NewScale)) + "(" +
221 tooling::fixit::getText(*Remainder, *Result.Context) + ")")
222 .str());
223 }
224}
225
226} // namespace abseil
227} // namespace tidy
228} // namespace clang

/build/llvm-toolchain-snapshot-14~++20220119111520+da61cb019eb2/clang/include/clang/Basic/SourceLocation.h

1//===- SourceLocation.h - Compact identifier for Source Files ---*- 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/// \file
10/// Defines the clang::SourceLocation class and associated facilities.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_CLANG_BASIC_SOURCELOCATION_H
15#define LLVM_CLANG_BASIC_SOURCELOCATION_H
16
17#include "clang/Basic/LLVM.h"
18#include "llvm/ADT/StringRef.h"
19#include <cassert>
20#include <cstdint>
21#include <string>
22#include <utility>
23
24namespace llvm {
25
26class FoldingSetNodeID;
27template <typename T> struct FoldingSetTrait;
28
29} // namespace llvm
30
31namespace clang {
32
33class SourceManager;
34
35/// An opaque identifier used by SourceManager which refers to a
36/// source file (MemoryBuffer) along with its \#include path and \#line data.
37///
38class FileID {
39 /// A mostly-opaque identifier, where 0 is "invalid", >0 is
40 /// this module, and <-1 is something loaded from another module.
41 int ID = 0;
42
43public:
44 bool isValid() const { return ID != 0; }
45 bool isInvalid() const { return ID == 0; }
46
47 bool operator==(const FileID &RHS) const { return ID == RHS.ID; }
48 bool operator<(const FileID &RHS) const { return ID < RHS.ID; }
49 bool operator<=(const FileID &RHS) const { return ID <= RHS.ID; }
50 bool operator!=(const FileID &RHS) const { return !(*this == RHS); }
51 bool operator>(const FileID &RHS) const { return RHS < *this; }
52 bool operator>=(const FileID &RHS) const { return RHS <= *this; }
53
54 static FileID getSentinel() { return get(-1); }
55 unsigned getHashValue() const { return static_cast<unsigned>(ID); }
56
57private:
58 friend class ASTWriter;
59 friend class ASTReader;
60 friend class SourceManager;
61
62 static FileID get(int V) {
63 FileID F;
64 F.ID = V;
65 return F;
66 }
67
68 int getOpaqueValue() const { return ID; }
69};
70
71/// Encodes a location in the source. The SourceManager can decode this
72/// to get at the full include stack, line and column information.
73///
74/// Technically, a source location is simply an offset into the manager's view
75/// of the input source, which is all input buffers (including macro
76/// expansions) concatenated in an effectively arbitrary order. The manager
77/// actually maintains two blocks of input buffers. One, starting at offset
78/// 0 and growing upwards, contains all buffers from this module. The other,
79/// starting at the highest possible offset and growing downwards, contains
80/// buffers of loaded modules.
81///
82/// In addition, one bit of SourceLocation is used for quick access to the
83/// information whether the location is in a file or a macro expansion.
84///
85/// It is important that this type remains small. It is currently 32 bits wide.
86class SourceLocation {
87 friend class ASTReader;
88 friend class ASTWriter;
89 friend class SourceManager;
90 friend struct llvm::FoldingSetTrait<SourceLocation>;
91
92public:
93 using UIntTy = uint32_t;
94 using IntTy = int32_t;
95
96private:
97 UIntTy ID = 0;
98
99 enum : UIntTy { MacroIDBit = 1ULL << (8 * sizeof(UIntTy) - 1) };
100
101public:
102 bool isFileID() const { return (ID & MacroIDBit) == 0; }
103 bool isMacroID() const { return (ID & MacroIDBit) != 0; }
2
Assuming the condition is false
3
Returning zero, which participates in a condition later
7
Assuming the condition is false
8
Returning zero, which participates in a condition later
104
105 /// Return true if this is a valid SourceLocation object.
106 ///
107 /// Invalid SourceLocations are often used when events have no corresponding
108 /// location in the source (e.g. a diagnostic is required for a command line
109 /// option).
110 bool isValid() const { return ID != 0; }
111 bool isInvalid() const { return ID == 0; }
112
113private:
114 /// Return the offset into the manager's global input view.
115 UIntTy getOffset() const { return ID & ~MacroIDBit; }
116
117 static SourceLocation getFileLoc(UIntTy ID) {
118 assert((ID & MacroIDBit) == 0 && "Ran out of source locations!")(static_cast <bool> ((ID & MacroIDBit) == 0 &&
"Ran out of source locations!") ? void (0) : __assert_fail (
"(ID & MacroIDBit) == 0 && \"Ran out of source locations!\""
, "clang/include/clang/Basic/SourceLocation.h", 118, __extension__
__PRETTY_FUNCTION__))
;
119 SourceLocation L;
120 L.ID = ID;
121 return L;
122 }
123
124 static SourceLocation getMacroLoc(UIntTy ID) {
125 assert((ID & MacroIDBit) == 0 && "Ran out of source locations!")(static_cast <bool> ((ID & MacroIDBit) == 0 &&
"Ran out of source locations!") ? void (0) : __assert_fail (
"(ID & MacroIDBit) == 0 && \"Ran out of source locations!\""
, "clang/include/clang/Basic/SourceLocation.h", 125, __extension__
__PRETTY_FUNCTION__))
;
126 SourceLocation L;
127 L.ID = MacroIDBit | ID;
128 return L;
129 }
130
131public:
132 /// Return a source location with the specified offset from this
133 /// SourceLocation.
134 SourceLocation getLocWithOffset(IntTy Offset) const {
135 assert(((getOffset()+Offset) & MacroIDBit) == 0 && "offset overflow")(static_cast <bool> (((getOffset()+Offset) & MacroIDBit
) == 0 && "offset overflow") ? void (0) : __assert_fail
("((getOffset()+Offset) & MacroIDBit) == 0 && \"offset overflow\""
, "clang/include/clang/Basic/SourceLocation.h", 135, __extension__
__PRETTY_FUNCTION__))
;
136 SourceLocation L;
137 L.ID = ID+Offset;
138 return L;
139 }
140
141 /// When a SourceLocation itself cannot be used, this returns
142 /// an (opaque) 32-bit integer encoding for it.
143 ///
144 /// This should only be passed to SourceLocation::getFromRawEncoding, it
145 /// should not be inspected directly.
146 UIntTy getRawEncoding() const { return ID; }
147
148 /// Turn a raw encoding of a SourceLocation object into
149 /// a real SourceLocation.
150 ///
151 /// \see getRawEncoding.
152 static SourceLocation getFromRawEncoding(UIntTy Encoding) {
153 SourceLocation X;
154 X.ID = Encoding;
155 return X;
156 }
157
158 /// When a SourceLocation itself cannot be used, this returns
159 /// an (opaque) pointer encoding for it.
160 ///
161 /// This should only be passed to SourceLocation::getFromPtrEncoding, it
162 /// should not be inspected directly.
163 void* getPtrEncoding() const {
164 // Double cast to avoid a warning "cast to pointer from integer of different
165 // size".
166 return (void*)(uintptr_t)getRawEncoding();
167 }
168
169 /// Turn a pointer encoding of a SourceLocation object back
170 /// into a real SourceLocation.
171 static SourceLocation getFromPtrEncoding(const void *Encoding) {
172 return getFromRawEncoding((SourceLocation::UIntTy)(uintptr_t)Encoding);
173 }
174
175 static bool isPairOfFileLocations(SourceLocation Start, SourceLocation End) {
176 return Start.isValid() && Start.isFileID() && End.isValid() &&
177 End.isFileID();
178 }
179
180 unsigned getHashValue() const;
181 void print(raw_ostream &OS, const SourceManager &SM) const;
182 std::string printToString(const SourceManager &SM) const;
183 void dump(const SourceManager &SM) const;
184};
185
186inline bool operator==(const SourceLocation &LHS, const SourceLocation &RHS) {
187 return LHS.getRawEncoding() == RHS.getRawEncoding();
188}
189
190inline bool operator!=(const SourceLocation &LHS, const SourceLocation &RHS) {
191 return !(LHS == RHS);
192}
193
194// Ordering is meaningful only if LHS and RHS have the same FileID!
195// Otherwise use SourceManager::isBeforeInTranslationUnit().
196inline bool operator<(const SourceLocation &LHS, const SourceLocation &RHS) {
197 return LHS.getRawEncoding() < RHS.getRawEncoding();
198}
199inline bool operator>(const SourceLocation &LHS, const SourceLocation &RHS) {
200 return LHS.getRawEncoding() > RHS.getRawEncoding();
201}
202inline bool operator<=(const SourceLocation &LHS, const SourceLocation &RHS) {
203 return LHS.getRawEncoding() <= RHS.getRawEncoding();
204}
205inline bool operator>=(const SourceLocation &LHS, const SourceLocation &RHS) {
206 return LHS.getRawEncoding() >= RHS.getRawEncoding();
207}
208
209/// A trivial tuple used to represent a source range.
210class SourceRange {
211 SourceLocation B;
212 SourceLocation E;
213
214public:
215 SourceRange() = default;
216 SourceRange(SourceLocation loc) : B(loc), E(loc) {}
217 SourceRange(SourceLocation begin, SourceLocation end) : B(begin), E(end) {}
218
219 SourceLocation getBegin() const { return B; }
220 SourceLocation getEnd() const { return E; }
221
222 void setBegin(SourceLocation b) { B = b; }
223 void setEnd(SourceLocation e) { E = e; }
224
225 bool isValid() const { return B.isValid() && E.isValid(); }
226 bool isInvalid() const { return !isValid(); }
227
228 bool operator==(const SourceRange &X) const {
229 return B == X.B && E == X.E;
230 }
231
232 bool operator!=(const SourceRange &X) const {
233 return B != X.B || E != X.E;
234 }
235
236 // Returns true iff other is wholly contained within this range.
237 bool fullyContains(const SourceRange &other) const {
238 return B <= other.B && E >= other.E;
239 }
240
241 void print(raw_ostream &OS, const SourceManager &SM) const;
242 std::string printToString(const SourceManager &SM) const;
243 void dump(const SourceManager &SM) const;
244};
245
246/// Represents a character-granular source range.
247///
248/// The underlying SourceRange can either specify the starting/ending character
249/// of the range, or it can specify the start of the range and the start of the
250/// last token of the range (a "token range"). In the token range case, the
251/// size of the last token must be measured to determine the actual end of the
252/// range.
253class CharSourceRange {
254 SourceRange Range;
255 bool IsTokenRange = false;
256
257public:
258 CharSourceRange() = default;
259 CharSourceRange(SourceRange R, bool ITR) : Range(R), IsTokenRange(ITR) {}
260
261 static CharSourceRange getTokenRange(SourceRange R) {
262 return CharSourceRange(R, true);
263 }
264
265 static CharSourceRange getCharRange(SourceRange R) {
266 return CharSourceRange(R, false);
267 }
268
269 static CharSourceRange getTokenRange(SourceLocation B, SourceLocation E) {
270 return getTokenRange(SourceRange(B, E));
271 }
272
273 static CharSourceRange getCharRange(SourceLocation B, SourceLocation E) {
274 return getCharRange(SourceRange(B, E));
275 }
276
277 /// Return true if the end of this range specifies the start of
278 /// the last token. Return false if the end of this range specifies the last
279 /// character in the range.
280 bool isTokenRange() const { return IsTokenRange; }
281 bool isCharRange() const { return !IsTokenRange; }
282
283 SourceLocation getBegin() const { return Range.getBegin(); }
284 SourceLocation getEnd() const { return Range.getEnd(); }
285 SourceRange getAsRange() const { return Range; }
286
287 void setBegin(SourceLocation b) { Range.setBegin(b); }
288 void setEnd(SourceLocation e) { Range.setEnd(e); }
289 void setTokenRange(bool TR) { IsTokenRange = TR; }
290
291 bool isValid() const { return Range.isValid(); }
292 bool isInvalid() const { return !isValid(); }
293};
294
295/// Represents an unpacked "presumed" location which can be presented
296/// to the user.
297///
298/// A 'presumed' location can be modified by \#line and GNU line marker
299/// directives and is always the expansion point of a normal location.
300///
301/// You can get a PresumedLoc from a SourceLocation with SourceManager.
302class PresumedLoc {
303 const char *Filename = nullptr;
304 FileID ID;
305 unsigned Line, Col;
306 SourceLocation IncludeLoc;
307
308public:
309 PresumedLoc() = default;
310 PresumedLoc(const char *FN, FileID FID, unsigned Ln, unsigned Co,
311 SourceLocation IL)
312 : Filename(FN), ID(FID), Line(Ln), Col(Co), IncludeLoc(IL) {}
313
314 /// Return true if this object is invalid or uninitialized.
315 ///
316 /// This occurs when created with invalid source locations or when walking
317 /// off the top of a \#include stack.
318 bool isInvalid() const { return Filename == nullptr; }
319 bool isValid() const { return Filename != nullptr; }
320
321 /// Return the presumed filename of this location.
322 ///
323 /// This can be affected by \#line etc.
324 const char *getFilename() const {
325 assert(isValid())(static_cast <bool> (isValid()) ? void (0) : __assert_fail
("isValid()", "clang/include/clang/Basic/SourceLocation.h", 325
, __extension__ __PRETTY_FUNCTION__))
;
326 return Filename;
327 }
328
329 FileID getFileID() const {
330 assert(isValid())(static_cast <bool> (isValid()) ? void (0) : __assert_fail
("isValid()", "clang/include/clang/Basic/SourceLocation.h", 330
, __extension__ __PRETTY_FUNCTION__))
;
331 return ID;
332 }
333
334 /// Return the presumed line number of this location.
335 ///
336 /// This can be affected by \#line etc.
337 unsigned getLine() const {
338 assert(isValid())(static_cast <bool> (isValid()) ? void (0) : __assert_fail
("isValid()", "clang/include/clang/Basic/SourceLocation.h", 338
, __extension__ __PRETTY_FUNCTION__))
;
339 return Line;
340 }
341
342 /// Return the presumed column number of this location.
343 ///
344 /// This cannot be affected by \#line, but is packaged here for convenience.
345 unsigned getColumn() const {
346 assert(isValid())(static_cast <bool> (isValid()) ? void (0) : __assert_fail
("isValid()", "clang/include/clang/Basic/SourceLocation.h", 346
, __extension__ __PRETTY_FUNCTION__))
;
347 return Col;
348 }
349
350 /// Return the presumed include location of this location.
351 ///
352 /// This can be affected by GNU linemarker directives.
353 SourceLocation getIncludeLoc() const {
354 assert(isValid())(static_cast <bool> (isValid()) ? void (0) : __assert_fail
("isValid()", "clang/include/clang/Basic/SourceLocation.h", 354
, __extension__ __PRETTY_FUNCTION__))
;
355 return IncludeLoc;
356 }
357};
358
359class FileEntry;
360
361/// A SourceLocation and its associated SourceManager.
362///
363/// This is useful for argument passing to functions that expect both objects.
364///
365/// This class does not guarantee the presence of either the SourceManager or
366/// a valid SourceLocation. Clients should use `isValid()` and `hasManager()`
367/// before calling the member functions.
368class FullSourceLoc : public SourceLocation {
369 const SourceManager *SrcMgr = nullptr;
370
371public:
372 /// Creates a FullSourceLoc where isValid() returns \c false.
373 FullSourceLoc() = default;
374
375 explicit FullSourceLoc(SourceLocation Loc, const SourceManager &SM)
376 : SourceLocation(Loc), SrcMgr(&SM) {}
377
378 /// Checks whether the SourceManager is present.
379 bool hasManager() const { return SrcMgr != nullptr; }
380
381 /// \pre hasManager()
382 const SourceManager &getManager() const {
383 assert(SrcMgr && "SourceManager is NULL.")(static_cast <bool> (SrcMgr && "SourceManager is NULL."
) ? void (0) : __assert_fail ("SrcMgr && \"SourceManager is NULL.\""
, "clang/include/clang/Basic/SourceLocation.h", 383, __extension__
__PRETTY_FUNCTION__))
;
384 return *SrcMgr;
385 }
386
387 FileID getFileID() const;
388
389 FullSourceLoc getExpansionLoc() const;
390 FullSourceLoc getSpellingLoc() const;
391 FullSourceLoc getFileLoc() const;
392 PresumedLoc getPresumedLoc(bool UseLineDirectives = true) const;
393 bool isMacroArgExpansion(FullSourceLoc *StartLoc = nullptr) const;
394 FullSourceLoc getImmediateMacroCallerLoc() const;
395 std::pair<FullSourceLoc, StringRef> getModuleImportLoc() const;
396 unsigned getFileOffset() const;
397
398 unsigned getExpansionLineNumber(bool *Invalid = nullptr) const;
399 unsigned getExpansionColumnNumber(bool *Invalid = nullptr) const;
400
401 unsigned getSpellingLineNumber(bool *Invalid = nullptr) const;
402 unsigned getSpellingColumnNumber(bool *Invalid = nullptr) const;
403
404 const char *getCharacterData(bool *Invalid = nullptr) const;
405
406 unsigned getLineNumber(bool *Invalid = nullptr) const;
407 unsigned getColumnNumber(bool *Invalid = nullptr) const;
408
409 const FileEntry *getFileEntry() const;
410
411 /// Return a StringRef to the source buffer data for the
412 /// specified FileID.
413 StringRef getBufferData(bool *Invalid = nullptr) const;
414
415 /// Decompose the specified location into a raw FileID + Offset pair.
416 ///
417 /// The first element is the FileID, the second is the offset from the
418 /// start of the buffer of the location.
419 std::pair<FileID, unsigned> getDecomposedLoc() const;
420
421 bool isInSystemHeader() const;
422
423 /// Determines the order of 2 source locations in the translation unit.
424 ///
425 /// \returns true if this source location comes before 'Loc', false otherwise.
426 bool isBeforeInTranslationUnitThan(SourceLocation Loc) const;
427
428 /// Determines the order of 2 source locations in the translation unit.
429 ///
430 /// \returns true if this source location comes before 'Loc', false otherwise.
431 bool isBeforeInTranslationUnitThan(FullSourceLoc Loc) const {
432 assert(Loc.isValid())(static_cast <bool> (Loc.isValid()) ? void (0) : __assert_fail
("Loc.isValid()", "clang/include/clang/Basic/SourceLocation.h"
, 432, __extension__ __PRETTY_FUNCTION__))
;
433 assert(SrcMgr == Loc.SrcMgr && "Loc comes from another SourceManager!")(static_cast <bool> (SrcMgr == Loc.SrcMgr && "Loc comes from another SourceManager!"
) ? void (0) : __assert_fail ("SrcMgr == Loc.SrcMgr && \"Loc comes from another SourceManager!\""
, "clang/include/clang/Basic/SourceLocation.h", 433, __extension__
__PRETTY_FUNCTION__))
;
434 return isBeforeInTranslationUnitThan((SourceLocation)Loc);
435 }
436
437 /// Comparison function class, useful for sorting FullSourceLocs.
438 struct BeforeThanCompare {
439 bool operator()(const FullSourceLoc& lhs, const FullSourceLoc& rhs) const {
440 return lhs.isBeforeInTranslationUnitThan(rhs);
441 }
442 };
443
444 /// Prints information about this FullSourceLoc to stderr.
445 ///
446 /// This is useful for debugging.
447 void dump() const;
448
449 friend bool
450 operator==(const FullSourceLoc &LHS, const FullSourceLoc &RHS) {
451 return LHS.getRawEncoding() == RHS.getRawEncoding() &&
452 LHS.SrcMgr == RHS.SrcMgr;
453 }
454
455 friend bool
456 operator!=(const FullSourceLoc &LHS, const FullSourceLoc &RHS) {
457 return !(LHS == RHS);
458 }
459};
460
461} // namespace clang
462
463namespace llvm {
464
465 /// Define DenseMapInfo so that FileID's can be used as keys in DenseMap and
466 /// DenseSets.
467 template <>
468 struct DenseMapInfo<clang::FileID, void> {
469 static clang::FileID getEmptyKey() {
470 return {};
471 }
472
473 static clang::FileID getTombstoneKey() {
474 return clang::FileID::getSentinel();
475 }
476
477 static unsigned getHashValue(clang::FileID S) {
478 return S.getHashValue();
479 }
480
481 static bool isEqual(clang::FileID LHS, clang::FileID RHS) {
482 return LHS == RHS;
483 }
484 };
485
486 /// Define DenseMapInfo so that SourceLocation's can be used as keys in
487 /// DenseMap and DenseSet. This trait class is eqivalent to
488 /// DenseMapInfo<unsigned> which uses SourceLocation::ID is used as a key.
489 template <> struct DenseMapInfo<clang::SourceLocation, void> {
490 static clang::SourceLocation getEmptyKey() {
491 constexpr clang::SourceLocation::UIntTy Zero = 0;
492 return clang::SourceLocation::getFromRawEncoding(~Zero);
493 }
494
495 static clang::SourceLocation getTombstoneKey() {
496 constexpr clang::SourceLocation::UIntTy Zero = 0;
497 return clang::SourceLocation::getFromRawEncoding(~Zero - 1);
498 }
499
500 static unsigned getHashValue(clang::SourceLocation Loc) {
501 return Loc.getHashValue();
502 }
503
504 static bool isEqual(clang::SourceLocation LHS, clang::SourceLocation RHS) {
505 return LHS == RHS;
506 }
507 };
508
509 // Allow calling FoldingSetNodeID::Add with SourceLocation object as parameter
510 template <> struct FoldingSetTrait<clang::SourceLocation> {
511 static void Profile(const clang::SourceLocation &X, FoldingSetNodeID &ID);
512 };
513
514} // namespace llvm
515
516#endif // LLVM_CLANG_BASIC_SOURCELOCATION_H

/build/llvm-toolchain-snapshot-14~++20220119111520+da61cb019eb2/llvm/include/llvm/ADT/Optional.h

1//===- Optional.h - Simple variant for passing optional values --*- 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 provides Optional, a template class modeled in the spirit of
10// OCaml's 'opt' variant. The idea is to strongly type whether or not
11// a value can be optional.
12//
13//===----------------------------------------------------------------------===//
14
15#ifndef LLVM_ADT_OPTIONAL_H
16#define LLVM_ADT_OPTIONAL_H
17
18#include "llvm/ADT/Hashing.h"
19#include "llvm/ADT/None.h"
20#include "llvm/ADT/STLForwardCompat.h"
21#include "llvm/Support/Compiler.h"
22#include "llvm/Support/type_traits.h"
23#include <cassert>
24#include <memory>
25#include <new>
26#include <utility>
27
28namespace llvm {
29
30class raw_ostream;
31
32namespace optional_detail {
33
34/// Storage for any type.
35//
36// The specialization condition intentionally uses
37// llvm::is_trivially_{copy/move}_constructible instead of
38// std::is_trivially_{copy/move}_constructible. GCC versions prior to 7.4 may
39// instantiate the copy/move constructor of `T` when
40// std::is_trivially_{copy/move}_constructible is instantiated. This causes
41// compilation to fail if we query the trivially copy/move constructible
42// property of a class which is not copy/move constructible.
43//
44// The current implementation of OptionalStorage insists that in order to use
45// the trivial specialization, the value_type must be trivially copy
46// constructible and trivially copy assignable due to =default implementations
47// of the copy/move constructor/assignment. It does not follow that this is
48// necessarily the case std::is_trivially_copyable is true (hence the expanded
49// specialization condition).
50//
51// The move constructible / assignable conditions emulate the remaining behavior
52// of std::is_trivially_copyable.
53template <typename T,
54 bool = (llvm::is_trivially_copy_constructible<T>::value &&
55 std::is_trivially_copy_assignable<T>::value &&
56 (llvm::is_trivially_move_constructible<T>::value ||
57 !std::is_move_constructible<T>::value) &&
58 (std::is_trivially_move_assignable<T>::value ||
59 !std::is_move_assignable<T>::value))>
60class OptionalStorage {
61 union {
62 char empty;
63 T value;
64 };
65 bool hasVal;
66
67public:
68 ~OptionalStorage() { reset(); }
69
70 constexpr OptionalStorage() noexcept : empty(), hasVal(false) {}
71
72 constexpr OptionalStorage(OptionalStorage const &other) : OptionalStorage() {
73 if (other.hasValue()) {
74 emplace(other.value);
75 }
76 }
77 constexpr OptionalStorage(OptionalStorage &&other) : OptionalStorage() {
78 if (other.hasValue()) {
79 emplace(std::move(other.value));
80 }
81 }
82
83 template <class... Args>
84 constexpr explicit OptionalStorage(in_place_t, Args &&... args)
85 : value(std::forward<Args>(args)...), hasVal(true) {}
86
87 void reset() noexcept {
88 if (hasVal) {
89 value.~T();
90 hasVal = false;
91 }
92 }
93
94 constexpr bool hasValue() const noexcept { return hasVal; }
95
96 T &getValue() LLVM_LVALUE_FUNCTION& noexcept {
97 assert(hasVal)(static_cast <bool> (hasVal) ? void (0) : __assert_fail
("hasVal", "llvm/include/llvm/ADT/Optional.h", 97, __extension__
__PRETTY_FUNCTION__))
;
98 return value;
99 }
100 constexpr T const &getValue() const LLVM_LVALUE_FUNCTION& noexcept {
101 assert(hasVal)(static_cast <bool> (hasVal) ? void (0) : __assert_fail
("hasVal", "llvm/include/llvm/ADT/Optional.h", 101, __extension__
__PRETTY_FUNCTION__))
;
102 return value;
103 }
104#if LLVM_HAS_RVALUE_REFERENCE_THIS1
105 T &&getValue() && noexcept {
106 assert(hasVal)(static_cast <bool> (hasVal) ? void (0) : __assert_fail
("hasVal", "llvm/include/llvm/ADT/Optional.h", 106, __extension__
__PRETTY_FUNCTION__))
;
107 return std::move(value);
108 }
109#endif
110
111 template <class... Args> void emplace(Args &&... args) {
112 reset();
113 ::new ((void *)std::addressof(value)) T(std::forward<Args>(args)...);
114 hasVal = true;
115 }
116
117 OptionalStorage &operator=(T const &y) {
118 if (hasValue()) {
119 value = y;
120 } else {
121 ::new ((void *)std::addressof(value)) T(y);
122 hasVal = true;
123 }
124 return *this;
125 }
126 OptionalStorage &operator=(T &&y) {
127 if (hasValue()) {
128 value = std::move(y);
129 } else {
130 ::new ((void *)std::addressof(value)) T(std::move(y));
131 hasVal = true;
132 }
133 return *this;
134 }
135
136 OptionalStorage &operator=(OptionalStorage const &other) {
137 if (other.hasValue()) {
138 if (hasValue()) {
139 value = other.value;
140 } else {
141 ::new ((void *)std::addressof(value)) T(other.value);
142 hasVal = true;
143 }
144 } else {
145 reset();
146 }
147 return *this;
148 }
149
150 OptionalStorage &operator=(OptionalStorage &&other) {
151 if (other.hasValue()) {
152 if (hasValue()) {
153 value = std::move(other.value);
154 } else {
155 ::new ((void *)std::addressof(value)) T(std::move(other.value));
156 hasVal = true;
157 }
158 } else {
159 reset();
160 }
161 return *this;
162 }
163};
164
165template <typename T> class OptionalStorage<T, true> {
166 union {
167 char empty;
168 T value;
169 };
170 bool hasVal = false;
171
172public:
173 ~OptionalStorage() = default;
174
175 constexpr OptionalStorage() noexcept : empty{} {}
176
177 constexpr OptionalStorage(OptionalStorage const &other) = default;
178 constexpr OptionalStorage(OptionalStorage &&other) = default;
179
180 OptionalStorage &operator=(OptionalStorage const &other) = default;
181 OptionalStorage &operator=(OptionalStorage &&other) = default;
182
183 template <class... Args>
184 constexpr explicit OptionalStorage(in_place_t, Args &&... args)
185 : value(std::forward<Args>(args)...), hasVal(true) {}
186
187 void reset() noexcept {
188 if (hasVal) {
189 value.~T();
190 hasVal = false;
191 }
192 }
193
194 constexpr bool hasValue() const noexcept { return hasVal; }
16
Returning the value 1, which participates in a condition later
195
196 T &getValue() LLVM_LVALUE_FUNCTION& noexcept {
197 assert(hasVal)(static_cast <bool> (hasVal) ? void (0) : __assert_fail
("hasVal", "llvm/include/llvm/ADT/Optional.h", 197, __extension__
__PRETTY_FUNCTION__))
;
198 return value;
199 }
200 constexpr T const &getValue() const LLVM_LVALUE_FUNCTION& noexcept {
201 assert(hasVal)(static_cast <bool> (hasVal) ? void (0) : __assert_fail
("hasVal", "llvm/include/llvm/ADT/Optional.h", 201, __extension__
__PRETTY_FUNCTION__))
;
202 return value;
203 }
204#if LLVM_HAS_RVALUE_REFERENCE_THIS1
205 T &&getValue() && noexcept {
206 assert(hasVal)(static_cast <bool> (hasVal) ? void (0) : __assert_fail
("hasVal", "llvm/include/llvm/ADT/Optional.h", 206, __extension__
__PRETTY_FUNCTION__))
;
207 return std::move(value);
208 }
209#endif
210
211 template <class... Args> void emplace(Args &&... args) {
212 reset();
213 ::new ((void *)std::addressof(value)) T(std::forward<Args>(args)...);
214 hasVal = true;
215 }
216
217 OptionalStorage &operator=(T const &y) {
218 if (hasValue()) {
219 value = y;
220 } else {
221 ::new ((void *)std::addressof(value)) T(y);
222 hasVal = true;
223 }
224 return *this;
225 }
226 OptionalStorage &operator=(T &&y) {
227 if (hasValue()) {
228 value = std::move(y);
229 } else {
230 ::new ((void *)std::addressof(value)) T(std::move(y));
231 hasVal = true;
232 }
233 return *this;
234 }
235};
236
237} // namespace optional_detail
238
239template <typename T> class Optional {
240 optional_detail::OptionalStorage<T> Storage;
241
242public:
243 using value_type = T;
244
245 constexpr Optional() {}
246 constexpr Optional(NoneType) {}
247
248 constexpr Optional(const T &y) : Storage(in_place, y) {}
249 constexpr Optional(const Optional &O) = default;
250
251 constexpr Optional(T &&y) : Storage(in_place, std::move(y)) {}
252 constexpr Optional(Optional &&O) = default;
253
254 template <typename... ArgTypes>
255 constexpr Optional(in_place_t, ArgTypes &&...Args)
256 : Storage(in_place, std::forward<ArgTypes>(Args)...) {}
257
258 Optional &operator=(T &&y) {
259 Storage = std::move(y);
260 return *this;
261 }
262 Optional &operator=(Optional &&O) = default;
263
264 /// Create a new object by constructing it in place with the given arguments.
265 template <typename... ArgTypes> void emplace(ArgTypes &&... Args) {
266 Storage.emplace(std::forward<ArgTypes>(Args)...);
267 }
268
269 static constexpr Optional create(const T *y) {
270 return y ? Optional(*y) : Optional();
271 }
272
273 Optional &operator=(const T &y) {
274 Storage = y;
275 return *this;
276 }
277 Optional &operator=(const Optional &O) = default;
278
279 void reset() { Storage.reset(); }
280
281 constexpr const T *getPointer() const { return &Storage.getValue(); }
282 T *getPointer() { return &Storage.getValue(); }
283 constexpr const T &getValue() const LLVM_LVALUE_FUNCTION& {
284 return Storage.getValue();
285 }
286 T &getValue() LLVM_LVALUE_FUNCTION& { return Storage.getValue(); }
287
288 constexpr explicit operator bool() const { return hasValue(); }
14
Calling 'Optional::hasValue'
19
Returning from 'Optional::hasValue'
20
Returning the value 1, which participates in a condition later
289 constexpr bool hasValue() const { return Storage.hasValue(); }
15
Calling 'OptionalStorage::hasValue'
17
Returning from 'OptionalStorage::hasValue'
18
Returning the value 1, which participates in a condition later
290 constexpr const T *operator->() const { return getPointer(); }
291 T *operator->() { return getPointer(); }
292 constexpr const T &operator*() const LLVM_LVALUE_FUNCTION& {
293 return getValue();
294 }
295 T &operator*() LLVM_LVALUE_FUNCTION& { return getValue(); }
296
297 template <typename U>
298 constexpr T getValueOr(U &&value) const LLVM_LVALUE_FUNCTION& {
299 return hasValue() ? getValue() : std::forward<U>(value);
300 }
301
302 /// Apply a function to the value if present; otherwise return None.
303 template <class Function>
304 auto map(const Function &F) const LLVM_LVALUE_FUNCTION&
305 -> Optional<decltype(F(getValue()))> {
306 if (*this) return F(getValue());
307 return None;
308 }
309
310#if LLVM_HAS_RVALUE_REFERENCE_THIS1
311 T &&getValue() && { return std::move(Storage.getValue()); }
312 T &&operator*() && { return std::move(Storage.getValue()); }
313
314 template <typename U>
315 T getValueOr(U &&value) && {
316 return hasValue() ? std::move(getValue()) : std::forward<U>(value);
317 }
318
319 /// Apply a function to the value if present; otherwise return None.
320 template <class Function>
321 auto map(const Function &F) &&
322 -> Optional<decltype(F(std::move(*this).getValue()))> {
323 if (*this) return F(std::move(*this).getValue());
324 return None;
325 }
326#endif
327};
328
329template <class T> llvm::hash_code hash_value(const Optional<T> &O) {
330 return O ? hash_combine(true, *O) : hash_value(false);
331}
332
333template <typename T, typename U>
334constexpr bool operator==(const Optional<T> &X, const Optional<U> &Y) {
335 if (X && Y)
336 return *X == *Y;
337 return X.hasValue() == Y.hasValue();
338}
339
340template <typename T, typename U>
341constexpr bool operator!=(const Optional<T> &X, const Optional<U> &Y) {
342 return !(X == Y);
343}
344
345template <typename T, typename U>
346constexpr bool operator<(const Optional<T> &X, const Optional<U> &Y) {
347 if (X && Y)
348 return *X < *Y;
349 return X.hasValue() < Y.hasValue();
350}
351
352template <typename T, typename U>
353constexpr bool operator<=(const Optional<T> &X, const Optional<U> &Y) {
354 return !(Y < X);
355}
356
357template <typename T, typename U>
358constexpr bool operator>(const Optional<T> &X, const Optional<U> &Y) {
359 return Y < X;
360}
361
362template <typename T, typename U>
363constexpr bool operator>=(const Optional<T> &X, const Optional<U> &Y) {
364 return !(X < Y);
365}
366
367template <typename T>
368constexpr bool operator==(const Optional<T> &X, NoneType) {
369 return !X;
370}
371
372template <typename T>
373constexpr bool operator==(NoneType, const Optional<T> &X) {
374 return X == None;
375}
376
377template <typename T>
378constexpr bool operator!=(const Optional<T> &X, NoneType) {
379 return !(X == None);
380}
381
382template <typename T>
383constexpr bool operator!=(NoneType, const Optional<T> &X) {
384 return X != None;
385}
386
387template <typename T> constexpr bool operator<(const Optional<T> &, NoneType) {
388 return false;
389}
390
391template <typename T> constexpr bool operator<(NoneType, const Optional<T> &X) {
392 return X.hasValue();
393}
394
395template <typename T>
396constexpr bool operator<=(const Optional<T> &X, NoneType) {
397 return !(None < X);
398}
399
400template <typename T>
401constexpr bool operator<=(NoneType, const Optional<T> &X) {
402 return !(X < None);
403}
404
405template <typename T> constexpr bool operator>(const Optional<T> &X, NoneType) {
406 return None < X;
407}
408
409template <typename T> constexpr bool operator>(NoneType, const Optional<T> &X) {
410 return X < None;
411}
412
413template <typename T>
414constexpr bool operator>=(const Optional<T> &X, NoneType) {
415 return None <= X;
416}
417
418template <typename T>
419constexpr bool operator>=(NoneType, const Optional<T> &X) {
420 return X <= None;
421}
422
423template <typename T>
424constexpr bool operator==(const Optional<T> &X, const T &Y) {
425 return X && *X == Y;
426}
427
428template <typename T>
429constexpr bool operator==(const T &X, const Optional<T> &Y) {
430 return Y && X == *Y;
431}
432
433template <typename T>
434constexpr bool operator!=(const Optional<T> &X, const T &Y) {
435 return !(X == Y);
436}
437
438template <typename T>
439constexpr bool operator!=(const T &X, const Optional<T> &Y) {
440 return !(X == Y);
441}
442
443template <typename T>
444constexpr bool operator<(const Optional<T> &X, const T &Y) {
445 return !X || *X < Y;
446}
447
448template <typename T>
449constexpr bool operator<(const T &X, const Optional<T> &Y) {
450 return Y && X < *Y;
451}
452
453template <typename T>
454constexpr bool operator<=(const Optional<T> &X, const T &Y) {
455 return !(Y < X);
456}
457
458template <typename T>
459constexpr bool operator<=(const T &X, const Optional<T> &Y) {
460 return !(Y < X);
461}
462
463template <typename T>
464constexpr bool operator>(const Optional<T> &X, const T &Y) {
465 return Y < X;
466}
467
468template <typename T>
469constexpr bool operator>(const T &X, const Optional<T> &Y) {
470 return Y < X;
471}
472
473template <typename T>
474constexpr bool operator>=(const Optional<T> &X, const T &Y) {
475 return !(X < Y);
476}
477
478template <typename T>
479constexpr bool operator>=(const T &X, const Optional<T> &Y) {
480 return !(X < Y);
481}
482
483raw_ostream &operator<<(raw_ostream &OS, NoneType);
484
485template <typename T, typename = decltype(std::declval<raw_ostream &>()
486 << std::declval<const T &>())>
487raw_ostream &operator<<(raw_ostream &OS, const Optional<T> &O) {
488 if (O)
489 OS << *O;
490 else
491 OS << None;
492 return OS;
493}
494
495} // end namespace llvm
496
497#endif // LLVM_ADT_OPTIONAL_H

/build/llvm-toolchain-snapshot-14~++20220119111520+da61cb019eb2/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);
24
Calling 'BoundNodesMap::getNodeAs'
31
Returning from 'BoundNodesMap::getNodeAs'
32
Returning null pointer, which participates in a condition later
36
Calling 'BoundNodesMap::getNodeAs'
51
Returning from 'BoundNodesMap::getNodeAs'
52
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;
4261/// static int y;
4262/// }
4263/// static int z;
4264/// \endcode
4265AST_MATCHER(VarDecl, isStaticLocal)namespace internal { class matcher_isStaticLocalMatcher : public
::clang::ast_matchers::internal::MatcherInterface<VarDecl
> { public: explicit matcher_isStaticLocalMatcher() = 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> isStaticLocal
() { return ::clang::ast_matchers::internal::makeMatcher( new
internal::matcher_isStaticLocalMatcher()); } inline bool internal
::matcher_isStaticLocalMatcher::matches( const VarDecl &Node
, ::clang::ast_matchers::internal::ASTMatchFinder *Finder, ::
clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder
) const
{
4266 return Node.isStaticLocal();
4267}
4268
4269/// Matches a variable declaration that has function scope and is a
4270/// non-static local variable.
4271///
4272/// Example matches x (matcher = varDecl(hasLocalStorage())
4273/// \code
4274/// void f() {
4275/// int x;
4276/// static int y;
4277/// }
4278/// int z;
4279/// \endcode
4280AST_MATCHER(VarDecl, hasLocalStorage)namespace internal { class matcher_hasLocalStorageMatcher : public
::clang::ast_matchers::internal::MatcherInterface<VarDecl
> { public: explicit matcher_hasLocalStorageMatcher() = 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> hasLocalStorage
() { return ::clang::ast_matchers::internal::makeMatcher( new
internal::matcher_hasLocalStorageMatcher()); } inline bool internal
::matcher_hasLocalStorageMatcher::matches( const VarDecl &
Node, ::clang::ast_matchers::internal::ASTMatchFinder *Finder
, ::clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder
) const
{
4281 return Node.hasLocalStorage();
4282}
4283
4284/// Matches a variable declaration that does not have local storage.
4285///
4286/// Example matches y and z (matcher = varDecl(hasGlobalStorage())
4287/// \code
4288/// void f() {
4289/// int x;
4290/// static int y;
4291/// }
4292/// int z;
4293/// \endcode
4294AST_MATCHER(VarDecl, hasGlobalStorage)namespace internal { class matcher_hasGlobalStorageMatcher : public
::clang::ast_matchers::internal::MatcherInterface<VarDecl
> { public: explicit matcher_hasGlobalStorageMatcher() = 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> hasGlobalStorage
() { return ::clang::ast_matchers::internal::makeMatcher( new
internal::matcher_hasGlobalStorageMatcher()); } inline bool internal
::matcher_hasGlobalStorageMatcher::matches( const VarDecl &
Node, ::clang::ast_matchers::internal::ASTMatchFinder *Finder
, ::clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder
) const
{
4295 return Node.hasGlobalStorage();
4296}
4297
4298/// Matches a variable declaration that has automatic storage duration.
4299///
4300/// Example matches x, but not y, z, or a.
4301/// (matcher = varDecl(hasAutomaticStorageDuration())
4302/// \code
4303/// void f() {
4304/// int x;
4305/// static int y;
4306/// thread_local int z;
4307/// }
4308/// int a;
4309/// \endcode
4310AST_MATCHER(VarDecl, hasAutomaticStorageDuration)namespace internal { class matcher_hasAutomaticStorageDurationMatcher
: public ::clang::ast_matchers::internal::MatcherInterface<
VarDecl> { public: explicit matcher_hasAutomaticStorageDurationMatcher
() = 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
> hasAutomaticStorageDuration() { return ::clang::ast_matchers
::internal::makeMatcher( new internal::matcher_hasAutomaticStorageDurationMatcher
()); } inline bool internal::matcher_hasAutomaticStorageDurationMatcher
::matches( const VarDecl &Node, ::clang::ast_matchers::internal
::ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
4311 return Node.getStorageDuration() == SD_Automatic;
4312}
4313
4314/// Matches a variable declaration that has static storage duration.
4315/// It includes the variable declared at namespace scope and those declared
4316/// with "static" and "extern" storage class specifiers.
4317///
4318/// \code
4319/// void f() {
4320/// int x;
4321/// static int y;
4322/// thread_local int z;
4323/// }
4324/// int a;
4325/// static int b;
4326/// extern int c;
4327/// varDecl(hasStaticStorageDuration())
4328/// matches the function declaration y, a, b and c.
4329/// \endcode
4330AST_MATCHER(VarDecl, hasStaticStorageDuration)namespace internal { class matcher_hasStaticStorageDurationMatcher
: public ::clang::ast_matchers::internal::MatcherInterface<
VarDecl> { public: explicit matcher_hasStaticStorageDurationMatcher
() = 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
> hasStaticStorageDuration() { return ::clang::ast_matchers
::internal::makeMatcher( new internal::matcher_hasStaticStorageDurationMatcher
()); } inline bool internal::matcher_hasStaticStorageDurationMatcher
::matches( const VarDecl &Node, ::clang::ast_matchers::internal
::ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
4331 return Node.getStorageDuration() == SD_Static;
4332}
4333
4334/// Matches a variable declaration that has thread storage duration.
4335///
4336/// Example matches z, but not x, z, or a.
4337/// (matcher = varDecl(hasThreadStorageDuration())
4338/// \code
4339/// void f() {
4340/// int x;
4341/// static int y;
4342/// thread_local int z;
4343/// }
4344/// int a;
4345/// \endcode
4346AST_MATCHER(VarDecl, hasThreadStorageDuration)namespace internal { class matcher_hasThreadStorageDurationMatcher
: public ::clang::ast_matchers::internal::MatcherInterface<
VarDecl> { public: explicit matcher_hasThreadStorageDurationMatcher
() = 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
> hasThreadStorageDuration() { return ::clang::ast_matchers
::internal::makeMatcher( new internal::matcher_hasThreadStorageDurationMatcher
()); } inline bool internal::matcher_hasThreadStorageDurationMatcher
::matches( const VarDecl &Node, ::clang::ast_matchers::internal
::ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
4347 return Node.getStorageDuration() == SD_Thread;
4348}
4349
4350/// Matches a variable declaration that is an exception variable from
4351/// a C++ catch block, or an Objective-C \@catch statement.
4352///
4353/// Example matches x (matcher = varDecl(isExceptionVariable())
4354/// \code
4355/// void f(int y) {
4356/// try {
4357/// } catch (int x) {
4358/// }
4359/// }
4360/// \endcode
4361AST_MATCHER(VarDecl, isExceptionVariable)namespace internal { class matcher_isExceptionVariableMatcher
: public ::clang::ast_matchers::internal::MatcherInterface<
VarDecl> { public: explicit matcher_isExceptionVariableMatcher
() = 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
> isExceptionVariable() { return ::clang::ast_matchers::internal
::makeMatcher( new internal::matcher_isExceptionVariableMatcher
()); } inline bool internal::matcher_isExceptionVariableMatcher
::matches( const VarDecl &Node, ::clang::ast_matchers::internal
::ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
4362 return Node.isExceptionVariable();
4363}
4364
4365/// Checks that a call expression or a constructor call expression has
4366/// a specific number of arguments (including absent default arguments).
4367///
4368/// Example matches f(0, 0) (matcher = callExpr(argumentCountIs(2)))
4369/// \code
4370/// void f(int x, int y);
4371/// f(0, 0);
4372/// \endcode
4373AST_POLYMORPHIC_MATCHER_P(argumentCountIs,namespace internal { template <typename NodeType, typename
ParamT> class matcher_argumentCountIs0Matcher : public ::
clang::ast_matchers::internal::MatcherInterface<NodeType>
{ public: explicit matcher_argumentCountIs0Matcher( 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_argumentCountIs0Matcher
, void(::clang::ast_matchers::internal::TypeList<CallExpr,
CXXConstructExpr, CXXUnresolvedConstructExpr, ObjCMessageExpr
>), unsigned> argumentCountIs(unsigned const &N) { return
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_argumentCountIs0Matcher, void(::clang::ast_matchers
::internal::TypeList<CallExpr, CXXConstructExpr, CXXUnresolvedConstructExpr
, ObjCMessageExpr>), unsigned>(N); } typedef ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_argumentCountIs0Matcher
, void(::clang::ast_matchers::internal::TypeList<CallExpr,
CXXConstructExpr, CXXUnresolvedConstructExpr, ObjCMessageExpr
>), unsigned> (&argumentCountIs_Type0)(unsigned const
&N); template <typename NodeType, typename ParamT>
bool internal:: matcher_argumentCountIs0Matcher<NodeType,
ParamT>::matches( const NodeType &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
4374 AST_POLYMORPHIC_SUPPORTED_TYPES(namespace internal { template <typename NodeType, typename
ParamT> class matcher_argumentCountIs0Matcher : public ::
clang::ast_matchers::internal::MatcherInterface<NodeType>
{ public: explicit matcher_argumentCountIs0Matcher( 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_argumentCountIs0Matcher
, void(::clang::ast_matchers::internal::TypeList<CallExpr,
CXXConstructExpr, CXXUnresolvedConstructExpr, ObjCMessageExpr
>), unsigned> argumentCountIs(unsigned const &N) { return
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_argumentCountIs0Matcher, void(::clang::ast_matchers
::internal::TypeList<CallExpr, CXXConstructExpr, CXXUnresolvedConstructExpr
, ObjCMessageExpr>), unsigned>(N); } typedef ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_argumentCountIs0Matcher
, void(::clang::ast_matchers::internal::TypeList<CallExpr,
CXXConstructExpr, CXXUnresolvedConstructExpr, ObjCMessageExpr
>), unsigned> (&argumentCountIs_Type0)(unsigned const
&N); template <typename NodeType, typename ParamT>
bool internal:: matcher_argumentCountIs0Matcher<NodeType,
ParamT>::matches( const NodeType &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
4375 CallExpr, CXXConstructExpr,namespace internal { template <typename NodeType, typename
ParamT> class matcher_argumentCountIs0Matcher : public ::
clang::ast_matchers::internal::MatcherInterface<NodeType>
{ public: explicit matcher_argumentCountIs0Matcher( 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_argumentCountIs0Matcher
, void(::clang::ast_matchers::internal::TypeList<CallExpr,
CXXConstructExpr, CXXUnresolvedConstructExpr, ObjCMessageExpr
>), unsigned> argumentCountIs(unsigned const &N) { return
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_argumentCountIs0Matcher, void(::clang::ast_matchers
::internal::TypeList<CallExpr, CXXConstructExpr, CXXUnresolvedConstructExpr
, ObjCMessageExpr>), unsigned>(N); } typedef ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_argumentCountIs0Matcher
, void(::clang::ast_matchers::internal::TypeList<CallExpr,
CXXConstructExpr, CXXUnresolvedConstructExpr, ObjCMessageExpr
>), unsigned> (&argumentCountIs_Type0)(unsigned const
&N); template <typename NodeType, typename ParamT>
bool internal:: matcher_argumentCountIs0Matcher<NodeType,
ParamT>::matches( const NodeType &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
4376 CXXUnresolvedConstructExpr, ObjCMessageExpr),namespace internal { template <typename NodeType, typename
ParamT> class matcher_argumentCountIs0Matcher : public ::
clang::ast_matchers::internal::MatcherInterface<NodeType>
{ public: explicit matcher_argumentCountIs0Matcher( 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_argumentCountIs0Matcher
, void(::clang::ast_matchers::internal::TypeList<CallExpr,
CXXConstructExpr, CXXUnresolvedConstructExpr, ObjCMessageExpr
>), unsigned> argumentCountIs(unsigned const &N) { return
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_argumentCountIs0Matcher, void(::clang::ast_matchers
::internal::TypeList<CallExpr, CXXConstructExpr, CXXUnresolvedConstructExpr
, ObjCMessageExpr>), unsigned>(N); } typedef ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_argumentCountIs0Matcher
, void(::clang::ast_matchers::internal::TypeList<CallExpr,
CXXConstructExpr, CXXUnresolvedConstructExpr, ObjCMessageExpr
>), unsigned> (&argumentCountIs_Type0)(unsigned const
&N); template <typename NodeType, typename ParamT>
bool internal:: matcher_argumentCountIs0Matcher<NodeType,
ParamT>::matches( const NodeType &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
4377 unsigned, N)namespace internal { template <typename NodeType, typename
ParamT> class matcher_argumentCountIs0Matcher : public ::
clang::ast_matchers::internal::MatcherInterface<NodeType>
{ public: explicit matcher_argumentCountIs0Matcher( 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_argumentCountIs0Matcher
, void(::clang::ast_matchers::internal::TypeList<CallExpr,
CXXConstructExpr, CXXUnresolvedConstructExpr, ObjCMessageExpr
>), unsigned> argumentCountIs(unsigned const &N) { return
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_argumentCountIs0Matcher, void(::clang::ast_matchers
::internal::TypeList<CallExpr, CXXConstructExpr, CXXUnresolvedConstructExpr
, ObjCMessageExpr>), unsigned>(N); } typedef ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_argumentCountIs0Matcher
, void(::clang::ast_matchers::internal::TypeList<CallExpr,
CXXConstructExpr, CXXUnresolvedConstructExpr, ObjCMessageExpr
>), unsigned> (&argumentCountIs_Type0)(unsigned const
&N); template <typename NodeType, typename ParamT>
bool internal:: matcher_argumentCountIs0Matcher<NodeType,
ParamT>::matches( const NodeType &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
{
4378 unsigned NumArgs = Node.getNumArgs();
4379 if (!Finder->isTraversalIgnoringImplicitNodes())
4380 return NumArgs == N;
4381 while (NumArgs) {
4382 if (!isa<CXXDefaultArgExpr>(Node.getArg(NumArgs - 1)))
4383 break;
4384 --NumArgs;
4385 }
4386 return NumArgs == N;
4387}
4388
4389/// Matches the n'th argument of a call expression or a constructor
4390/// call expression.
4391///
4392/// Example matches y in x(y)
4393/// (matcher = callExpr(hasArgument(0, declRefExpr())))
4394/// \code
4395/// void x(int) { int y; x(y); }
4396/// \endcode
4397AST_POLYMORPHIC_MATCHER_P2(hasArgument,namespace internal { template <typename NodeType, typename
ParamT1, typename ParamT2> class matcher_hasArgument0Matcher
: public ::clang::ast_matchers::internal::MatcherInterface<
NodeType> { public: matcher_hasArgument0Matcher(unsigned const
&AN, internal::Matcher<Expr> 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
<Expr> InnerMatcher; }; } inline ::clang::ast_matchers::
internal::PolymorphicMatcher< internal::matcher_hasArgument0Matcher
, void(::clang::ast_matchers::internal::TypeList<CallExpr,
CXXConstructExpr, CXXUnresolvedConstructExpr, ObjCMessageExpr
>), unsigned, internal::Matcher<Expr> > hasArgument
(unsigned const &N, internal::Matcher<Expr> const &
InnerMatcher) { return ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_hasArgument0Matcher, void(::clang::ast_matchers
::internal::TypeList<CallExpr, CXXConstructExpr, CXXUnresolvedConstructExpr
, ObjCMessageExpr>), unsigned, internal::Matcher<Expr>
>(N, InnerMatcher); } typedef ::clang::ast_matchers::internal
::PolymorphicMatcher< internal::matcher_hasArgument0Matcher
, void(::clang::ast_matchers::internal::TypeList<CallExpr,
CXXConstructExpr, CXXUnresolvedConstructExpr, ObjCMessageExpr
>), unsigned, internal::Matcher<Expr> > (&hasArgument_Type0
)( unsigned const &N, internal::Matcher<Expr> const
&InnerMatcher); template <typename NodeType, typename
ParamT1, typename ParamT2> bool internal::matcher_hasArgument0Matcher
< NodeType, ParamT1, ParamT2>:: matches(const NodeType &
Node, ::clang::ast_matchers::internal::ASTMatchFinder *Finder
, ::clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder
) const
4398 AST_POLYMORPHIC_SUPPORTED_TYPES(namespace internal { template <typename NodeType, typename
ParamT1, typename ParamT2> class matcher_hasArgument0Matcher
: public ::clang::ast_matchers::internal::MatcherInterface<
NodeType> { public: matcher_hasArgument0Matcher(unsigned const
&AN, internal::Matcher<Expr> 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
<Expr> InnerMatcher; }; } inline ::clang::ast_matchers::
internal::PolymorphicMatcher< internal::matcher_hasArgument0Matcher
, void(::clang::ast_matchers::internal::TypeList<CallExpr,
CXXConstructExpr, CXXUnresolvedConstructExpr, ObjCMessageExpr
>), unsigned, internal::Matcher<Expr> > hasArgument
(unsigned const &N, internal::Matcher<Expr> const &
InnerMatcher) { return ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_hasArgument0Matcher, void(::clang::ast_matchers
::internal::TypeList<CallExpr, CXXConstructExpr, CXXUnresolvedConstructExpr
, ObjCMessageExpr>), unsigned, internal::Matcher<Expr>
>(N, InnerMatcher); } typedef ::clang::ast_matchers::internal
::PolymorphicMatcher< internal::matcher_hasArgument0Matcher
, void(::clang::ast_matchers::internal::TypeList<CallExpr,
CXXConstructExpr, CXXUnresolvedConstructExpr, ObjCMessageExpr
>), unsigned, internal::Matcher<Expr> > (&hasArgument_Type0
)( unsigned const &N, internal::Matcher<Expr> const
&InnerMatcher); template <typename NodeType, typename
ParamT1, typename ParamT2> bool internal::matcher_hasArgument0Matcher
< NodeType, ParamT1, ParamT2>:: matches(const NodeType &
Node, ::clang::ast_matchers::internal::ASTMatchFinder *Finder
, ::clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder
) const
4399 CallExpr, CXXConstructExpr,namespace internal { template <typename NodeType, typename
ParamT1, typename ParamT2> class matcher_hasArgument0Matcher
: public ::clang::ast_matchers::internal::MatcherInterface<
NodeType> { public: matcher_hasArgument0Matcher(unsigned const
&AN, internal::Matcher<Expr> 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
<Expr> InnerMatcher; }; } inline ::clang::ast_matchers::
internal::PolymorphicMatcher< internal::matcher_hasArgument0Matcher
, void(::clang::ast_matchers::internal::TypeList<CallExpr,
CXXConstructExpr, CXXUnresolvedConstructExpr, ObjCMessageExpr
>), unsigned, internal::Matcher<Expr> > hasArgument
(unsigned const &N, internal::Matcher<Expr> const &
InnerMatcher) { return ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_hasArgument0Matcher, void(::clang::ast_matchers
::internal::TypeList<CallExpr, CXXConstructExpr, CXXUnresolvedConstructExpr
, ObjCMessageExpr>), unsigned, internal::Matcher<Expr>
>(N, InnerMatcher); } typedef ::clang::ast_matchers::internal
::PolymorphicMatcher< internal::matcher_hasArgument0Matcher
, void(::clang::ast_matchers::internal::TypeList<CallExpr,
CXXConstructExpr, CXXUnresolvedConstructExpr, ObjCMessageExpr
>), unsigned, internal::Matcher<Expr> > (&hasArgument_Type0
)( unsigned const &N, internal::Matcher<Expr> const
&InnerMatcher); template <typename NodeType, typename
ParamT1, typename ParamT2> bool internal::matcher_hasArgument0Matcher
< NodeType, ParamT1, ParamT2>:: matches(const NodeType &
Node, ::clang::ast_matchers::internal::ASTMatchFinder *Finder
, ::clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder
) const
4400 CXXUnresolvedConstructExpr, ObjCMessageExpr),namespace internal { template <typename NodeType, typename
ParamT1, typename ParamT2> class matcher_hasArgument0Matcher
: public ::clang::ast_matchers::internal::MatcherInterface<
NodeType> { public: matcher_hasArgument0Matcher(unsigned const
&AN, internal::Matcher<Expr> 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
<Expr> InnerMatcher; }; } inline ::clang::ast_matchers::
internal::PolymorphicMatcher< internal::matcher_hasArgument0Matcher
, void(::clang::ast_matchers::internal::TypeList<CallExpr,
CXXConstructExpr, CXXUnresolvedConstructExpr, ObjCMessageExpr
>), unsigned, internal::Matcher<Expr> > hasArgument
(unsigned const &N, internal::Matcher<Expr> const &
InnerMatcher) { return ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_hasArgument0Matcher, void(::clang::ast_matchers
::internal::TypeList<CallExpr, CXXConstructExpr, CXXUnresolvedConstructExpr
, ObjCMessageExpr>), unsigned, internal::Matcher<Expr>
>(N, InnerMatcher); } typedef ::clang::ast_matchers::internal
::PolymorphicMatcher< internal::matcher_hasArgument0Matcher
, void(::clang::ast_matchers::internal::TypeList<CallExpr,
CXXConstructExpr, CXXUnresolvedConstructExpr, ObjCMessageExpr
>), unsigned, internal::Matcher<Expr> > (&hasArgument_Type0
)( unsigned const &N, internal::Matcher<Expr> const
&InnerMatcher); template <typename NodeType, typename
ParamT1, typename ParamT2> bool internal::matcher_hasArgument0Matcher
< NodeType, ParamT1, ParamT2>:: matches(const NodeType &
Node, ::clang::ast_matchers::internal::ASTMatchFinder *Finder
, ::clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder
) const
4401 unsigned, N, internal::Matcher<Expr>, InnerMatcher)namespace internal { template <typename NodeType, typename
ParamT1, typename ParamT2> class matcher_hasArgument0Matcher
: public ::clang::ast_matchers::internal::MatcherInterface<
NodeType> { public: matcher_hasArgument0Matcher(unsigned const
&AN, internal::Matcher<Expr> 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
<Expr> InnerMatcher; }; } inline ::clang::ast_matchers::
internal::PolymorphicMatcher< internal::matcher_hasArgument0Matcher
, void(::clang::ast_matchers::internal::TypeList<CallExpr,
CXXConstructExpr, CXXUnresolvedConstructExpr, ObjCMessageExpr
>), unsigned, internal::Matcher<Expr> > hasArgument
(unsigned const &N, internal::Matcher<Expr> const &
InnerMatcher) { return ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_hasArgument0Matcher, void(::clang::ast_matchers
::internal::TypeList<CallExpr, CXXConstructExpr, CXXUnresolvedConstructExpr
, ObjCMessageExpr>), unsigned, internal::Matcher<Expr>
>(N, InnerMatcher); } typedef ::clang::ast_matchers::internal
::PolymorphicMatcher< internal::matcher_hasArgument0Matcher
, void(::clang::ast_matchers::internal::TypeList<CallExpr,
CXXConstructExpr, CXXUnresolvedConstructExpr, ObjCMessageExpr
>), unsigned, internal::Matcher<Expr> > (&hasArgument_Type0
)( unsigned const &N, internal::Matcher<Expr> const
&InnerMatcher); template <typename NodeType, typename
ParamT1, typename ParamT2> bool internal::matcher_hasArgument0Matcher
< NodeType, ParamT1, ParamT2>:: matches(const NodeType &
Node, ::clang::ast_matchers::internal::ASTMatchFinder *Finder
, ::clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder
) const
{
4402 if (N >= Node.getNumArgs())
4403 return false;
4404 const Expr *Arg = Node.getArg(N);
4405 if (Finder->isTraversalIgnoringImplicitNodes() && isa<CXXDefaultArgExpr>(Arg))
4406 return false;
4407 return InnerMatcher.matches(*Arg->IgnoreParenImpCasts(), Finder, Builder);
4408}
4409
4410/// Matches the n'th item of an initializer list expression.
4411///
4412/// Example matches y.
4413/// (matcher = initListExpr(hasInit(0, expr())))
4414/// \code
4415/// int x{y}.
4416/// \endcode
4417AST_MATCHER_P2(InitListExpr, hasInit, unsigned, N,namespace internal { class matcher_hasInit0Matcher : public ::
clang::ast_matchers::internal::MatcherInterface<InitListExpr
> { public: matcher_hasInit0Matcher(unsigned const &AN
, ast_matchers::internal::Matcher<Expr> const &AInnerMatcher
) : N(AN), InnerMatcher(AInnerMatcher) {} bool matches(const InitListExpr
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: unsigned N; ast_matchers::
internal::Matcher<Expr> InnerMatcher; }; } inline ::clang
::ast_matchers::internal::Matcher<InitListExpr> hasInit
( unsigned const &N, ast_matchers::internal::Matcher<Expr
> const &InnerMatcher) { return ::clang::ast_matchers::
internal::makeMatcher( new internal::matcher_hasInit0Matcher(
N, InnerMatcher)); } typedef ::clang::ast_matchers::internal::
Matcher<InitListExpr> ( &hasInit_Type0)(unsigned const
&N, ast_matchers::internal::Matcher<Expr> const &
InnerMatcher); inline bool internal::matcher_hasInit0Matcher::
matches( const InitListExpr &Node, ::clang::ast_matchers::
internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
4418 ast_matchers::internal::Matcher<Expr>, InnerMatcher)namespace internal { class matcher_hasInit0Matcher : public ::
clang::ast_matchers::internal::MatcherInterface<InitListExpr
> { public: matcher_hasInit0Matcher(unsigned const &AN
, ast_matchers::internal::Matcher<Expr> const &AInnerMatcher
) : N(AN), InnerMatcher(AInnerMatcher) {} bool matches(const InitListExpr
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: unsigned N; ast_matchers::
internal::Matcher<Expr> InnerMatcher; }; } inline ::clang
::ast_matchers::internal::Matcher<InitListExpr> hasInit
( unsigned const &N, ast_matchers::internal::Matcher<Expr
> const &InnerMatcher) { return ::clang::ast_matchers::
internal::makeMatcher( new internal::matcher_hasInit0Matcher(
N, InnerMatcher)); } typedef ::clang::ast_matchers::internal::
Matcher<InitListExpr> ( &hasInit_Type0)(unsigned const
&N, ast_matchers::internal::Matcher<Expr> const &
InnerMatcher); inline bool internal::matcher_hasInit0Matcher::
matches( const InitListExpr &Node, ::clang::ast_matchers::
internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
{
4419 return N < Node.getNumInits() &&
4420 InnerMatcher.matches(*Node.getInit(N), Finder, Builder);
4421}
4422
4423/// Matches declaration statements that contain a specific number of
4424/// declarations.
4425///
4426/// Example: Given
4427/// \code
4428/// int a, b;
4429/// int c;
4430/// int d = 2, e;
4431/// \endcode
4432/// declCountIs(2)
4433/// matches 'int a, b;' and 'int d = 2, e;', but not 'int c;'.
4434AST_MATCHER_P(DeclStmt, declCountIs, unsigned, N)namespace internal { class matcher_declCountIs0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<DeclStmt
> { public: explicit matcher_declCountIs0Matcher( unsigned
const &AN) : N(AN) {} bool matches(const DeclStmt &Node
, ::clang::ast_matchers::internal::ASTMatchFinder *Finder, ::
clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder
) const override; private: unsigned N; }; } inline ::clang::ast_matchers
::internal::Matcher<DeclStmt> declCountIs( unsigned const
&N) { return ::clang::ast_matchers::internal::makeMatcher
( new internal::matcher_declCountIs0Matcher(N)); } typedef ::
clang::ast_matchers::internal::Matcher<DeclStmt> ( &
declCountIs_Type0)(unsigned const &N); inline bool internal
::matcher_declCountIs0Matcher::matches( const DeclStmt &Node
, ::clang::ast_matchers::internal::ASTMatchFinder *Finder, ::
clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder
) const
{
4435 return std::distance(Node.decl_begin(), Node.decl_end()) == (ptrdiff_t)N;
4436}
4437
4438/// Matches the n'th declaration of a declaration statement.
4439///
4440/// Note that this does not work for global declarations because the AST
4441/// breaks up multiple-declaration DeclStmt's into multiple single-declaration
4442/// DeclStmt's.
4443/// Example: Given non-global declarations
4444/// \code
4445/// int a, b = 0;
4446/// int c;
4447/// int d = 2, e;
4448/// \endcode
4449/// declStmt(containsDeclaration(
4450/// 0, varDecl(hasInitializer(anything()))))
4451/// matches only 'int d = 2, e;', and
4452/// declStmt(containsDeclaration(1, varDecl()))
4453/// \code
4454/// matches 'int a, b = 0' as well as 'int d = 2, e;'
4455/// but 'int c;' is not matched.
4456/// \endcode
4457AST_MATCHER_P2(DeclStmt, containsDeclaration, unsigned, N,namespace internal { class matcher_containsDeclaration0Matcher
: public ::clang::ast_matchers::internal::MatcherInterface<
DeclStmt> { public: matcher_containsDeclaration0Matcher(unsigned
const &AN, internal::Matcher<Decl> const &AInnerMatcher
) : N(AN), InnerMatcher(AInnerMatcher) {} bool matches(const DeclStmt
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: unsigned N; internal::Matcher
<Decl> InnerMatcher; }; } inline ::clang::ast_matchers::
internal::Matcher<DeclStmt> containsDeclaration( unsigned
const &N, internal::Matcher<Decl> const &InnerMatcher
) { return ::clang::ast_matchers::internal::makeMatcher( new internal
::matcher_containsDeclaration0Matcher(N, InnerMatcher)); } typedef
::clang::ast_matchers::internal::Matcher<DeclStmt> ( &
containsDeclaration_Type0)(unsigned const &N, internal::Matcher
<Decl> const &InnerMatcher); inline bool internal::
matcher_containsDeclaration0Matcher::matches( const DeclStmt &
Node, ::clang::ast_matchers::internal::ASTMatchFinder *Finder
, ::clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder
) const
4458 internal::Matcher<Decl>, InnerMatcher)namespace internal { class matcher_containsDeclaration0Matcher
: public ::clang::ast_matchers::internal::MatcherInterface<
DeclStmt> { public: matcher_containsDeclaration0Matcher(unsigned
const &AN, internal::Matcher<Decl> const &AInnerMatcher
) : N(AN), InnerMatcher(AInnerMatcher) {} bool matches(const DeclStmt
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: unsigned N; internal::Matcher
<Decl> InnerMatcher; }; } inline ::clang::ast_matchers::
internal::Matcher<DeclStmt> containsDeclaration( unsigned
const &N, internal::Matcher<Decl> const &InnerMatcher
) { return ::clang::ast_matchers::internal::makeMatcher( new internal
::matcher_containsDeclaration0Matcher(N, InnerMatcher)); } typedef
::clang::ast_matchers::internal::Matcher<DeclStmt> ( &
containsDeclaration_Type0)(unsigned const &N, internal::Matcher
<Decl> const &InnerMatcher); inline bool internal::
matcher_containsDeclaration0Matcher::matches( const DeclStmt &
Node, ::clang::ast_matchers::internal::ASTMatchFinder *Finder
, ::clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder
) const
{
4459 const unsigned NumDecls = std::distance(Node.decl_begin(), Node.decl_end());
4460 if (N >= NumDecls)
4461 return false;
4462 DeclStmt::const_decl_iterator Iterator = Node.decl_begin();
4463 std::advance(Iterator, N);
4464 return InnerMatcher.matches(**Iterator, Finder, Builder);
4465}
4466
4467/// Matches a C++ catch statement that has a catch-all handler.
4468///
4469/// Given
4470/// \code
4471/// try {
4472/// // ...
4473/// } catch (int) {
4474/// // ...
4475/// } catch (...) {
4476/// // ...
4477/// }
4478/// \endcode
4479/// cxxCatchStmt(isCatchAll()) matches catch(...) but not catch(int).
4480AST_MATCHER(CXXCatchStmt, isCatchAll)namespace internal { class matcher_isCatchAllMatcher : public
::clang::ast_matchers::internal::MatcherInterface<CXXCatchStmt
> { public: explicit matcher_isCatchAllMatcher() = default
; bool matches(const CXXCatchStmt &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const override; }; } inline
::clang::ast_matchers::internal::Matcher<CXXCatchStmt>
isCatchAll() { return ::clang::ast_matchers::internal::makeMatcher
( new internal::matcher_isCatchAllMatcher()); } inline bool internal
::matcher_isCatchAllMatcher::matches( const CXXCatchStmt &
Node, ::clang::ast_matchers::internal::ASTMatchFinder *Finder
, ::clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder
) const
{
4481 return Node.getExceptionDecl() == nullptr;
4482}
4483
4484/// Matches a constructor initializer.
4485///
4486/// Given
4487/// \code
4488/// struct Foo {
4489/// Foo() : foo_(1) { }
4490/// int foo_;
4491/// };
4492/// \endcode
4493/// cxxRecordDecl(has(cxxConstructorDecl(
4494/// hasAnyConstructorInitializer(anything())
4495/// )))
4496/// record matches Foo, hasAnyConstructorInitializer matches foo_(1)
4497AST_MATCHER_P(CXXConstructorDecl, hasAnyConstructorInitializer,namespace internal { class matcher_hasAnyConstructorInitializer0Matcher
: public ::clang::ast_matchers::internal::MatcherInterface<
CXXConstructorDecl> { public: explicit matcher_hasAnyConstructorInitializer0Matcher
( internal::Matcher<CXXCtorInitializer> const &AInnerMatcher
) : InnerMatcher(AInnerMatcher) {} bool matches(const CXXConstructorDecl
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: internal::Matcher<CXXCtorInitializer
> InnerMatcher; }; } inline ::clang::ast_matchers::internal
::Matcher<CXXConstructorDecl> hasAnyConstructorInitializer
( internal::Matcher<CXXCtorInitializer> const &InnerMatcher
) { return ::clang::ast_matchers::internal::makeMatcher( new internal
::matcher_hasAnyConstructorInitializer0Matcher(InnerMatcher))
; } typedef ::clang::ast_matchers::internal::Matcher<CXXConstructorDecl
> ( &hasAnyConstructorInitializer_Type0)(internal::Matcher
<CXXCtorInitializer> const &InnerMatcher); inline bool
internal::matcher_hasAnyConstructorInitializer0Matcher::matches
( const CXXConstructorDecl &Node, ::clang::ast_matchers::
internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
4498 internal::Matcher<CXXCtorInitializer>, InnerMatcher)namespace internal { class matcher_hasAnyConstructorInitializer0Matcher
: public ::clang::ast_matchers::internal::MatcherInterface<
CXXConstructorDecl> { public: explicit matcher_hasAnyConstructorInitializer0Matcher
( internal::Matcher<CXXCtorInitializer> const &AInnerMatcher
) : InnerMatcher(AInnerMatcher) {} bool matches(const CXXConstructorDecl
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: internal::Matcher<CXXCtorInitializer
> InnerMatcher; }; } inline ::clang::ast_matchers::internal
::Matcher<CXXConstructorDecl> hasAnyConstructorInitializer
( internal::Matcher<CXXCtorInitializer> const &InnerMatcher
) { return ::clang::ast_matchers::internal::makeMatcher( new internal
::matcher_hasAnyConstructorInitializer0Matcher(InnerMatcher))
; } typedef ::clang::ast_matchers::internal::Matcher<CXXConstructorDecl
> ( &hasAnyConstructorInitializer_Type0)(internal::Matcher
<CXXCtorInitializer> const &InnerMatcher); inline bool
internal::matcher_hasAnyConstructorInitializer0Matcher::matches
( const CXXConstructorDecl &Node, ::clang::ast_matchers::
internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
{
4499 auto MatchIt = matchesFirstInPointerRange(InnerMatcher, Node.init_begin(),
4500 Node.init_end(), Finder, Builder);
4501 if (MatchIt == Node.init_end())
4502 return false;
4503 return (*MatchIt)->isWritten() || !Finder->isTraversalIgnoringImplicitNodes();
4504}
4505
4506/// Matches the field declaration of a constructor initializer.
4507///
4508/// Given
4509/// \code
4510/// struct Foo {
4511/// Foo() : foo_(1) { }
4512/// int foo_;
4513/// };
4514/// \endcode
4515/// cxxRecordDecl(has(cxxConstructorDecl(hasAnyConstructorInitializer(
4516/// forField(hasName("foo_"))))))
4517/// matches Foo
4518/// with forField matching foo_
4519AST_MATCHER_P(CXXCtorInitializer, forField,namespace internal { class matcher_forField0Matcher : public ::
clang::ast_matchers::internal::MatcherInterface<CXXCtorInitializer
> { public: explicit matcher_forField0Matcher( internal::Matcher
<FieldDecl> const &AInnerMatcher) : InnerMatcher(AInnerMatcher
) {} bool matches(const CXXCtorInitializer &Node, ::clang
::ast_matchers::internal::ASTMatchFinder *Finder, ::clang::ast_matchers
::internal::BoundNodesTreeBuilder *Builder) const override; private
: internal::Matcher<FieldDecl> InnerMatcher; }; } inline
::clang::ast_matchers::internal::Matcher<CXXCtorInitializer
> forField( internal::Matcher<FieldDecl> const &
InnerMatcher) { return ::clang::ast_matchers::internal::makeMatcher
( new internal::matcher_forField0Matcher(InnerMatcher)); } typedef
::clang::ast_matchers::internal::Matcher<CXXCtorInitializer
> ( &forField_Type0)(internal::Matcher<FieldDecl>
const &InnerMatcher); inline bool internal::matcher_forField0Matcher
::matches( const CXXCtorInitializer &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
4520 internal::Matcher<FieldDecl>, InnerMatcher)namespace internal { class matcher_forField0Matcher : public ::
clang::ast_matchers::internal::MatcherInterface<CXXCtorInitializer
> { public: explicit matcher_forField0Matcher( internal::Matcher
<FieldDecl> const &AInnerMatcher) : InnerMatcher(AInnerMatcher
) {} bool matches(const CXXCtorInitializer &Node, ::clang
::ast_matchers::internal::ASTMatchFinder *Finder, ::clang::ast_matchers
::internal::BoundNodesTreeBuilder *Builder) const override; private
: internal::Matcher<FieldDecl> InnerMatcher; }; } inline
::clang::ast_matchers::internal::Matcher<CXXCtorInitializer
> forField( internal::Matcher<FieldDecl> const &
InnerMatcher) { return ::clang::ast_matchers::internal::makeMatcher
( new internal::matcher_forField0Matcher(InnerMatcher)); } typedef
::clang::ast_matchers::internal::Matcher<CXXCtorInitializer
> ( &forField_Type0)(internal::Matcher<FieldDecl>
const &InnerMatcher); inline bool internal::matcher_forField0Matcher
::matches( const CXXCtorInitializer &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
{
4521 const FieldDecl *NodeAsDecl = Node.getAnyMember();
4522 return (NodeAsDecl != nullptr &&
4523 InnerMatcher.matches(*NodeAsDecl, Finder, Builder));
4524}
4525
4526/// Matches the initializer expression of a constructor initializer.
4527///
4528/// Given
4529/// \code
4530/// struct Foo {
4531/// Foo() : foo_(1) { }
4532/// int foo_;
4533/// };
4534/// \endcode
4535/// cxxRecordDecl(has(cxxConstructorDecl(hasAnyConstructorInitializer(
4536/// withInitializer(integerLiteral(equals(1)))))))
4537/// matches Foo
4538/// with withInitializer matching (1)
4539AST_MATCHER_P(CXXCtorInitializer, withInitializer,namespace internal { class matcher_withInitializer0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<CXXCtorInitializer
> { public: explicit matcher_withInitializer0Matcher( internal
::Matcher<Expr> const &AInnerMatcher) : InnerMatcher
(AInnerMatcher) {} bool matches(const CXXCtorInitializer &
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<CXXCtorInitializer
> withInitializer( internal::Matcher<Expr> const &
InnerMatcher) { return ::clang::ast_matchers::internal::makeMatcher
( new internal::matcher_withInitializer0Matcher(InnerMatcher)
); } typedef ::clang::ast_matchers::internal::Matcher<CXXCtorInitializer
> ( &withInitializer_Type0)(internal::Matcher<Expr>
const &InnerMatcher); inline bool internal::matcher_withInitializer0Matcher
::matches( const CXXCtorInitializer &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
4540 internal::Matcher<Expr>, InnerMatcher)namespace internal { class matcher_withInitializer0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<CXXCtorInitializer
> { public: explicit matcher_withInitializer0Matcher( internal
::Matcher<Expr> const &AInnerMatcher) : InnerMatcher
(AInnerMatcher) {} bool matches(const CXXCtorInitializer &
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<CXXCtorInitializer
> withInitializer( internal::Matcher<Expr> const &
InnerMatcher) { return ::clang::ast_matchers::internal::makeMatcher
( new internal::matcher_withInitializer0Matcher(InnerMatcher)
); } typedef ::clang::ast_matchers::internal::Matcher<CXXCtorInitializer
> ( &withInitializer_Type0)(internal::Matcher<Expr>
const &InnerMatcher); inline bool internal::matcher_withInitializer0Matcher
::matches( const CXXCtorInitializer &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
{
4541 const Expr* NodeAsExpr = Node.getInit();
4542 return (NodeAsExpr != nullptr &&
4543 InnerMatcher.matches(*NodeAsExpr, Finder, Builder));
4544}
4545
4546/// Matches a constructor initializer if it is explicitly written in
4547/// code (as opposed to implicitly added by the compiler).
4548///
4549/// Given
4550/// \code
4551/// struct Foo {
4552/// Foo() { }
4553/// Foo(int) : foo_("A") { }
4554/// string foo_;
4555/// };
4556/// \endcode
4557/// cxxConstructorDecl(hasAnyConstructorInitializer(isWritten()))
4558/// will match Foo(int), but not Foo()
4559AST_MATCHER(CXXCtorInitializer, isWritten)namespace internal { class matcher_isWrittenMatcher : public ::
clang::ast_matchers::internal::MatcherInterface<CXXCtorInitializer
> { public: explicit matcher_isWrittenMatcher() = default;
bool matches(const CXXCtorInitializer &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const override; }; } inline
::clang::ast_matchers::internal::Matcher<CXXCtorInitializer
> isWritten() { return ::clang::ast_matchers::internal::makeMatcher
( new internal::matcher_isWrittenMatcher()); } inline bool internal
::matcher_isWrittenMatcher::matches( const CXXCtorInitializer
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
4560 return Node.isWritten();
4561}
4562
4563/// Matches a constructor initializer if it is initializing a base, as
4564/// opposed to a member.
4565///
4566/// Given
4567/// \code
4568/// struct B {};
4569/// struct D : B {
4570/// int I;
4571/// D(int i) : I(i) {}
4572/// };
4573/// struct E : B {
4574/// E() : B() {}
4575/// };
4576/// \endcode
4577/// cxxConstructorDecl(hasAnyConstructorInitializer(isBaseInitializer()))
4578/// will match E(), but not match D(int).
4579AST_MATCHER(CXXCtorInitializer, isBaseInitializer)namespace internal { class matcher_isBaseInitializerMatcher :
public ::clang::ast_matchers::internal::MatcherInterface<
CXXCtorInitializer> { public: explicit matcher_isBaseInitializerMatcher
() = default; bool matches(const CXXCtorInitializer &Node
, ::clang::ast_matchers::internal::ASTMatchFinder *Finder, ::
clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder
) const override; }; } inline ::clang::ast_matchers::internal
::Matcher<CXXCtorInitializer> isBaseInitializer() { return
::clang::ast_matchers::internal::makeMatcher( new internal::
matcher_isBaseInitializerMatcher()); } inline bool internal::
matcher_isBaseInitializerMatcher::matches( const CXXCtorInitializer
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
4580 return Node.isBaseInitializer();
4581}
4582
4583/// Matches a constructor initializer if it is initializing a member, as
4584/// opposed to a base.
4585///
4586/// Given
4587/// \code
4588/// struct B {};
4589/// struct D : B {
4590/// int I;
4591/// D(int i) : I(i) {}
4592/// };
4593/// struct E : B {
4594/// E() : B() {}
4595/// };
4596/// \endcode
4597/// cxxConstructorDecl(hasAnyConstructorInitializer(isMemberInitializer()))
4598/// will match D(int), but not match E().
4599AST_MATCHER(CXXCtorInitializer, isMemberInitializer)namespace internal { class matcher_isMemberInitializerMatcher
: public ::clang::ast_matchers::internal::MatcherInterface<
CXXCtorInitializer> { public: explicit matcher_isMemberInitializerMatcher
() = default; bool matches(const CXXCtorInitializer &Node
, ::clang::ast_matchers::internal::ASTMatchFinder *Finder, ::
clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder
) const override; }; } inline ::clang::ast_matchers::internal
::Matcher<CXXCtorInitializer> isMemberInitializer() { return
::clang::ast_matchers::internal::makeMatcher( new internal::
matcher_isMemberInitializerMatcher()); } inline bool internal
::matcher_isMemberInitializerMatcher::matches( const CXXCtorInitializer
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
4600 return Node.isMemberInitializer();
4601}
4602
4603/// Matches any argument of a call expression or a constructor call
4604/// expression, or an ObjC-message-send expression.
4605///
4606/// Given
4607/// \code
4608/// void x(int, int, int) { int y; x(1, y, 42); }
4609/// \endcode
4610/// callExpr(hasAnyArgument(declRefExpr()))
4611/// matches x(1, y, 42)
4612/// with hasAnyArgument(...)
4613/// matching y
4614///
4615/// For ObjectiveC, given
4616/// \code
4617/// @interface I - (void) f:(int) y; @end
4618/// void foo(I *i) { [i f:12]; }
4619/// \endcode
4620/// objcMessageExpr(hasAnyArgument(integerLiteral(equals(12))))
4621/// matches [i f:12]
4622AST_POLYMORPHIC_MATCHER_P(hasAnyArgument,namespace internal { template <typename NodeType, typename
ParamT> class matcher_hasAnyArgument0Matcher : public ::clang
::ast_matchers::internal::MatcherInterface<NodeType> { public
: explicit matcher_hasAnyArgument0Matcher( internal::Matcher<
Expr> 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<Expr> InnerMatcher; }; } inline ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_hasAnyArgument0Matcher
, void(::clang::ast_matchers::internal::TypeList<CallExpr,
CXXConstructExpr, CXXUnresolvedConstructExpr, ObjCMessageExpr
>), internal::Matcher<Expr> > hasAnyArgument(internal
::Matcher<Expr> const &InnerMatcher) { return ::clang
::ast_matchers::internal::PolymorphicMatcher< internal::matcher_hasAnyArgument0Matcher
, void(::clang::ast_matchers::internal::TypeList<CallExpr,
CXXConstructExpr, CXXUnresolvedConstructExpr, ObjCMessageExpr
>), internal::Matcher<Expr> >(InnerMatcher); } typedef
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_hasAnyArgument0Matcher, void(::clang::ast_matchers::
internal::TypeList<CallExpr, CXXConstructExpr, CXXUnresolvedConstructExpr
, ObjCMessageExpr>), internal::Matcher<Expr> > (&
hasAnyArgument_Type0)(internal::Matcher<Expr> const &
InnerMatcher); template <typename NodeType, typename ParamT
> bool internal:: matcher_hasAnyArgument0Matcher<NodeType
, ParamT>::matches( const NodeType &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
4623 AST_POLYMORPHIC_SUPPORTED_TYPES(namespace internal { template <typename NodeType, typename
ParamT> class matcher_hasAnyArgument0Matcher : public ::clang
::ast_matchers::internal::MatcherInterface<NodeType> { public
: explicit matcher_hasAnyArgument0Matcher( internal::Matcher<
Expr> 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<Expr> InnerMatcher; }; } inline ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_hasAnyArgument0Matcher
, void(::clang::ast_matchers::internal::TypeList<CallExpr,
CXXConstructExpr, CXXUnresolvedConstructExpr, ObjCMessageExpr
>), internal::Matcher<Expr> > hasAnyArgument(internal
::Matcher<Expr> const &InnerMatcher) { return ::clang
::ast_matchers::internal::PolymorphicMatcher< internal::matcher_hasAnyArgument0Matcher
, void(::clang::ast_matchers::internal::TypeList<CallExpr,
CXXConstructExpr, CXXUnresolvedConstructExpr, ObjCMessageExpr
>), internal::Matcher<Expr> >(InnerMatcher); } typedef
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_hasAnyArgument0Matcher, void(::clang::ast_matchers::
internal::TypeList<CallExpr, CXXConstructExpr, CXXUnresolvedConstructExpr
, ObjCMessageExpr>), internal::Matcher<Expr> > (&
hasAnyArgument_Type0)(internal::Matcher<Expr> const &
InnerMatcher); template <typename NodeType, typename ParamT
> bool internal:: matcher_hasAnyArgument0Matcher<NodeType
, ParamT>::matches( const NodeType &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
4624 CallExpr, CXXConstructExpr,namespace internal { template <typename NodeType, typename
ParamT> class matcher_hasAnyArgument0Matcher : public ::clang
::ast_matchers::internal::MatcherInterface<NodeType> { public
: explicit matcher_hasAnyArgument0Matcher( internal::Matcher<
Expr> 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<Expr> InnerMatcher; }; } inline ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_hasAnyArgument0Matcher
, void(::clang::ast_matchers::internal::TypeList<CallExpr,
CXXConstructExpr, CXXUnresolvedConstructExpr, ObjCMessageExpr
>), internal::Matcher<Expr> > hasAnyArgument(internal
::Matcher<Expr> const &InnerMatcher) { return ::clang
::ast_matchers::internal::PolymorphicMatcher< internal::matcher_hasAnyArgument0Matcher
, void(::clang::ast_matchers::internal::TypeList<CallExpr,
CXXConstructExpr, CXXUnresolvedConstructExpr, ObjCMessageExpr
>), internal::Matcher<Expr> >(InnerMatcher); } typedef
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_hasAnyArgument0Matcher, void(::clang::ast_matchers::
internal::TypeList<CallExpr, CXXConstructExpr, CXXUnresolvedConstructExpr
, ObjCMessageExpr>), internal::Matcher<Expr> > (&
hasAnyArgument_Type0)(internal::Matcher<Expr> const &
InnerMatcher); template <typename NodeType, typename ParamT
> bool internal:: matcher_hasAnyArgument0Matcher<NodeType
, ParamT>::matches( const NodeType &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
4625 CXXUnresolvedConstructExpr, ObjCMessageExpr),namespace internal { template <typename NodeType, typename
ParamT> class matcher_hasAnyArgument0Matcher : public ::clang
::ast_matchers::internal::MatcherInterface<NodeType> { public
: explicit matcher_hasAnyArgument0Matcher( internal::Matcher<
Expr> 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<Expr> InnerMatcher; }; } inline ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_hasAnyArgument0Matcher
, void(::clang::ast_matchers::internal::TypeList<CallExpr,
CXXConstructExpr, CXXUnresolvedConstructExpr, ObjCMessageExpr
>), internal::Matcher<Expr> > hasAnyArgument(internal
::Matcher<Expr> const &InnerMatcher) { return ::clang
::ast_matchers::internal::PolymorphicMatcher< internal::matcher_hasAnyArgument0Matcher
, void(::clang::ast_matchers::internal::TypeList<CallExpr,
CXXConstructExpr, CXXUnresolvedConstructExpr, ObjCMessageExpr
>), internal::Matcher<Expr> >(InnerMatcher); } typedef
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_hasAnyArgument0Matcher, void(::clang::ast_matchers::
internal::TypeList<CallExpr, CXXConstructExpr, CXXUnresolvedConstructExpr
, ObjCMessageExpr>), internal::Matcher<Expr> > (&
hasAnyArgument_Type0)(internal::Matcher<Expr> const &
InnerMatcher); template <typename NodeType, typename ParamT
> bool internal:: matcher_hasAnyArgument0Matcher<NodeType
, ParamT>::matches( const NodeType &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
4626 internal::Matcher<Expr>, InnerMatcher)namespace internal { template <typename NodeType, typename
ParamT> class matcher_hasAnyArgument0Matcher : public ::clang
::ast_matchers::internal::MatcherInterface<NodeType> { public
: explicit matcher_hasAnyArgument0Matcher( internal::Matcher<
Expr> 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<Expr> InnerMatcher; }; } inline ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_hasAnyArgument0Matcher
, void(::clang::ast_matchers::internal::TypeList<CallExpr,
CXXConstructExpr, CXXUnresolvedConstructExpr, ObjCMessageExpr
>), internal::Matcher<Expr> > hasAnyArgument(internal
::Matcher<Expr> const &InnerMatcher) { return ::clang
::ast_matchers::internal::PolymorphicMatcher< internal::matcher_hasAnyArgument0Matcher
, void(::clang::ast_matchers::internal::TypeList<CallExpr,
CXXConstructExpr, CXXUnresolvedConstructExpr, ObjCMessageExpr
>), internal::Matcher<Expr> >(InnerMatcher); } typedef
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_hasAnyArgument0Matcher, void(::clang::ast_matchers::
internal::TypeList<CallExpr, CXXConstructExpr, CXXUnresolvedConstructExpr
, ObjCMessageExpr>), internal::Matcher<Expr> > (&
hasAnyArgument_Type0)(internal::Matcher<Expr> const &
InnerMatcher); template <typename NodeType, typename ParamT
> bool internal:: matcher_hasAnyArgument0Matcher<NodeType
, ParamT>::matches( const NodeType &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
{
4627 for (const Expr *Arg : Node.arguments()) {
4628 if (Finder->isTraversalIgnoringImplicitNodes() &&
4629 isa<CXXDefaultArgExpr>(Arg))
4630 break;
4631 BoundNodesTreeBuilder Result(*Builder);
4632 if (InnerMatcher.matches(*Arg, Finder, &Result)) {
4633 *Builder = std::move(Result);
4634 return true;
4635 }
4636 }
4637 return false;
4638}
4639
4640/// Matches lambda captures.
4641///
4642/// Given
4643/// \code
4644/// int main() {
4645/// int x;
4646/// auto f = [x](){};
4647/// auto g = [x = 1](){};
4648/// }
4649/// \endcode
4650/// In the matcher `lambdaExpr(hasAnyCapture(lambdaCapture()))`,
4651/// `lambdaCapture()` matches `x` and `x=1`.
4652extern const internal::VariadicAllOfMatcher<LambdaCapture> lambdaCapture;
4653
4654/// Matches any capture in a lambda expression.
4655///
4656/// Given
4657/// \code
4658/// void foo() {
4659/// int t = 5;
4660/// auto f = [=](){ return t; };
4661/// }
4662/// \endcode
4663/// lambdaExpr(hasAnyCapture(lambdaCapture())) and
4664/// lambdaExpr(hasAnyCapture(lambdaCapture(refersToVarDecl(hasName("t")))))
4665/// both match `[=](){ return t; }`.
4666AST_MATCHER_P(LambdaExpr, hasAnyCapture, internal::Matcher<LambdaCapture>,namespace internal { class matcher_hasAnyCapture0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<LambdaExpr
> { public: explicit matcher_hasAnyCapture0Matcher( 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
> hasAnyCapture( internal::Matcher<LambdaCapture> const
&InnerMatcher) { return ::clang::ast_matchers::internal::
makeMatcher( new internal::matcher_hasAnyCapture0Matcher(InnerMatcher
)); } typedef ::clang::ast_matchers::internal::Matcher<LambdaExpr
> ( &hasAnyCapture_Type0)(internal::Matcher<LambdaCapture
> const &InnerMatcher); inline bool internal::matcher_hasAnyCapture0Matcher
::matches( const LambdaExpr &Node, ::clang::ast_matchers::
internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
4667 InnerMatcher)namespace internal { class matcher_hasAnyCapture0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<LambdaExpr
> { public: explicit matcher_hasAnyCapture0Matcher( 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
> hasAnyCapture( internal::Matcher<LambdaCapture> const
&InnerMatcher) { return ::clang::ast_matchers::internal::
makeMatcher( new internal::matcher_hasAnyCapture0Matcher(InnerMatcher
)); } typedef ::clang::ast_matchers::internal::Matcher<LambdaExpr
> ( &hasAnyCapture_Type0)(internal::Matcher<LambdaCapture
> const &InnerMatcher); inline bool internal::matcher_hasAnyCapture0Matcher
::matches( const LambdaExpr &Node, ::clang::ast_matchers::
internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
{
4668 for (const LambdaCapture &Capture : Node.captures()) {
4669 clang::ast_matchers::internal::BoundNodesTreeBuilder Result(*Builder);
4670 if (InnerMatcher.matches(Capture, Finder, &Result)) {
4671 *Builder = std::move(Result);
4672 return true;
4673 }
4674 }
4675 return false;
4676}
4677
4678/// Matches a `LambdaCapture` that refers to the specified `VarDecl`. The
4679/// `VarDecl` can be a separate variable that is captured by value or
4680/// reference, or a synthesized variable if the capture has an initializer.
4681///
4682/// Given
4683/// \code
4684/// void foo() {
4685/// int x;
4686/// auto f = [x](){};
4687/// auto g = [x = 1](){};
4688/// }
4689/// \endcode
4690/// In the matcher
4691/// lambdaExpr(hasAnyCapture(lambdaCapture(capturesVar(hasName("x")))),
4692/// capturesVar(hasName("x")) matches `x` and `x = 1`.
4693AST_MATCHER_P(LambdaCapture, capturesVar, internal::Matcher<VarDecl>,namespace internal { class matcher_capturesVar0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<LambdaCapture
> { public: explicit matcher_capturesVar0Matcher( internal
::Matcher<VarDecl> const &AInnerMatcher) : InnerMatcher
(AInnerMatcher) {} bool matches(const LambdaCapture &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<LambdaCapture
> capturesVar( internal::Matcher<VarDecl> const &
InnerMatcher) { return ::clang::ast_matchers::internal::makeMatcher
( new internal::matcher_capturesVar0Matcher(InnerMatcher)); }
typedef ::clang::ast_matchers::internal::Matcher<LambdaCapture
> ( &capturesVar_Type0)(internal::Matcher<VarDecl>
const &InnerMatcher); inline bool internal::matcher_capturesVar0Matcher
::matches( const LambdaCapture &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
4694 InnerMatcher)namespace internal { class matcher_capturesVar0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<LambdaCapture
> { public: explicit matcher_capturesVar0Matcher( internal
::Matcher<VarDecl> const &AInnerMatcher) : InnerMatcher
(AInnerMatcher) {} bool matches(const LambdaCapture &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<LambdaCapture
> capturesVar( internal::Matcher<VarDecl> const &
InnerMatcher) { return ::clang::ast_matchers::internal::makeMatcher
( new internal::matcher_capturesVar0Matcher(InnerMatcher)); }
typedef ::clang::ast_matchers::internal::Matcher<LambdaCapture
> ( &capturesVar_Type0)(internal::Matcher<VarDecl>
const &InnerMatcher); inline bool internal::matcher_capturesVar0Matcher
::matches( const LambdaCapture &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
{
4695 auto *capturedVar = Node.getCapturedVar();
4696 return capturedVar && InnerMatcher.matches(*capturedVar, Finder, Builder);
4697}
4698
4699/// Matches a `LambdaCapture` that refers to 'this'.
4700///
4701/// Given
4702/// \code
4703/// class C {
4704/// int cc;
4705/// int f() {
4706/// auto l = [this]() { return cc; };
4707/// return l();
4708/// }
4709/// };
4710/// \endcode
4711/// lambdaExpr(hasAnyCapture(lambdaCapture(capturesThis())))
4712/// matches `[this]() { return cc; }`.
4713AST_MATCHER(LambdaCapture, capturesThis)namespace internal { class matcher_capturesThisMatcher : public
::clang::ast_matchers::internal::MatcherInterface<LambdaCapture
> { public: explicit matcher_capturesThisMatcher() = default
; bool matches(const LambdaCapture &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const override; }; } inline
::clang::ast_matchers::internal::Matcher<LambdaCapture>
capturesThis() { return ::clang::ast_matchers::internal::makeMatcher
( new internal::matcher_capturesThisMatcher()); } inline bool
internal::matcher_capturesThisMatcher::matches( const LambdaCapture
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{ return Node.capturesThis(); }
4714
4715/// Matches a constructor call expression which uses list initialization.
4716AST_MATCHER(CXXConstructExpr, isListInitialization)namespace internal { class matcher_isListInitializationMatcher
: public ::clang::ast_matchers::internal::MatcherInterface<
CXXConstructExpr> { public: explicit matcher_isListInitializationMatcher
() = default; bool matches(const CXXConstructExpr &Node, ::
clang::ast_matchers::internal::ASTMatchFinder *Finder, ::clang
::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
override; }; } inline ::clang::ast_matchers::internal::Matcher
<CXXConstructExpr> isListInitialization() { return ::clang
::ast_matchers::internal::makeMatcher( new internal::matcher_isListInitializationMatcher
()); } inline bool internal::matcher_isListInitializationMatcher
::matches( const CXXConstructExpr &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
{
4717 return Node.isListInitialization();
4718}
4719
4720/// Matches a constructor call expression which requires
4721/// zero initialization.
4722///
4723/// Given
4724/// \code
4725/// void foo() {
4726/// struct point { double x; double y; };
4727/// point pt[2] = { { 1.0, 2.0 } };
4728/// }
4729/// \endcode
4730/// initListExpr(has(cxxConstructExpr(requiresZeroInitialization()))
4731/// will match the implicit array filler for pt[1].
4732AST_MATCHER(CXXConstructExpr, requiresZeroInitialization)namespace internal { class matcher_requiresZeroInitializationMatcher
: public ::clang::ast_matchers::internal::MatcherInterface<
CXXConstructExpr> { public: explicit matcher_requiresZeroInitializationMatcher
() = default; bool matches(const CXXConstructExpr &Node, ::
clang::ast_matchers::internal::ASTMatchFinder *Finder, ::clang
::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
override; }; } inline ::clang::ast_matchers::internal::Matcher
<CXXConstructExpr> requiresZeroInitialization() { return
::clang::ast_matchers::internal::makeMatcher( new internal::
matcher_requiresZeroInitializationMatcher()); } inline bool internal
::matcher_requiresZeroInitializationMatcher::matches( const CXXConstructExpr
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
4733 return Node.requiresZeroInitialization();
4734}
4735
4736/// Matches the n'th parameter of a function or an ObjC method
4737/// declaration or a block.
4738///
4739/// Given
4740/// \code
4741/// class X { void f(int x) {} };
4742/// \endcode
4743/// cxxMethodDecl(hasParameter(0, hasType(varDecl())))
4744/// matches f(int x) {}
4745/// with hasParameter(...)
4746/// matching int x
4747///
4748/// For ObjectiveC, given
4749/// \code
4750/// @interface I - (void) f:(int) y; @end
4751/// \endcode
4752//
4753/// the matcher objcMethodDecl(hasParameter(0, hasName("y")))
4754/// matches the declaration of method f with hasParameter
4755/// matching y.
4756AST_POLYMORPHIC_MATCHER_P2(hasParameter,namespace internal { template <typename NodeType, typename
ParamT1, typename ParamT2> class matcher_hasParameter0Matcher
: public ::clang::ast_matchers::internal::MatcherInterface<
NodeType> { public: matcher_hasParameter0Matcher(unsigned const
&AN, internal::Matcher<ParmVarDecl> 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
<ParmVarDecl> InnerMatcher; }; } inline ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_hasParameter0Matcher
, void(::clang::ast_matchers::internal::TypeList<FunctionDecl
, ObjCMethodDecl, BlockDecl>), unsigned, internal::Matcher
<ParmVarDecl> > hasParameter(unsigned const &N, internal
::Matcher<ParmVarDecl> const &InnerMatcher) { return
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_hasParameter0Matcher, void(::clang::ast_matchers::internal
::TypeList<FunctionDecl, ObjCMethodDecl, BlockDecl>), unsigned
, internal::Matcher<ParmVarDecl> >(N, InnerMatcher);
} typedef ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_hasParameter0Matcher, void(::clang::ast_matchers
::internal::TypeList<FunctionDecl, ObjCMethodDecl, BlockDecl
>), unsigned, internal::Matcher<ParmVarDecl> > (&
hasParameter_Type0)( unsigned const &N, internal::Matcher
<ParmVarDecl> const &InnerMatcher); template <typename
NodeType, typename ParamT1, typename ParamT2> bool internal
::matcher_hasParameter0Matcher< NodeType, ParamT1, ParamT2
>:: matches(const NodeType &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
4757 AST_POLYMORPHIC_SUPPORTED_TYPES(FunctionDecl,namespace internal { template <typename NodeType, typename
ParamT1, typename ParamT2> class matcher_hasParameter0Matcher
: public ::clang::ast_matchers::internal::MatcherInterface<
NodeType> { public: matcher_hasParameter0Matcher(unsigned const
&AN, internal::Matcher<ParmVarDecl> 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
<ParmVarDecl> InnerMatcher; }; } inline ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_hasParameter0Matcher
, void(::clang::ast_matchers::internal::TypeList<FunctionDecl
, ObjCMethodDecl, BlockDecl>), unsigned, internal::Matcher
<ParmVarDecl> > hasParameter(unsigned const &N, internal
::Matcher<ParmVarDecl> const &InnerMatcher) { return
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_hasParameter0Matcher, void(::clang::ast_matchers::internal
::TypeList<FunctionDecl, ObjCMethodDecl, BlockDecl>), unsigned
, internal::Matcher<ParmVarDecl> >(N, InnerMatcher);
} typedef ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_hasParameter0Matcher, void(::clang::ast_matchers
::internal::TypeList<FunctionDecl, ObjCMethodDecl, BlockDecl
>), unsigned, internal::Matcher<ParmVarDecl> > (&
hasParameter_Type0)( unsigned const &N, internal::Matcher
<ParmVarDecl> const &InnerMatcher); template <typename
NodeType, typename ParamT1, typename ParamT2> bool internal
::matcher_hasParameter0Matcher< NodeType, ParamT1, ParamT2
>:: matches(const NodeType &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
4758 ObjCMethodDecl,namespace internal { template <typename NodeType, typename
ParamT1, typename ParamT2> class matcher_hasParameter0Matcher
: public ::clang::ast_matchers::internal::MatcherInterface<
NodeType> { public: matcher_hasParameter0Matcher(unsigned const
&AN, internal::Matcher<ParmVarDecl> 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
<ParmVarDecl> InnerMatcher; }; } inline ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_hasParameter0Matcher
, void(::clang::ast_matchers::internal::TypeList<FunctionDecl
, ObjCMethodDecl, BlockDecl>), unsigned, internal::Matcher
<ParmVarDecl> > hasParameter(unsigned const &N, internal
::Matcher<ParmVarDecl> const &InnerMatcher) { return
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_hasParameter0Matcher, void(::clang::ast_matchers::internal
::TypeList<FunctionDecl, ObjCMethodDecl, BlockDecl>), unsigned
, internal::Matcher<ParmVarDecl> >(N, InnerMatcher);
} typedef ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_hasParameter0Matcher, void(::clang::ast_matchers
::internal::TypeList<FunctionDecl, ObjCMethodDecl, BlockDecl
>), unsigned, internal::Matcher<ParmVarDecl> > (&
hasParameter_Type0)( unsigned const &N, internal::Matcher
<ParmVarDecl> const &InnerMatcher); template <typename
NodeType, typename ParamT1, typename ParamT2> bool internal
::matcher_hasParameter0Matcher< NodeType, ParamT1, ParamT2
>:: matches(const NodeType &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
4759 BlockDecl),namespace internal { template <typename NodeType, typename
ParamT1, typename ParamT2> class matcher_hasParameter0Matcher
: public ::clang::ast_matchers::internal::MatcherInterface<
NodeType> { public: matcher_hasParameter0Matcher(unsigned const
&AN, internal::Matcher<ParmVarDecl> 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
<ParmVarDecl> InnerMatcher; }; } inline ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_hasParameter0Matcher
, void(::clang::ast_matchers::internal::TypeList<FunctionDecl
, ObjCMethodDecl, BlockDecl>), unsigned, internal::Matcher
<ParmVarDecl> > hasParameter(unsigned const &N, internal
::Matcher<ParmVarDecl> const &InnerMatcher) { return
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_hasParameter0Matcher, void(::clang::ast_matchers::internal
::TypeList<FunctionDecl, ObjCMethodDecl, BlockDecl>), unsigned
, internal::Matcher<ParmVarDecl> >(N, InnerMatcher);
} typedef ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_hasParameter0Matcher, void(::clang::ast_matchers
::internal::TypeList<FunctionDecl, ObjCMethodDecl, BlockDecl
>), unsigned, internal::Matcher<ParmVarDecl> > (&
hasParameter_Type0)( unsigned const &N, internal::Matcher
<ParmVarDecl> const &InnerMatcher); template <typename
NodeType, typename ParamT1, typename ParamT2> bool internal
::matcher_hasParameter0Matcher< NodeType, ParamT1, ParamT2
>:: matches(const NodeType &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
4760 unsigned, N, internal::Matcher<ParmVarDecl>,namespace internal { template <typename NodeType, typename
ParamT1, typename ParamT2> class matcher_hasParameter0Matcher
: public ::clang::ast_matchers::internal::MatcherInterface<
NodeType> { public: matcher_hasParameter0Matcher(unsigned const
&AN, internal::Matcher<ParmVarDecl> 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
<ParmVarDecl> InnerMatcher; }; } inline ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_hasParameter0Matcher
, void(::clang::ast_matchers::internal::TypeList<FunctionDecl
, ObjCMethodDecl, BlockDecl>), unsigned, internal::Matcher
<ParmVarDecl> > hasParameter(unsigned const &N, internal
::Matcher<ParmVarDecl> const &InnerMatcher) { return
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_hasParameter0Matcher, void(::clang::ast_matchers::internal
::TypeList<FunctionDecl, ObjCMethodDecl, BlockDecl>), unsigned
, internal::Matcher<ParmVarDecl> >(N, InnerMatcher);
} typedef ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_hasParameter0Matcher, void(::clang::ast_matchers
::internal::TypeList<FunctionDecl, ObjCMethodDecl, BlockDecl
>), unsigned, internal::Matcher<ParmVarDecl> > (&
hasParameter_Type0)( unsigned const &N, internal::Matcher
<ParmVarDecl> const &InnerMatcher); template <typename
NodeType, typename ParamT1, typename ParamT2> bool internal
::matcher_hasParameter0Matcher< NodeType, ParamT1, ParamT2
>:: matches(const NodeType &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
4761 InnerMatcher)namespace internal { template <typename NodeType, typename
ParamT1, typename ParamT2> class matcher_hasParameter0Matcher
: public ::clang::ast_matchers::internal::MatcherInterface<
NodeType> { public: matcher_hasParameter0Matcher(unsigned const
&AN, internal::Matcher<ParmVarDecl> 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
<ParmVarDecl> InnerMatcher; }; } inline ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_hasParameter0Matcher
, void(::clang::ast_matchers::internal::TypeList<FunctionDecl
, ObjCMethodDecl, BlockDecl>), unsigned, internal::Matcher
<ParmVarDecl> > hasParameter(unsigned const &N, internal
::Matcher<ParmVarDecl> const &InnerMatcher) { return
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_hasParameter0Matcher, void(::clang::ast_matchers::internal
::TypeList<FunctionDecl, ObjCMethodDecl, BlockDecl>), unsigned
, internal::Matcher<ParmVarDecl> >(N, InnerMatcher);
} typedef ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_hasParameter0Matcher, void(::clang::ast_matchers
::internal::TypeList<FunctionDecl, ObjCMethodDecl, BlockDecl
>), unsigned, internal::Matcher<ParmVarDecl> > (&
hasParameter_Type0)( unsigned const &N, internal::Matcher
<ParmVarDecl> const &InnerMatcher); template <typename
NodeType, typename ParamT1, typename ParamT2> bool internal
::matcher_hasParameter0Matcher< NodeType, ParamT1, ParamT2
>:: matches(const NodeType &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
{
4762 return (N < Node.parameters().size()
4763 && InnerMatcher.matches(*Node.parameters()[N], Finder, Builder));
4764}
4765
4766/// Matches all arguments and their respective ParmVarDecl.
4767///
4768/// Given
4769/// \code
4770/// void f(int i);
4771/// int y;
4772/// f(y);
4773/// \endcode
4774/// callExpr(
4775/// forEachArgumentWithParam(
4776/// declRefExpr(to(varDecl(hasName("y")))),
4777/// parmVarDecl(hasType(isInteger()))
4778/// ))
4779/// matches f(y);
4780/// with declRefExpr(...)
4781/// matching int y
4782/// and parmVarDecl(...)
4783/// matching int i
4784AST_POLYMORPHIC_MATCHER_P2(forEachArgumentWithParam,namespace internal { template <typename NodeType, typename
ParamT1, typename ParamT2> class matcher_forEachArgumentWithParam0Matcher
: public ::clang::ast_matchers::internal::MatcherInterface<
NodeType> { public: matcher_forEachArgumentWithParam0Matcher
(internal::Matcher<Expr> const &AArgMatcher, internal
::Matcher<ParmVarDecl> const &AParamMatcher) : ArgMatcher
(AArgMatcher), ParamMatcher(AParamMatcher) {} bool matches(const
NodeType &Node, ::clang::ast_matchers::internal::ASTMatchFinder
*Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: internal::Matcher<Expr
> ArgMatcher; internal::Matcher<ParmVarDecl> ParamMatcher
; }; } inline ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_forEachArgumentWithParam0Matcher, void
(::clang::ast_matchers::internal::TypeList<CallExpr, CXXConstructExpr
>), internal::Matcher<Expr>, internal::Matcher<ParmVarDecl
> > forEachArgumentWithParam(internal::Matcher<Expr>
const &ArgMatcher, internal::Matcher<ParmVarDecl> const
&ParamMatcher) { return ::clang::ast_matchers::internal::
PolymorphicMatcher< internal::matcher_forEachArgumentWithParam0Matcher
, void(::clang::ast_matchers::internal::TypeList<CallExpr,
CXXConstructExpr>), internal::Matcher<Expr>, internal
::Matcher<ParmVarDecl> >(ArgMatcher, ParamMatcher); }
typedef ::clang::ast_matchers::internal::PolymorphicMatcher<
internal::matcher_forEachArgumentWithParam0Matcher, void(::clang
::ast_matchers::internal::TypeList<CallExpr, CXXConstructExpr
>), internal::Matcher<Expr>, internal::Matcher<ParmVarDecl
> > (&forEachArgumentWithParam_Type0)( internal::Matcher
<Expr> const &ArgMatcher, internal::Matcher<ParmVarDecl
> const &ParamMatcher); template <typename NodeType
, typename ParamT1, typename ParamT2> bool internal::matcher_forEachArgumentWithParam0Matcher
< NodeType, ParamT1, ParamT2>:: matches(const NodeType &
Node, ::clang::ast_matchers::internal::ASTMatchFinder *Finder
, ::clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder
) const
4785 AST_POLYMORPHIC_SUPPORTED_TYPES(CallExpr,namespace internal { template <typename NodeType, typename
ParamT1, typename ParamT2> class matcher_forEachArgumentWithParam0Matcher
: public ::clang::ast_matchers::internal::MatcherInterface<
NodeType> { public: matcher_forEachArgumentWithParam0Matcher
(internal::Matcher<Expr> const &AArgMatcher, internal
::Matcher<ParmVarDecl> const &AParamMatcher) : ArgMatcher
(AArgMatcher), ParamMatcher(AParamMatcher) {} bool matches(const
NodeType &Node, ::clang::ast_matchers::internal::ASTMatchFinder
*Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: internal::Matcher<Expr
> ArgMatcher; internal::Matcher<ParmVarDecl> ParamMatcher
; }; } inline ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_forEachArgumentWithParam0Matcher, void
(::clang::ast_matchers::internal::TypeList<CallExpr, CXXConstructExpr
>), internal::Matcher<Expr>, internal::Matcher<ParmVarDecl
> > forEachArgumentWithParam(internal::Matcher<Expr>
const &ArgMatcher, internal::Matcher<ParmVarDecl> const
&ParamMatcher) { return ::clang::ast_matchers::internal::
PolymorphicMatcher< internal::matcher_forEachArgumentWithParam0Matcher
, void(::clang::ast_matchers::internal::TypeList<CallExpr,
CXXConstructExpr>), internal::Matcher<Expr>, internal
::Matcher<ParmVarDecl> >(ArgMatcher, ParamMatcher); }
typedef ::clang::ast_matchers::internal::PolymorphicMatcher<
internal::matcher_forEachArgumentWithParam0Matcher, void(::clang
::ast_matchers::internal::TypeList<CallExpr, CXXConstructExpr
>), internal::Matcher<Expr>, internal::Matcher<ParmVarDecl
> > (&forEachArgumentWithParam_Type0)( internal::Matcher
<Expr> const &ArgMatcher, internal::Matcher<ParmVarDecl
> const &ParamMatcher); template <typename NodeType
, typename ParamT1, typename ParamT2> bool internal::matcher_forEachArgumentWithParam0Matcher
< NodeType, ParamT1, ParamT2>:: matches(const NodeType &
Node, ::clang::ast_matchers::internal::ASTMatchFinder *Finder
, ::clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder
) const
4786 CXXConstructExpr),namespace internal { template <typename NodeType, typename
ParamT1, typename ParamT2> class matcher_forEachArgumentWithParam0Matcher
: public ::clang::ast_matchers::internal::MatcherInterface<
NodeType> { public: matcher_forEachArgumentWithParam0Matcher
(internal::Matcher<Expr> const &AArgMatcher, internal
::Matcher<ParmVarDecl> const &AParamMatcher) : ArgMatcher
(AArgMatcher), ParamMatcher(AParamMatcher) {} bool matches(const
NodeType &Node, ::clang::ast_matchers::internal::ASTMatchFinder
*Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: internal::Matcher<Expr
> ArgMatcher; internal::Matcher<ParmVarDecl> ParamMatcher
; }; } inline ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_forEachArgumentWithParam0Matcher, void
(::clang::ast_matchers::internal::TypeList<CallExpr, CXXConstructExpr
>), internal::Matcher<Expr>, internal::Matcher<ParmVarDecl
> > forEachArgumentWithParam(internal::Matcher<Expr>
const &ArgMatcher, internal::Matcher<ParmVarDecl> const
&ParamMatcher) { return ::clang::ast_matchers::internal::
PolymorphicMatcher< internal::matcher_forEachArgumentWithParam0Matcher
, void(::clang::ast_matchers::internal::TypeList<CallExpr,
CXXConstructExpr>), internal::Matcher<Expr>, internal
::Matcher<ParmVarDecl> >(ArgMatcher, ParamMatcher); }
typedef ::clang::ast_matchers::internal::PolymorphicMatcher<
internal::matcher_forEachArgumentWithParam0Matcher, void(::clang
::ast_matchers::internal::TypeList<CallExpr, CXXConstructExpr
>), internal::Matcher<Expr>, internal::Matcher<ParmVarDecl
> > (&forEachArgumentWithParam_Type0)( internal::Matcher
<Expr> const &ArgMatcher, internal::Matcher<ParmVarDecl
> const &ParamMatcher); template <typename NodeType
, typename ParamT1, typename ParamT2> bool internal::matcher_forEachArgumentWithParam0Matcher
< NodeType, ParamT1, ParamT2>:: matches(const NodeType &
Node, ::clang::ast_matchers::internal::ASTMatchFinder *Finder
, ::clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder
) const
4787 internal::Matcher<Expr>, ArgMatcher,namespace internal { template <typename NodeType, typename
ParamT1, typename ParamT2> class matcher_forEachArgumentWithParam0Matcher
: public ::clang::ast_matchers::internal::MatcherInterface<
NodeType> { public: matcher_forEachArgumentWithParam0Matcher
(internal::Matcher<Expr> const &AArgMatcher, internal
::Matcher<ParmVarDecl> const &AParamMatcher) : ArgMatcher
(AArgMatcher), ParamMatcher(AParamMatcher) {} bool matches(const
NodeType &Node, ::clang::ast_matchers::internal::ASTMatchFinder
*Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: internal::Matcher<Expr
> ArgMatcher; internal::Matcher<ParmVarDecl> ParamMatcher
; }; } inline ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_forEachArgumentWithParam0Matcher, void
(::clang::ast_matchers::internal::TypeList<CallExpr, CXXConstructExpr
>), internal::Matcher<Expr>, internal::Matcher<ParmVarDecl
> > forEachArgumentWithParam(internal::Matcher<Expr>
const &ArgMatcher, internal::Matcher<ParmVarDecl> const
&ParamMatcher) { return ::clang::ast_matchers::internal::
PolymorphicMatcher< internal::matcher_forEachArgumentWithParam0Matcher
, void(::clang::ast_matchers::internal::TypeList<CallExpr,
CXXConstructExpr>), internal::Matcher<Expr>, internal
::Matcher<ParmVarDecl> >(ArgMatcher, ParamMatcher); }
typedef ::clang::ast_matchers::internal::PolymorphicMatcher<
internal::matcher_forEachArgumentWithParam0Matcher, void(::clang
::ast_matchers::internal::TypeList<CallExpr, CXXConstructExpr
>), internal::Matcher<Expr>, internal::Matcher<ParmVarDecl
> > (&forEachArgumentWithParam_Type0)( internal::Matcher
<Expr> const &ArgMatcher, internal::Matcher<ParmVarDecl
> const &ParamMatcher); template <typename NodeType
, typename ParamT1, typename ParamT2> bool internal::matcher_forEachArgumentWithParam0Matcher
< NodeType, ParamT1, ParamT2>:: matches(const NodeType &
Node, ::clang::ast_matchers::internal::ASTMatchFinder *Finder
, ::clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder
) const
4788 internal::Matcher<ParmVarDecl>, ParamMatcher)namespace internal { template <typename NodeType, typename
ParamT1, typename ParamT2> class matcher_forEachArgumentWithParam0Matcher
: public ::clang::ast_matchers::internal::MatcherInterface<
NodeType> { public: matcher_forEachArgumentWithParam0Matcher
(internal::Matcher<Expr> const &AArgMatcher, internal
::Matcher<ParmVarDecl> const &AParamMatcher) : ArgMatcher
(AArgMatcher), ParamMatcher(AParamMatcher) {} bool matches(const
NodeType &Node, ::clang::ast_matchers::internal::ASTMatchFinder
*Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: internal::Matcher<Expr
> ArgMatcher; internal::Matcher<ParmVarDecl> ParamMatcher
; }; } inline ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_forEachArgumentWithParam0Matcher, void
(::clang::ast_matchers::internal::TypeList<CallExpr, CXXConstructExpr
>), internal::Matcher<Expr>, internal::Matcher<ParmVarDecl
> > forEachArgumentWithParam(internal::Matcher<Expr>
const &ArgMatcher, internal::Matcher<ParmVarDecl> const
&ParamMatcher) { return ::clang::ast_matchers::internal::
PolymorphicMatcher< internal::matcher_forEachArgumentWithParam0Matcher
, void(::clang::ast_matchers::internal::TypeList<CallExpr,
CXXConstructExpr>), internal::Matcher<Expr>, internal
::Matcher<ParmVarDecl> >(ArgMatcher, ParamMatcher); }
typedef ::clang::ast_matchers::internal::PolymorphicMatcher<
internal::matcher_forEachArgumentWithParam0Matcher, void(::clang
::ast_matchers::internal::TypeList<CallExpr, CXXConstructExpr
>), internal::Matcher<Expr>, internal::Matcher<ParmVarDecl
> > (&forEachArgumentWithParam_Type0)( internal::Matcher
<Expr> const &ArgMatcher, internal::Matcher<ParmVarDecl
> const &ParamMatcher); template <typename NodeType
, typename ParamT1, typename ParamT2> bool internal::matcher_forEachArgumentWithParam0Matcher
< NodeType, ParamT1, ParamT2>:: matches(const NodeType &
Node, ::clang::ast_matchers::internal::ASTMatchFinder *Finder
, ::clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder
) const
{
4789 BoundNodesTreeBuilder Result;
4790 // The first argument of an overloaded member operator is the implicit object
4791 // argument of the method which should not be matched against a parameter, so
4792 // we skip over it here.
4793 BoundNodesTreeBuilder Matches;
4794 unsigned ArgIndex = cxxOperatorCallExpr(callee(cxxMethodDecl()))
4795 .matches(Node, Finder, &Matches)
4796 ? 1
4797 : 0;
4798 int ParamIndex = 0;
4799 bool Matched = false;
4800 for (; ArgIndex < Node.getNumArgs(); ++ArgIndex) {
4801 BoundNodesTreeBuilder ArgMatches(*Builder);
4802 if (ArgMatcher.matches(*(Node.getArg(ArgIndex)->IgnoreParenCasts()),
4803 Finder, &ArgMatches)) {
4804 BoundNodesTreeBuilder ParamMatches(ArgMatches);
4805 if (expr(anyOf(cxxConstructExpr(hasDeclaration(cxxConstructorDecl(
4806 hasParameter(ParamIndex, ParamMatcher)))),
4807 callExpr(callee(functionDecl(
4808 hasParameter(ParamIndex, ParamMatcher))))))
4809 .matches(Node, Finder, &ParamMatches)) {
4810 Result.addMatch(ParamMatches);
4811 Matched = true;
4812 }
4813 }
4814 ++ParamIndex;
4815 }
4816 *Builder = std::move(Result);
4817 return Matched;
4818}
4819
4820/// Matches all arguments and their respective types for a \c CallExpr or
4821/// \c CXXConstructExpr. It is very similar to \c forEachArgumentWithParam but
4822/// it works on calls through function pointers as well.
4823///
4824/// The difference is, that function pointers do not provide access to a
4825/// \c ParmVarDecl, but only the \c QualType for each argument.
4826///
4827/// Given
4828/// \code
4829/// void f(int i);
4830/// int y;
4831/// f(y);
4832/// void (*f_ptr)(int) = f;
4833/// f_ptr(y);
4834/// \endcode
4835/// callExpr(
4836/// forEachArgumentWithParamType(
4837/// declRefExpr(to(varDecl(hasName("y")))),
4838/// qualType(isInteger()).bind("type)
4839/// ))
4840/// matches f(y) and f_ptr(y)
4841/// with declRefExpr(...)
4842/// matching int y
4843/// and qualType(...)
4844/// matching int
4845AST_POLYMORPHIC_MATCHER_P2(forEachArgumentWithParamType,namespace internal { template <typename NodeType, typename
ParamT1, typename ParamT2> class matcher_forEachArgumentWithParamType0Matcher
: public ::clang::ast_matchers::internal::MatcherInterface<
NodeType> { public: matcher_forEachArgumentWithParamType0Matcher
(internal::Matcher<Expr> const &AArgMatcher, internal
::Matcher<QualType> const &AParamMatcher) : ArgMatcher
(AArgMatcher), ParamMatcher(AParamMatcher) {} bool matches(const
NodeType &Node, ::clang::ast_matchers::internal::ASTMatchFinder
*Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: internal::Matcher<Expr
> ArgMatcher; internal::Matcher<QualType> ParamMatcher
; }; } inline ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_forEachArgumentWithParamType0Matcher, void
(::clang::ast_matchers::internal::TypeList<CallExpr, CXXConstructExpr
>), internal::Matcher<Expr>, internal::Matcher<QualType
> > forEachArgumentWithParamType(internal::Matcher<Expr
> const &ArgMatcher, internal::Matcher<QualType>
const &ParamMatcher) { return ::clang::ast_matchers::internal
::PolymorphicMatcher< internal::matcher_forEachArgumentWithParamType0Matcher
, void(::clang::ast_matchers::internal::TypeList<CallExpr,
CXXConstructExpr>), internal::Matcher<Expr>, internal
::Matcher<QualType> >(ArgMatcher, ParamMatcher); } typedef
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_forEachArgumentWithParamType0Matcher, void(::clang::
ast_matchers::internal::TypeList<CallExpr, CXXConstructExpr
>), internal::Matcher<Expr>, internal::Matcher<QualType
> > (&forEachArgumentWithParamType_Type0)( internal
::Matcher<Expr> const &ArgMatcher, internal::Matcher
<QualType> const &ParamMatcher); template <typename
NodeType, typename ParamT1, typename ParamT2> bool internal
::matcher_forEachArgumentWithParamType0Matcher< NodeType, ParamT1
, ParamT2>:: matches(const NodeType &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
4846 AST_POLYMORPHIC_SUPPORTED_TYPES(CallExpr,namespace internal { template <typename NodeType, typename
ParamT1, typename ParamT2> class matcher_forEachArgumentWithParamType0Matcher
: public ::clang::ast_matchers::internal::MatcherInterface<
NodeType> { public: matcher_forEachArgumentWithParamType0Matcher
(internal::Matcher<Expr> const &AArgMatcher, internal
::Matcher<QualType> const &AParamMatcher) : ArgMatcher
(AArgMatcher), ParamMatcher(AParamMatcher) {} bool matches(const
NodeType &Node, ::clang::ast_matchers::internal::ASTMatchFinder
*Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: internal::Matcher<Expr
> ArgMatcher; internal::Matcher<QualType> ParamMatcher
; }; } inline ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_forEachArgumentWithParamType0Matcher, void
(::clang::ast_matchers::internal::TypeList<CallExpr, CXXConstructExpr
>), internal::Matcher<Expr>, internal::Matcher<QualType
> > forEachArgumentWithParamType(internal::Matcher<Expr
> const &ArgMatcher, internal::Matcher<QualType>
const &ParamMatcher) { return ::clang::ast_matchers::internal
::PolymorphicMatcher< internal::matcher_forEachArgumentWithParamType0Matcher
, void(::clang::ast_matchers::internal::TypeList<CallExpr,
CXXConstructExpr>), internal::Matcher<Expr>, internal
::Matcher<QualType> >(ArgMatcher, ParamMatcher); } typedef
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_forEachArgumentWithParamType0Matcher, void(::clang::
ast_matchers::internal::TypeList<CallExpr, CXXConstructExpr
>), internal::Matcher<Expr>, internal::Matcher<QualType
> > (&forEachArgumentWithParamType_Type0)( internal
::Matcher<Expr> const &ArgMatcher, internal::Matcher
<QualType> const &ParamMatcher); template <typename
NodeType, typename ParamT1, typename ParamT2> bool internal
::matcher_forEachArgumentWithParamType0Matcher< NodeType, ParamT1
, ParamT2>:: matches(const NodeType &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
4847 CXXConstructExpr),namespace internal { template <typename NodeType, typename
ParamT1, typename ParamT2> class matcher_forEachArgumentWithParamType0Matcher
: public ::clang::ast_matchers::internal::MatcherInterface<
NodeType> { public: matcher_forEachArgumentWithParamType0Matcher
(internal::Matcher<Expr> const &AArgMatcher, internal
::Matcher<QualType> const &AParamMatcher) : ArgMatcher
(AArgMatcher), ParamMatcher(AParamMatcher) {} bool matches(const
NodeType &Node, ::clang::ast_matchers::internal::ASTMatchFinder
*Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: internal::Matcher<Expr
> ArgMatcher; internal::Matcher<QualType> ParamMatcher
; }; } inline ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_forEachArgumentWithParamType0Matcher, void
(::clang::ast_matchers::internal::TypeList<CallExpr, CXXConstructExpr
>), internal::Matcher<Expr>, internal::Matcher<QualType
> > forEachArgumentWithParamType(internal::Matcher<Expr
> const &ArgMatcher, internal::Matcher<QualType>
const &ParamMatcher) { return ::clang::ast_matchers::internal
::PolymorphicMatcher< internal::matcher_forEachArgumentWithParamType0Matcher
, void(::clang::ast_matchers::internal::TypeList<CallExpr,
CXXConstructExpr>), internal::Matcher<Expr>, internal
::Matcher<QualType> >(ArgMatcher, ParamMatcher); } typedef
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_forEachArgumentWithParamType0Matcher, void(::clang::
ast_matchers::internal::TypeList<CallExpr, CXXConstructExpr
>), internal::Matcher<Expr>, internal::Matcher<QualType
> > (&forEachArgumentWithParamType_Type0)( internal
::Matcher<Expr> const &ArgMatcher, internal::Matcher
<QualType> const &ParamMatcher); template <typename
NodeType, typename ParamT1, typename ParamT2> bool internal
::matcher_forEachArgumentWithParamType0Matcher< NodeType, ParamT1
, ParamT2>:: matches(const NodeType &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
4848 internal::Matcher<Expr>, ArgMatcher,namespace internal { template <typename NodeType, typename
ParamT1, typename ParamT2> class matcher_forEachArgumentWithParamType0Matcher
: public ::clang::ast_matchers::internal::MatcherInterface<
NodeType> { public: matcher_forEachArgumentWithParamType0Matcher
(internal::Matcher<Expr> const &AArgMatcher, internal
::Matcher<QualType> const &AParamMatcher) : ArgMatcher
(AArgMatcher), ParamMatcher(AParamMatcher) {} bool matches(const
NodeType &Node, ::clang::ast_matchers::internal::ASTMatchFinder
*Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: internal::Matcher<Expr
> ArgMatcher; internal::Matcher<QualType> ParamMatcher
; }; } inline ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_forEachArgumentWithParamType0Matcher, void
(::clang::ast_matchers::internal::TypeList<CallExpr, CXXConstructExpr
>), internal::Matcher<Expr>, internal::Matcher<QualType
> > forEachArgumentWithParamType(internal::Matcher<Expr
> const &ArgMatcher, internal::Matcher<QualType>
const &ParamMatcher) { return ::clang::ast_matchers::internal
::PolymorphicMatcher< internal::matcher_forEachArgumentWithParamType0Matcher
, void(::clang::ast_matchers::internal::TypeList<CallExpr,
CXXConstructExpr>), internal::Matcher<Expr>, internal
::Matcher<QualType> >(ArgMatcher, ParamMatcher); } typedef
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_forEachArgumentWithParamType0Matcher, void(::clang::
ast_matchers::internal::TypeList<CallExpr, CXXConstructExpr
>), internal::Matcher<Expr>, internal::Matcher<QualType
> > (&forEachArgumentWithParamType_Type0)( internal
::Matcher<Expr> const &ArgMatcher, internal::Matcher
<QualType> const &ParamMatcher); template <typename
NodeType, typename ParamT1, typename ParamT2> bool internal
::matcher_forEachArgumentWithParamType0Matcher< NodeType, ParamT1
, ParamT2>:: matches(const NodeType &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
4849 internal::Matcher<QualType>, ParamMatcher)namespace internal { template <typename NodeType, typename
ParamT1, typename ParamT2> class matcher_forEachArgumentWithParamType0Matcher
: public ::clang::ast_matchers::internal::MatcherInterface<
NodeType> { public: matcher_forEachArgumentWithParamType0Matcher
(internal::Matcher<Expr> const &AArgMatcher, internal
::Matcher<QualType> const &AParamMatcher) : ArgMatcher
(AArgMatcher), ParamMatcher(AParamMatcher) {} bool matches(const
NodeType &Node, ::clang::ast_matchers::internal::ASTMatchFinder
*Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: internal::Matcher<Expr
> ArgMatcher; internal::Matcher<QualType> ParamMatcher
; }; } inline ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_forEachArgumentWithParamType0Matcher, void
(::clang::ast_matchers::internal::TypeList<CallExpr, CXXConstructExpr
>), internal::Matcher<Expr>, internal::Matcher<QualType
> > forEachArgumentWithParamType(internal::Matcher<Expr
> const &ArgMatcher, internal::Matcher<QualType>
const &ParamMatcher) { return ::clang::ast_matchers::internal
::PolymorphicMatcher< internal::matcher_forEachArgumentWithParamType0Matcher
, void(::clang::ast_matchers::internal::TypeList<CallExpr,
CXXConstructExpr>), internal::Matcher<Expr>, internal
::Matcher<QualType> >(ArgMatcher, ParamMatcher); } typedef
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_forEachArgumentWithParamType0Matcher, void(::clang::
ast_matchers::internal::TypeList<CallExpr, CXXConstructExpr
>), internal::Matcher<Expr>, internal::Matcher<QualType
> > (&forEachArgumentWithParamType_Type0)( internal
::Matcher<Expr> const &ArgMatcher, internal::Matcher
<QualType> const &ParamMatcher); template <typename
NodeType, typename ParamT1, typename ParamT2> bool internal
::matcher_forEachArgumentWithParamType0Matcher< NodeType, ParamT1
, ParamT2>:: matches(const NodeType &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
{
4850 BoundNodesTreeBuilder Result;
4851 // The first argument of an overloaded member operator is the implicit object
4852 // argument of the method which should not be matched against a parameter, so
4853 // we skip over it here.
4854 BoundNodesTreeBuilder Matches;
4855 unsigned ArgIndex = cxxOperatorCallExpr(callee(cxxMethodDecl()))
4856 .matches(Node, Finder, &Matches)
4857 ? 1
4858 : 0;
4859
4860 const FunctionProtoType *FProto = nullptr;
4861
4862 if (const auto *Call = dyn_cast<CallExpr>(&Node)) {
4863 if (const auto *Value =
4864 dyn_cast_or_null<ValueDecl>(Call->getCalleeDecl())) {
4865 QualType QT = Value->getType().getCanonicalType();
4866
4867 // This does not necessarily lead to a `FunctionProtoType`,
4868 // e.g. K&R functions do not have a function prototype.
4869 if (QT->isFunctionPointerType())
4870 FProto = QT->getPointeeType()->getAs<FunctionProtoType>();
4871
4872 if (QT->isMemberFunctionPointerType()) {
4873 const auto *MP = QT->getAs<MemberPointerType>();
4874 assert(MP && "Must be member-pointer if its a memberfunctionpointer")(static_cast <bool> (MP && "Must be member-pointer if its a memberfunctionpointer"
) ? void (0) : __assert_fail ("MP && \"Must be member-pointer if its a memberfunctionpointer\""
, "clang/include/clang/ASTMatchers/ASTMatchers.h", 4874, __extension__
__PRETTY_FUNCTION__))
;
4875 FProto = MP->getPointeeType()->getAs<FunctionProtoType>();
4876 assert(FProto &&(static_cast <bool> (FProto && "The call must have happened through a member function "
"pointer") ? void (0) : __assert_fail ("FProto && \"The call must have happened through a member function \" \"pointer\""
, "clang/include/clang/ASTMatchers/ASTMatchers.h", 4878, __extension__
__PRETTY_FUNCTION__))
4877 "The call must have happened through a member function "(static_cast <bool> (FProto && "The call must have happened through a member function "
"pointer") ? void (0) : __assert_fail ("FProto && \"The call must have happened through a member function \" \"pointer\""
, "clang/include/clang/ASTMatchers/ASTMatchers.h", 4878, __extension__
__PRETTY_FUNCTION__))
4878 "pointer")(static_cast <bool> (FProto && "The call must have happened through a member function "
"pointer") ? void (0) : __assert_fail ("FProto && \"The call must have happened through a member function \" \"pointer\""
, "clang/include/clang/ASTMatchers/ASTMatchers.h", 4878, __extension__
__PRETTY_FUNCTION__))
;
4879 }
4880 }
4881 }
4882
4883 unsigned ParamIndex = 0;
4884 bool Matched = false;
4885 unsigned NumArgs = Node.getNumArgs();
4886 if (FProto && FProto->isVariadic())
4887 NumArgs = std::min(NumArgs, FProto->getNumParams());
4888
4889 for (; ArgIndex < NumArgs; ++ArgIndex, ++ParamIndex) {
4890 BoundNodesTreeBuilder ArgMatches(*Builder);
4891 if (ArgMatcher.matches(*(Node.getArg(ArgIndex)->IgnoreParenCasts()), Finder,
4892 &ArgMatches)) {
4893 BoundNodesTreeBuilder ParamMatches(ArgMatches);
4894
4895 // This test is cheaper compared to the big matcher in the next if.
4896 // Therefore, please keep this order.
4897 if (FProto && FProto->getNumParams() > ParamIndex) {
4898 QualType ParamType = FProto->getParamType(ParamIndex);
4899 if (ParamMatcher.matches(ParamType, Finder, &ParamMatches)) {
4900 Result.addMatch(ParamMatches);
4901 Matched = true;
4902 continue;
4903 }
4904 }
4905 if (expr(anyOf(cxxConstructExpr(hasDeclaration(cxxConstructorDecl(
4906 hasParameter(ParamIndex, hasType(ParamMatcher))))),
4907 callExpr(callee(functionDecl(
4908 hasParameter(ParamIndex, hasType(ParamMatcher)))))))
4909 .matches(Node, Finder, &ParamMatches)) {
4910 Result.addMatch(ParamMatches);
4911 Matched = true;
4912 continue;
4913 }
4914 }
4915 }
4916 *Builder = std::move(Result);
4917 return Matched;
4918}
4919
4920/// Matches the ParmVarDecl nodes that are at the N'th position in the parameter
4921/// list. The parameter list could be that of either a block, function, or
4922/// objc-method.
4923///
4924///
4925/// Given
4926///
4927/// \code
4928/// void f(int a, int b, int c) {
4929/// }
4930/// \endcode
4931///
4932/// ``parmVarDecl(isAtPosition(0))`` matches ``int a``.
4933///
4934/// ``parmVarDecl(isAtPosition(1))`` matches ``int b``.
4935AST_MATCHER_P(ParmVarDecl, isAtPosition, unsigned, N)namespace internal { class matcher_isAtPosition0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<ParmVarDecl
> { public: explicit matcher_isAtPosition0Matcher( unsigned
const &AN) : N(AN) {} bool matches(const ParmVarDecl &
Node, ::clang::ast_matchers::internal::ASTMatchFinder *Finder
, ::clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder
) const override; private: unsigned N; }; } inline ::clang::ast_matchers
::internal::Matcher<ParmVarDecl> isAtPosition( unsigned
const &N) { return ::clang::ast_matchers::internal::makeMatcher
( new internal::matcher_isAtPosition0Matcher(N)); } typedef ::
clang::ast_matchers::internal::Matcher<ParmVarDecl> ( &
isAtPosition_Type0)(unsigned const &N); inline bool internal
::matcher_isAtPosition0Matcher::matches( const ParmVarDecl &
Node, ::clang::ast_matchers::internal::ASTMatchFinder *Finder
, ::clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder
) const
{
4936 const clang::DeclContext *Context = Node.getParentFunctionOrMethod();
4937
4938 if (const auto *Decl = dyn_cast_or_null<FunctionDecl>(Context))
4939 return N < Decl->param_size() && Decl->getParamDecl(N) == &Node;
4940 if (const auto *Decl = dyn_cast_or_null<BlockDecl>(Context))
4941 return N < Decl->param_size() && Decl->getParamDecl(N) == &Node;
4942 if (const auto *Decl = dyn_cast_or_null<ObjCMethodDecl>(Context))
4943 return N < Decl->param_size() && Decl->getParamDecl(N) == &Node;
4944
4945 return false;
4946}
4947
4948/// Matches any parameter of a function or an ObjC method declaration or a
4949/// block.
4950///
4951/// Does not match the 'this' parameter of a method.
4952///
4953/// Given
4954/// \code
4955/// class X { void f(int x, int y, int z) {} };
4956/// \endcode
4957/// cxxMethodDecl(hasAnyParameter(hasName("y")))
4958/// matches f(int x, int y, int z) {}
4959/// with hasAnyParameter(...)
4960/// matching int y
4961///
4962/// For ObjectiveC, given
4963/// \code
4964/// @interface I - (void) f:(int) y; @end
4965/// \endcode
4966//
4967/// the matcher objcMethodDecl(hasAnyParameter(hasName("y")))
4968/// matches the declaration of method f with hasParameter
4969/// matching y.
4970///
4971/// For blocks, given
4972/// \code
4973/// b = ^(int y) { printf("%d", y) };
4974/// \endcode
4975///
4976/// the matcher blockDecl(hasAnyParameter(hasName("y")))
4977/// matches the declaration of the block b with hasParameter
4978/// matching y.
4979AST_POLYMORPHIC_MATCHER_P(hasAnyParameter,namespace internal { template <typename NodeType, typename
ParamT> class matcher_hasAnyParameter0Matcher : public ::
clang::ast_matchers::internal::MatcherInterface<NodeType>
{ public: explicit matcher_hasAnyParameter0Matcher( internal
::Matcher<ParmVarDecl> 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<ParmVarDecl> InnerMatcher; }; } inline
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_hasAnyParameter0Matcher, void(::clang::ast_matchers
::internal::TypeList<FunctionDecl, ObjCMethodDecl, BlockDecl
>), internal::Matcher<ParmVarDecl> > hasAnyParameter
(internal::Matcher<ParmVarDecl> const &InnerMatcher
) { return ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_hasAnyParameter0Matcher, void(::clang::
ast_matchers::internal::TypeList<FunctionDecl, ObjCMethodDecl
, BlockDecl>), internal::Matcher<ParmVarDecl> >(InnerMatcher
); } typedef ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_hasAnyParameter0Matcher, void(::clang::
ast_matchers::internal::TypeList<FunctionDecl, ObjCMethodDecl
, BlockDecl>), internal::Matcher<ParmVarDecl> > (
&hasAnyParameter_Type0)(internal::Matcher<ParmVarDecl>
const &InnerMatcher); template <typename NodeType, typename
ParamT> bool internal:: matcher_hasAnyParameter0Matcher<
NodeType, ParamT>::matches( const NodeType &Node, ::clang
::ast_matchers::internal::ASTMatchFinder *Finder, ::clang::ast_matchers
::internal::BoundNodesTreeBuilder *Builder) const
4980 AST_POLYMORPHIC_SUPPORTED_TYPES(FunctionDecl,namespace internal { template <typename NodeType, typename
ParamT> class matcher_hasAnyParameter0Matcher : public ::
clang::ast_matchers::internal::MatcherInterface<NodeType>
{ public: explicit matcher_hasAnyParameter0Matcher( internal
::Matcher<ParmVarDecl> 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<ParmVarDecl> InnerMatcher; }; } inline
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_hasAnyParameter0Matcher, void(::clang::ast_matchers
::internal::TypeList<FunctionDecl, ObjCMethodDecl, BlockDecl
>), internal::Matcher<ParmVarDecl> > hasAnyParameter
(internal::Matcher<ParmVarDecl> const &InnerMatcher
) { return ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_hasAnyParameter0Matcher, void(::clang::
ast_matchers::internal::TypeList<FunctionDecl, ObjCMethodDecl
, BlockDecl>), internal::Matcher<ParmVarDecl> >(InnerMatcher
); } typedef ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_hasAnyParameter0Matcher, void(::clang::
ast_matchers::internal::TypeList<FunctionDecl, ObjCMethodDecl
, BlockDecl>), internal::Matcher<ParmVarDecl> > (
&hasAnyParameter_Type0)(internal::Matcher<ParmVarDecl>
const &InnerMatcher); template <typename NodeType, typename
ParamT> bool internal:: matcher_hasAnyParameter0Matcher<
NodeType, ParamT>::matches( const NodeType &Node, ::clang
::ast_matchers::internal::ASTMatchFinder *Finder, ::clang::ast_matchers
::internal::BoundNodesTreeBuilder *Builder) const
4981 ObjCMethodDecl,namespace internal { template <typename NodeType, typename
ParamT> class matcher_hasAnyParameter0Matcher : public ::
clang::ast_matchers::internal::MatcherInterface<NodeType>
{ public: explicit matcher_hasAnyParameter0Matcher( internal
::Matcher<ParmVarDecl> 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<ParmVarDecl> InnerMatcher; }; } inline
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_hasAnyParameter0Matcher, void(::clang::ast_matchers
::internal::TypeList<FunctionDecl, ObjCMethodDecl, BlockDecl
>), internal::Matcher<ParmVarDecl> > hasAnyParameter
(internal::Matcher<ParmVarDecl> const &InnerMatcher
) { return ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_hasAnyParameter0Matcher, void(::clang::
ast_matchers::internal::TypeList<FunctionDecl, ObjCMethodDecl
, BlockDecl>), internal::Matcher<ParmVarDecl> >(InnerMatcher
); } typedef ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_hasAnyParameter0Matcher, void(::clang::
ast_matchers::internal::TypeList<FunctionDecl, ObjCMethodDecl
, BlockDecl>), internal::Matcher<ParmVarDecl> > (
&hasAnyParameter_Type0)(internal::Matcher<ParmVarDecl>
const &InnerMatcher); template <typename NodeType, typename
ParamT> bool internal:: matcher_hasAnyParameter0Matcher<
NodeType, ParamT>::matches( const NodeType &Node, ::clang
::ast_matchers::internal::ASTMatchFinder *Finder, ::clang::ast_matchers
::internal::BoundNodesTreeBuilder *Builder) const
4982 BlockDecl),namespace internal { template <typename NodeType, typename
ParamT> class matcher_hasAnyParameter0Matcher : public ::
clang::ast_matchers::internal::MatcherInterface<NodeType>
{ public: explicit matcher_hasAnyParameter0Matcher( internal
::Matcher<ParmVarDecl> 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<ParmVarDecl> InnerMatcher; }; } inline
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_hasAnyParameter0Matcher, void(::clang::ast_matchers
::internal::TypeList<FunctionDecl, ObjCMethodDecl, BlockDecl
>), internal::Matcher<ParmVarDecl> > hasAnyParameter
(internal::Matcher<ParmVarDecl> const &InnerMatcher
) { return ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_hasAnyParameter0Matcher, void(::clang::
ast_matchers::internal::TypeList<FunctionDecl, ObjCMethodDecl
, BlockDecl>), internal::Matcher<ParmVarDecl> >(InnerMatcher
); } typedef ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_hasAnyParameter0Matcher, void(::clang::
ast_matchers::internal::TypeList<FunctionDecl, ObjCMethodDecl
, BlockDecl>), internal::Matcher<ParmVarDecl> > (
&hasAnyParameter_Type0)(internal::Matcher<ParmVarDecl>
const &InnerMatcher); template <typename NodeType, typename
ParamT> bool internal:: matcher_hasAnyParameter0Matcher<
NodeType, ParamT>::matches( const NodeType &Node, ::clang
::ast_matchers::internal::ASTMatchFinder *Finder, ::clang::ast_matchers
::internal::BoundNodesTreeBuilder *Builder) const
4983 internal::Matcher<ParmVarDecl>,namespace internal { template <typename NodeType, typename
ParamT> class matcher_hasAnyParameter0Matcher : public ::
clang::ast_matchers::internal::MatcherInterface<NodeType>
{ public: explicit matcher_hasAnyParameter0Matcher( internal
::Matcher<ParmVarDecl> 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<ParmVarDecl> InnerMatcher; }; } inline
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_hasAnyParameter0Matcher, void(::clang::ast_matchers
::internal::TypeList<FunctionDecl, ObjCMethodDecl, BlockDecl
>), internal::Matcher<ParmVarDecl> > hasAnyParameter
(internal::Matcher<ParmVarDecl> const &InnerMatcher
) { return ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_hasAnyParameter0Matcher, void(::clang::
ast_matchers::internal::TypeList<FunctionDecl, ObjCMethodDecl
, BlockDecl>), internal::Matcher<ParmVarDecl> >(InnerMatcher
); } typedef ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_hasAnyParameter0Matcher, void(::clang::
ast_matchers::internal::TypeList<FunctionDecl, ObjCMethodDecl
, BlockDecl>), internal::Matcher<ParmVarDecl> > (
&hasAnyParameter_Type0)(internal::Matcher<ParmVarDecl>
const &InnerMatcher); template <typename NodeType, typename
ParamT> bool internal:: matcher_hasAnyParameter0Matcher<
NodeType, ParamT>::matches( const NodeType &Node, ::clang
::ast_matchers::internal::ASTMatchFinder *Finder, ::clang::ast_matchers
::internal::BoundNodesTreeBuilder *Builder) const
4984 InnerMatcher)namespace internal { template <typename NodeType, typename
ParamT> class matcher_hasAnyParameter0Matcher : public ::
clang::ast_matchers::internal::MatcherInterface<NodeType>
{ public: explicit matcher_hasAnyParameter0Matcher( internal
::Matcher<ParmVarDecl> 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<ParmVarDecl> InnerMatcher; }; } inline
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_hasAnyParameter0Matcher, void(::clang::ast_matchers
::internal::TypeList<FunctionDecl, ObjCMethodDecl, BlockDecl
>), internal::Matcher<ParmVarDecl> > hasAnyParameter
(internal::Matcher<ParmVarDecl> const &InnerMatcher
) { return ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_hasAnyParameter0Matcher, void(::clang::
ast_matchers::internal::TypeList<FunctionDecl, ObjCMethodDecl
, BlockDecl>), internal::Matcher<ParmVarDecl> >(InnerMatcher
); } typedef ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_hasAnyParameter0Matcher, void(::clang::
ast_matchers::internal::TypeList<FunctionDecl, ObjCMethodDecl
, BlockDecl>), internal::Matcher<ParmVarDecl> > (
&hasAnyParameter_Type0)(internal::Matcher<ParmVarDecl>
const &InnerMatcher); template <typename NodeType, typename
ParamT> bool internal:: matcher_hasAnyParameter0Matcher<
NodeType, ParamT>::matches( const NodeType &Node, ::clang
::ast_matchers::internal::ASTMatchFinder *Finder, ::clang::ast_matchers
::internal::BoundNodesTreeBuilder *Builder) const
{
4985 return matchesFirstInPointerRange(InnerMatcher, Node.param_begin(),
4986 Node.param_end(), Finder,
4987 Builder) != Node.param_end();
4988}
4989
4990/// Matches \c FunctionDecls and \c FunctionProtoTypes that have a
4991/// specific parameter count.
4992///
4993/// Given
4994/// \code
4995/// void f(int i) {}
4996/// void g(int i, int j) {}
4997/// void h(int i, int j);
4998/// void j(int i);
4999/// void k(int x, int y, int z, ...);
5000/// \endcode
5001/// functionDecl(parameterCountIs(2))
5002/// matches \c g and \c h
5003/// functionProtoType(parameterCountIs(2))
5004/// matches \c g and \c h
5005/// functionProtoType(parameterCountIs(3))
5006/// matches \c k
5007AST_POLYMORPHIC_MATCHER_P(parameterCountIs,namespace internal { template <typename NodeType, typename
ParamT> class matcher_parameterCountIs0Matcher : public ::
clang::ast_matchers::internal::MatcherInterface<NodeType>
{ public: explicit matcher_parameterCountIs0Matcher( 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_parameterCountIs0Matcher
, void(::clang::ast_matchers::internal::TypeList<FunctionDecl
, FunctionProtoType>), unsigned> parameterCountIs(unsigned
const &N) { return ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_parameterCountIs0Matcher, void(::clang
::ast_matchers::internal::TypeList<FunctionDecl, FunctionProtoType
>), unsigned>(N); } typedef ::clang::ast_matchers::internal
::PolymorphicMatcher< internal::matcher_parameterCountIs0Matcher
, void(::clang::ast_matchers::internal::TypeList<FunctionDecl
, FunctionProtoType>), unsigned> (&parameterCountIs_Type0
)(unsigned const &N); template <typename NodeType, typename
ParamT> bool internal:: matcher_parameterCountIs0Matcher<
NodeType, ParamT>::matches( const NodeType &Node, ::clang
::ast_matchers::internal::ASTMatchFinder *Finder, ::clang::ast_matchers
::internal::BoundNodesTreeBuilder *Builder) const
5008 AST_POLYMORPHIC_SUPPORTED_TYPES(FunctionDecl,namespace internal { template <typename NodeType, typename
ParamT> class matcher_parameterCountIs0Matcher : public ::
clang::ast_matchers::internal::MatcherInterface<NodeType>
{ public: explicit matcher_parameterCountIs0Matcher( 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_parameterCountIs0Matcher
, void(::clang::ast_matchers::internal::TypeList<FunctionDecl
, FunctionProtoType>), unsigned> parameterCountIs(unsigned
const &N) { return ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_parameterCountIs0Matcher, void(::clang
::ast_matchers::internal::TypeList<FunctionDecl, FunctionProtoType
>), unsigned>(N); } typedef ::clang::ast_matchers::internal
::PolymorphicMatcher< internal::matcher_parameterCountIs0Matcher
, void(::clang::ast_matchers::internal::TypeList<FunctionDecl
, FunctionProtoType>), unsigned> (&parameterCountIs_Type0
)(unsigned const &N); template <typename NodeType, typename
ParamT> bool internal:: matcher_parameterCountIs0Matcher<
NodeType, ParamT>::matches( const NodeType &Node, ::clang
::ast_matchers::internal::ASTMatchFinder *Finder, ::clang::ast_matchers
::internal::BoundNodesTreeBuilder *Builder) const
5009 FunctionProtoType),namespace internal { template <typename NodeType, typename
ParamT> class matcher_parameterCountIs0Matcher : public ::
clang::ast_matchers::internal::MatcherInterface<NodeType>
{ public: explicit matcher_parameterCountIs0Matcher( 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_parameterCountIs0Matcher
, void(::clang::ast_matchers::internal::TypeList<FunctionDecl
, FunctionProtoType>), unsigned> parameterCountIs(unsigned
const &N) { return ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_parameterCountIs0Matcher, void(::clang
::ast_matchers::internal::TypeList<FunctionDecl, FunctionProtoType
>), unsigned>(N); } typedef ::clang::ast_matchers::internal
::PolymorphicMatcher< internal::matcher_parameterCountIs0Matcher
, void(::clang::ast_matchers::internal::TypeList<FunctionDecl
, FunctionProtoType>), unsigned> (&parameterCountIs_Type0
)(unsigned const &N); template <typename NodeType, typename
ParamT> bool internal:: matcher_parameterCountIs0Matcher<
NodeType, ParamT>::matches( const NodeType &Node, ::clang
::ast_matchers::internal::ASTMatchFinder *Finder, ::clang::ast_matchers
::internal::BoundNodesTreeBuilder *Builder) const
5010 unsigned, N)namespace internal { template <typename NodeType, typename
ParamT> class matcher_parameterCountIs0Matcher : public ::
clang::ast_matchers::internal::MatcherInterface<NodeType>
{ public: explicit matcher_parameterCountIs0Matcher( 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_parameterCountIs0Matcher
, void(::clang::ast_matchers::internal::TypeList<FunctionDecl
, FunctionProtoType>), unsigned> parameterCountIs(unsigned
const &N) { return ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_parameterCountIs0Matcher, void(::clang
::ast_matchers::internal::TypeList<FunctionDecl, FunctionProtoType
>), unsigned>(N); } typedef ::clang::ast_matchers::internal
::PolymorphicMatcher< internal::matcher_parameterCountIs0Matcher
, void(::clang::ast_matchers::internal::TypeList<FunctionDecl
, FunctionProtoType>), unsigned> (&parameterCountIs_Type0
)(unsigned const &N); template <typename NodeType, typename
ParamT> bool internal:: matcher_parameterCountIs0Matcher<
NodeType, ParamT>::matches( const NodeType &Node, ::clang
::ast_matchers::internal::ASTMatchFinder *Finder, ::clang::ast_matchers
::internal::BoundNodesTreeBuilder *Builder) const
{
5011 return Node.getNumParams() == N;
5012}
5013
5014/// Matches \c FunctionDecls that have a noreturn attribute.
5015///
5016/// Given
5017/// \code
5018/// void nope();
5019/// [[noreturn]] void a();
5020/// __attribute__((noreturn)) void b();
5021/// struct c { [[noreturn]] c(); };
5022/// \endcode
5023/// functionDecl(isNoReturn())
5024/// matches all of those except
5025/// \code
5026/// void nope();
5027/// \endcode
5028AST_MATCHER(FunctionDecl, isNoReturn)namespace internal { class matcher_isNoReturnMatcher : public
::clang::ast_matchers::internal::MatcherInterface<FunctionDecl
> { public: explicit matcher_isNoReturnMatcher() = 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>
isNoReturn() { return ::clang::ast_matchers::internal::makeMatcher
( new internal::matcher_isNoReturnMatcher()); } inline bool internal
::matcher_isNoReturnMatcher::matches( const FunctionDecl &
Node, ::clang::ast_matchers::internal::ASTMatchFinder *Finder
, ::clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder
) const
{ return Node.isNoReturn(); }
5029
5030/// Matches the return type of a function declaration.
5031///
5032/// Given:
5033/// \code
5034/// class X { int f() { return 1; } };
5035/// \endcode
5036/// cxxMethodDecl(returns(asString("int")))
5037/// matches int f() { return 1; }
5038AST_MATCHER_P(FunctionDecl, returns,namespace internal { class matcher_returns0Matcher : public ::
clang::ast_matchers::internal::MatcherInterface<FunctionDecl
> { public: explicit matcher_returns0Matcher( internal::Matcher
<QualType> const &AInnerMatcher) : InnerMatcher(AInnerMatcher
) {} bool matches(const FunctionDecl &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<FunctionDecl> returns( internal
::Matcher<QualType> const &InnerMatcher) { return ::
clang::ast_matchers::internal::makeMatcher( new internal::matcher_returns0Matcher
(InnerMatcher)); } typedef ::clang::ast_matchers::internal::Matcher
<FunctionDecl> ( &returns_Type0)(internal::Matcher<
QualType> const &InnerMatcher); inline bool internal::
matcher_returns0Matcher::matches( const FunctionDecl &Node
, ::clang::ast_matchers::internal::ASTMatchFinder *Finder, ::
clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder
) const
5039 internal::Matcher<QualType>, InnerMatcher)namespace internal { class matcher_returns0Matcher : public ::
clang::ast_matchers::internal::MatcherInterface<FunctionDecl
> { public: explicit matcher_returns0Matcher( internal::Matcher
<QualType> const &AInnerMatcher) : InnerMatcher(AInnerMatcher
) {} bool matches(const FunctionDecl &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<FunctionDecl> returns( internal
::Matcher<QualType> const &InnerMatcher) { return ::
clang::ast_matchers::internal::makeMatcher( new internal::matcher_returns0Matcher
(InnerMatcher)); } typedef ::clang::ast_matchers::internal::Matcher
<FunctionDecl> ( &returns_Type0)(internal::Matcher<
QualType> const &InnerMatcher); inline bool internal::
matcher_returns0Matcher::matches( const FunctionDecl &Node
, ::clang::ast_matchers::internal::ASTMatchFinder *Finder, ::
clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder
) const
{
5040 return InnerMatcher.matches(Node.getReturnType(), Finder, Builder);
5041}
5042
5043/// Matches extern "C" function or variable declarations.
5044///
5045/// Given:
5046/// \code
5047/// extern "C" void f() {}
5048/// extern "C" { void g() {} }
5049/// void h() {}
5050/// extern "C" int x = 1;
5051/// extern "C" int y = 2;
5052/// int z = 3;
5053/// \endcode
5054/// functionDecl(isExternC())
5055/// matches the declaration of f and g, but not the declaration of h.
5056/// varDecl(isExternC())
5057/// matches the declaration of x and y, but not the declaration of z.
5058AST_POLYMORPHIC_MATCHER(isExternC, AST_POLYMORPHIC_SUPPORTED_TYPES(FunctionDecl,namespace internal { template <typename NodeType> class
matcher_isExternCMatcher : 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_isExternCMatcher
, void(::clang::ast_matchers::internal::TypeList<FunctionDecl
, VarDecl>)> isExternC() { return ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_isExternCMatcher
, void(::clang::ast_matchers::internal::TypeList<FunctionDecl
, VarDecl>)>(); } template <typename NodeType> bool
internal::matcher_isExternCMatcher<NodeType>::matches(
const NodeType &Node, ::clang::ast_matchers::internal::ASTMatchFinder
*Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
5059 VarDecl))namespace internal { template <typename NodeType> class
matcher_isExternCMatcher : 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_isExternCMatcher
, void(::clang::ast_matchers::internal::TypeList<FunctionDecl
, VarDecl>)> isExternC() { return ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_isExternCMatcher
, void(::clang::ast_matchers::internal::TypeList<FunctionDecl
, VarDecl>)>(); } template <typename NodeType> bool
internal::matcher_isExternCMatcher<NodeType>::matches(
const NodeType &Node, ::clang::ast_matchers::internal::ASTMatchFinder
*Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
5060 return Node.isExternC();
5061}
5062
5063/// Matches variable/function declarations that have "static" storage
5064/// class specifier ("static" keyword) written in the source.
5065///
5066/// Given:
5067/// \code
5068/// static void f() {}
5069/// static int i = 0;
5070/// extern int j;
5071/// int k;
5072/// \endcode
5073/// functionDecl(isStaticStorageClass())
5074/// matches the function declaration f.
5075/// varDecl(isStaticStorageClass())
5076/// matches the variable declaration i.
5077AST_POLYMORPHIC_MATCHER(isStaticStorageClass,namespace internal { template <typename NodeType> class
matcher_isStaticStorageClassMatcher : 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_isStaticStorageClassMatcher
, void(::clang::ast_matchers::internal::TypeList<FunctionDecl
, VarDecl>)> isStaticStorageClass() { return ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_isStaticStorageClassMatcher
, void(::clang::ast_matchers::internal::TypeList<FunctionDecl
, VarDecl>)>(); } template <typename NodeType> bool
internal::matcher_isStaticStorageClassMatcher<NodeType>
::matches( const NodeType &Node, ::clang::ast_matchers::internal
::ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
5078 AST_POLYMORPHIC_SUPPORTED_TYPES(FunctionDecl,namespace internal { template <typename NodeType> class
matcher_isStaticStorageClassMatcher : 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_isStaticStorageClassMatcher
, void(::clang::ast_matchers::internal::TypeList<FunctionDecl
, VarDecl>)> isStaticStorageClass() { return ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_isStaticStorageClassMatcher
, void(::clang::ast_matchers::internal::TypeList<FunctionDecl
, VarDecl>)>(); } template <typename NodeType> bool
internal::matcher_isStaticStorageClassMatcher<NodeType>
::matches( const NodeType &Node, ::clang::ast_matchers::internal
::ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
5079 VarDecl))namespace internal { template <typename NodeType> class
matcher_isStaticStorageClassMatcher : 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_isStaticStorageClassMatcher
, void(::clang::ast_matchers::internal::TypeList<FunctionDecl
, VarDecl>)> isStaticStorageClass() { return ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_isStaticStorageClassMatcher
, void(::clang::ast_matchers::internal::TypeList<FunctionDecl
, VarDecl>)>(); } template <typename NodeType> bool
internal::matcher_isStaticStorageClassMatcher<NodeType>
::matches( const NodeType &Node, ::clang::ast_matchers::internal
::ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
5080 return Node.getStorageClass() == SC_Static;
5081}
5082
5083/// Matches deleted function declarations.
5084///
5085/// Given:
5086/// \code
5087/// void Func();
5088/// void DeletedFunc() = delete;
5089/// \endcode
5090/// functionDecl(isDeleted())
5091/// matches the declaration of DeletedFunc, but not Func.
5092AST_MATCHER(FunctionDecl, isDeleted)namespace internal { class matcher_isDeletedMatcher : public ::
clang::ast_matchers::internal::MatcherInterface<FunctionDecl
> { public: explicit matcher_isDeletedMatcher() = 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>
isDeleted() { return ::clang::ast_matchers::internal::makeMatcher
( new internal::matcher_isDeletedMatcher()); } inline bool internal
::matcher_isDeletedMatcher::matches( const FunctionDecl &
Node, ::clang::ast_matchers::internal::ASTMatchFinder *Finder
, ::clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder
) const
{
5093 return Node.isDeleted();
5094}
5095
5096/// Matches defaulted function declarations.
5097///
5098/// Given:
5099/// \code
5100/// class A { ~A(); };
5101/// class B { ~B() = default; };
5102/// \endcode
5103/// functionDecl(isDefaulted())
5104/// matches the declaration of ~B, but not ~A.
5105AST_MATCHER(FunctionDecl, isDefaulted)namespace internal { class matcher_isDefaultedMatcher : public
::clang::ast_matchers::internal::MatcherInterface<FunctionDecl
> { public: explicit matcher_isDefaultedMatcher() = 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>
isDefaulted() { return ::clang::ast_matchers::internal::makeMatcher
( new internal::matcher_isDefaultedMatcher()); } inline bool internal
::matcher_isDefaultedMatcher::matches( const FunctionDecl &
Node, ::clang::ast_matchers::internal::ASTMatchFinder *Finder
, ::clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder
) const
{
5106 return Node.isDefaulted();
5107}
5108
5109/// Matches weak function declarations.
5110///
5111/// Given:
5112/// \code
5113/// void foo() __attribute__((__weakref__("__foo")));
5114/// void bar();
5115/// \endcode
5116/// functionDecl(isWeak())
5117/// matches the weak declaration "foo", but not "bar".
5118AST_MATCHER(FunctionDecl, isWeak)namespace internal { class matcher_isWeakMatcher : public ::clang
::ast_matchers::internal::MatcherInterface<FunctionDecl>
{ public: explicit matcher_isWeakMatcher() = 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> isWeak() { return ::clang
::ast_matchers::internal::makeMatcher( new internal::matcher_isWeakMatcher
()); } inline bool internal::matcher_isWeakMatcher::matches( const
FunctionDecl &Node, ::clang::ast_matchers::internal::ASTMatchFinder
*Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{ return Node.isWeak(); }
5119
5120/// Matches functions that have a dynamic exception specification.
5121///
5122/// Given:
5123/// \code
5124/// void f();
5125/// void g() noexcept;
5126/// void h() noexcept(true);
5127/// void i() noexcept(false);
5128/// void j() throw();
5129/// void k() throw(int);
5130/// void l() throw(...);
5131/// \endcode
5132/// functionDecl(hasDynamicExceptionSpec()) and
5133/// functionProtoType(hasDynamicExceptionSpec())
5134/// match the declarations of j, k, and l, but not f, g, h, or i.
5135AST_POLYMORPHIC_MATCHER(hasDynamicExceptionSpec,namespace internal { template <typename NodeType> class
matcher_hasDynamicExceptionSpecMatcher : 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_hasDynamicExceptionSpecMatcher
, void(::clang::ast_matchers::internal::TypeList<FunctionDecl
, FunctionProtoType>)> hasDynamicExceptionSpec() { return
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_hasDynamicExceptionSpecMatcher, void(::clang::ast_matchers
::internal::TypeList<FunctionDecl, FunctionProtoType>)>
(); } template <typename NodeType> bool internal::matcher_hasDynamicExceptionSpecMatcher
<NodeType>::matches( const NodeType &Node, ::clang::
ast_matchers::internal::ASTMatchFinder *Finder, ::clang::ast_matchers
::internal::BoundNodesTreeBuilder *Builder) const
5136 AST_POLYMORPHIC_SUPPORTED_TYPES(FunctionDecl,namespace internal { template <typename NodeType> class
matcher_hasDynamicExceptionSpecMatcher : 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_hasDynamicExceptionSpecMatcher
, void(::clang::ast_matchers::internal::TypeList<FunctionDecl
, FunctionProtoType>)> hasDynamicExceptionSpec() { return
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_hasDynamicExceptionSpecMatcher, void(::clang::ast_matchers
::internal::TypeList<FunctionDecl, FunctionProtoType>)>
(); } template <typename NodeType> bool internal::matcher_hasDynamicExceptionSpecMatcher
<NodeType>::matches( const NodeType &Node, ::clang::
ast_matchers::internal::ASTMatchFinder *Finder, ::clang::ast_matchers
::internal::BoundNodesTreeBuilder *Builder) const
5137 FunctionProtoType))namespace internal { template <typename NodeType> class
matcher_hasDynamicExceptionSpecMatcher : 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_hasDynamicExceptionSpecMatcher
, void(::clang::ast_matchers::internal::TypeList<FunctionDecl
, FunctionProtoType>)> hasDynamicExceptionSpec() { return
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_hasDynamicExceptionSpecMatcher, void(::clang::ast_matchers
::internal::TypeList<FunctionDecl, FunctionProtoType>)>
(); } template <typename NodeType> bool internal::matcher_hasDynamicExceptionSpecMatcher
<NodeType>::matches( const NodeType &Node, ::clang::
ast_matchers::internal::ASTMatchFinder *Finder, ::clang::ast_matchers
::internal::BoundNodesTreeBuilder *Builder) const
{
5138 if (const FunctionProtoType *FnTy = internal::getFunctionProtoType(Node))
5139 return FnTy->hasDynamicExceptionSpec();
5140 return false;
5141}
5142
5143/// Matches functions that have a non-throwing exception specification.
5144///
5145/// Given:
5146/// \code
5147/// void f();
5148/// void g() noexcept;
5149/// void h() throw();
5150/// void i() throw(int);
5151/// void j() noexcept(false);
5152/// \endcode
5153/// functionDecl(isNoThrow()) and functionProtoType(isNoThrow())
5154/// match the declarations of g, and h, but not f, i or j.
5155AST_POLYMORPHIC_MATCHER(isNoThrow,namespace internal { template <typename NodeType> class
matcher_isNoThrowMatcher : 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_isNoThrowMatcher
, void(::clang::ast_matchers::internal::TypeList<FunctionDecl
, FunctionProtoType>)> isNoThrow() { return ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_isNoThrowMatcher
, void(::clang::ast_matchers::internal::TypeList<FunctionDecl
, FunctionProtoType>)>(); } template <typename NodeType
> bool internal::matcher_isNoThrowMatcher<NodeType>::
matches( const NodeType &Node, ::clang::ast_matchers::internal
::ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
5156 AST_POLYMORPHIC_SUPPORTED_TYPES(FunctionDecl,namespace internal { template <typename NodeType> class
matcher_isNoThrowMatcher : 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_isNoThrowMatcher
, void(::clang::ast_matchers::internal::TypeList<FunctionDecl
, FunctionProtoType>)> isNoThrow() { return ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_isNoThrowMatcher
, void(::clang::ast_matchers::internal::TypeList<FunctionDecl
, FunctionProtoType>)>(); } template <typename NodeType
> bool internal::matcher_isNoThrowMatcher<NodeType>::
matches( const NodeType &Node, ::clang::ast_matchers::internal
::ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
5157 FunctionProtoType))namespace internal { template <typename NodeType> class
matcher_isNoThrowMatcher : 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_isNoThrowMatcher
, void(::clang::ast_matchers::internal::TypeList<FunctionDecl
, FunctionProtoType>)> isNoThrow() { return ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_isNoThrowMatcher
, void(::clang::ast_matchers::internal::TypeList<FunctionDecl
, FunctionProtoType>)>(); } template <typename NodeType
> bool internal::matcher_isNoThrowMatcher<NodeType>::
matches( const NodeType &Node, ::clang::ast_matchers::internal
::ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
5158 const FunctionProtoType *FnTy = internal::getFunctionProtoType(Node);
5159
5160 // If the function does not have a prototype, then it is assumed to be a
5161 // throwing function (as it would if the function did not have any exception
5162 // specification).
5163 if (!FnTy)
5164 return false;
5165
5166 // Assume the best for any unresolved exception specification.
5167 if (isUnresolvedExceptionSpec(FnTy->getExceptionSpecType()))
5168 return true;
5169
5170 return FnTy->isNothrow();
5171}
5172
5173/// Matches constexpr variable and function declarations,
5174/// and if constexpr.
5175///
5176/// Given:
5177/// \code
5178/// constexpr int foo = 42;
5179/// constexpr int bar();
5180/// void baz() { if constexpr(1 > 0) {} }
5181/// \endcode
5182/// varDecl(isConstexpr())
5183/// matches the declaration of foo.
5184/// functionDecl(isConstexpr())
5185/// matches the declaration of bar.
5186/// ifStmt(isConstexpr())
5187/// matches the if statement in baz.
5188AST_POLYMORPHIC_MATCHER(isConstexpr,namespace internal { template <typename NodeType> class
matcher_isConstexprMatcher : 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_isConstexprMatcher
, void(::clang::ast_matchers::internal::TypeList<VarDecl, FunctionDecl
, IfStmt>)> isConstexpr() { return ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_isConstexprMatcher
, void(::clang::ast_matchers::internal::TypeList<VarDecl, FunctionDecl
, IfStmt>)>(); } template <typename NodeType> bool
internal::matcher_isConstexprMatcher<NodeType>::matches
( const NodeType &Node, ::clang::ast_matchers::internal::
ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
5189 AST_POLYMORPHIC_SUPPORTED_TYPES(VarDecl,namespace internal { template <typename NodeType> class
matcher_isConstexprMatcher : 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_isConstexprMatcher
, void(::clang::ast_matchers::internal::TypeList<VarDecl, FunctionDecl
, IfStmt>)> isConstexpr() { return ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_isConstexprMatcher
, void(::clang::ast_matchers::internal::TypeList<VarDecl, FunctionDecl
, IfStmt>)>(); } template <typename NodeType> bool
internal::matcher_isConstexprMatcher<NodeType>::matches
( const NodeType &Node, ::clang::ast_matchers::internal::
ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
5190 FunctionDecl,namespace internal { template <typename NodeType> class
matcher_isConstexprMatcher : 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_isConstexprMatcher
, void(::clang::ast_matchers::internal::TypeList<VarDecl, FunctionDecl
, IfStmt>)> isConstexpr() { return ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_isConstexprMatcher
, void(::clang::ast_matchers::internal::TypeList<VarDecl, FunctionDecl
, IfStmt>)>(); } template <typename NodeType> bool
internal::matcher_isConstexprMatcher<NodeType>::matches
( const NodeType &Node, ::clang::ast_matchers::internal::
ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
5191 IfStmt))namespace internal { template <typename NodeType> class
matcher_isConstexprMatcher : 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_isConstexprMatcher
, void(::clang::ast_matchers::internal::TypeList<VarDecl, FunctionDecl
, IfStmt>)> isConstexpr() { return ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_isConstexprMatcher
, void(::clang::ast_matchers::internal::TypeList<VarDecl, FunctionDecl
, IfStmt>)>(); } template <typename NodeType> bool
internal::matcher_isConstexprMatcher<NodeType>::matches
( const NodeType &Node, ::clang::ast_matchers::internal::
ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
5192 return Node.isConstexpr();
5193}
5194
5195/// Matches selection statements with initializer.
5196///
5197/// Given:
5198/// \code
5199/// void foo() {
5200/// if (int i = foobar(); i > 0) {}
5201/// switch (int i = foobar(); i) {}
5202/// for (auto& a = get_range(); auto& x : a) {}
5203/// }
5204/// void bar() {
5205/// if (foobar() > 0) {}
5206/// switch (foobar()) {}
5207/// for (auto& x : get_range()) {}
5208/// }
5209/// \endcode
5210/// ifStmt(hasInitStatement(anything()))
5211/// matches the if statement in foo but not in bar.
5212/// switchStmt(hasInitStatement(anything()))
5213/// matches the switch statement in foo but not in bar.
5214/// cxxForRangeStmt(hasInitStatement(anything()))
5215/// matches the range for statement in foo but not in bar.
5216AST_POLYMORPHIC_MATCHER_P(hasInitStatement,namespace internal { template <typename NodeType, typename
ParamT> class matcher_hasInitStatement0Matcher : public ::
clang::ast_matchers::internal::MatcherInterface<NodeType>
{ public: explicit matcher_hasInitStatement0Matcher( internal
::Matcher<Stmt> 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<Stmt> InnerMatcher; }; } inline ::clang
::ast_matchers::internal::PolymorphicMatcher< internal::matcher_hasInitStatement0Matcher
, void(::clang::ast_matchers::internal::TypeList<IfStmt, SwitchStmt
, CXXForRangeStmt>), internal::Matcher<Stmt> > hasInitStatement
(internal::Matcher<Stmt> const &InnerMatcher) { return
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_hasInitStatement0Matcher, void(::clang::ast_matchers
::internal::TypeList<IfStmt, SwitchStmt, CXXForRangeStmt>
), internal::Matcher<Stmt> >(InnerMatcher); } typedef
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_hasInitStatement0Matcher, void(::clang::ast_matchers
::internal::TypeList<IfStmt, SwitchStmt, CXXForRangeStmt>
), internal::Matcher<Stmt> > (&hasInitStatement_Type0
)(internal::Matcher<Stmt> const &InnerMatcher); template
<typename NodeType, typename ParamT> bool internal:: matcher_hasInitStatement0Matcher
<NodeType, ParamT>::matches( const NodeType &Node, ::
clang::ast_matchers::internal::ASTMatchFinder *Finder, ::clang
::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
5217 AST_POLYMORPHIC_SUPPORTED_TYPES(IfStmt, SwitchStmt,namespace internal { template <typename NodeType, typename
ParamT> class matcher_hasInitStatement0Matcher : public ::
clang::ast_matchers::internal::MatcherInterface<NodeType>
{ public: explicit matcher_hasInitStatement0Matcher( internal
::Matcher<Stmt> 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<Stmt> InnerMatcher; }; } inline ::clang
::ast_matchers::internal::PolymorphicMatcher< internal::matcher_hasInitStatement0Matcher
, void(::clang::ast_matchers::internal::TypeList<IfStmt, SwitchStmt
, CXXForRangeStmt>), internal::Matcher<Stmt> > hasInitStatement
(internal::Matcher<Stmt> const &InnerMatcher) { return
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_hasInitStatement0Matcher, void(::clang::ast_matchers
::internal::TypeList<IfStmt, SwitchStmt, CXXForRangeStmt>
), internal::Matcher<Stmt> >(InnerMatcher); } typedef
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_hasInitStatement0Matcher, void(::clang::ast_matchers
::internal::TypeList<IfStmt, SwitchStmt, CXXForRangeStmt>
), internal::Matcher<Stmt> > (&hasInitStatement_Type0
)(internal::Matcher<Stmt> const &InnerMatcher); template
<typename NodeType, typename ParamT> bool internal:: matcher_hasInitStatement0Matcher
<NodeType, ParamT>::matches( const NodeType &Node, ::
clang::ast_matchers::internal::ASTMatchFinder *Finder, ::clang
::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
5218 CXXForRangeStmt),namespace internal { template <typename NodeType, typename
ParamT> class matcher_hasInitStatement0Matcher : public ::
clang::ast_matchers::internal::MatcherInterface<NodeType>
{ public: explicit matcher_hasInitStatement0Matcher( internal
::Matcher<Stmt> 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<Stmt> InnerMatcher; }; } inline ::clang
::ast_matchers::internal::PolymorphicMatcher< internal::matcher_hasInitStatement0Matcher
, void(::clang::ast_matchers::internal::TypeList<IfStmt, SwitchStmt
, CXXForRangeStmt>), internal::Matcher<Stmt> > hasInitStatement
(internal::Matcher<Stmt> const &InnerMatcher) { return
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_hasInitStatement0Matcher, void(::clang::ast_matchers
::internal::TypeList<IfStmt, SwitchStmt, CXXForRangeStmt>
), internal::Matcher<Stmt> >(InnerMatcher); } typedef
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_hasInitStatement0Matcher, void(::clang::ast_matchers
::internal::TypeList<IfStmt, SwitchStmt, CXXForRangeStmt>
), internal::Matcher<Stmt> > (&hasInitStatement_Type0
)(internal::Matcher<Stmt> const &InnerMatcher); template
<typename NodeType, typename ParamT> bool internal:: matcher_hasInitStatement0Matcher
<NodeType, ParamT>::matches( const NodeType &Node, ::
clang::ast_matchers::internal::ASTMatchFinder *Finder, ::clang
::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
5219 internal::Matcher<Stmt>, InnerMatcher)namespace internal { template <typename NodeType, typename
ParamT> class matcher_hasInitStatement0Matcher : public ::
clang::ast_matchers::internal::MatcherInterface<NodeType>
{ public: explicit matcher_hasInitStatement0Matcher( internal
::Matcher<Stmt> 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<Stmt> InnerMatcher; }; } inline ::clang
::ast_matchers::internal::PolymorphicMatcher< internal::matcher_hasInitStatement0Matcher
, void(::clang::ast_matchers::internal::TypeList<IfStmt, SwitchStmt
, CXXForRangeStmt>), internal::Matcher<Stmt> > hasInitStatement
(internal::Matcher<Stmt> const &InnerMatcher) { return
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_hasInitStatement0Matcher, void(::clang::ast_matchers
::internal::TypeList<IfStmt, SwitchStmt, CXXForRangeStmt>
), internal::Matcher<Stmt> >(InnerMatcher); } typedef
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_hasInitStatement0Matcher, void(::clang::ast_matchers
::internal::TypeList<IfStmt, SwitchStmt, CXXForRangeStmt>
), internal::Matcher<Stmt> > (&hasInitStatement_Type0
)(internal::Matcher<Stmt> const &InnerMatcher); template
<typename NodeType, typename ParamT> bool internal:: matcher_hasInitStatement0Matcher
<NodeType, ParamT>::matches( const NodeType &Node, ::
clang::ast_matchers::internal::ASTMatchFinder *Finder, ::clang
::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
{
5220 const Stmt *Init = Node.getInit();
5221 return Init != nullptr && InnerMatcher.matches(*Init, Finder, Builder);
5222}
5223
5224/// Matches the condition expression of an if statement, for loop,
5225/// switch statement or conditional operator.
5226///
5227/// Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true))))
5228/// \code
5229/// if (true) {}
5230/// \endcode
5231AST_POLYMORPHIC_MATCHER_P(namespace internal { template <typename NodeType, typename
ParamT> class matcher_hasCondition0Matcher : public ::clang
::ast_matchers::internal::MatcherInterface<NodeType> { public
: explicit matcher_hasCondition0Matcher( internal::Matcher<
Expr> 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<Expr> InnerMatcher; }; } inline ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_hasCondition0Matcher
, void(::clang::ast_matchers::internal::TypeList<IfStmt, ForStmt
, WhileStmt, DoStmt, SwitchStmt, AbstractConditionalOperator>
), internal::Matcher<Expr> > hasCondition(internal::
Matcher<Expr> const &InnerMatcher) { return ::clang
::ast_matchers::internal::PolymorphicMatcher< internal::matcher_hasCondition0Matcher
, void(::clang::ast_matchers::internal::TypeList<IfStmt, ForStmt
, WhileStmt, DoStmt, SwitchStmt, AbstractConditionalOperator>
), internal::Matcher<Expr> >(InnerMatcher); } typedef
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_hasCondition0Matcher, void(::clang::ast_matchers::internal
::TypeList<IfStmt, ForStmt, WhileStmt, DoStmt, SwitchStmt,
AbstractConditionalOperator>), internal::Matcher<Expr>
> (&hasCondition_Type0)(internal::Matcher<Expr>
const &InnerMatcher); template <typename NodeType, typename
ParamT> bool internal:: matcher_hasCondition0Matcher<NodeType
, ParamT>::matches( const NodeType &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
5232 hasCondition,namespace internal { template <typename NodeType, typename
ParamT> class matcher_hasCondition0Matcher : public ::clang
::ast_matchers::internal::MatcherInterface<NodeType> { public
: explicit matcher_hasCondition0Matcher( internal::Matcher<
Expr> 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<Expr> InnerMatcher; }; } inline ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_hasCondition0Matcher
, void(::clang::ast_matchers::internal::TypeList<IfStmt, ForStmt
, WhileStmt, DoStmt, SwitchStmt, AbstractConditionalOperator>
), internal::Matcher<Expr> > hasCondition(internal::
Matcher<Expr> const &InnerMatcher) { return ::clang
::ast_matchers::internal::PolymorphicMatcher< internal::matcher_hasCondition0Matcher
, void(::clang::ast_matchers::internal::TypeList<IfStmt, ForStmt
, WhileStmt, DoStmt, SwitchStmt, AbstractConditionalOperator>
), internal::Matcher<Expr> >(InnerMatcher); } typedef
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_hasCondition0Matcher, void(::clang::ast_matchers::internal
::TypeList<IfStmt, ForStmt, WhileStmt, DoStmt, SwitchStmt,
AbstractConditionalOperator>), internal::Matcher<Expr>
> (&hasCondition_Type0)(internal::Matcher<Expr>
const &InnerMatcher); template <typename NodeType, typename
ParamT> bool internal:: matcher_hasCondition0Matcher<NodeType
, ParamT>::matches( const NodeType &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
5233 AST_POLYMORPHIC_SUPPORTED_TYPES(IfStmt, ForStmt, WhileStmt, DoStmt,namespace internal { template <typename NodeType, typename
ParamT> class matcher_hasCondition0Matcher : public ::clang
::ast_matchers::internal::MatcherInterface<NodeType> { public
: explicit matcher_hasCondition0Matcher( internal::Matcher<
Expr> 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<Expr> InnerMatcher; }; } inline ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_hasCondition0Matcher
, void(::clang::ast_matchers::internal::TypeList<IfStmt, ForStmt
, WhileStmt, DoStmt, SwitchStmt, AbstractConditionalOperator>
), internal::Matcher<Expr> > hasCondition(internal::
Matcher<Expr> const &InnerMatcher) { return ::clang
::ast_matchers::internal::PolymorphicMatcher< internal::matcher_hasCondition0Matcher
, void(::clang::ast_matchers::internal::TypeList<IfStmt, ForStmt
, WhileStmt, DoStmt, SwitchStmt, AbstractConditionalOperator>
), internal::Matcher<Expr> >(InnerMatcher); } typedef
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_hasCondition0Matcher, void(::clang::ast_matchers::internal
::TypeList<IfStmt, ForStmt, WhileStmt, DoStmt, SwitchStmt,
AbstractConditionalOperator>), internal::Matcher<Expr>
> (&hasCondition_Type0)(internal::Matcher<Expr>
const &InnerMatcher); template <typename NodeType, typename
ParamT> bool internal:: matcher_hasCondition0Matcher<NodeType
, ParamT>::matches( const NodeType &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
5234 SwitchStmt, AbstractConditionalOperator),namespace internal { template <typename NodeType, typename
ParamT> class matcher_hasCondition0Matcher : public ::clang
::ast_matchers::internal::MatcherInterface<NodeType> { public
: explicit matcher_hasCondition0Matcher( internal::Matcher<
Expr> 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<Expr> InnerMatcher; }; } inline ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_hasCondition0Matcher
, void(::clang::ast_matchers::internal::TypeList<IfStmt, ForStmt
, WhileStmt, DoStmt, SwitchStmt, AbstractConditionalOperator>
), internal::Matcher<Expr> > hasCondition(internal::
Matcher<Expr> const &InnerMatcher) { return ::clang
::ast_matchers::internal::PolymorphicMatcher< internal::matcher_hasCondition0Matcher
, void(::clang::ast_matchers::internal::TypeList<IfStmt, ForStmt
, WhileStmt, DoStmt, SwitchStmt, AbstractConditionalOperator>
), internal::Matcher<Expr> >(InnerMatcher); } typedef
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_hasCondition0Matcher, void(::clang::ast_matchers::internal
::TypeList<IfStmt, ForStmt, WhileStmt, DoStmt, SwitchStmt,
AbstractConditionalOperator>), internal::Matcher<Expr>
> (&hasCondition_Type0)(internal::Matcher<Expr>
const &InnerMatcher); template <typename NodeType, typename
ParamT> bool internal:: matcher_hasCondition0Matcher<NodeType
, ParamT>::matches( const NodeType &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
5235 internal::Matcher<Expr>, InnerMatcher)namespace internal { template <typename NodeType, typename
ParamT> class matcher_hasCondition0Matcher : public ::clang
::ast_matchers::internal::MatcherInterface<NodeType> { public
: explicit matcher_hasCondition0Matcher( internal::Matcher<
Expr> 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<Expr> InnerMatcher; }; } inline ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_hasCondition0Matcher
, void(::clang::ast_matchers::internal::TypeList<IfStmt, ForStmt
, WhileStmt, DoStmt, SwitchStmt, AbstractConditionalOperator>
), internal::Matcher<Expr> > hasCondition(internal::
Matcher<Expr> const &InnerMatcher) { return ::clang
::ast_matchers::internal::PolymorphicMatcher< internal::matcher_hasCondition0Matcher
, void(::clang::ast_matchers::internal::TypeList<IfStmt, ForStmt
, WhileStmt, DoStmt, SwitchStmt, AbstractConditionalOperator>
), internal::Matcher<Expr> >(InnerMatcher); } typedef
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_hasCondition0Matcher, void(::clang::ast_matchers::internal
::TypeList<IfStmt, ForStmt, WhileStmt, DoStmt, SwitchStmt,
AbstractConditionalOperator>), internal::Matcher<Expr>
> (&hasCondition_Type0)(internal::Matcher<Expr>
const &InnerMatcher); template <typename NodeType, typename
ParamT> bool internal:: matcher_hasCondition0Matcher<NodeType
, ParamT>::matches( const NodeType &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
{
5236 const Expr *const Condition = Node.getCond();
5237 return (Condition != nullptr &&
5238 InnerMatcher.matches(*Condition, Finder, Builder));
5239}
5240
5241/// Matches the then-statement of an if statement.
5242///
5243/// Examples matches the if statement
5244/// (matcher = ifStmt(hasThen(cxxBoolLiteral(equals(true)))))
5245/// \code
5246/// if (false) true; else false;
5247/// \endcode
5248AST_MATCHER_P(IfStmt, hasThen, internal::Matcher<Stmt>, InnerMatcher)namespace internal { class matcher_hasThen0Matcher : public ::
clang::ast_matchers::internal::MatcherInterface<IfStmt>
{ public: explicit matcher_hasThen0Matcher( internal::Matcher
<Stmt> const &AInnerMatcher) : InnerMatcher(AInnerMatcher
) {} bool matches(const IfStmt &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<IfStmt> hasThen( internal::Matcher<
Stmt> const &InnerMatcher) { return ::clang::ast_matchers
::internal::makeMatcher( new internal::matcher_hasThen0Matcher
(InnerMatcher)); } typedef ::clang::ast_matchers::internal::Matcher
<IfStmt> ( &hasThen_Type0)(internal::Matcher<Stmt
> const &InnerMatcher); inline bool internal::matcher_hasThen0Matcher
::matches( const IfStmt &Node, ::clang::ast_matchers::internal
::ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
5249 const Stmt *const Then = Node.getThen();
5250 return (Then != nullptr && InnerMatcher.matches(*Then, Finder, Builder));
5251}
5252
5253/// Matches the else-statement of an if statement.
5254///
5255/// Examples matches the if statement
5256/// (matcher = ifStmt(hasElse(cxxBoolLiteral(equals(true)))))
5257/// \code
5258/// if (false) false; else true;
5259/// \endcode
5260AST_MATCHER_P(IfStmt, hasElse, internal::Matcher<Stmt>, InnerMatcher)namespace internal { class matcher_hasElse0Matcher : public ::
clang::ast_matchers::internal::MatcherInterface<IfStmt>
{ public: explicit matcher_hasElse0Matcher( internal::Matcher
<Stmt> const &AInnerMatcher) : InnerMatcher(AInnerMatcher
) {} bool matches(const IfStmt &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<IfStmt> hasElse( internal::Matcher<
Stmt> const &InnerMatcher) { return ::clang::ast_matchers
::internal::makeMatcher( new internal::matcher_hasElse0Matcher
(InnerMatcher)); } typedef ::clang::ast_matchers::internal::Matcher
<IfStmt> ( &hasElse_Type0)(internal::Matcher<Stmt
> const &InnerMatcher); inline bool internal::matcher_hasElse0Matcher
::matches( const IfStmt &Node, ::clang::ast_matchers::internal
::ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
5261 const Stmt *const Else = Node.getElse();
5262 return (Else != nullptr && InnerMatcher.matches(*Else, Finder, Builder));
5263}
5264
5265/// Matches if a node equals a previously bound node.
5266///
5267/// Matches a node if it equals the node previously bound to \p ID.
5268///
5269/// Given
5270/// \code
5271/// class X { int a; int b; };
5272/// \endcode
5273/// cxxRecordDecl(
5274/// has(fieldDecl(hasName("a"), hasType(type().bind("t")))),
5275/// has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t"))))))
5276/// matches the class \c X, as \c a and \c b have the same type.
5277///
5278/// Note that when multiple matches are involved via \c forEach* matchers,
5279/// \c equalsBoundNodes acts as a filter.
5280/// For example:
5281/// compoundStmt(
5282/// forEachDescendant(varDecl().bind("d")),
5283/// forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d"))))))
5284/// will trigger a match for each combination of variable declaration
5285/// and reference to that variable declaration within a compound statement.
5286AST_POLYMORPHIC_MATCHER_P(equalsBoundNode,namespace internal { template <typename NodeType, typename
ParamT> class matcher_equalsBoundNode0Matcher : public ::
clang::ast_matchers::internal::MatcherInterface<NodeType>
{ public: explicit matcher_equalsBoundNode0Matcher( std::string
const &AID) : ID(AID) {} bool matches(const NodeType &
Node, ::clang::ast_matchers::internal::ASTMatchFinder *Finder
, ::clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder
) const override; private: std::string ID; }; } inline ::clang
::ast_matchers::internal::PolymorphicMatcher< internal::matcher_equalsBoundNode0Matcher
, void(::clang::ast_matchers::internal::TypeList<Stmt, Decl
, Type, QualType>), std::string> equalsBoundNode(std::string
const &ID) { return ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_equalsBoundNode0Matcher, void(::clang::
ast_matchers::internal::TypeList<Stmt, Decl, Type, QualType
>), std::string>(ID); } typedef ::clang::ast_matchers::
internal::PolymorphicMatcher< internal::matcher_equalsBoundNode0Matcher
, void(::clang::ast_matchers::internal::TypeList<Stmt, Decl
, Type, QualType>), std::string> (&equalsBoundNode_Type0
)(std::string const &ID); template <typename NodeType,
typename ParamT> bool internal:: matcher_equalsBoundNode0Matcher
<NodeType, ParamT>::matches( const NodeType &Node, ::
clang::ast_matchers::internal::ASTMatchFinder *Finder, ::clang
::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
5287 AST_POLYMORPHIC_SUPPORTED_TYPES(Stmt, Decl, Type,namespace internal { template <typename NodeType, typename
ParamT> class matcher_equalsBoundNode0Matcher : public ::
clang::ast_matchers::internal::MatcherInterface<NodeType>
{ public: explicit matcher_equalsBoundNode0Matcher( std::string
const &AID) : ID(AID) {} bool matches(const NodeType &
Node, ::clang::ast_matchers::internal::ASTMatchFinder *Finder
, ::clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder
) const override; private: std::string ID; }; } inline ::clang
::ast_matchers::internal::PolymorphicMatcher< internal::matcher_equalsBoundNode0Matcher
, void(::clang::ast_matchers::internal::TypeList<Stmt, Decl
, Type, QualType>), std::string> equalsBoundNode(std::string
const &ID) { return ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_equalsBoundNode0Matcher, void(::clang::
ast_matchers::internal::TypeList<Stmt, Decl, Type, QualType
>), std::string>(ID); } typedef ::clang::ast_matchers::
internal::PolymorphicMatcher< internal::matcher_equalsBoundNode0Matcher
, void(::clang::ast_matchers::internal::TypeList<Stmt, Decl
, Type, QualType>), std::string> (&equalsBoundNode_Type0
)(std::string const &ID); template <typename NodeType,
typename ParamT> bool internal:: matcher_equalsBoundNode0Matcher
<NodeType, ParamT>::matches( const NodeType &Node, ::
clang::ast_matchers::internal::ASTMatchFinder *Finder, ::clang
::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
5288 QualType),namespace internal { template <typename NodeType, typename
ParamT> class matcher_equalsBoundNode0Matcher : public ::
clang::ast_matchers::internal::MatcherInterface<NodeType>
{ public: explicit matcher_equalsBoundNode0Matcher( std::string
const &AID) : ID(AID) {} bool matches(const NodeType &
Node, ::clang::ast_matchers::internal::ASTMatchFinder *Finder
, ::clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder
) const override; private: std::string ID; }; } inline ::clang
::ast_matchers::internal::PolymorphicMatcher< internal::matcher_equalsBoundNode0Matcher
, void(::clang::ast_matchers::internal::TypeList<Stmt, Decl
, Type, QualType>), std::string> equalsBoundNode(std::string
const &ID) { return ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_equalsBoundNode0Matcher, void(::clang::
ast_matchers::internal::TypeList<Stmt, Decl, Type, QualType
>), std::string>(ID); } typedef ::clang::ast_matchers::
internal::PolymorphicMatcher< internal::matcher_equalsBoundNode0Matcher
, void(::clang::ast_matchers::internal::TypeList<Stmt, Decl
, Type, QualType>), std::string> (&equalsBoundNode_Type0
)(std::string const &ID); template <typename NodeType,
typename ParamT> bool internal:: matcher_equalsBoundNode0Matcher
<NodeType, ParamT>::matches( const NodeType &Node, ::
clang::ast_matchers::internal::ASTMatchFinder *Finder, ::clang
::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
5289 std::string, ID)namespace internal { template <typename NodeType, typename
ParamT> class matcher_equalsBoundNode0Matcher : public ::
clang::ast_matchers::internal::MatcherInterface<NodeType>
{ public: explicit matcher_equalsBoundNode0Matcher( std::string
const &AID) : ID(AID) {} bool matches(const NodeType &
Node, ::clang::ast_matchers::internal::ASTMatchFinder *Finder
, ::clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder
) const override; private: std::string ID; }; } inline ::clang
::ast_matchers::internal::PolymorphicMatcher< internal::matcher_equalsBoundNode0Matcher
, void(::clang::ast_matchers::internal::TypeList<Stmt, Decl
, Type, QualType>), std::string> equalsBoundNode(std::string
const &ID) { return ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_equalsBoundNode0Matcher, void(::clang::
ast_matchers::internal::TypeList<Stmt, Decl, Type, QualType
>), std::string>(ID); } typedef ::clang::ast_matchers::
internal::PolymorphicMatcher< internal::matcher_equalsBoundNode0Matcher
, void(::clang::ast_matchers::internal::TypeList<Stmt, Decl
, Type, QualType>), std::string> (&equalsBoundNode_Type0
)(std::string const &ID); template <typename NodeType,
typename ParamT> bool internal:: matcher_equalsBoundNode0Matcher
<NodeType, ParamT>::matches( const NodeType &Node, ::
clang::ast_matchers::internal::ASTMatchFinder *Finder, ::clang
::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
{
5290 // FIXME: Figure out whether it makes sense to allow this
5291 // on any other node types.
5292 // For *Loc it probably does not make sense, as those seem
5293 // unique. For NestedNameSepcifier it might make sense, as
5294 // those also have pointer identity, but I'm not sure whether
5295 // they're ever reused.
5296 internal::NotEqualsBoundNodePredicate Predicate;
5297 Predicate.ID = ID;
5298 Predicate.Node = DynTypedNode::create(Node);
5299 return Builder->removeBindings(Predicate);
5300}
5301
5302/// Matches the condition variable statement in an if statement.
5303///
5304/// Given
5305/// \code
5306/// if (A* a = GetAPointer()) {}
5307/// \endcode
5308/// hasConditionVariableStatement(...)
5309/// matches 'A* a = GetAPointer()'.
5310AST_MATCHER_P(IfStmt, hasConditionVariableStatement,namespace internal { class matcher_hasConditionVariableStatement0Matcher
: public ::clang::ast_matchers::internal::MatcherInterface<
IfStmt> { public: explicit matcher_hasConditionVariableStatement0Matcher
( internal::Matcher<DeclStmt> const &AInnerMatcher)
: InnerMatcher(AInnerMatcher) {} bool matches(const IfStmt &
Node, ::clang::ast_matchers::internal::ASTMatchFinder *Finder
, ::clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder
) const override; private: internal::Matcher<DeclStmt> InnerMatcher
; }; } inline ::clang::ast_matchers::internal::Matcher<IfStmt
> hasConditionVariableStatement( internal::Matcher<DeclStmt
> const &InnerMatcher) { return ::clang::ast_matchers::
internal::makeMatcher( new internal::matcher_hasConditionVariableStatement0Matcher
(InnerMatcher)); } typedef ::clang::ast_matchers::internal::Matcher
<IfStmt> ( &hasConditionVariableStatement_Type0)(internal
::Matcher<DeclStmt> const &InnerMatcher); inline bool
internal::matcher_hasConditionVariableStatement0Matcher::matches
( const IfStmt &Node, ::clang::ast_matchers::internal::ASTMatchFinder
*Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
5311 internal::Matcher<DeclStmt>, InnerMatcher)namespace internal { class matcher_hasConditionVariableStatement0Matcher
: public ::clang::ast_matchers::internal::MatcherInterface<
IfStmt> { public: explicit matcher_hasConditionVariableStatement0Matcher
( internal::Matcher<DeclStmt> const &AInnerMatcher)
: InnerMatcher(AInnerMatcher) {} bool matches(const IfStmt &
Node, ::clang::ast_matchers::internal::ASTMatchFinder *Finder
, ::clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder
) const override; private: internal::Matcher<DeclStmt> InnerMatcher
; }; } inline ::clang::ast_matchers::internal::Matcher<IfStmt
> hasConditionVariableStatement( internal::Matcher<DeclStmt
> const &InnerMatcher) { return ::clang::ast_matchers::
internal::makeMatcher( new internal::matcher_hasConditionVariableStatement0Matcher
(InnerMatcher)); } typedef ::clang::ast_matchers::internal::Matcher
<IfStmt> ( &hasConditionVariableStatement_Type0)(internal
::Matcher<DeclStmt> const &InnerMatcher); inline bool
internal::matcher_hasConditionVariableStatement0Matcher::matches
( const IfStmt &Node, ::clang::ast_matchers::internal::ASTMatchFinder
*Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
5312 const DeclStmt* const DeclarationStatement =
5313 Node.getConditionVariableDeclStmt();
5314 return DeclarationStatement != nullptr &&
5315 InnerMatcher.matches(*DeclarationStatement, Finder, Builder);
5316}
5317
5318/// Matches the index expression of an array subscript expression.
5319///
5320/// Given
5321/// \code
5322/// int i[5];
5323/// void f() { i[1] = 42; }
5324/// \endcode
5325/// arraySubscriptExpression(hasIndex(integerLiteral()))
5326/// matches \c i[1] with the \c integerLiteral() matching \c 1
5327AST_MATCHER_P(ArraySubscriptExpr, hasIndex,namespace internal { class matcher_hasIndex0Matcher : public ::
clang::ast_matchers::internal::MatcherInterface<ArraySubscriptExpr
> { public: explicit matcher_hasIndex0Matcher( internal::Matcher
<Expr> const &AInnerMatcher) : InnerMatcher(AInnerMatcher
) {} bool matches(const ArraySubscriptExpr &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<ArraySubscriptExpr> hasIndex
( internal::Matcher<Expr> const &InnerMatcher) { return
::clang::ast_matchers::internal::makeMatcher( new internal::
matcher_hasIndex0Matcher(InnerMatcher)); } typedef ::clang::ast_matchers
::internal::Matcher<ArraySubscriptExpr> ( &hasIndex_Type0
)(internal::Matcher<Expr> const &InnerMatcher); inline
bool internal::matcher_hasIndex0Matcher::matches( const ArraySubscriptExpr
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
5328 internal::Matcher<Expr>, InnerMatcher)namespace internal { class matcher_hasIndex0Matcher : public ::
clang::ast_matchers::internal::MatcherInterface<ArraySubscriptExpr
> { public: explicit matcher_hasIndex0Matcher( internal::Matcher
<Expr> const &AInnerMatcher) : InnerMatcher(AInnerMatcher
) {} bool matches(const ArraySubscriptExpr &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<ArraySubscriptExpr> hasIndex
( internal::Matcher<Expr> const &InnerMatcher) { return
::clang::ast_matchers::internal::makeMatcher( new internal::
matcher_hasIndex0Matcher(InnerMatcher)); } typedef ::clang::ast_matchers
::internal::Matcher<ArraySubscriptExpr> ( &hasIndex_Type0
)(internal::Matcher<Expr> const &InnerMatcher); inline
bool internal::matcher_hasIndex0Matcher::matches( const ArraySubscriptExpr
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
5329 if (const Expr* Expression = Node.getIdx())
5330 return InnerMatcher.matches(*Expression, Finder, Builder);
5331 return false;
5332}
5333
5334/// Matches the base expression of an array subscript expression.
5335///
5336/// Given
5337/// \code
5338/// int i[5];
5339/// void f() { i[1] = 42; }
5340/// \endcode
5341/// arraySubscriptExpression(hasBase(implicitCastExpr(
5342/// hasSourceExpression(declRefExpr()))))
5343/// matches \c i[1] with the \c declRefExpr() matching \c i
5344AST_MATCHER_P(ArraySubscriptExpr, hasBase,namespace internal { class matcher_hasBase0Matcher : public ::
clang::ast_matchers::internal::MatcherInterface<ArraySubscriptExpr
> { public: explicit matcher_hasBase0Matcher( internal::Matcher
<Expr> const &AInnerMatcher) : InnerMatcher(AInnerMatcher
) {} bool matches(const ArraySubscriptExpr &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<ArraySubscriptExpr> hasBase
( internal::Matcher<Expr> const &InnerMatcher) { return
::clang::ast_matchers::internal::makeMatcher( new internal::
matcher_hasBase0Matcher(InnerMatcher)); } typedef ::clang::ast_matchers
::internal::Matcher<ArraySubscriptExpr> ( &hasBase_Type0
)(internal::Matcher<Expr> const &InnerMatcher); inline
bool internal::matcher_hasBase0Matcher::matches( const ArraySubscriptExpr
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
5345 internal::Matcher<Expr>, InnerMatcher)namespace internal { class matcher_hasBase0Matcher : public ::
clang::ast_matchers::internal::MatcherInterface<ArraySubscriptExpr
> { public: explicit matcher_hasBase0Matcher( internal::Matcher
<Expr> const &AInnerMatcher) : InnerMatcher(AInnerMatcher
) {} bool matches(const ArraySubscriptExpr &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<ArraySubscriptExpr> hasBase
( internal::Matcher<Expr> const &InnerMatcher) { return
::clang::ast_matchers::internal::makeMatcher( new internal::
matcher_hasBase0Matcher(InnerMatcher)); } typedef ::clang::ast_matchers
::internal::Matcher<ArraySubscriptExpr> ( &hasBase_Type0
)(internal::Matcher<Expr> const &InnerMatcher); inline
bool internal::matcher_hasBase0Matcher::matches( const ArraySubscriptExpr
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
5346 if (const Expr* Expression = Node.getBase())
5347 return InnerMatcher.matches(*Expression, Finder, Builder);
5348 return false;
5349}
5350
5351/// Matches a 'for', 'while', 'do while' statement or a function
5352/// definition that has a given body. Note that in case of functions
5353/// this matcher only matches the definition itself and not the other
5354/// declarations of the same function.
5355///
5356/// Given
5357/// \code
5358/// for (;;) {}
5359/// \endcode
5360/// hasBody(compoundStmt())
5361/// matches 'for (;;) {}'
5362/// with compoundStmt()
5363/// matching '{}'
5364///
5365/// Given
5366/// \code
5367/// void f();
5368/// void f() {}
5369/// \endcode
5370/// hasBody(functionDecl())
5371/// matches 'void f() {}'
5372/// with compoundStmt()
5373/// matching '{}'
5374/// but does not match 'void f();'
5375
5376AST_POLYMORPHIC_MATCHER_P(hasBody,namespace internal { template <typename NodeType, typename
ParamT> class matcher_hasBody0Matcher : public ::clang::ast_matchers
::internal::MatcherInterface<NodeType> { public: explicit
matcher_hasBody0Matcher( internal::Matcher<Stmt> 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<Stmt
> InnerMatcher; }; } inline ::clang::ast_matchers::internal
::PolymorphicMatcher< internal::matcher_hasBody0Matcher, void
(::clang::ast_matchers::internal::TypeList<DoStmt, ForStmt
, WhileStmt, CXXForRangeStmt, FunctionDecl>), internal::Matcher
<Stmt> > hasBody(internal::Matcher<Stmt> const
&InnerMatcher) { return ::clang::ast_matchers::internal::
PolymorphicMatcher< internal::matcher_hasBody0Matcher, void
(::clang::ast_matchers::internal::TypeList<DoStmt, ForStmt
, WhileStmt, CXXForRangeStmt, FunctionDecl>), internal::Matcher
<Stmt> >(InnerMatcher); } typedef ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_hasBody0Matcher
, void(::clang::ast_matchers::internal::TypeList<DoStmt, ForStmt
, WhileStmt, CXXForRangeStmt, FunctionDecl>), internal::Matcher
<Stmt> > (&hasBody_Type0)(internal::Matcher<Stmt
> const &InnerMatcher); template <typename NodeType
, typename ParamT> bool internal:: matcher_hasBody0Matcher
<NodeType, ParamT>::matches( const NodeType &Node, ::
clang::ast_matchers::internal::ASTMatchFinder *Finder, ::clang
::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
5377 AST_POLYMORPHIC_SUPPORTED_TYPES(DoStmt, ForStmt,namespace internal { template <typename NodeType, typename
ParamT> class matcher_hasBody0Matcher : public ::clang::ast_matchers
::internal::MatcherInterface<NodeType> { public: explicit
matcher_hasBody0Matcher( internal::Matcher<Stmt> 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<Stmt
> InnerMatcher; }; } inline ::clang::ast_matchers::internal
::PolymorphicMatcher< internal::matcher_hasBody0Matcher, void
(::clang::ast_matchers::internal::TypeList<DoStmt, ForStmt
, WhileStmt, CXXForRangeStmt, FunctionDecl>), internal::Matcher
<Stmt> > hasBody(internal::Matcher<Stmt> const
&InnerMatcher) { return ::clang::ast_matchers::internal::
PolymorphicMatcher< internal::matcher_hasBody0Matcher, void
(::clang::ast_matchers::internal::TypeList<DoStmt, ForStmt
, WhileStmt, CXXForRangeStmt, FunctionDecl>), internal::Matcher
<Stmt> >(InnerMatcher); } typedef ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_hasBody0Matcher
, void(::clang::ast_matchers::internal::TypeList<DoStmt, ForStmt
, WhileStmt, CXXForRangeStmt, FunctionDecl>), internal::Matcher
<Stmt> > (&hasBody_Type0)(internal::Matcher<Stmt
> const &InnerMatcher); template <typename NodeType
, typename ParamT> bool internal:: matcher_hasBody0Matcher
<NodeType, ParamT>::matches( const NodeType &Node, ::
clang::ast_matchers::internal::ASTMatchFinder *Finder, ::clang
::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
5378 WhileStmt,namespace internal { template <typename NodeType, typename
ParamT> class matcher_hasBody0Matcher : public ::clang::ast_matchers
::internal::MatcherInterface<NodeType> { public: explicit
matcher_hasBody0Matcher( internal::Matcher<Stmt> 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<Stmt
> InnerMatcher; }; } inline ::clang::ast_matchers::internal
::PolymorphicMatcher< internal::matcher_hasBody0Matcher, void
(::clang::ast_matchers::internal::TypeList<DoStmt, ForStmt
, WhileStmt, CXXForRangeStmt, FunctionDecl>), internal::Matcher
<Stmt> > hasBody(internal::Matcher<Stmt> const
&InnerMatcher) { return ::clang::ast_matchers::internal::
PolymorphicMatcher< internal::matcher_hasBody0Matcher, void
(::clang::ast_matchers::internal::TypeList<DoStmt, ForStmt
, WhileStmt, CXXForRangeStmt, FunctionDecl>), internal::Matcher
<Stmt> >(InnerMatcher); } typedef ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_hasBody0Matcher
, void(::clang::ast_matchers::internal::TypeList<DoStmt, ForStmt
, WhileStmt, CXXForRangeStmt, FunctionDecl>), internal::Matcher
<Stmt> > (&hasBody_Type0)(internal::Matcher<Stmt
> const &InnerMatcher); template <typename NodeType
, typename ParamT> bool internal:: matcher_hasBody0Matcher
<NodeType, ParamT>::matches( const NodeType &Node, ::
clang::ast_matchers::internal::ASTMatchFinder *Finder, ::clang
::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
5379 CXXForRangeStmt,namespace internal { template <typename NodeType, typename
ParamT> class matcher_hasBody0Matcher : public ::clang::ast_matchers
::internal::MatcherInterface<NodeType> { public: explicit
matcher_hasBody0Matcher( internal::Matcher<Stmt> 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<Stmt
> InnerMatcher; }; } inline ::clang::ast_matchers::internal
::PolymorphicMatcher< internal::matcher_hasBody0Matcher, void
(::clang::ast_matchers::internal::TypeList<DoStmt, ForStmt
, WhileStmt, CXXForRangeStmt, FunctionDecl>), internal::Matcher
<Stmt> > hasBody(internal::Matcher<Stmt> const
&InnerMatcher) { return ::clang::ast_matchers::internal::
PolymorphicMatcher< internal::matcher_hasBody0Matcher, void
(::clang::ast_matchers::internal::TypeList<DoStmt, ForStmt
, WhileStmt, CXXForRangeStmt, FunctionDecl>), internal::Matcher
<Stmt> >(InnerMatcher); } typedef ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_hasBody0Matcher
, void(::clang::ast_matchers::internal::TypeList<DoStmt, ForStmt
, WhileStmt, CXXForRangeStmt, FunctionDecl>), internal::Matcher
<Stmt> > (&hasBody_Type0)(internal::Matcher<Stmt
> const &InnerMatcher); template <typename NodeType
, typename ParamT> bool internal:: matcher_hasBody0Matcher
<NodeType, ParamT>::matches( const NodeType &Node, ::
clang::ast_matchers::internal::ASTMatchFinder *Finder, ::clang
::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
5380 FunctionDecl),namespace internal { template <typename NodeType, typename
ParamT> class matcher_hasBody0Matcher : public ::clang::ast_matchers
::internal::MatcherInterface<NodeType> { public: explicit
matcher_hasBody0Matcher( internal::Matcher<Stmt> 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<Stmt
> InnerMatcher; }; } inline ::clang::ast_matchers::internal
::PolymorphicMatcher< internal::matcher_hasBody0Matcher, void
(::clang::ast_matchers::internal::TypeList<DoStmt, ForStmt
, WhileStmt, CXXForRangeStmt, FunctionDecl>), internal::Matcher
<Stmt> > hasBody(internal::Matcher<Stmt> const
&InnerMatcher) { return ::clang::ast_matchers::internal::
PolymorphicMatcher< internal::matcher_hasBody0Matcher, void
(::clang::ast_matchers::internal::TypeList<DoStmt, ForStmt
, WhileStmt, CXXForRangeStmt, FunctionDecl>), internal::Matcher
<Stmt> >(InnerMatcher); } typedef ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_hasBody0Matcher
, void(::clang::ast_matchers::internal::TypeList<DoStmt, ForStmt
, WhileStmt, CXXForRangeStmt, FunctionDecl>), internal::Matcher
<Stmt> > (&hasBody_Type0)(internal::Matcher<Stmt
> const &InnerMatcher); template <typename NodeType
, typename ParamT> bool internal:: matcher_hasBody0Matcher
<NodeType, ParamT>::matches( const NodeType &Node, ::
clang::ast_matchers::internal::ASTMatchFinder *Finder, ::clang
::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
5381 internal::Matcher<Stmt>, InnerMatcher)namespace internal { template <typename NodeType, typename
ParamT> class matcher_hasBody0Matcher : public ::clang::ast_matchers
::internal::MatcherInterface<NodeType> { public: explicit
matcher_hasBody0Matcher( internal::Matcher<Stmt> 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<Stmt
> InnerMatcher; }; } inline ::clang::ast_matchers::internal
::PolymorphicMatcher< internal::matcher_hasBody0Matcher, void
(::clang::ast_matchers::internal::TypeList<DoStmt, ForStmt
, WhileStmt, CXXForRangeStmt, FunctionDecl>), internal::Matcher
<Stmt> > hasBody(internal::Matcher<Stmt> const
&InnerMatcher) { return ::clang::ast_matchers::internal::
PolymorphicMatcher< internal::matcher_hasBody0Matcher, void
(::clang::ast_matchers::internal::TypeList<DoStmt, ForStmt
, WhileStmt, CXXForRangeStmt, FunctionDecl>), internal::Matcher
<Stmt> >(InnerMatcher); } typedef ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_hasBody0Matcher
, void(::clang::ast_matchers::internal::TypeList<DoStmt, ForStmt
, WhileStmt, CXXForRangeStmt, FunctionDecl>), internal::Matcher
<Stmt> > (&hasBody_Type0)(internal::Matcher<Stmt
> const &InnerMatcher); template <typename NodeType
, typename ParamT> bool internal:: matcher_hasBody0Matcher
<NodeType, ParamT>::matches( const NodeType &Node, ::
clang::ast_matchers::internal::ASTMatchFinder *Finder, ::clang
::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
{
5382 if (Finder->isTraversalIgnoringImplicitNodes() && isDefaultedHelper(&Node))
5383 return false;
5384 const Stmt *const Statement = internal::GetBodyMatcher<NodeType>::get(Node);
5385 return (Statement != nullptr &&
5386 InnerMatcher.matches(*Statement, Finder, Builder));
5387}
5388
5389/// Matches a function declaration that has a given body present in the AST.
5390/// Note that this matcher matches all the declarations of a function whose
5391/// body is present in the AST.
5392///
5393/// Given
5394/// \code
5395/// void f();
5396/// void f() {}
5397/// void g();
5398/// \endcode
5399/// functionDecl(hasAnyBody(compoundStmt()))
5400/// matches both 'void f();'
5401/// and 'void f() {}'
5402/// with compoundStmt()
5403/// matching '{}'
5404/// but does not match 'void g();'
5405AST_MATCHER_P(FunctionDecl, hasAnyBody,namespace internal { class matcher_hasAnyBody0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<FunctionDecl
> { public: explicit matcher_hasAnyBody0Matcher( internal::
Matcher<Stmt> const &AInnerMatcher) : InnerMatcher(
AInnerMatcher) {} bool matches(const FunctionDecl &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<FunctionDecl
> hasAnyBody( internal::Matcher<Stmt> const &InnerMatcher
) { return ::clang::ast_matchers::internal::makeMatcher( new internal
::matcher_hasAnyBody0Matcher(InnerMatcher)); } typedef ::clang
::ast_matchers::internal::Matcher<FunctionDecl> ( &
hasAnyBody_Type0)(internal::Matcher<Stmt> const &InnerMatcher
); inline bool internal::matcher_hasAnyBody0Matcher::matches(
const FunctionDecl &Node, ::clang::ast_matchers::internal
::ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
5406 internal::Matcher<Stmt>, InnerMatcher)namespace internal { class matcher_hasAnyBody0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<FunctionDecl
> { public: explicit matcher_hasAnyBody0Matcher( internal::
Matcher<Stmt> const &AInnerMatcher) : InnerMatcher(
AInnerMatcher) {} bool matches(const FunctionDecl &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<FunctionDecl
> hasAnyBody( internal::Matcher<Stmt> const &InnerMatcher
) { return ::clang::ast_matchers::internal::makeMatcher( new internal
::matcher_hasAnyBody0Matcher(InnerMatcher)); } typedef ::clang
::ast_matchers::internal::Matcher<FunctionDecl> ( &
hasAnyBody_Type0)(internal::Matcher<Stmt> const &InnerMatcher
); inline bool internal::matcher_hasAnyBody0Matcher::matches(
const FunctionDecl &Node, ::clang::ast_matchers::internal
::ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
5407 const Stmt *const Statement = Node.getBody();
5408 return (Statement != nullptr &&
5409 InnerMatcher.matches(*Statement, Finder, Builder));
5410}
5411
5412
5413/// Matches compound statements where at least one substatement matches
5414/// a given matcher. Also matches StmtExprs that have CompoundStmt as children.
5415///
5416/// Given
5417/// \code
5418/// { {}; 1+2; }
5419/// \endcode
5420/// hasAnySubstatement(compoundStmt())
5421/// matches '{ {}; 1+2; }'
5422/// with compoundStmt()
5423/// matching '{}'
5424AST_POLYMORPHIC_MATCHER_P(hasAnySubstatement,namespace internal { template <typename NodeType, typename
ParamT> class matcher_hasAnySubstatement0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<NodeType
> { public: explicit matcher_hasAnySubstatement0Matcher( internal
::Matcher<Stmt> 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<Stmt> InnerMatcher; }; } inline ::clang
::ast_matchers::internal::PolymorphicMatcher< internal::matcher_hasAnySubstatement0Matcher
, void(::clang::ast_matchers::internal::TypeList<CompoundStmt
, StmtExpr>), internal::Matcher<Stmt> > hasAnySubstatement
(internal::Matcher<Stmt> const &InnerMatcher) { return
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_hasAnySubstatement0Matcher, void(::clang::ast_matchers
::internal::TypeList<CompoundStmt, StmtExpr>), internal
::Matcher<Stmt> >(InnerMatcher); } typedef ::clang::
ast_matchers::internal::PolymorphicMatcher< internal::matcher_hasAnySubstatement0Matcher
, void(::clang::ast_matchers::internal::TypeList<CompoundStmt
, StmtExpr>), internal::Matcher<Stmt> > (&hasAnySubstatement_Type0
)(internal::Matcher<Stmt> const &InnerMatcher); template
<typename NodeType, typename ParamT> bool internal:: matcher_hasAnySubstatement0Matcher
<NodeType, ParamT>::matches( const NodeType &Node, ::
clang::ast_matchers::internal::ASTMatchFinder *Finder, ::clang
::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
5425 AST_POLYMORPHIC_SUPPORTED_TYPES(CompoundStmt,namespace internal { template <typename NodeType, typename
ParamT> class matcher_hasAnySubstatement0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<NodeType
> { public: explicit matcher_hasAnySubstatement0Matcher( internal
::Matcher<Stmt> 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<Stmt> InnerMatcher; }; } inline ::clang
::ast_matchers::internal::PolymorphicMatcher< internal::matcher_hasAnySubstatement0Matcher
, void(::clang::ast_matchers::internal::TypeList<CompoundStmt
, StmtExpr>), internal::Matcher<Stmt> > hasAnySubstatement
(internal::Matcher<Stmt> const &InnerMatcher) { return
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_hasAnySubstatement0Matcher, void(::clang::ast_matchers
::internal::TypeList<CompoundStmt, StmtExpr>), internal
::Matcher<Stmt> >(InnerMatcher); } typedef ::clang::
ast_matchers::internal::PolymorphicMatcher< internal::matcher_hasAnySubstatement0Matcher
, void(::clang::ast_matchers::internal::TypeList<CompoundStmt
, StmtExpr>), internal::Matcher<Stmt> > (&hasAnySubstatement_Type0
)(internal::Matcher<Stmt> const &InnerMatcher); template
<typename NodeType, typename ParamT> bool internal:: matcher_hasAnySubstatement0Matcher
<NodeType, ParamT>::matches( const NodeType &Node, ::
clang::ast_matchers::internal::ASTMatchFinder *Finder, ::clang
::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
5426 StmtExpr),namespace internal { template <typename NodeType, typename
ParamT> class matcher_hasAnySubstatement0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<NodeType
> { public: explicit matcher_hasAnySubstatement0Matcher( internal
::Matcher<Stmt> 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<Stmt> InnerMatcher; }; } inline ::clang
::ast_matchers::internal::PolymorphicMatcher< internal::matcher_hasAnySubstatement0Matcher
, void(::clang::ast_matchers::internal::TypeList<CompoundStmt
, StmtExpr>), internal::Matcher<Stmt> > hasAnySubstatement
(internal::Matcher<Stmt> const &InnerMatcher) { return
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_hasAnySubstatement0Matcher, void(::clang::ast_matchers
::internal::TypeList<CompoundStmt, StmtExpr>), internal
::Matcher<Stmt> >(InnerMatcher); } typedef ::clang::
ast_matchers::internal::PolymorphicMatcher< internal::matcher_hasAnySubstatement0Matcher
, void(::clang::ast_matchers::internal::TypeList<CompoundStmt
, StmtExpr>), internal::Matcher<Stmt> > (&hasAnySubstatement_Type0
)(internal::Matcher<Stmt> const &InnerMatcher); template
<typename NodeType, typename ParamT> bool internal:: matcher_hasAnySubstatement0Matcher
<NodeType, ParamT>::matches( const NodeType &Node, ::
clang::ast_matchers::internal::ASTMatchFinder *Finder, ::clang
::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
5427 internal::Matcher<Stmt>, InnerMatcher)namespace internal { template <typename NodeType, typename
ParamT> class matcher_hasAnySubstatement0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<NodeType
> { public: explicit matcher_hasAnySubstatement0Matcher( internal
::Matcher<Stmt> 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<Stmt> InnerMatcher; }; } inline ::clang
::ast_matchers::internal::PolymorphicMatcher< internal::matcher_hasAnySubstatement0Matcher
, void(::clang::ast_matchers::internal::TypeList<CompoundStmt
, StmtExpr>), internal::Matcher<Stmt> > hasAnySubstatement
(internal::Matcher<Stmt> const &InnerMatcher) { return
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_hasAnySubstatement0Matcher, void(::clang::ast_matchers
::internal::TypeList<CompoundStmt, StmtExpr>), internal
::Matcher<Stmt> >(InnerMatcher); } typedef ::clang::
ast_matchers::internal::PolymorphicMatcher< internal::matcher_hasAnySubstatement0Matcher
, void(::clang::ast_matchers::internal::TypeList<CompoundStmt
, StmtExpr>), internal::Matcher<Stmt> > (&hasAnySubstatement_Type0
)(internal::Matcher<Stmt> const &InnerMatcher); template
<typename NodeType, typename ParamT> bool internal:: matcher_hasAnySubstatement0Matcher
<NodeType, ParamT>::matches( const NodeType &Node, ::
clang::ast_matchers::internal::ASTMatchFinder *Finder, ::clang
::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
{
5428 const CompoundStmt *CS = CompoundStmtMatcher<NodeType>::get(Node);
5429 return CS && matchesFirstInPointerRange(InnerMatcher, CS->body_begin(),
5430 CS->body_end(), Finder,
5431 Builder) != CS->body_end();
5432}
5433
5434/// Checks that a compound statement contains a specific number of
5435/// child statements.
5436///
5437/// Example: Given
5438/// \code
5439/// { for (;;) {} }
5440/// \endcode
5441/// compoundStmt(statementCountIs(0)))
5442/// matches '{}'
5443/// but does not match the outer compound statement.
5444AST_MATCHER_P(CompoundStmt, statementCountIs, unsigned, N)namespace internal { class matcher_statementCountIs0Matcher :
public ::clang::ast_matchers::internal::MatcherInterface<
CompoundStmt> { public: explicit matcher_statementCountIs0Matcher
( unsigned const &AN) : N(AN) {} bool matches(const CompoundStmt
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: unsigned N; }; } inline ::
clang::ast_matchers::internal::Matcher<CompoundStmt> statementCountIs
( unsigned const &N) { return ::clang::ast_matchers::internal
::makeMatcher( new internal::matcher_statementCountIs0Matcher
(N)); } typedef ::clang::ast_matchers::internal::Matcher<CompoundStmt
> ( &statementCountIs_Type0)(unsigned const &N); inline
bool internal::matcher_statementCountIs0Matcher::matches( const
CompoundStmt &Node, ::clang::ast_matchers::internal::ASTMatchFinder
*Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
5445 return Node.size() == N;
5446}
5447
5448/// Matches literals that are equal to the given value of type ValueT.
5449///
5450/// Given
5451/// \code
5452/// f('\0', false, 3.14, 42);
5453/// \endcode
5454/// characterLiteral(equals(0))
5455/// matches '\0'
5456/// cxxBoolLiteral(equals(false)) and cxxBoolLiteral(equals(0))
5457/// match false
5458/// floatLiteral(equals(3.14)) and floatLiteral(equals(314e-2))
5459/// match 3.14
5460/// integerLiteral(equals(42))
5461/// matches 42
5462///
5463/// Note that you cannot directly match a negative numeric literal because the
5464/// minus sign is not part of the literal: It is a unary operator whose operand
5465/// is the positive numeric literal. Instead, you must use a unaryOperator()
5466/// matcher to match the minus sign:
5467///
5468/// unaryOperator(hasOperatorName("-"),
5469/// hasUnaryOperand(integerLiteral(equals(13))))
5470///
5471/// Usable as: Matcher<CharacterLiteral>, Matcher<CXXBoolLiteralExpr>,
5472/// Matcher<FloatingLiteral>, Matcher<IntegerLiteral>
5473template <typename ValueT>
5474internal::PolymorphicMatcher<internal::ValueEqualsMatcher,
5475 void(internal::AllNodeBaseTypes), ValueT>
5476equals(const ValueT &Value) {
5477 return internal::PolymorphicMatcher<internal::ValueEqualsMatcher,
5478 void(internal::AllNodeBaseTypes), ValueT>(
5479 Value);
5480}
5481
5482AST_POLYMORPHIC_MATCHER_P_OVERLOAD(equals,namespace internal { template <typename NodeType, typename
ParamT> class matcher_equals0Matcher : public ::clang::ast_matchers
::internal::MatcherInterface<NodeType> { public: explicit
matcher_equals0Matcher( bool const &AValue) : Value(AValue
) {} bool matches(const NodeType &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const override; private: bool
Value; }; } inline ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_equals0Matcher, void(::clang::ast_matchers
::internal::TypeList<CharacterLiteral, CXXBoolLiteralExpr,
IntegerLiteral>), bool> equals(bool const &Value) {
return ::clang::ast_matchers::internal::PolymorphicMatcher<
internal::matcher_equals0Matcher, void(::clang::ast_matchers
::internal::TypeList<CharacterLiteral, CXXBoolLiteralExpr,
IntegerLiteral>), bool>(Value); } typedef ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_equals0Matcher
, void(::clang::ast_matchers::internal::TypeList<CharacterLiteral
, CXXBoolLiteralExpr, IntegerLiteral>), bool> (&equals_Type0
)(bool const &Value); template <typename NodeType, typename
ParamT> bool internal:: matcher_equals0Matcher<NodeType
, ParamT>::matches( const NodeType &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
5483 AST_POLYMORPHIC_SUPPORTED_TYPES(CharacterLiteral,namespace internal { template <typename NodeType, typename
ParamT> class matcher_equals0Matcher : public ::clang::ast_matchers
::internal::MatcherInterface<NodeType> { public: explicit
matcher_equals0Matcher( bool const &AValue) : Value(AValue
) {} bool matches(const NodeType &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const override; private: bool
Value; }; } inline ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_equals0Matcher, void(::clang::ast_matchers
::internal::TypeList<CharacterLiteral, CXXBoolLiteralExpr,
IntegerLiteral>), bool> equals(bool const &Value) {
return ::clang::ast_matchers::internal::PolymorphicMatcher<
internal::matcher_equals0Matcher, void(::clang::ast_matchers
::internal::TypeList<CharacterLiteral, CXXBoolLiteralExpr,
IntegerLiteral>), bool>(Value); } typedef ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_equals0Matcher
, void(::clang::ast_matchers::internal::TypeList<CharacterLiteral
, CXXBoolLiteralExpr, IntegerLiteral>), bool> (&equals_Type0
)(bool const &Value); template <typename NodeType, typename
ParamT> bool internal:: matcher_equals0Matcher<NodeType
, ParamT>::matches( const NodeType &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
5484 CXXBoolLiteralExpr,namespace internal { template <typename NodeType, typename
ParamT> class matcher_equals0Matcher : public ::clang::ast_matchers
::internal::MatcherInterface<NodeType> { public: explicit
matcher_equals0Matcher( bool const &AValue) : Value(AValue
) {} bool matches(const NodeType &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const override; private: bool
Value; }; } inline ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_equals0Matcher, void(::clang::ast_matchers
::internal::TypeList<CharacterLiteral, CXXBoolLiteralExpr,
IntegerLiteral>), bool> equals(bool const &Value) {
return ::clang::ast_matchers::internal::PolymorphicMatcher<
internal::matcher_equals0Matcher, void(::clang::ast_matchers
::internal::TypeList<CharacterLiteral, CXXBoolLiteralExpr,
IntegerLiteral>), bool>(Value); } typedef ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_equals0Matcher
, void(::clang::ast_matchers::internal::TypeList<CharacterLiteral
, CXXBoolLiteralExpr, IntegerLiteral>), bool> (&equals_Type0
)(bool const &Value); template <typename NodeType, typename
ParamT> bool internal:: matcher_equals0Matcher<NodeType
, ParamT>::matches( const NodeType &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
5485 IntegerLiteral),namespace internal { template <typename NodeType, typename
ParamT> class matcher_equals0Matcher : public ::clang::ast_matchers
::internal::MatcherInterface<NodeType> { public: explicit
matcher_equals0Matcher( bool const &AValue) : Value(AValue
) {} bool matches(const NodeType &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const override; private: bool
Value; }; } inline ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_equals0Matcher, void(::clang::ast_matchers
::internal::TypeList<CharacterLiteral, CXXBoolLiteralExpr,
IntegerLiteral>), bool> equals(bool const &Value) {
return ::clang::ast_matchers::internal::PolymorphicMatcher<
internal::matcher_equals0Matcher, void(::clang::ast_matchers
::internal::TypeList<CharacterLiteral, CXXBoolLiteralExpr,
IntegerLiteral>), bool>(Value); } typedef ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_equals0Matcher
, void(::clang::ast_matchers::internal::TypeList<CharacterLiteral
, CXXBoolLiteralExpr, IntegerLiteral>), bool> (&equals_Type0
)(bool const &Value); template <typename NodeType, typename
ParamT> bool internal:: matcher_equals0Matcher<NodeType
, ParamT>::matches( const NodeType &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
5486 bool, Value, 0)namespace internal { template <typename NodeType, typename
ParamT> class matcher_equals0Matcher : public ::clang::ast_matchers
::internal::MatcherInterface<NodeType> { public: explicit
matcher_equals0Matcher( bool const &AValue) : Value(AValue
) {} bool matches(const NodeType &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const override; private: bool
Value; }; } inline ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_equals0Matcher, void(::clang::ast_matchers
::internal::TypeList<CharacterLiteral, CXXBoolLiteralExpr,
IntegerLiteral>), bool> equals(bool const &Value) {
return ::clang::ast_matchers::internal::PolymorphicMatcher<
internal::matcher_equals0Matcher, void(::clang::ast_matchers
::internal::TypeList<CharacterLiteral, CXXBoolLiteralExpr,
IntegerLiteral>), bool>(Value); } typedef ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_equals0Matcher
, void(::clang::ast_matchers::internal::TypeList<CharacterLiteral
, CXXBoolLiteralExpr, IntegerLiteral>), bool> (&equals_Type0
)(bool const &Value); template <typename NodeType, typename
ParamT> bool internal:: matcher_equals0Matcher<NodeType
, ParamT>::matches( const NodeType &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
{
5487 return internal::ValueEqualsMatcher<NodeType, ParamT>(Value)
5488 .matchesNode(Node);
5489}
5490
5491AST_POLYMORPHIC_MATCHER_P_OVERLOAD(equals,namespace internal { template <typename NodeType, typename
ParamT> class matcher_equals1Matcher : public ::clang::ast_matchers
::internal::MatcherInterface<NodeType> { public: explicit
matcher_equals1Matcher( unsigned const &AValue) : Value(
AValue) {} bool matches(const NodeType &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const override; private: unsigned
Value; }; } inline ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_equals1Matcher, void(::clang::ast_matchers
::internal::TypeList<CharacterLiteral, CXXBoolLiteralExpr,
IntegerLiteral>), unsigned> equals(unsigned const &
Value) { return ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_equals1Matcher, void(::clang::ast_matchers
::internal::TypeList<CharacterLiteral, CXXBoolLiteralExpr,
IntegerLiteral>), unsigned>(Value); } typedef ::clang::
ast_matchers::internal::PolymorphicMatcher< internal::matcher_equals1Matcher
, void(::clang::ast_matchers::internal::TypeList<CharacterLiteral
, CXXBoolLiteralExpr, IntegerLiteral>), unsigned> (&
equals_Type1)(unsigned const &Value); template <typename
NodeType, typename ParamT> bool internal:: matcher_equals1Matcher
<NodeType, ParamT>::matches( const NodeType &Node, ::
clang::ast_matchers::internal::ASTMatchFinder *Finder, ::clang
::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
5492 AST_POLYMORPHIC_SUPPORTED_TYPES(CharacterLiteral,namespace internal { template <typename NodeType, typename
ParamT> class matcher_equals1Matcher : public ::clang::ast_matchers
::internal::MatcherInterface<NodeType> { public: explicit
matcher_equals1Matcher( unsigned const &AValue) : Value(
AValue) {} bool matches(const NodeType &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const override; private: unsigned
Value; }; } inline ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_equals1Matcher, void(::clang::ast_matchers
::internal::TypeList<CharacterLiteral, CXXBoolLiteralExpr,
IntegerLiteral>), unsigned> equals(unsigned const &
Value) { return ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_equals1Matcher, void(::clang::ast_matchers
::internal::TypeList<CharacterLiteral, CXXBoolLiteralExpr,
IntegerLiteral>), unsigned>(Value); } typedef ::clang::
ast_matchers::internal::PolymorphicMatcher< internal::matcher_equals1Matcher
, void(::clang::ast_matchers::internal::TypeList<CharacterLiteral
, CXXBoolLiteralExpr, IntegerLiteral>), unsigned> (&
equals_Type1)(unsigned const &Value); template <typename
NodeType, typename ParamT> bool internal:: matcher_equals1Matcher
<NodeType, ParamT>::matches( const NodeType &Node, ::
clang::ast_matchers::internal::ASTMatchFinder *Finder, ::clang
::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
5493 CXXBoolLiteralExpr,namespace internal { template <typename NodeType, typename
ParamT> class matcher_equals1Matcher : public ::clang::ast_matchers
::internal::MatcherInterface<NodeType> { public: explicit
matcher_equals1Matcher( unsigned const &AValue) : Value(
AValue) {} bool matches(const NodeType &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const override; private: unsigned
Value; }; } inline ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_equals1Matcher, void(::clang::ast_matchers
::internal::TypeList<CharacterLiteral, CXXBoolLiteralExpr,
IntegerLiteral>), unsigned> equals(unsigned const &
Value) { return ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_equals1Matcher, void(::clang::ast_matchers
::internal::TypeList<CharacterLiteral, CXXBoolLiteralExpr,
IntegerLiteral>), unsigned>(Value); } typedef ::clang::
ast_matchers::internal::PolymorphicMatcher< internal::matcher_equals1Matcher
, void(::clang::ast_matchers::internal::TypeList<CharacterLiteral
, CXXBoolLiteralExpr, IntegerLiteral>), unsigned> (&
equals_Type1)(unsigned const &Value); template <typename
NodeType, typename ParamT> bool internal:: matcher_equals1Matcher
<NodeType, ParamT>::matches( const NodeType &Node, ::
clang::ast_matchers::internal::ASTMatchFinder *Finder, ::clang
::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
5494 IntegerLiteral),namespace internal { template <typename NodeType, typename
ParamT> class matcher_equals1Matcher : public ::clang::ast_matchers
::internal::MatcherInterface<NodeType> { public: explicit
matcher_equals1Matcher( unsigned const &AValue) : Value(
AValue) {} bool matches(const NodeType &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const override; private: unsigned
Value; }; } inline ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_equals1Matcher, void(::clang::ast_matchers
::internal::TypeList<CharacterLiteral, CXXBoolLiteralExpr,
IntegerLiteral>), unsigned> equals(unsigned const &
Value) { return ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_equals1Matcher, void(::clang::ast_matchers
::internal::TypeList<CharacterLiteral, CXXBoolLiteralExpr,
IntegerLiteral>), unsigned>(Value); } typedef ::clang::
ast_matchers::internal::PolymorphicMatcher< internal::matcher_equals1Matcher
, void(::clang::ast_matchers::internal::TypeList<CharacterLiteral
, CXXBoolLiteralExpr, IntegerLiteral>), unsigned> (&
equals_Type1)(unsigned const &Value); template <typename
NodeType, typename ParamT> bool internal:: matcher_equals1Matcher
<NodeType, ParamT>::matches( const NodeType &Node, ::
clang::ast_matchers::internal::ASTMatchFinder *Finder, ::clang
::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
5495 unsigned, Value, 1)namespace internal { template <typename NodeType, typename
ParamT> class matcher_equals1Matcher : public ::clang::ast_matchers
::internal::MatcherInterface<NodeType> { public: explicit
matcher_equals1Matcher( unsigned const &AValue) : Value(
AValue) {} bool matches(const NodeType &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const override; private: unsigned
Value; }; } inline ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_equals1Matcher, void(::clang::ast_matchers
::internal::TypeList<CharacterLiteral, CXXBoolLiteralExpr,
IntegerLiteral>), unsigned> equals(unsigned const &
Value) { return ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_equals1Matcher, void(::clang::ast_matchers
::internal::TypeList<CharacterLiteral, CXXBoolLiteralExpr,
IntegerLiteral>), unsigned>(Value); } typedef ::clang::
ast_matchers::internal::PolymorphicMatcher< internal::matcher_equals1Matcher
, void(::clang::ast_matchers::internal::TypeList<CharacterLiteral
, CXXBoolLiteralExpr, IntegerLiteral>), unsigned> (&
equals_Type1)(unsigned const &Value); template <typename
NodeType, typename ParamT> bool internal:: matcher_equals1Matcher
<NodeType, ParamT>::matches( const NodeType &Node, ::
clang::ast_matchers::internal::ASTMatchFinder *Finder, ::clang
::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
{
5496 return internal::ValueEqualsMatcher<NodeType, ParamT>(Value)
5497 .matchesNode(Node);
5498}
5499
5500AST_POLYMORPHIC_MATCHER_P_OVERLOAD(equals,namespace internal { template <typename NodeType, typename
ParamT> class matcher_equals2Matcher : public ::clang::ast_matchers
::internal::MatcherInterface<NodeType> { public: explicit
matcher_equals2Matcher( double const &AValue) : Value(AValue
) {} bool matches(const NodeType &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const override; private: double
Value; }; } inline ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_equals2Matcher, void(::clang::ast_matchers
::internal::TypeList<CharacterLiteral, CXXBoolLiteralExpr,
FloatingLiteral, IntegerLiteral>), double> equals(double
const &Value) { return ::clang::ast_matchers::internal::
PolymorphicMatcher< internal::matcher_equals2Matcher, void
(::clang::ast_matchers::internal::TypeList<CharacterLiteral
, CXXBoolLiteralExpr, FloatingLiteral, IntegerLiteral>), double
>(Value); } typedef ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_equals2Matcher, void(::clang::ast_matchers
::internal::TypeList<CharacterLiteral, CXXBoolLiteralExpr,
FloatingLiteral, IntegerLiteral>), double> (&equals_Type2
)(double const &Value); template <typename NodeType, typename
ParamT> bool internal:: matcher_equals2Matcher<NodeType
, ParamT>::matches( const NodeType &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
5501 AST_POLYMORPHIC_SUPPORTED_TYPES(CharacterLiteral,namespace internal { template <typename NodeType, typename
ParamT> class matcher_equals2Matcher : public ::clang::ast_matchers
::internal::MatcherInterface<NodeType> { public: explicit
matcher_equals2Matcher( double const &AValue) : Value(AValue
) {} bool matches(const NodeType &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const override; private: double
Value; }; } inline ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_equals2Matcher, void(::clang::ast_matchers
::internal::TypeList<CharacterLiteral, CXXBoolLiteralExpr,
FloatingLiteral, IntegerLiteral>), double> equals(double
const &Value) { return ::clang::ast_matchers::internal::
PolymorphicMatcher< internal::matcher_equals2Matcher, void
(::clang::ast_matchers::internal::TypeList<CharacterLiteral
, CXXBoolLiteralExpr, FloatingLiteral, IntegerLiteral>), double
>(Value); } typedef ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_equals2Matcher, void(::clang::ast_matchers
::internal::TypeList<CharacterLiteral, CXXBoolLiteralExpr,
FloatingLiteral, IntegerLiteral>), double> (&equals_Type2
)(double const &Value); template <typename NodeType, typename
ParamT> bool internal:: matcher_equals2Matcher<NodeType
, ParamT>::matches( const NodeType &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
5502 CXXBoolLiteralExpr,namespace internal { template <typename NodeType, typename
ParamT> class matcher_equals2Matcher : public ::clang::ast_matchers
::internal::MatcherInterface<NodeType> { public: explicit
matcher_equals2Matcher( double const &AValue) : Value(AValue
) {} bool matches(const NodeType &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const override; private: double
Value; }; } inline ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_equals2Matcher, void(::clang::ast_matchers
::internal::TypeList<CharacterLiteral, CXXBoolLiteralExpr,
FloatingLiteral, IntegerLiteral>), double> equals(double
const &Value) { return ::clang::ast_matchers::internal::
PolymorphicMatcher< internal::matcher_equals2Matcher, void
(::clang::ast_matchers::internal::TypeList<CharacterLiteral
, CXXBoolLiteralExpr, FloatingLiteral, IntegerLiteral>), double
>(Value); } typedef ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_equals2Matcher, void(::clang::ast_matchers
::internal::TypeList<CharacterLiteral, CXXBoolLiteralExpr,
FloatingLiteral, IntegerLiteral>), double> (&equals_Type2
)(double const &Value); template <typename NodeType, typename
ParamT> bool internal:: matcher_equals2Matcher<NodeType
, ParamT>::matches( const NodeType &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
5503 FloatingLiteral,namespace internal { template <typename NodeType, typename
ParamT> class matcher_equals2Matcher : public ::clang::ast_matchers
::internal::MatcherInterface<NodeType> { public: explicit
matcher_equals2Matcher( double const &AValue) : Value(AValue
) {} bool matches(const NodeType &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const override; private: double
Value; }; } inline ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_equals2Matcher, void(::clang::ast_matchers
::internal::TypeList<CharacterLiteral, CXXBoolLiteralExpr,
FloatingLiteral, IntegerLiteral>), double> equals(double
const &Value) { return ::clang::ast_matchers::internal::
PolymorphicMatcher< internal::matcher_equals2Matcher, void
(::clang::ast_matchers::internal::TypeList<CharacterLiteral
, CXXBoolLiteralExpr, FloatingLiteral, IntegerLiteral>), double
>(Value); } typedef ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_equals2Matcher, void(::clang::ast_matchers
::internal::TypeList<CharacterLiteral, CXXBoolLiteralExpr,
FloatingLiteral, IntegerLiteral>), double> (&equals_Type2
)(double const &Value); template <typename NodeType, typename
ParamT> bool internal:: matcher_equals2Matcher<NodeType
, ParamT>::matches( const NodeType &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
5504 IntegerLiteral),namespace internal { template <typename NodeType, typename
ParamT> class matcher_equals2Matcher : public ::clang::ast_matchers
::internal::MatcherInterface<NodeType> { public: explicit
matcher_equals2Matcher( double const &AValue) : Value(AValue
) {} bool matches(const NodeType &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const override; private: double
Value; }; } inline ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_equals2Matcher, void(::clang::ast_matchers
::internal::TypeList<CharacterLiteral, CXXBoolLiteralExpr,
FloatingLiteral, IntegerLiteral>), double> equals(double
const &Value) { return ::clang::ast_matchers::internal::
PolymorphicMatcher< internal::matcher_equals2Matcher, void
(::clang::ast_matchers::internal::TypeList<CharacterLiteral
, CXXBoolLiteralExpr, FloatingLiteral, IntegerLiteral>), double
>(Value); } typedef ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_equals2Matcher, void(::clang::ast_matchers
::internal::TypeList<CharacterLiteral, CXXBoolLiteralExpr,
FloatingLiteral, IntegerLiteral>), double> (&equals_Type2
)(double const &Value); template <typename NodeType, typename
ParamT> bool internal:: matcher_equals2Matcher<NodeType
, ParamT>::matches( const NodeType &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
5505 double, Value, 2)namespace internal { template <typename NodeType, typename
ParamT> class matcher_equals2Matcher : public ::clang::ast_matchers
::internal::MatcherInterface<NodeType> { public: explicit
matcher_equals2Matcher( double const &AValue) : Value(AValue
) {} bool matches(const NodeType &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const override; private: double
Value; }; } inline ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_equals2Matcher, void(::clang::ast_matchers
::internal::TypeList<CharacterLiteral, CXXBoolLiteralExpr,
FloatingLiteral, IntegerLiteral>), double> equals(double
const &Value) { return ::clang::ast_matchers::internal::
PolymorphicMatcher< internal::matcher_equals2Matcher, void
(::clang::ast_matchers::internal::TypeList<CharacterLiteral
, CXXBoolLiteralExpr, FloatingLiteral, IntegerLiteral>), double
>(Value); } typedef ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_equals2Matcher, void(::clang::ast_matchers
::internal::TypeList<CharacterLiteral, CXXBoolLiteralExpr,
FloatingLiteral, IntegerLiteral>), double> (&equals_Type2
)(double const &Value); template <typename NodeType, typename
ParamT> bool internal:: matcher_equals2Matcher<NodeType
, ParamT>::matches( const NodeType &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
{
5506 return internal::ValueEqualsMatcher<NodeType, ParamT>(Value)
5507 .matchesNode(Node);
5508}
5509
5510/// Matches the operator Name of operator expressions (binary or
5511/// unary).
5512///
5513/// Example matches a || b (matcher = binaryOperator(hasOperatorName("||")))
5514/// \code
5515/// !(a || b)
5516/// \endcode
5517AST_POLYMORPHIC_MATCHER_P(namespace internal { template <typename NodeType, typename
ParamT> class matcher_hasOperatorName0Matcher : public ::
clang::ast_matchers::internal::MatcherInterface<NodeType>
{ public: explicit matcher_hasOperatorName0Matcher( std::string
const &AName) : Name(AName) {} bool matches(const NodeType
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: std::string Name; }; } inline
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_hasOperatorName0Matcher, void(::clang::ast_matchers
::internal::TypeList<BinaryOperator, CXXOperatorCallExpr, CXXRewrittenBinaryOperator
, UnaryOperator>), std::string> hasOperatorName(std::string
const &Name) { return ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_hasOperatorName0Matcher, void(::clang::
ast_matchers::internal::TypeList<BinaryOperator, CXXOperatorCallExpr
, CXXRewrittenBinaryOperator, UnaryOperator>), std::string
>(Name); } typedef ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_hasOperatorName0Matcher, void(::clang::
ast_matchers::internal::TypeList<BinaryOperator, CXXOperatorCallExpr
, CXXRewrittenBinaryOperator, UnaryOperator>), std::string
> (&hasOperatorName_Type0)(std::string const &Name
); template <typename NodeType, typename ParamT> bool internal
:: matcher_hasOperatorName0Matcher<NodeType, ParamT>::matches
( const NodeType &Node, ::clang::ast_matchers::internal::
ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
5518 hasOperatorName,namespace internal { template <typename NodeType, typename
ParamT> class matcher_hasOperatorName0Matcher : public ::
clang::ast_matchers::internal::MatcherInterface<NodeType>
{ public: explicit matcher_hasOperatorName0Matcher( std::string
const &AName) : Name(AName) {} bool matches(const NodeType
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: std::string Name; }; } inline
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_hasOperatorName0Matcher, void(::clang::ast_matchers
::internal::TypeList<BinaryOperator, CXXOperatorCallExpr, CXXRewrittenBinaryOperator
, UnaryOperator>), std::string> hasOperatorName(std::string
const &Name) { return ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_hasOperatorName0Matcher, void(::clang::
ast_matchers::internal::TypeList<BinaryOperator, CXXOperatorCallExpr
, CXXRewrittenBinaryOperator, UnaryOperator>), std::string
>(Name); } typedef ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_hasOperatorName0Matcher, void(::clang::
ast_matchers::internal::TypeList<BinaryOperator, CXXOperatorCallExpr
, CXXRewrittenBinaryOperator, UnaryOperator>), std::string
> (&hasOperatorName_Type0)(std::string const &Name
); template <typename NodeType, typename ParamT> bool internal
:: matcher_hasOperatorName0Matcher<NodeType, ParamT>::matches
( const NodeType &Node, ::clang::ast_matchers::internal::
ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
5519 AST_POLYMORPHIC_SUPPORTED_TYPES(BinaryOperator, CXXOperatorCallExpr,namespace internal { template <typename NodeType, typename
ParamT> class matcher_hasOperatorName0Matcher : public ::
clang::ast_matchers::internal::MatcherInterface<NodeType>
{ public: explicit matcher_hasOperatorName0Matcher( std::string
const &AName) : Name(AName) {} bool matches(const NodeType
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: std::string Name; }; } inline
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_hasOperatorName0Matcher, void(::clang::ast_matchers
::internal::TypeList<BinaryOperator, CXXOperatorCallExpr, CXXRewrittenBinaryOperator
, UnaryOperator>), std::string> hasOperatorName(std::string
const &Name) { return ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_hasOperatorName0Matcher, void(::clang::
ast_matchers::internal::TypeList<BinaryOperator, CXXOperatorCallExpr
, CXXRewrittenBinaryOperator, UnaryOperator>), std::string
>(Name); } typedef ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_hasOperatorName0Matcher, void(::clang::
ast_matchers::internal::TypeList<BinaryOperator, CXXOperatorCallExpr
, CXXRewrittenBinaryOperator, UnaryOperator>), std::string
> (&hasOperatorName_Type0)(std::string const &Name
); template <typename NodeType, typename ParamT> bool internal
:: matcher_hasOperatorName0Matcher<NodeType, ParamT>::matches
( const NodeType &Node, ::clang::ast_matchers::internal::
ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
5520 CXXRewrittenBinaryOperator, UnaryOperator),namespace internal { template <typename NodeType, typename
ParamT> class matcher_hasOperatorName0Matcher : public ::
clang::ast_matchers::internal::MatcherInterface<NodeType>
{ public: explicit matcher_hasOperatorName0Matcher( std::string
const &AName) : Name(AName) {} bool matches(const NodeType
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: std::string Name; }; } inline
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_hasOperatorName0Matcher, void(::clang::ast_matchers
::internal::TypeList<BinaryOperator, CXXOperatorCallExpr, CXXRewrittenBinaryOperator
, UnaryOperator>), std::string> hasOperatorName(std::string
const &Name) { return ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_hasOperatorName0Matcher, void(::clang::
ast_matchers::internal::TypeList<BinaryOperator, CXXOperatorCallExpr
, CXXRewrittenBinaryOperator, UnaryOperator>), std::string
>(Name); } typedef ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_hasOperatorName0Matcher, void(::clang::
ast_matchers::internal::TypeList<BinaryOperator, CXXOperatorCallExpr
, CXXRewrittenBinaryOperator, UnaryOperator>), std::string
> (&hasOperatorName_Type0)(std::string const &Name
); template <typename NodeType, typename ParamT> bool internal
:: matcher_hasOperatorName0Matcher<NodeType, ParamT>::matches
( const NodeType &Node, ::clang::ast_matchers::internal::
ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
5521 std::string, Name)namespace internal { template <typename NodeType, typename
ParamT> class matcher_hasOperatorName0Matcher : public ::
clang::ast_matchers::internal::MatcherInterface<NodeType>
{ public: explicit matcher_hasOperatorName0Matcher( std::string
const &AName) : Name(AName) {} bool matches(const NodeType
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: std::string Name; }; } inline
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_hasOperatorName0Matcher, void(::clang::ast_matchers
::internal::TypeList<BinaryOperator, CXXOperatorCallExpr, CXXRewrittenBinaryOperator
, UnaryOperator>), std::string> hasOperatorName(std::string
const &Name) { return ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_hasOperatorName0Matcher, void(::clang::
ast_matchers::internal::TypeList<BinaryOperator, CXXOperatorCallExpr
, CXXRewrittenBinaryOperator, UnaryOperator>), std::string
>(Name); } typedef ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_hasOperatorName0Matcher, void(::clang::
ast_matchers::internal::TypeList<BinaryOperator, CXXOperatorCallExpr
, CXXRewrittenBinaryOperator, UnaryOperator>), std::string
> (&hasOperatorName_Type0)(std::string const &Name
); template <typename NodeType, typename ParamT> bool internal
:: matcher_hasOperatorName0Matcher<NodeType, ParamT>::matches
( const NodeType &Node, ::clang::ast_matchers::internal::
ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
5522 if (Optional<StringRef> OpName = internal::getOpName(Node))
5523 return *OpName == Name;
5524 return false;
5525}
5526
5527/// Matches operator expressions (binary or unary) that have any of the
5528/// specified names.
5529///
5530/// hasAnyOperatorName("+", "-")
5531/// Is equivalent to
5532/// anyOf(hasOperatorName("+"), hasOperatorName("-"))
5533extern const internal::VariadicFunction<
5534 internal::PolymorphicMatcher<internal::HasAnyOperatorNameMatcher,
5535 AST_POLYMORPHIC_SUPPORTED_TYPES(void(::clang::ast_matchers::internal::TypeList<BinaryOperator
, CXXOperatorCallExpr, CXXRewrittenBinaryOperator, UnaryOperator
>)
5536 BinaryOperator, CXXOperatorCallExpr,void(::clang::ast_matchers::internal::TypeList<BinaryOperator
, CXXOperatorCallExpr, CXXRewrittenBinaryOperator, UnaryOperator
>)
5537 CXXRewrittenBinaryOperator, UnaryOperator)void(::clang::ast_matchers::internal::TypeList<BinaryOperator
, CXXOperatorCallExpr, CXXRewrittenBinaryOperator, UnaryOperator
>)
,
5538 std::vector<std::string>>,
5539 StringRef, internal::hasAnyOperatorNameFunc>
5540 hasAnyOperatorName;
5541
5542/// Matches all kinds of assignment operators.
5543///
5544/// Example 1: matches a += b (matcher = binaryOperator(isAssignmentOperator()))
5545/// \code
5546/// if (a == b)
5547/// a += b;
5548/// \endcode
5549///
5550/// Example 2: matches s1 = s2
5551/// (matcher = cxxOperatorCallExpr(isAssignmentOperator()))
5552/// \code
5553/// struct S { S& operator=(const S&); };
5554/// void x() { S s1, s2; s1 = s2; }
5555/// \endcode
5556AST_POLYMORPHIC_MATCHER(namespace internal { template <typename NodeType> class
matcher_isAssignmentOperatorMatcher : 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_isAssignmentOperatorMatcher
, void(::clang::ast_matchers::internal::TypeList<BinaryOperator
, CXXOperatorCallExpr, CXXRewrittenBinaryOperator>)> isAssignmentOperator
() { return ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_isAssignmentOperatorMatcher, void(::clang
::ast_matchers::internal::TypeList<BinaryOperator, CXXOperatorCallExpr
, CXXRewrittenBinaryOperator>)>(); } template <typename
NodeType> bool internal::matcher_isAssignmentOperatorMatcher
<NodeType>::matches( const NodeType &Node, ::clang::
ast_matchers::internal::ASTMatchFinder *Finder, ::clang::ast_matchers
::internal::BoundNodesTreeBuilder *Builder) const
5557 isAssignmentOperator,namespace internal { template <typename NodeType> class
matcher_isAssignmentOperatorMatcher : 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_isAssignmentOperatorMatcher
, void(::clang::ast_matchers::internal::TypeList<BinaryOperator
, CXXOperatorCallExpr, CXXRewrittenBinaryOperator>)> isAssignmentOperator
() { return ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_isAssignmentOperatorMatcher, void(::clang
::ast_matchers::internal::TypeList<BinaryOperator, CXXOperatorCallExpr
, CXXRewrittenBinaryOperator>)>(); } template <typename
NodeType> bool internal::matcher_isAssignmentOperatorMatcher
<NodeType>::matches( const NodeType &Node, ::clang::
ast_matchers::internal::ASTMatchFinder *Finder, ::clang::ast_matchers
::internal::BoundNodesTreeBuilder *Builder) const
5558 AST_POLYMORPHIC_SUPPORTED_TYPES(BinaryOperator, CXXOperatorCallExpr,namespace internal { template <typename NodeType> class
matcher_isAssignmentOperatorMatcher : 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_isAssignmentOperatorMatcher
, void(::clang::ast_matchers::internal::TypeList<BinaryOperator
, CXXOperatorCallExpr, CXXRewrittenBinaryOperator>)> isAssignmentOperator
() { return ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_isAssignmentOperatorMatcher, void(::clang
::ast_matchers::internal::TypeList<BinaryOperator, CXXOperatorCallExpr
, CXXRewrittenBinaryOperator>)>(); } template <typename
NodeType> bool internal::matcher_isAssignmentOperatorMatcher
<NodeType>::matches( const NodeType &Node, ::clang::
ast_matchers::internal::ASTMatchFinder *Finder, ::clang::ast_matchers
::internal::BoundNodesTreeBuilder *Builder) const
5559 CXXRewrittenBinaryOperator))namespace internal { template <typename NodeType> class
matcher_isAssignmentOperatorMatcher : 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_isAssignmentOperatorMatcher
, void(::clang::ast_matchers::internal::TypeList<BinaryOperator
, CXXOperatorCallExpr, CXXRewrittenBinaryOperator>)> isAssignmentOperator
() { return ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_isAssignmentOperatorMatcher, void(::clang
::ast_matchers::internal::TypeList<BinaryOperator, CXXOperatorCallExpr
, CXXRewrittenBinaryOperator>)>(); } template <typename
NodeType> bool internal::matcher_isAssignmentOperatorMatcher
<NodeType>::matches( const NodeType &Node, ::clang::
ast_matchers::internal::ASTMatchFinder *Finder, ::clang::ast_matchers
::internal::BoundNodesTreeBuilder *Builder) const
{
5560 return Node.isAssignmentOp();
5561}
5562
5563/// Matches comparison operators.
5564///
5565/// Example 1: matches a == b (matcher = binaryOperator(isComparisonOperator()))
5566/// \code
5567/// if (a == b)
5568/// a += b;
5569/// \endcode
5570///
5571/// Example 2: matches s1 < s2
5572/// (matcher = cxxOperatorCallExpr(isComparisonOperator()))
5573/// \code
5574/// struct S { bool operator<(const S& other); };
5575/// void x(S s1, S s2) { bool b1 = s1 < s2; }
5576/// \endcode
5577AST_POLYMORPHIC_MATCHER(namespace internal { template <typename NodeType> class
matcher_isComparisonOperatorMatcher : 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_isComparisonOperatorMatcher
, void(::clang::ast_matchers::internal::TypeList<BinaryOperator
, CXXOperatorCallExpr, CXXRewrittenBinaryOperator>)> isComparisonOperator
() { return ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_isComparisonOperatorMatcher, void(::clang
::ast_matchers::internal::TypeList<BinaryOperator, CXXOperatorCallExpr
, CXXRewrittenBinaryOperator>)>(); } template <typename
NodeType> bool internal::matcher_isComparisonOperatorMatcher
<NodeType>::matches( const NodeType &Node, ::clang::
ast_matchers::internal::ASTMatchFinder *Finder, ::clang::ast_matchers
::internal::BoundNodesTreeBuilder *Builder) const
5578 isComparisonOperator,namespace internal { template <typename NodeType> class
matcher_isComparisonOperatorMatcher : 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_isComparisonOperatorMatcher
, void(::clang::ast_matchers::internal::TypeList<BinaryOperator
, CXXOperatorCallExpr, CXXRewrittenBinaryOperator>)> isComparisonOperator
() { return ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_isComparisonOperatorMatcher, void(::clang
::ast_matchers::internal::TypeList<BinaryOperator, CXXOperatorCallExpr
, CXXRewrittenBinaryOperator>)>(); } template <typename
NodeType> bool internal::matcher_isComparisonOperatorMatcher
<NodeType>::matches( const NodeType &Node, ::clang::
ast_matchers::internal::ASTMatchFinder *Finder, ::clang::ast_matchers
::internal::BoundNodesTreeBuilder *Builder) const
5579 AST_POLYMORPHIC_SUPPORTED_TYPES(BinaryOperator, CXXOperatorCallExpr,namespace internal { template <typename NodeType> class
matcher_isComparisonOperatorMatcher : 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_isComparisonOperatorMatcher
, void(::clang::ast_matchers::internal::TypeList<BinaryOperator
, CXXOperatorCallExpr, CXXRewrittenBinaryOperator>)> isComparisonOperator
() { return ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_isComparisonOperatorMatcher, void(::clang
::ast_matchers::internal::TypeList<BinaryOperator, CXXOperatorCallExpr
, CXXRewrittenBinaryOperator>)>(); } template <typename
NodeType> bool internal::matcher_isComparisonOperatorMatcher
<NodeType>::matches( const NodeType &Node, ::clang::
ast_matchers::internal::ASTMatchFinder *Finder, ::clang::ast_matchers
::internal::BoundNodesTreeBuilder *Builder) const
5580 CXXRewrittenBinaryOperator))namespace internal { template <typename NodeType> class
matcher_isComparisonOperatorMatcher : 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_isComparisonOperatorMatcher
, void(::clang::ast_matchers::internal::TypeList<BinaryOperator
, CXXOperatorCallExpr, CXXRewrittenBinaryOperator>)> isComparisonOperator
() { return ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_isComparisonOperatorMatcher, void(::clang
::ast_matchers::internal::TypeList<BinaryOperator, CXXOperatorCallExpr
, CXXRewrittenBinaryOperator>)>(); } template <typename
NodeType> bool internal::matcher_isComparisonOperatorMatcher
<NodeType>::matches( const NodeType &Node, ::clang::
ast_matchers::internal::ASTMatchFinder *Finder, ::clang::ast_matchers
::internal::BoundNodesTreeBuilder *Builder) const
{
5581 return Node.isComparisonOp();
5582}
5583
5584/// Matches the left hand side of binary operator expressions.
5585///
5586/// Example matches a (matcher = binaryOperator(hasLHS()))
5587/// \code
5588/// a || b
5589/// \endcode
5590AST_POLYMORPHIC_MATCHER_P(hasLHS,namespace internal { template <typename NodeType, typename
ParamT> class matcher_hasLHS0Matcher : public ::clang::ast_matchers
::internal::MatcherInterface<NodeType> { public: explicit
matcher_hasLHS0Matcher( internal::Matcher<Expr> 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<Expr
> InnerMatcher; }; } inline ::clang::ast_matchers::internal
::PolymorphicMatcher< internal::matcher_hasLHS0Matcher, void
(::clang::ast_matchers::internal::TypeList<BinaryOperator,
CXXOperatorCallExpr, CXXRewrittenBinaryOperator, ArraySubscriptExpr
>), internal::Matcher<Expr> > hasLHS(internal::Matcher
<Expr> const &InnerMatcher) { return ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_hasLHS0Matcher
, void(::clang::ast_matchers::internal::TypeList<BinaryOperator
, CXXOperatorCallExpr, CXXRewrittenBinaryOperator, ArraySubscriptExpr
>), internal::Matcher<Expr> >(InnerMatcher); } typedef
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_hasLHS0Matcher, void(::clang::ast_matchers::internal
::TypeList<BinaryOperator, CXXOperatorCallExpr, CXXRewrittenBinaryOperator
, ArraySubscriptExpr>), internal::Matcher<Expr> >
(&hasLHS_Type0)(internal::Matcher<Expr> const &
InnerMatcher); template <typename NodeType, typename ParamT
> bool internal:: matcher_hasLHS0Matcher<NodeType, ParamT
>::matches( const NodeType &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
5591 AST_POLYMORPHIC_SUPPORTED_TYPES(namespace internal { template <typename NodeType, typename
ParamT> class matcher_hasLHS0Matcher : public ::clang::ast_matchers
::internal::MatcherInterface<NodeType> { public: explicit
matcher_hasLHS0Matcher( internal::Matcher<Expr> 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<Expr
> InnerMatcher; }; } inline ::clang::ast_matchers::internal
::PolymorphicMatcher< internal::matcher_hasLHS0Matcher, void
(::clang::ast_matchers::internal::TypeList<BinaryOperator,
CXXOperatorCallExpr, CXXRewrittenBinaryOperator, ArraySubscriptExpr
>), internal::Matcher<Expr> > hasLHS(internal::Matcher
<Expr> const &InnerMatcher) { return ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_hasLHS0Matcher
, void(::clang::ast_matchers::internal::TypeList<BinaryOperator
, CXXOperatorCallExpr, CXXRewrittenBinaryOperator, ArraySubscriptExpr
>), internal::Matcher<Expr> >(InnerMatcher); } typedef
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_hasLHS0Matcher, void(::clang::ast_matchers::internal
::TypeList<BinaryOperator, CXXOperatorCallExpr, CXXRewrittenBinaryOperator
, ArraySubscriptExpr>), internal::Matcher<Expr> >
(&hasLHS_Type0)(internal::Matcher<Expr> const &
InnerMatcher); template <typename NodeType, typename ParamT
> bool internal:: matcher_hasLHS0Matcher<NodeType, ParamT
>::matches( const NodeType &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
5592 BinaryOperator, CXXOperatorCallExpr,namespace internal { template <typename NodeType, typename
ParamT> class matcher_hasLHS0Matcher : public ::clang::ast_matchers
::internal::MatcherInterface<NodeType> { public: explicit
matcher_hasLHS0Matcher( internal::Matcher<Expr> 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<Expr
> InnerMatcher; }; } inline ::clang::ast_matchers::internal
::PolymorphicMatcher< internal::matcher_hasLHS0Matcher, void
(::clang::ast_matchers::internal::TypeList<BinaryOperator,
CXXOperatorCallExpr, CXXRewrittenBinaryOperator, ArraySubscriptExpr
>), internal::Matcher<Expr> > hasLHS(internal::Matcher
<Expr> const &InnerMatcher) { return ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_hasLHS0Matcher
, void(::clang::ast_matchers::internal::TypeList<BinaryOperator
, CXXOperatorCallExpr, CXXRewrittenBinaryOperator, ArraySubscriptExpr
>), internal::Matcher<Expr> >(InnerMatcher); } typedef
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_hasLHS0Matcher, void(::clang::ast_matchers::internal
::TypeList<BinaryOperator, CXXOperatorCallExpr, CXXRewrittenBinaryOperator
, ArraySubscriptExpr>), internal::Matcher<Expr> >
(&hasLHS_Type0)(internal::Matcher<Expr> const &
InnerMatcher); template <typename NodeType, typename ParamT
> bool internal:: matcher_hasLHS0Matcher<NodeType, ParamT
>::matches( const NodeType &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
5593 CXXRewrittenBinaryOperator, ArraySubscriptExpr),namespace internal { template <typename NodeType, typename
ParamT> class matcher_hasLHS0Matcher : public ::clang::ast_matchers
::internal::MatcherInterface<NodeType> { public: explicit
matcher_hasLHS0Matcher( internal::Matcher<Expr> 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<Expr
> InnerMatcher; }; } inline ::clang::ast_matchers::internal
::PolymorphicMatcher< internal::matcher_hasLHS0Matcher, void
(::clang::ast_matchers::internal::TypeList<BinaryOperator,
CXXOperatorCallExpr, CXXRewrittenBinaryOperator, ArraySubscriptExpr
>), internal::Matcher<Expr> > hasLHS(internal::Matcher
<Expr> const &InnerMatcher) { return ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_hasLHS0Matcher
, void(::clang::ast_matchers::internal::TypeList<BinaryOperator
, CXXOperatorCallExpr, CXXRewrittenBinaryOperator, ArraySubscriptExpr
>), internal::Matcher<Expr> >(InnerMatcher); } typedef
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_hasLHS0Matcher, void(::clang::ast_matchers::internal
::TypeList<BinaryOperator, CXXOperatorCallExpr, CXXRewrittenBinaryOperator
, ArraySubscriptExpr>), internal::Matcher<Expr> >
(&hasLHS_Type0)(internal::Matcher<Expr> const &
InnerMatcher); template <typename NodeType, typename ParamT
> bool internal:: matcher_hasLHS0Matcher<NodeType, ParamT
>::matches( const NodeType &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
5594 internal::Matcher<Expr>, InnerMatcher)namespace internal { template <typename NodeType, typename
ParamT> class matcher_hasLHS0Matcher : public ::clang::ast_matchers
::internal::MatcherInterface<NodeType> { public: explicit
matcher_hasLHS0Matcher( internal::Matcher<Expr> 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<Expr
> InnerMatcher; }; } inline ::clang::ast_matchers::internal
::PolymorphicMatcher< internal::matcher_hasLHS0Matcher, void
(::clang::ast_matchers::internal::TypeList<BinaryOperator,
CXXOperatorCallExpr, CXXRewrittenBinaryOperator, ArraySubscriptExpr
>), internal::Matcher<Expr> > hasLHS(internal::Matcher
<Expr> const &InnerMatcher) { return ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_hasLHS0Matcher
, void(::clang::ast_matchers::internal::TypeList<BinaryOperator
, CXXOperatorCallExpr, CXXRewrittenBinaryOperator, ArraySubscriptExpr
>), internal::Matcher<Expr> >(InnerMatcher); } typedef
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_hasLHS0Matcher, void(::clang::ast_matchers::internal
::TypeList<BinaryOperator, CXXOperatorCallExpr, CXXRewrittenBinaryOperator
, ArraySubscriptExpr>), internal::Matcher<Expr> >
(&hasLHS_Type0)(internal::Matcher<Expr> const &
InnerMatcher); template <typename NodeType, typename ParamT
> bool internal:: matcher_hasLHS0Matcher<NodeType, ParamT
>::matches( const NodeType &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
{
5595 const Expr *LeftHandSide = internal::getLHS(Node);
5596 return (LeftHandSide != nullptr &&
5597 InnerMatcher.matches(*LeftHandSide, Finder, Builder));
5598}
5599
5600/// Matches the right hand side of binary operator expressions.
5601///
5602/// Example matches b (matcher = binaryOperator(hasRHS()))
5603/// \code
5604/// a || b
5605/// \endcode
5606AST_POLYMORPHIC_MATCHER_P(hasRHS,namespace internal { template <typename NodeType, typename
ParamT> class matcher_hasRHS0Matcher : public ::clang::ast_matchers
::internal::MatcherInterface<NodeType> { public: explicit
matcher_hasRHS0Matcher( internal::Matcher<Expr> 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<Expr
> InnerMatcher; }; } inline ::clang::ast_matchers::internal
::PolymorphicMatcher< internal::matcher_hasRHS0Matcher, void
(::clang::ast_matchers::internal::TypeList<BinaryOperator,
CXXOperatorCallExpr, CXXRewrittenBinaryOperator, ArraySubscriptExpr
>), internal::Matcher<Expr> > hasRHS(internal::Matcher
<Expr> const &InnerMatcher) { return ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_hasRHS0Matcher
, void(::clang::ast_matchers::internal::TypeList<BinaryOperator
, CXXOperatorCallExpr, CXXRewrittenBinaryOperator, ArraySubscriptExpr
>), internal::Matcher<Expr> >(InnerMatcher); } typedef
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_hasRHS0Matcher, void(::clang::ast_matchers::internal
::TypeList<BinaryOperator, CXXOperatorCallExpr, CXXRewrittenBinaryOperator
, ArraySubscriptExpr>), internal::Matcher<Expr> >
(&hasRHS_Type0)(internal::Matcher<Expr> const &
InnerMatcher); template <typename NodeType, typename ParamT
> bool internal:: matcher_hasRHS0Matcher<NodeType, ParamT
>::matches( const NodeType &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
5607 AST_POLYMORPHIC_SUPPORTED_TYPES(namespace internal { template <typename NodeType, typename
ParamT> class matcher_hasRHS0Matcher : public ::clang::ast_matchers
::internal::MatcherInterface<NodeType> { public: explicit
matcher_hasRHS0Matcher( internal::Matcher<Expr> 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<Expr
> InnerMatcher; }; } inline ::clang::ast_matchers::internal
::PolymorphicMatcher< internal::matcher_hasRHS0Matcher, void
(::clang::ast_matchers::internal::TypeList<BinaryOperator,
CXXOperatorCallExpr, CXXRewrittenBinaryOperator, ArraySubscriptExpr
>), internal::Matcher<Expr> > hasRHS(internal::Matcher
<Expr> const &InnerMatcher) { return ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_hasRHS0Matcher
, void(::clang::ast_matchers::internal::TypeList<BinaryOperator
, CXXOperatorCallExpr, CXXRewrittenBinaryOperator, ArraySubscriptExpr
>), internal::Matcher<Expr> >(InnerMatcher); } typedef
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_hasRHS0Matcher, void(::clang::ast_matchers::internal
::TypeList<BinaryOperator, CXXOperatorCallExpr, CXXRewrittenBinaryOperator
, ArraySubscriptExpr>), internal::Matcher<Expr> >
(&hasRHS_Type0)(internal::Matcher<Expr> const &
InnerMatcher); template <typename NodeType, typename ParamT
> bool internal:: matcher_hasRHS0Matcher<NodeType, ParamT
>::matches( const NodeType &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
5608 BinaryOperator, CXXOperatorCallExpr,namespace internal { template <typename NodeType, typename
ParamT> class matcher_hasRHS0Matcher : public ::clang::ast_matchers
::internal::MatcherInterface<NodeType> { public: explicit
matcher_hasRHS0Matcher( internal::Matcher<Expr> 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<Expr
> InnerMatcher; }; } inline ::clang::ast_matchers::internal
::PolymorphicMatcher< internal::matcher_hasRHS0Matcher, void
(::clang::ast_matchers::internal::TypeList<BinaryOperator,
CXXOperatorCallExpr, CXXRewrittenBinaryOperator, ArraySubscriptExpr
>), internal::Matcher<Expr> > hasRHS(internal::Matcher
<Expr> const &InnerMatcher) { return ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_hasRHS0Matcher
, void(::clang::ast_matchers::internal::TypeList<BinaryOperator
, CXXOperatorCallExpr, CXXRewrittenBinaryOperator, ArraySubscriptExpr
>), internal::Matcher<Expr> >(InnerMatcher); } typedef
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_hasRHS0Matcher, void(::clang::ast_matchers::internal
::TypeList<BinaryOperator, CXXOperatorCallExpr, CXXRewrittenBinaryOperator
, ArraySubscriptExpr>), internal::Matcher<Expr> >
(&hasRHS_Type0)(internal::Matcher<Expr> const &
InnerMatcher); template <typename NodeType, typename ParamT
> bool internal:: matcher_hasRHS0Matcher<NodeType, ParamT
>::matches( const NodeType &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
5609 CXXRewrittenBinaryOperator, ArraySubscriptExpr),namespace internal { template <typename NodeType, typename
ParamT> class matcher_hasRHS0Matcher : public ::clang::ast_matchers
::internal::MatcherInterface<NodeType> { public: explicit
matcher_hasRHS0Matcher( internal::Matcher<Expr> 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<Expr
> InnerMatcher; }; } inline ::clang::ast_matchers::internal
::PolymorphicMatcher< internal::matcher_hasRHS0Matcher, void
(::clang::ast_matchers::internal::TypeList<BinaryOperator,
CXXOperatorCallExpr, CXXRewrittenBinaryOperator, ArraySubscriptExpr
>), internal::Matcher<Expr> > hasRHS(internal::Matcher
<Expr> const &InnerMatcher) { return ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_hasRHS0Matcher
, void(::clang::ast_matchers::internal::TypeList<BinaryOperator
, CXXOperatorCallExpr, CXXRewrittenBinaryOperator, ArraySubscriptExpr
>), internal::Matcher<Expr> >(InnerMatcher); } typedef
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_hasRHS0Matcher, void(::clang::ast_matchers::internal
::TypeList<BinaryOperator, CXXOperatorCallExpr, CXXRewrittenBinaryOperator
, ArraySubscriptExpr>), internal::Matcher<Expr> >
(&hasRHS_Type0)(internal::Matcher<Expr> const &
InnerMatcher); template <typename NodeType, typename ParamT
> bool internal:: matcher_hasRHS0Matcher<NodeType, ParamT
>::matches( const NodeType &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
5610 internal::Matcher<Expr>, InnerMatcher)namespace internal { template <typename NodeType, typename
ParamT> class matcher_hasRHS0Matcher : public ::clang::ast_matchers
::internal::MatcherInterface<NodeType> { public: explicit
matcher_hasRHS0Matcher( internal::Matcher<Expr> 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<Expr
> InnerMatcher; }; } inline ::clang::ast_matchers::internal
::PolymorphicMatcher< internal::matcher_hasRHS0Matcher, void
(::clang::ast_matchers::internal::TypeList<BinaryOperator,
CXXOperatorCallExpr, CXXRewrittenBinaryOperator, ArraySubscriptExpr
>), internal::Matcher<Expr> > hasRHS(internal::Matcher
<Expr> const &InnerMatcher) { return ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_hasRHS0Matcher
, void(::clang::ast_matchers::internal::TypeList<BinaryOperator
, CXXOperatorCallExpr, CXXRewrittenBinaryOperator, ArraySubscriptExpr
>), internal::Matcher<Expr> >(InnerMatcher); } typedef
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_hasRHS0Matcher, void(::clang::ast_matchers::internal
::TypeList<BinaryOperator, CXXOperatorCallExpr, CXXRewrittenBinaryOperator
, ArraySubscriptExpr>), internal::Matcher<Expr> >
(&hasRHS_Type0)(internal::Matcher<Expr> const &
InnerMatcher); template <typename NodeType, typename ParamT
> bool internal:: matcher_hasRHS0Matcher<NodeType, ParamT
>::matches( const NodeType &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
{
5611 const Expr *RightHandSide = internal::getRHS(Node);
5612 return (RightHandSide != nullptr &&
5613 InnerMatcher.matches(*RightHandSide, Finder, Builder));
5614}
5615
5616/// Matches if either the left hand side or the right hand side of a
5617/// binary operator matches.
5618AST_POLYMORPHIC_MATCHER_P(namespace internal { template <typename NodeType, typename
ParamT> class matcher_hasEitherOperand0Matcher : public ::
clang::ast_matchers::internal::MatcherInterface<NodeType>
{ public: explicit matcher_hasEitherOperand0Matcher( internal
::Matcher<Expr> 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<Expr> InnerMatcher; }; } inline ::clang
::ast_matchers::internal::PolymorphicMatcher< internal::matcher_hasEitherOperand0Matcher
, void(::clang::ast_matchers::internal::TypeList<BinaryOperator
, CXXOperatorCallExpr, CXXRewrittenBinaryOperator>), internal
::Matcher<Expr> > hasEitherOperand(internal::Matcher
<Expr> const &InnerMatcher) { return ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_hasEitherOperand0Matcher
, void(::clang::ast_matchers::internal::TypeList<BinaryOperator
, CXXOperatorCallExpr, CXXRewrittenBinaryOperator>), internal
::Matcher<Expr> >(InnerMatcher); } typedef ::clang::
ast_matchers::internal::PolymorphicMatcher< internal::matcher_hasEitherOperand0Matcher
, void(::clang::ast_matchers::internal::TypeList<BinaryOperator
, CXXOperatorCallExpr, CXXRewrittenBinaryOperator>), internal
::Matcher<Expr> > (&hasEitherOperand_Type0)(internal
::Matcher<Expr> const &InnerMatcher); template <
typename NodeType, typename ParamT> bool internal:: matcher_hasEitherOperand0Matcher
<NodeType, ParamT>::matches( const NodeType &Node, ::
clang::ast_matchers::internal::ASTMatchFinder *Finder, ::clang
::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
5619 hasEitherOperand,namespace internal { template <typename NodeType, typename
ParamT> class matcher_hasEitherOperand0Matcher : public ::
clang::ast_matchers::internal::MatcherInterface<NodeType>
{ public: explicit matcher_hasEitherOperand0Matcher( internal
::Matcher<Expr> 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<Expr> InnerMatcher; }; } inline ::clang
::ast_matchers::internal::PolymorphicMatcher< internal::matcher_hasEitherOperand0Matcher
, void(::clang::ast_matchers::internal::TypeList<BinaryOperator
, CXXOperatorCallExpr, CXXRewrittenBinaryOperator>), internal
::Matcher<Expr> > hasEitherOperand(internal::Matcher
<Expr> const &InnerMatcher) { return ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_hasEitherOperand0Matcher
, void(::clang::ast_matchers::internal::TypeList<BinaryOperator
, CXXOperatorCallExpr, CXXRewrittenBinaryOperator>), internal
::Matcher<Expr> >(InnerMatcher); } typedef ::clang::
ast_matchers::internal::PolymorphicMatcher< internal::matcher_hasEitherOperand0Matcher
, void(::clang::ast_matchers::internal::TypeList<BinaryOperator
, CXXOperatorCallExpr, CXXRewrittenBinaryOperator>), internal
::Matcher<Expr> > (&hasEitherOperand_Type0)(internal
::Matcher<Expr> const &InnerMatcher); template <
typename NodeType, typename ParamT> bool internal:: matcher_hasEitherOperand0Matcher
<NodeType, ParamT>::matches( const NodeType &Node, ::
clang::ast_matchers::internal::ASTMatchFinder *Finder, ::clang
::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
5620 AST_POLYMORPHIC_SUPPORTED_TYPES(BinaryOperator, CXXOperatorCallExpr,namespace internal { template <typename NodeType, typename
ParamT> class matcher_hasEitherOperand0Matcher : public ::
clang::ast_matchers::internal::MatcherInterface<NodeType>
{ public: explicit matcher_hasEitherOperand0Matcher( internal
::Matcher<Expr> 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<Expr> InnerMatcher; }; } inline ::clang
::ast_matchers::internal::PolymorphicMatcher< internal::matcher_hasEitherOperand0Matcher
, void(::clang::ast_matchers::internal::TypeList<BinaryOperator
, CXXOperatorCallExpr, CXXRewrittenBinaryOperator>), internal
::Matcher<Expr> > hasEitherOperand(internal::Matcher
<Expr> const &InnerMatcher) { return ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_hasEitherOperand0Matcher
, void(::clang::ast_matchers::internal::TypeList<BinaryOperator
, CXXOperatorCallExpr, CXXRewrittenBinaryOperator>), internal
::Matcher<Expr> >(InnerMatcher); } typedef ::clang::
ast_matchers::internal::PolymorphicMatcher< internal::matcher_hasEitherOperand0Matcher
, void(::clang::ast_matchers::internal::TypeList<BinaryOperator
, CXXOperatorCallExpr, CXXRewrittenBinaryOperator>), internal
::Matcher<Expr> > (&hasEitherOperand_Type0)(internal
::Matcher<Expr> const &InnerMatcher); template <
typename NodeType, typename ParamT> bool internal:: matcher_hasEitherOperand0Matcher
<NodeType, ParamT>::matches( const NodeType &Node, ::
clang::ast_matchers::internal::ASTMatchFinder *Finder, ::clang
::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
5621 CXXRewrittenBinaryOperator),namespace internal { template <typename NodeType, typename
ParamT> class matcher_hasEitherOperand0Matcher : public ::
clang::ast_matchers::internal::MatcherInterface<NodeType>
{ public: explicit matcher_hasEitherOperand0Matcher( internal
::Matcher<Expr> 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<Expr> InnerMatcher; }; } inline ::clang
::ast_matchers::internal::PolymorphicMatcher< internal::matcher_hasEitherOperand0Matcher
, void(::clang::ast_matchers::internal::TypeList<BinaryOperator
, CXXOperatorCallExpr, CXXRewrittenBinaryOperator>), internal
::Matcher<Expr> > hasEitherOperand(internal::Matcher
<Expr> const &InnerMatcher) { return ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_hasEitherOperand0Matcher
, void(::clang::ast_matchers::internal::TypeList<BinaryOperator
, CXXOperatorCallExpr, CXXRewrittenBinaryOperator>), internal
::Matcher<Expr> >(InnerMatcher); } typedef ::clang::
ast_matchers::internal::PolymorphicMatcher< internal::matcher_hasEitherOperand0Matcher
, void(::clang::ast_matchers::internal::TypeList<BinaryOperator
, CXXOperatorCallExpr, CXXRewrittenBinaryOperator>), internal
::Matcher<Expr> > (&hasEitherOperand_Type0)(internal
::Matcher<Expr> const &InnerMatcher); template <
typename NodeType, typename ParamT> bool internal:: matcher_hasEitherOperand0Matcher
<NodeType, ParamT>::matches( const NodeType &Node, ::
clang::ast_matchers::internal::ASTMatchFinder *Finder, ::clang
::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
5622 internal::Matcher<Expr>, InnerMatcher)namespace internal { template <typename NodeType, typename
ParamT> class matcher_hasEitherOperand0Matcher : public ::
clang::ast_matchers::internal::MatcherInterface<NodeType>
{ public: explicit matcher_hasEitherOperand0Matcher( internal
::Matcher<Expr> 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<Expr> InnerMatcher; }; } inline ::clang
::ast_matchers::internal::PolymorphicMatcher< internal::matcher_hasEitherOperand0Matcher
, void(::clang::ast_matchers::internal::TypeList<BinaryOperator
, CXXOperatorCallExpr, CXXRewrittenBinaryOperator>), internal
::Matcher<Expr> > hasEitherOperand(internal::Matcher
<Expr> const &InnerMatcher) { return ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_hasEitherOperand0Matcher
, void(::clang::ast_matchers::internal::TypeList<BinaryOperator
, CXXOperatorCallExpr, CXXRewrittenBinaryOperator>), internal
::Matcher<Expr> >(InnerMatcher); } typedef ::clang::
ast_matchers::internal::PolymorphicMatcher< internal::matcher_hasEitherOperand0Matcher
, void(::clang::ast_matchers::internal::TypeList<BinaryOperator
, CXXOperatorCallExpr, CXXRewrittenBinaryOperator>), internal
::Matcher<Expr> > (&hasEitherOperand_Type0)(internal
::Matcher<Expr> const &InnerMatcher); template <
typename NodeType, typename ParamT> bool internal:: matcher_hasEitherOperand0Matcher
<NodeType, ParamT>::matches( const NodeType &Node, ::
clang::ast_matchers::internal::ASTMatchFinder *Finder, ::clang
::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
{
5623 return internal::VariadicDynCastAllOfMatcher<Stmt, NodeType>()(
5624 anyOf(hasLHS(InnerMatcher), hasRHS(InnerMatcher)))
5625 .matches(Node, Finder, Builder);
5626}
5627
5628/// Matches if both matchers match with opposite sides of the binary operator.
5629///
5630/// Example matcher = binaryOperator(hasOperands(integerLiteral(equals(1),
5631/// integerLiteral(equals(2)))
5632/// \code
5633/// 1 + 2 // Match
5634/// 2 + 1 // Match
5635/// 1 + 1 // No match
5636/// 2 + 2 // No match
5637/// \endcode
5638AST_POLYMORPHIC_MATCHER_P2(namespace internal { template <typename NodeType, typename
ParamT1, typename ParamT2> class matcher_hasOperands0Matcher
: public ::clang::ast_matchers::internal::MatcherInterface<
NodeType> { public: matcher_hasOperands0Matcher(internal::
Matcher<Expr> const &AMatcher1, internal::Matcher<
Expr> const &AMatcher2) : Matcher1(AMatcher1), Matcher2
(AMatcher2) {} bool matches(const NodeType &Node, ::clang
::ast_matchers::internal::ASTMatchFinder *Finder, ::clang::ast_matchers
::internal::BoundNodesTreeBuilder *Builder) const override; private
: internal::Matcher<Expr> Matcher1; internal::Matcher<
Expr> Matcher2; }; } inline ::clang::ast_matchers::internal
::PolymorphicMatcher< internal::matcher_hasOperands0Matcher
, void(::clang::ast_matchers::internal::TypeList<BinaryOperator
, CXXOperatorCallExpr, CXXRewrittenBinaryOperator>), internal
::Matcher<Expr>, internal::Matcher<Expr> > hasOperands
(internal::Matcher<Expr> const &Matcher1, internal::
Matcher<Expr> const &Matcher2) { return ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_hasOperands0Matcher
, void(::clang::ast_matchers::internal::TypeList<BinaryOperator
, CXXOperatorCallExpr, CXXRewrittenBinaryOperator>), internal
::Matcher<Expr>, internal::Matcher<Expr> >(Matcher1
, Matcher2); } typedef ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_hasOperands0Matcher, void(::clang::ast_matchers
::internal::TypeList<BinaryOperator, CXXOperatorCallExpr, CXXRewrittenBinaryOperator
>), internal::Matcher<Expr>, internal::Matcher<Expr
> > (&hasOperands_Type0)( internal::Matcher<Expr
> const &Matcher1, internal::Matcher<Expr> const
&Matcher2); template <typename NodeType, typename ParamT1
, typename ParamT2> bool internal::matcher_hasOperands0Matcher
< NodeType, ParamT1, ParamT2>:: matches(const NodeType &
Node, ::clang::ast_matchers::internal::ASTMatchFinder *Finder
, ::clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder
) const
5639 hasOperands,namespace internal { template <typename NodeType, typename
ParamT1, typename ParamT2> class matcher_hasOperands0Matcher
: public ::clang::ast_matchers::internal::MatcherInterface<
NodeType> { public: matcher_hasOperands0Matcher(internal::
Matcher<Expr> const &AMatcher1, internal::Matcher<
Expr> const &AMatcher2) : Matcher1(AMatcher1), Matcher2
(AMatcher2) {} bool matches(const NodeType &Node, ::clang
::ast_matchers::internal::ASTMatchFinder *Finder, ::clang::ast_matchers
::internal::BoundNodesTreeBuilder *Builder) const override; private
: internal::Matcher<Expr> Matcher1; internal::Matcher<
Expr> Matcher2; }; } inline ::clang::ast_matchers::internal
::PolymorphicMatcher< internal::matcher_hasOperands0Matcher
, void(::clang::ast_matchers::internal::TypeList<BinaryOperator
, CXXOperatorCallExpr, CXXRewrittenBinaryOperator>), internal
::Matcher<Expr>, internal::Matcher<Expr> > hasOperands
(internal::Matcher<Expr> const &Matcher1, internal::
Matcher<Expr> const &Matcher2) { return ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_hasOperands0Matcher
, void(::clang::ast_matchers::internal::TypeList<BinaryOperator
, CXXOperatorCallExpr, CXXRewrittenBinaryOperator>), internal
::Matcher<Expr>, internal::Matcher<Expr> >(Matcher1
, Matcher2); } typedef ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_hasOperands0Matcher, void(::clang::ast_matchers
::internal::TypeList<BinaryOperator, CXXOperatorCallExpr, CXXRewrittenBinaryOperator
>), internal::Matcher<Expr>, internal::Matcher<Expr
> > (&hasOperands_Type0)( internal::Matcher<Expr
> const &Matcher1, internal::Matcher<Expr> const
&Matcher2); template <typename NodeType, typename ParamT1
, typename ParamT2> bool internal::matcher_hasOperands0Matcher
< NodeType, ParamT1, ParamT2>:: matches(const NodeType &
Node, ::clang::ast_matchers::internal::ASTMatchFinder *Finder
, ::clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder
) const
5640 AST_POLYMORPHIC_SUPPORTED_TYPES(BinaryOperator, CXXOperatorCallExpr,namespace internal { template <typename NodeType, typename
ParamT1, typename ParamT2> class matcher_hasOperands0Matcher
: public ::clang::ast_matchers::internal::MatcherInterface<
NodeType> { public: matcher_hasOperands0Matcher(internal::
Matcher<Expr> const &AMatcher1, internal::Matcher<
Expr> const &AMatcher2) : Matcher1(AMatcher1), Matcher2
(AMatcher2) {} bool matches(const NodeType &Node, ::clang
::ast_matchers::internal::ASTMatchFinder *Finder, ::clang::ast_matchers
::internal::BoundNodesTreeBuilder *Builder) const override; private
: internal::Matcher<Expr> Matcher1; internal::Matcher<
Expr> Matcher2; }; } inline ::clang::ast_matchers::internal
::PolymorphicMatcher< internal::matcher_hasOperands0Matcher
, void(::clang::ast_matchers::internal::TypeList<BinaryOperator
, CXXOperatorCallExpr, CXXRewrittenBinaryOperator>), internal
::Matcher<Expr>, internal::Matcher<Expr> > hasOperands
(internal::Matcher<Expr> const &Matcher1, internal::
Matcher<Expr> const &Matcher2) { return ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_hasOperands0Matcher
, void(::clang::ast_matchers::internal::TypeList<BinaryOperator
, CXXOperatorCallExpr, CXXRewrittenBinaryOperator>), internal
::Matcher<Expr>, internal::Matcher<Expr> >(Matcher1
, Matcher2); } typedef ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_hasOperands0Matcher, void(::clang::ast_matchers
::internal::TypeList<BinaryOperator, CXXOperatorCallExpr, CXXRewrittenBinaryOperator
>), internal::Matcher<Expr>, internal::Matcher<Expr
> > (&hasOperands_Type0)( internal::Matcher<Expr
> const &Matcher1, internal::Matcher<Expr> const
&Matcher2); template <typename NodeType, typename ParamT1
, typename ParamT2> bool internal::matcher_hasOperands0Matcher
< NodeType, ParamT1, ParamT2>:: matches(const NodeType &
Node, ::clang::ast_matchers::internal::ASTMatchFinder *Finder
, ::clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder
) const
5641 CXXRewrittenBinaryOperator),namespace internal { template <typename NodeType, typename
ParamT1, typename ParamT2> class matcher_hasOperands0Matcher
: public ::clang::ast_matchers::internal::MatcherInterface<
NodeType> { public: matcher_hasOperands0Matcher(internal::
Matcher<Expr> const &AMatcher1, internal::Matcher<
Expr> const &AMatcher2) : Matcher1(AMatcher1), Matcher2
(AMatcher2) {} bool matches(const NodeType &Node, ::clang
::ast_matchers::internal::ASTMatchFinder *Finder, ::clang::ast_matchers
::internal::BoundNodesTreeBuilder *Builder) const override; private
: internal::Matcher<Expr> Matcher1; internal::Matcher<
Expr> Matcher2; }; } inline ::clang::ast_matchers::internal
::PolymorphicMatcher< internal::matcher_hasOperands0Matcher
, void(::clang::ast_matchers::internal::TypeList<BinaryOperator
, CXXOperatorCallExpr, CXXRewrittenBinaryOperator>), internal
::Matcher<Expr>, internal::Matcher<Expr> > hasOperands
(internal::Matcher<Expr> const &Matcher1, internal::
Matcher<Expr> const &Matcher2) { return ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_hasOperands0Matcher
, void(::clang::ast_matchers::internal::TypeList<BinaryOperator
, CXXOperatorCallExpr, CXXRewrittenBinaryOperator>), internal
::Matcher<Expr>, internal::Matcher<Expr> >(Matcher1
, Matcher2); } typedef ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_hasOperands0Matcher, void(::clang::ast_matchers
::internal::TypeList<BinaryOperator, CXXOperatorCallExpr, CXXRewrittenBinaryOperator
>), internal::Matcher<Expr>, internal::Matcher<Expr
> > (&hasOperands_Type0)( internal::Matcher<Expr
> const &Matcher1, internal::Matcher<Expr> const
&Matcher2); template <typename NodeType, typename ParamT1
, typename ParamT2> bool internal::matcher_hasOperands0Matcher
< NodeType, ParamT1, ParamT2>:: matches(const NodeType &
Node, ::clang::ast_matchers::internal::ASTMatchFinder *Finder
, ::clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder
) const
5642 internal::Matcher<Expr>, Matcher1, internal::Matcher<Expr>, Matcher2)namespace internal { template <typename NodeType, typename
ParamT1, typename ParamT2> class matcher_hasOperands0Matcher
: public ::clang::ast_matchers::internal::MatcherInterface<
NodeType> { public: matcher_hasOperands0Matcher(internal::
Matcher<Expr> const &AMatcher1, internal::Matcher<
Expr> const &AMatcher2) : Matcher1(AMatcher1), Matcher2
(AMatcher2) {} bool matches(const NodeType &Node, ::clang
::ast_matchers::internal::ASTMatchFinder *Finder, ::clang::ast_matchers
::internal::BoundNodesTreeBuilder *Builder) const override; private
: internal::Matcher<Expr> Matcher1; internal::Matcher<
Expr> Matcher2; }; } inline ::clang::ast_matchers::internal
::PolymorphicMatcher< internal::matcher_hasOperands0Matcher
, void(::clang::ast_matchers::internal::TypeList<BinaryOperator
, CXXOperatorCallExpr, CXXRewrittenBinaryOperator>), internal
::Matcher<Expr>, internal::Matcher<Expr> > hasOperands
(internal::Matcher<Expr> const &Matcher1, internal::
Matcher<Expr> const &Matcher2) { return ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_hasOperands0Matcher
, void(::clang::ast_matchers::internal::TypeList<BinaryOperator
, CXXOperatorCallExpr, CXXRewrittenBinaryOperator>), internal
::Matcher<Expr>, internal::Matcher<Expr> >(Matcher1
, Matcher2); } typedef ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_hasOperands0Matcher, void(::clang::ast_matchers
::internal::TypeList<BinaryOperator, CXXOperatorCallExpr, CXXRewrittenBinaryOperator
>), internal::Matcher<Expr>, internal::Matcher<Expr
> > (&hasOperands_Type0)( internal::Matcher<Expr
> const &Matcher1, internal::Matcher<Expr> const
&Matcher2); template <typename NodeType, typename ParamT1
, typename ParamT2> bool internal::matcher_hasOperands0Matcher
< NodeType, ParamT1, ParamT2>:: matches(const NodeType &
Node, ::clang::ast_matchers::internal::ASTMatchFinder *Finder
, ::clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder
) const
{
5643 return internal::VariadicDynCastAllOfMatcher<Stmt, NodeType>()(
5644 anyOf(allOf(hasLHS(Matcher1), hasRHS(Matcher2)),
5645 allOf(hasLHS(Matcher2), hasRHS(Matcher1))))
5646 .matches(Node, Finder, Builder);
5647}
5648
5649/// Matches if the operand of a unary operator matches.
5650///
5651/// Example matches true (matcher = hasUnaryOperand(
5652/// cxxBoolLiteral(equals(true))))
5653/// \code
5654/// !true
5655/// \endcode
5656AST_POLYMORPHIC_MATCHER_P(hasUnaryOperand,namespace internal { template <typename NodeType, typename
ParamT> class matcher_hasUnaryOperand0Matcher : public ::
clang::ast_matchers::internal::MatcherInterface<NodeType>
{ public: explicit matcher_hasUnaryOperand0Matcher( internal
::Matcher<Expr> 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<Expr> InnerMatcher; }; } inline ::clang
::ast_matchers::internal::PolymorphicMatcher< internal::matcher_hasUnaryOperand0Matcher
, void(::clang::ast_matchers::internal::TypeList<UnaryOperator
, CXXOperatorCallExpr>), internal::Matcher<Expr> >
hasUnaryOperand(internal::Matcher<Expr> const &InnerMatcher
) { return ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_hasUnaryOperand0Matcher, void(::clang::
ast_matchers::internal::TypeList<UnaryOperator, CXXOperatorCallExpr
>), internal::Matcher<Expr> >(InnerMatcher); } typedef
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_hasUnaryOperand0Matcher, void(::clang::ast_matchers
::internal::TypeList<UnaryOperator, CXXOperatorCallExpr>
), internal::Matcher<Expr> > (&hasUnaryOperand_Type0
)(internal::Matcher<Expr> const &InnerMatcher); template
<typename NodeType, typename ParamT> bool internal:: matcher_hasUnaryOperand0Matcher
<NodeType, ParamT>::matches( const NodeType &Node, ::
clang::ast_matchers::internal::ASTMatchFinder *Finder, ::clang
::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
5657 AST_POLYMORPHIC_SUPPORTED_TYPES(UnaryOperator,namespace internal { template <typename NodeType, typename
ParamT> class matcher_hasUnaryOperand0Matcher : public ::
clang::ast_matchers::internal::MatcherInterface<NodeType>
{ public: explicit matcher_hasUnaryOperand0Matcher( internal
::Matcher<Expr> 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<Expr> InnerMatcher; }; } inline ::clang
::ast_matchers::internal::PolymorphicMatcher< internal::matcher_hasUnaryOperand0Matcher
, void(::clang::ast_matchers::internal::TypeList<UnaryOperator
, CXXOperatorCallExpr>), internal::Matcher<Expr> >
hasUnaryOperand(internal::Matcher<Expr> const &InnerMatcher
) { return ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_hasUnaryOperand0Matcher, void(::clang::
ast_matchers::internal::TypeList<UnaryOperator, CXXOperatorCallExpr
>), internal::Matcher<Expr> >(InnerMatcher); } typedef
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_hasUnaryOperand0Matcher, void(::clang::ast_matchers
::internal::TypeList<UnaryOperator, CXXOperatorCallExpr>
), internal::Matcher<Expr> > (&hasUnaryOperand_Type0
)(internal::Matcher<Expr> const &InnerMatcher); template
<typename NodeType, typename ParamT> bool internal:: matcher_hasUnaryOperand0Matcher
<NodeType, ParamT>::matches( const NodeType &Node, ::
clang::ast_matchers::internal::ASTMatchFinder *Finder, ::clang
::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
5658 CXXOperatorCallExpr),namespace internal { template <typename NodeType, typename
ParamT> class matcher_hasUnaryOperand0Matcher : public ::
clang::ast_matchers::internal::MatcherInterface<NodeType>
{ public: explicit matcher_hasUnaryOperand0Matcher( internal
::Matcher<Expr> 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<Expr> InnerMatcher; }; } inline ::clang
::ast_matchers::internal::PolymorphicMatcher< internal::matcher_hasUnaryOperand0Matcher
, void(::clang::ast_matchers::internal::TypeList<UnaryOperator
, CXXOperatorCallExpr>), internal::Matcher<Expr> >
hasUnaryOperand(internal::Matcher<Expr> const &InnerMatcher
) { return ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_hasUnaryOperand0Matcher, void(::clang::
ast_matchers::internal::TypeList<UnaryOperator, CXXOperatorCallExpr
>), internal::Matcher<Expr> >(InnerMatcher); } typedef
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_hasUnaryOperand0Matcher, void(::clang::ast_matchers
::internal::TypeList<UnaryOperator, CXXOperatorCallExpr>
), internal::Matcher<Expr> > (&hasUnaryOperand_Type0
)(internal::Matcher<Expr> const &InnerMatcher); template
<typename NodeType, typename ParamT> bool internal:: matcher_hasUnaryOperand0Matcher
<NodeType, ParamT>::matches( const NodeType &Node, ::
clang::ast_matchers::internal::ASTMatchFinder *Finder, ::clang
::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
5659 internal::Matcher<Expr>, InnerMatcher)namespace internal { template <typename NodeType, typename
ParamT> class matcher_hasUnaryOperand0Matcher : public ::
clang::ast_matchers::internal::MatcherInterface<NodeType>
{ public: explicit matcher_hasUnaryOperand0Matcher( internal
::Matcher<Expr> 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<Expr> InnerMatcher; }; } inline ::clang
::ast_matchers::internal::PolymorphicMatcher< internal::matcher_hasUnaryOperand0Matcher
, void(::clang::ast_matchers::internal::TypeList<UnaryOperator
, CXXOperatorCallExpr>), internal::Matcher<Expr> >
hasUnaryOperand(internal::Matcher<Expr> const &InnerMatcher
) { return ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_hasUnaryOperand0Matcher, void(::clang::
ast_matchers::internal::TypeList<UnaryOperator, CXXOperatorCallExpr
>), internal::Matcher<Expr> >(InnerMatcher); } typedef
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_hasUnaryOperand0Matcher, void(::clang::ast_matchers
::internal::TypeList<UnaryOperator, CXXOperatorCallExpr>
), internal::Matcher<Expr> > (&hasUnaryOperand_Type0
)(internal::Matcher<Expr> const &InnerMatcher); template
<typename NodeType, typename ParamT> bool internal:: matcher_hasUnaryOperand0Matcher
<NodeType, ParamT>::matches( const NodeType &Node, ::
clang::ast_matchers::internal::ASTMatchFinder *Finder, ::clang
::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
{
5660 const Expr *const Operand = internal::getSubExpr(Node);
5661 return (Operand != nullptr &&
5662 InnerMatcher.matches(*Operand, Finder, Builder));
5663}
5664
5665/// Matches if the cast's source expression
5666/// or opaque value's source expression matches the given matcher.
5667///
5668/// Example 1: matches "a string"
5669/// (matcher = castExpr(hasSourceExpression(cxxConstructExpr())))
5670/// \code
5671/// class URL { URL(string); };
5672/// URL url = "a string";
5673/// \endcode
5674///
5675/// Example 2: matches 'b' (matcher =
5676/// opaqueValueExpr(hasSourceExpression(implicitCastExpr(declRefExpr())))
5677/// \code
5678/// int a = b ?: 1;
5679/// \endcode
5680AST_POLYMORPHIC_MATCHER_P(hasSourceExpression,namespace internal { template <typename NodeType, typename
ParamT> class matcher_hasSourceExpression0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<NodeType
> { public: explicit matcher_hasSourceExpression0Matcher( internal
::Matcher<Expr> 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<Expr> InnerMatcher; }; } inline ::clang
::ast_matchers::internal::PolymorphicMatcher< internal::matcher_hasSourceExpression0Matcher
, void(::clang::ast_matchers::internal::TypeList<CastExpr,
OpaqueValueExpr>), internal::Matcher<Expr> > hasSourceExpression
(internal::Matcher<Expr> const &InnerMatcher) { return
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_hasSourceExpression0Matcher, void(::clang::ast_matchers
::internal::TypeList<CastExpr, OpaqueValueExpr>), internal
::Matcher<Expr> >(InnerMatcher); } typedef ::clang::
ast_matchers::internal::PolymorphicMatcher< internal::matcher_hasSourceExpression0Matcher
, void(::clang::ast_matchers::internal::TypeList<CastExpr,
OpaqueValueExpr>), internal::Matcher<Expr> > (&
hasSourceExpression_Type0)(internal::Matcher<Expr> const
&InnerMatcher); template <typename NodeType, typename
ParamT> bool internal:: matcher_hasSourceExpression0Matcher
<NodeType, ParamT>::matches( const NodeType &Node, ::
clang::ast_matchers::internal::ASTMatchFinder *Finder, ::clang
::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
5681 AST_POLYMORPHIC_SUPPORTED_TYPES(CastExpr,namespace internal { template <typename NodeType, typename
ParamT> class matcher_hasSourceExpression0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<NodeType
> { public: explicit matcher_hasSourceExpression0Matcher( internal
::Matcher<Expr> 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<Expr> InnerMatcher; }; } inline ::clang
::ast_matchers::internal::PolymorphicMatcher< internal::matcher_hasSourceExpression0Matcher
, void(::clang::ast_matchers::internal::TypeList<CastExpr,
OpaqueValueExpr>), internal::Matcher<Expr> > hasSourceExpression
(internal::Matcher<Expr> const &InnerMatcher) { return
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_hasSourceExpression0Matcher, void(::clang::ast_matchers
::internal::TypeList<CastExpr, OpaqueValueExpr>), internal
::Matcher<Expr> >(InnerMatcher); } typedef ::clang::
ast_matchers::internal::PolymorphicMatcher< internal::matcher_hasSourceExpression0Matcher
, void(::clang::ast_matchers::internal::TypeList<CastExpr,
OpaqueValueExpr>), internal::Matcher<Expr> > (&
hasSourceExpression_Type0)(internal::Matcher<Expr> const
&InnerMatcher); template <typename NodeType, typename
ParamT> bool internal:: matcher_hasSourceExpression0Matcher
<NodeType, ParamT>::matches( const NodeType &Node, ::
clang::ast_matchers::internal::ASTMatchFinder *Finder, ::clang
::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
5682 OpaqueValueExpr),namespace internal { template <typename NodeType, typename
ParamT> class matcher_hasSourceExpression0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<NodeType
> { public: explicit matcher_hasSourceExpression0Matcher( internal
::Matcher<Expr> 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<Expr> InnerMatcher; }; } inline ::clang
::ast_matchers::internal::PolymorphicMatcher< internal::matcher_hasSourceExpression0Matcher
, void(::clang::ast_matchers::internal::TypeList<CastExpr,
OpaqueValueExpr>), internal::Matcher<Expr> > hasSourceExpression
(internal::Matcher<Expr> const &InnerMatcher) { return
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_hasSourceExpression0Matcher, void(::clang::ast_matchers
::internal::TypeList<CastExpr, OpaqueValueExpr>), internal
::Matcher<Expr> >(InnerMatcher); } typedef ::clang::
ast_matchers::internal::PolymorphicMatcher< internal::matcher_hasSourceExpression0Matcher
, void(::clang::ast_matchers::internal::TypeList<CastExpr,
OpaqueValueExpr>), internal::Matcher<Expr> > (&
hasSourceExpression_Type0)(internal::Matcher<Expr> const
&InnerMatcher); template <typename NodeType, typename
ParamT> bool internal:: matcher_hasSourceExpression0Matcher
<NodeType, ParamT>::matches( const NodeType &Node, ::
clang::ast_matchers::internal::ASTMatchFinder *Finder, ::clang
::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
5683 internal::Matcher<Expr>, InnerMatcher)namespace internal { template <typename NodeType, typename
ParamT> class matcher_hasSourceExpression0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<NodeType
> { public: explicit matcher_hasSourceExpression0Matcher( internal
::Matcher<Expr> 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<Expr> InnerMatcher; }; } inline ::clang
::ast_matchers::internal::PolymorphicMatcher< internal::matcher_hasSourceExpression0Matcher
, void(::clang::ast_matchers::internal::TypeList<CastExpr,
OpaqueValueExpr>), internal::Matcher<Expr> > hasSourceExpression
(internal::Matcher<Expr> const &InnerMatcher) { return
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_hasSourceExpression0Matcher, void(::clang::ast_matchers
::internal::TypeList<CastExpr, OpaqueValueExpr>), internal
::Matcher<Expr> >(InnerMatcher); } typedef ::clang::
ast_matchers::internal::PolymorphicMatcher< internal::matcher_hasSourceExpression0Matcher
, void(::clang::ast_matchers::internal::TypeList<CastExpr,
OpaqueValueExpr>), internal::Matcher<Expr> > (&
hasSourceExpression_Type0)(internal::Matcher<Expr> const
&InnerMatcher); template <typename NodeType, typename
ParamT> bool internal:: matcher_hasSourceExpression0Matcher
<NodeType, ParamT>::matches( const NodeType &Node, ::
clang::ast_matchers::internal::ASTMatchFinder *Finder, ::clang
::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
{
5684 const Expr *const SubExpression =
5685 internal::GetSourceExpressionMatcher<NodeType>::get(Node);
5686 return (SubExpression != nullptr &&
5687 InnerMatcher.matches(*SubExpression, Finder, Builder));
5688}
5689
5690/// Matches casts that has a given cast kind.
5691///
5692/// Example: matches the implicit cast around \c 0
5693/// (matcher = castExpr(hasCastKind(CK_NullToPointer)))
5694/// \code
5695/// int *p = 0;
5696/// \endcode
5697///
5698/// If the matcher is use from clang-query, CastKind parameter
5699/// should be passed as a quoted string. e.g., hasCastKind("CK_NullToPointer").
5700AST_MATCHER_P(CastExpr, hasCastKind, CastKind, Kind)namespace internal { class matcher_hasCastKind0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<CastExpr
> { public: explicit matcher_hasCastKind0Matcher( CastKind
const &AKind) : Kind(AKind) {} bool matches(const CastExpr
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: CastKind Kind; }; } inline
::clang::ast_matchers::internal::Matcher<CastExpr> hasCastKind
( CastKind const &Kind) { return ::clang::ast_matchers::internal
::makeMatcher( new internal::matcher_hasCastKind0Matcher(Kind
)); } typedef ::clang::ast_matchers::internal::Matcher<CastExpr
> ( &hasCastKind_Type0)(CastKind const &Kind); inline
bool internal::matcher_hasCastKind0Matcher::matches( const CastExpr
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
5701 return Node.getCastKind() == Kind;
5702}
5703
5704/// Matches casts whose destination type matches a given matcher.
5705///
5706/// (Note: Clang's AST refers to other conversions as "casts" too, and calls
5707/// actual casts "explicit" casts.)
5708AST_MATCHER_P(ExplicitCastExpr, hasDestinationType,namespace internal { class matcher_hasDestinationType0Matcher
: public ::clang::ast_matchers::internal::MatcherInterface<
ExplicitCastExpr> { public: explicit matcher_hasDestinationType0Matcher
( internal::Matcher<QualType> const &AInnerMatcher)
: InnerMatcher(AInnerMatcher) {} bool matches(const ExplicitCastExpr
&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<ExplicitCastExpr> hasDestinationType( internal
::Matcher<QualType> const &InnerMatcher) { return ::
clang::ast_matchers::internal::makeMatcher( new internal::matcher_hasDestinationType0Matcher
(InnerMatcher)); } typedef ::clang::ast_matchers::internal::Matcher
<ExplicitCastExpr> ( &hasDestinationType_Type0)(internal
::Matcher<QualType> const &InnerMatcher); inline bool
internal::matcher_hasDestinationType0Matcher::matches( const
ExplicitCastExpr &Node, ::clang::ast_matchers::internal::
ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
5709 internal::Matcher<QualType>, InnerMatcher)namespace internal { class matcher_hasDestinationType0Matcher
: public ::clang::ast_matchers::internal::MatcherInterface<
ExplicitCastExpr> { public: explicit matcher_hasDestinationType0Matcher
( internal::Matcher<QualType> const &AInnerMatcher)
: InnerMatcher(AInnerMatcher) {} bool matches(const ExplicitCastExpr
&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<ExplicitCastExpr> hasDestinationType( internal
::Matcher<QualType> const &InnerMatcher) { return ::
clang::ast_matchers::internal::makeMatcher( new internal::matcher_hasDestinationType0Matcher
(InnerMatcher)); } typedef ::clang::ast_matchers::internal::Matcher
<ExplicitCastExpr> ( &hasDestinationType_Type0)(internal
::Matcher<QualType> const &InnerMatcher); inline bool
internal::matcher_hasDestinationType0Matcher::matches( const
ExplicitCastExpr &Node, ::clang::ast_matchers::internal::
ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
5710 const QualType NodeType = Node.getTypeAsWritten();
5711 return InnerMatcher.matches(NodeType, Finder, Builder);
5712}
5713
5714/// Matches implicit casts whose destination type matches a given
5715/// matcher.
5716///
5717/// FIXME: Unit test this matcher
5718AST_MATCHER_P(ImplicitCastExpr, hasImplicitDestinationType,namespace internal { class matcher_hasImplicitDestinationType0Matcher
: public ::clang::ast_matchers::internal::MatcherInterface<
ImplicitCastExpr> { public: explicit matcher_hasImplicitDestinationType0Matcher
( internal::Matcher<QualType> const &AInnerMatcher)
: InnerMatcher(AInnerMatcher) {} bool matches(const ImplicitCastExpr
&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<ImplicitCastExpr> hasImplicitDestinationType(
internal::Matcher<QualType> const &InnerMatcher) {
return ::clang::ast_matchers::internal::makeMatcher( new internal
::matcher_hasImplicitDestinationType0Matcher(InnerMatcher)); }
typedef ::clang::ast_matchers::internal::Matcher<ImplicitCastExpr
> ( &hasImplicitDestinationType_Type0)(internal::Matcher
<QualType> const &InnerMatcher); inline bool internal
::matcher_hasImplicitDestinationType0Matcher::matches( const ImplicitCastExpr
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
5719 internal::Matcher<QualType>, InnerMatcher)namespace internal { class matcher_hasImplicitDestinationType0Matcher
: public ::clang::ast_matchers::internal::MatcherInterface<
ImplicitCastExpr> { public: explicit matcher_hasImplicitDestinationType0Matcher
( internal::Matcher<QualType> const &AInnerMatcher)
: InnerMatcher(AInnerMatcher) {} bool matches(const ImplicitCastExpr
&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<ImplicitCastExpr> hasImplicitDestinationType(
internal::Matcher<QualType> const &InnerMatcher) {
return ::clang::ast_matchers::internal::makeMatcher( new internal
::matcher_hasImplicitDestinationType0Matcher(InnerMatcher)); }
typedef ::clang::ast_matchers::internal::Matcher<ImplicitCastExpr
> ( &hasImplicitDestinationType_Type0)(internal::Matcher
<QualType> const &InnerMatcher); inline bool internal
::matcher_hasImplicitDestinationType0Matcher::matches( const ImplicitCastExpr
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
5720 return InnerMatcher.matches(Node.getType(), Finder, Builder);
5721}
5722
5723/// Matches TagDecl object that are spelled with "struct."
5724///
5725/// Example matches S, but not C, U or E.
5726/// \code
5727/// struct S {};
5728/// class C {};
5729/// union U {};
5730/// enum E {};
5731/// \endcode
5732AST_MATCHER(TagDecl, isStruct)namespace internal { class matcher_isStructMatcher : public ::
clang::ast_matchers::internal::MatcherInterface<TagDecl>
{ public: explicit matcher_isStructMatcher() = default; bool
matches(const TagDecl &Node, ::clang::ast_matchers::internal
::ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; }; } inline ::clang::ast_matchers::
internal::Matcher<TagDecl> isStruct() { return ::clang::
ast_matchers::internal::makeMatcher( new internal::matcher_isStructMatcher
()); } inline bool internal::matcher_isStructMatcher::matches
( const TagDecl &Node, ::clang::ast_matchers::internal::ASTMatchFinder
*Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
5733 return Node.isStruct();
5734}
5735
5736/// Matches TagDecl object that are spelled with "union."
5737///
5738/// Example matches U, but not C, S or E.
5739/// \code
5740/// struct S {};
5741/// class C {};
5742/// union U {};
5743/// enum E {};
5744/// \endcode
5745AST_MATCHER(TagDecl, isUnion)namespace internal { class matcher_isUnionMatcher : public ::
clang::ast_matchers::internal::MatcherInterface<TagDecl>
{ public: explicit matcher_isUnionMatcher() = default; bool matches
(const TagDecl &Node, ::clang::ast_matchers::internal::ASTMatchFinder
*Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; }; } inline ::clang::ast_matchers::
internal::Matcher<TagDecl> isUnion() { return ::clang::
ast_matchers::internal::makeMatcher( new internal::matcher_isUnionMatcher
()); } inline bool internal::matcher_isUnionMatcher::matches(
const TagDecl &Node, ::clang::ast_matchers::internal::ASTMatchFinder
*Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
5746 return Node.isUnion();
5747}
5748
5749/// Matches TagDecl object that are spelled with "class."
5750///
5751/// Example matches C, but not S, U or E.
5752/// \code
5753/// struct S {};
5754/// class C {};
5755/// union U {};
5756/// enum E {};
5757/// \endcode
5758AST_MATCHER(TagDecl, isClass)namespace internal { class matcher_isClassMatcher : public ::
clang::ast_matchers::internal::MatcherInterface<TagDecl>
{ public: explicit matcher_isClassMatcher() = default; bool matches
(const TagDecl &Node, ::clang::ast_matchers::internal::ASTMatchFinder
*Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; }; } inline ::clang::ast_matchers::
internal::Matcher<TagDecl> isClass() { return ::clang::
ast_matchers::internal::makeMatcher( new internal::matcher_isClassMatcher
()); } inline bool internal::matcher_isClassMatcher::matches(
const TagDecl &Node, ::clang::ast_matchers::internal::ASTMatchFinder
*Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
5759 return Node.isClass();
5760}
5761
5762/// Matches TagDecl object that are spelled with "enum."
5763///
5764/// Example matches E, but not C, S or U.
5765/// \code
5766/// struct S {};
5767/// class C {};
5768/// union U {};
5769/// enum E {};
5770/// \endcode
5771AST_MATCHER(TagDecl, isEnum)namespace internal { class matcher_isEnumMatcher : public ::clang
::ast_matchers::internal::MatcherInterface<TagDecl> { public
: explicit matcher_isEnumMatcher() = default; bool matches(const
TagDecl &Node, ::clang::ast_matchers::internal::ASTMatchFinder
*Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; }; } inline ::clang::ast_matchers::
internal::Matcher<TagDecl> isEnum() { return ::clang::ast_matchers
::internal::makeMatcher( new internal::matcher_isEnumMatcher(
)); } inline bool internal::matcher_isEnumMatcher::matches( const
TagDecl &Node, ::clang::ast_matchers::internal::ASTMatchFinder
*Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
5772 return Node.isEnum();
5773}
5774
5775/// Matches the true branch expression of a conditional operator.
5776///
5777/// Example 1 (conditional ternary operator): matches a
5778/// \code
5779/// condition ? a : b
5780/// \endcode
5781///
5782/// Example 2 (conditional binary operator): matches opaqueValueExpr(condition)
5783/// \code
5784/// condition ?: b
5785/// \endcode
5786AST_MATCHER_P(AbstractConditionalOperator, hasTrueExpression,namespace internal { class matcher_hasTrueExpression0Matcher :
public ::clang::ast_matchers::internal::MatcherInterface<
AbstractConditionalOperator> { public: explicit matcher_hasTrueExpression0Matcher
( internal::Matcher<Expr> const &AInnerMatcher) : InnerMatcher
(AInnerMatcher) {} bool matches(const AbstractConditionalOperator
&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<AbstractConditionalOperator> hasTrueExpression
( internal::Matcher<Expr> const &InnerMatcher) { return
::clang::ast_matchers::internal::makeMatcher( new internal::
matcher_hasTrueExpression0Matcher(InnerMatcher)); } typedef ::
clang::ast_matchers::internal::Matcher<AbstractConditionalOperator
> ( &hasTrueExpression_Type0)(internal::Matcher<Expr
> const &InnerMatcher); inline bool internal::matcher_hasTrueExpression0Matcher
::matches( const AbstractConditionalOperator &Node, ::clang
::ast_matchers::internal::ASTMatchFinder *Finder, ::clang::ast_matchers
::internal::BoundNodesTreeBuilder *Builder) const
5787 internal::Matcher<Expr>, InnerMatcher)namespace internal { class matcher_hasTrueExpression0Matcher :
public ::clang::ast_matchers::internal::MatcherInterface<
AbstractConditionalOperator> { public: explicit matcher_hasTrueExpression0Matcher
( internal::Matcher<Expr> const &AInnerMatcher) : InnerMatcher
(AInnerMatcher) {} bool matches(const AbstractConditionalOperator
&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<AbstractConditionalOperator> hasTrueExpression
( internal::Matcher<Expr> const &InnerMatcher) { return
::clang::ast_matchers::internal::makeMatcher( new internal::
matcher_hasTrueExpression0Matcher(InnerMatcher)); } typedef ::
clang::ast_matchers::internal::Matcher<AbstractConditionalOperator
> ( &hasTrueExpression_Type0)(internal::Matcher<Expr
> const &InnerMatcher); inline bool internal::matcher_hasTrueExpression0Matcher
::matches( const AbstractConditionalOperator &Node, ::clang
::ast_matchers::internal::ASTMatchFinder *Finder, ::clang::ast_matchers
::internal::BoundNodesTreeBuilder *Builder) const
{
5788 const Expr *Expression = Node.getTrueExpr();
5789 return (Expression != nullptr &&
5790 InnerMatcher.matches(*Expression, Finder, Builder));
5791}
5792
5793/// Matches the false branch expression of a conditional operator
5794/// (binary or ternary).
5795///
5796/// Example matches b
5797/// \code
5798/// condition ? a : b
5799/// condition ?: b
5800/// \endcode
5801AST_MATCHER_P(AbstractConditionalOperator, hasFalseExpression,namespace internal { class matcher_hasFalseExpression0Matcher
: public ::clang::ast_matchers::internal::MatcherInterface<
AbstractConditionalOperator> { public: explicit matcher_hasFalseExpression0Matcher
( internal::Matcher<Expr> const &AInnerMatcher) : InnerMatcher
(AInnerMatcher) {} bool matches(const AbstractConditionalOperator
&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<AbstractConditionalOperator> hasFalseExpression
( internal::Matcher<Expr> const &InnerMatcher) { return
::clang::ast_matchers::internal::makeMatcher( new internal::
matcher_hasFalseExpression0Matcher(InnerMatcher)); } typedef ::
clang::ast_matchers::internal::Matcher<AbstractConditionalOperator
> ( &hasFalseExpression_Type0)(internal::Matcher<Expr
> const &InnerMatcher); inline bool internal::matcher_hasFalseExpression0Matcher
::matches( const AbstractConditionalOperator &Node, ::clang
::ast_matchers::internal::ASTMatchFinder *Finder, ::clang::ast_matchers
::internal::BoundNodesTreeBuilder *Builder) const
5802 internal::Matcher<Expr>, InnerMatcher)namespace internal { class matcher_hasFalseExpression0Matcher
: public ::clang::ast_matchers::internal::MatcherInterface<
AbstractConditionalOperator> { public: explicit matcher_hasFalseExpression0Matcher
( internal::Matcher<Expr> const &AInnerMatcher) : InnerMatcher
(AInnerMatcher) {} bool matches(const AbstractConditionalOperator
&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<AbstractConditionalOperator> hasFalseExpression
( internal::Matcher<Expr> const &InnerMatcher) { return
::clang::ast_matchers::internal::makeMatcher( new internal::
matcher_hasFalseExpression0Matcher(InnerMatcher)); } typedef ::
clang::ast_matchers::internal::Matcher<AbstractConditionalOperator
> ( &hasFalseExpression_Type0)(internal::Matcher<Expr
> const &InnerMatcher); inline bool internal::matcher_hasFalseExpression0Matcher
::matches( const AbstractConditionalOperator &Node, ::clang
::ast_matchers::internal::ASTMatchFinder *Finder, ::clang::ast_matchers
::internal::BoundNodesTreeBuilder *Builder) const
{
5803 const Expr *Expression = Node.getFalseExpr();
5804 return (Expression != nullptr &&
5805 InnerMatcher.matches(*Expression, Finder, Builder));
5806}
5807
5808/// Matches if a declaration has a body attached.
5809///
5810/// Example matches A, va, fa
5811/// \code
5812/// class A {};
5813/// class B; // Doesn't match, as it has no body.
5814/// int va;
5815/// extern int vb; // Doesn't match, as it doesn't define the variable.
5816/// void fa() {}
5817/// void fb(); // Doesn't match, as it has no body.
5818/// @interface X
5819/// - (void)ma; // Doesn't match, interface is declaration.
5820/// @end
5821/// @implementation X
5822/// - (void)ma {}
5823/// @end
5824/// \endcode
5825///
5826/// Usable as: Matcher<TagDecl>, Matcher<VarDecl>, Matcher<FunctionDecl>,
5827/// Matcher<ObjCMethodDecl>
5828AST_POLYMORPHIC_MATCHER(isDefinition,namespace internal { template <typename NodeType> class
matcher_isDefinitionMatcher : 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_isDefinitionMatcher
, void(::clang::ast_matchers::internal::TypeList<TagDecl, VarDecl
, ObjCMethodDecl, FunctionDecl>)> isDefinition() { return
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_isDefinitionMatcher, void(::clang::ast_matchers::internal
::TypeList<TagDecl, VarDecl, ObjCMethodDecl, FunctionDecl>
)>(); } template <typename NodeType> bool internal::
matcher_isDefinitionMatcher<NodeType>::matches( const NodeType
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
5829 AST_POLYMORPHIC_SUPPORTED_TYPES(TagDecl, VarDecl,namespace internal { template <typename NodeType> class
matcher_isDefinitionMatcher : 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_isDefinitionMatcher
, void(::clang::ast_matchers::internal::TypeList<TagDecl, VarDecl
, ObjCMethodDecl, FunctionDecl>)> isDefinition() { return
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_isDefinitionMatcher, void(::clang::ast_matchers::internal
::TypeList<TagDecl, VarDecl, ObjCMethodDecl, FunctionDecl>
)>(); } template <typename NodeType> bool internal::
matcher_isDefinitionMatcher<NodeType>::matches( const NodeType
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
5830 ObjCMethodDecl,namespace internal { template <typename NodeType> class
matcher_isDefinitionMatcher : 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_isDefinitionMatcher
, void(::clang::ast_matchers::internal::TypeList<TagDecl, VarDecl
, ObjCMethodDecl, FunctionDecl>)> isDefinition() { return
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_isDefinitionMatcher, void(::clang::ast_matchers::internal
::TypeList<TagDecl, VarDecl, ObjCMethodDecl, FunctionDecl>
)>(); } template <typename NodeType> bool internal::
matcher_isDefinitionMatcher<NodeType>::matches( const NodeType
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
5831 FunctionDecl))namespace internal { template <typename NodeType> class
matcher_isDefinitionMatcher : 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_isDefinitionMatcher
, void(::clang::ast_matchers::internal::TypeList<TagDecl, VarDecl
, ObjCMethodDecl, FunctionDecl>)> isDefinition() { return
::clang::ast_matchers::internal::PolymorphicMatcher< internal
::matcher_isDefinitionMatcher, void(::clang::ast_matchers::internal
::TypeList<TagDecl, VarDecl, ObjCMethodDecl, FunctionDecl>
)>(); } template <typename NodeType> bool internal::
matcher_isDefinitionMatcher<NodeType>::matches( const NodeType
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
5832 return Node.isThisDeclarationADefinition();
5833}
5834
5835/// Matches if a function declaration is variadic.
5836///
5837/// Example matches f, but not g or h. The function i will not match, even when
5838/// compiled in C mode.
5839/// \code
5840/// void f(...);
5841/// void g(int);
5842/// template <typename... Ts> void h(Ts...);
5843/// void i();
5844/// \endcode
5845AST_MATCHER(FunctionDecl, isVariadic)namespace internal { class matcher_isVariadicMatcher : public
::clang::ast_matchers::internal::MatcherInterface<FunctionDecl
> { public: explicit matcher_isVariadicMatcher() = 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>
isVariadic() { return ::clang::ast_matchers::internal::makeMatcher
( new internal::matcher_isVariadicMatcher()); } inline bool internal
::matcher_isVariadicMatcher::matches( const FunctionDecl &
Node, ::clang::ast_matchers::internal::ASTMatchFinder *Finder
, ::clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder
) const
{
5846 return Node.isVariadic();
5847}
5848
5849/// Matches the class declaration that the given method declaration
5850/// belongs to.
5851///
5852/// FIXME: Generalize this for other kinds of declarations.
5853/// FIXME: What other kind of declarations would we need to generalize
5854/// this to?
5855///
5856/// Example matches A() in the last line
5857/// (matcher = cxxConstructExpr(hasDeclaration(cxxMethodDecl(
5858/// ofClass(hasName("A"))))))
5859/// \code
5860/// class A {
5861/// public:
5862/// A();
5863/// };
5864/// A a = A();
5865/// \endcode
5866AST_MATCHER_P(CXXMethodDecl, ofClass,namespace internal { class matcher_ofClass0Matcher : public ::
clang::ast_matchers::internal::MatcherInterface<CXXMethodDecl
> { public: explicit matcher_ofClass0Matcher( internal::Matcher
<CXXRecordDecl> const &AInnerMatcher) : InnerMatcher
(AInnerMatcher) {} bool matches(const CXXMethodDecl &Node
, ::clang::ast_matchers::internal::ASTMatchFinder *Finder, ::
clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder
) const override; private: internal::Matcher<CXXRecordDecl
> InnerMatcher; }; } inline ::clang::ast_matchers::internal
::Matcher<CXXMethodDecl> ofClass( internal::Matcher<
CXXRecordDecl> const &InnerMatcher) { return ::clang::
ast_matchers::internal::makeMatcher( new internal::matcher_ofClass0Matcher
(InnerMatcher)); } typedef ::clang::ast_matchers::internal::Matcher
<CXXMethodDecl> ( &ofClass_Type0)(internal::Matcher
<CXXRecordDecl> const &InnerMatcher); inline bool internal
::matcher_ofClass0Matcher::matches( const CXXMethodDecl &
Node, ::clang::ast_matchers::internal::ASTMatchFinder *Finder
, ::clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder
) const
5867 internal::Matcher<CXXRecordDecl>, InnerMatcher)namespace internal { class matcher_ofClass0Matcher : public ::
clang::ast_matchers::internal::MatcherInterface<CXXMethodDecl
> { public: explicit matcher_ofClass0Matcher( internal::Matcher
<CXXRecordDecl> const &AInnerMatcher) : InnerMatcher
(AInnerMatcher) {} bool matches(const CXXMethodDecl &Node
, ::clang::ast_matchers::internal::ASTMatchFinder *Finder, ::
clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder
) const override; private: internal::Matcher<CXXRecordDecl
> InnerMatcher; }; } inline ::clang::ast_matchers::internal
::Matcher<CXXMethodDecl> ofClass( internal::Matcher<
CXXRecordDecl> const &InnerMatcher) { return ::clang::
ast_matchers::internal::makeMatcher( new internal::matcher_ofClass0Matcher
(InnerMatcher)); } typedef ::clang::ast_matchers::internal::Matcher
<CXXMethodDecl> ( &ofClass_Type0)(internal::Matcher
<CXXRecordDecl> const &InnerMatcher); inline bool internal
::matcher_ofClass0Matcher::matches( const CXXMethodDecl &
Node, ::clang::ast_matchers::internal::ASTMatchFinder *Finder
, ::clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder
) const
{
5868
5869 ASTChildrenNotSpelledInSourceScope RAII(Finder, false);
5870
5871 const CXXRecordDecl *Parent = Node.getParent();
5872 return (Parent != nullptr &&
5873 InnerMatcher.matches(*Parent, Finder, Builder));
5874}
5875
5876/// Matches each method overridden by the given method. This matcher may
5877/// produce multiple matches.
5878///
5879/// Given
5880/// \code
5881/// class A { virtual void f(); };
5882/// class B : public A { void f(); };
5883/// class C : public B { void f(); };
5884/// \endcode
5885/// cxxMethodDecl(ofClass(hasName("C")),
5886/// forEachOverridden(cxxMethodDecl().bind("b"))).bind("d")
5887/// matches once, with "b" binding "A::f" and "d" binding "C::f" (Note
5888/// that B::f is not overridden by C::f).
5889///
5890/// The check can produce multiple matches in case of multiple inheritance, e.g.
5891/// \code
5892/// class A1 { virtual void f(); };
5893/// class A2 { virtual void f(); };
5894/// class C : public A1, public A2 { void f(); };
5895/// \endcode
5896/// cxxMethodDecl(ofClass(hasName("C")),
5897/// forEachOverridden(cxxMethodDecl().bind("b"))).bind("d")
5898/// matches twice, once with "b" binding "A1::f" and "d" binding "C::f", and
5899/// once with "b" binding "A2::f" and "d" binding "C::f".
5900AST_MATCHER_P(CXXMethodDecl, forEachOverridden,namespace internal { class matcher_forEachOverridden0Matcher :
public ::clang::ast_matchers::internal::MatcherInterface<
CXXMethodDecl> { public: explicit matcher_forEachOverridden0Matcher
( internal::Matcher<CXXMethodDecl> const &AInnerMatcher
) : InnerMatcher(AInnerMatcher) {} bool matches(const CXXMethodDecl
&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<CXXMethodDecl> forEachOverridden( internal::Matcher
<CXXMethodDecl> const &InnerMatcher) { return ::clang
::ast_matchers::internal::makeMatcher( new internal::matcher_forEachOverridden0Matcher
(InnerMatcher)); } typedef ::clang::ast_matchers::internal::Matcher
<CXXMethodDecl> ( &forEachOverridden_Type0)(internal
::Matcher<CXXMethodDecl> const &InnerMatcher); inline
bool internal::matcher_forEachOverridden0Matcher::matches( const
CXXMethodDecl &Node, ::clang::ast_matchers::internal::ASTMatchFinder
*Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
5901 internal::Matcher<CXXMethodDecl>, InnerMatcher)namespace internal { class matcher_forEachOverridden0Matcher :
public ::clang::ast_matchers::internal::MatcherInterface<
CXXMethodDecl> { public: explicit matcher_forEachOverridden0Matcher
( internal::Matcher<CXXMethodDecl> const &AInnerMatcher
) : InnerMatcher(AInnerMatcher) {} bool matches(const CXXMethodDecl
&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<CXXMethodDecl> forEachOverridden( internal::Matcher
<CXXMethodDecl> const &InnerMatcher) { return ::clang
::ast_matchers::internal::makeMatcher( new internal::matcher_forEachOverridden0Matcher
(InnerMatcher)); } typedef ::clang::ast_matchers::internal::Matcher
<CXXMethodDecl> ( &forEachOverridden_Type0)(internal
::Matcher<CXXMethodDecl> const &InnerMatcher); inline
bool internal::matcher_forEachOverridden0Matcher::matches( const
CXXMethodDecl &Node, ::clang::ast_matchers::internal::ASTMatchFinder
*Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
5902 BoundNodesTreeBuilder Result;
5903 bool Matched = false;
5904 for (const auto *Overridden : Node.overridden_methods()) {
5905 BoundNodesTreeBuilder OverriddenBuilder(*Builder);
5906 const bool OverriddenMatched =
5907 InnerMatcher.matches(*Overridden, Finder, &OverriddenBuilder);
5908 if (OverriddenMatched) {
5909 Matched = true;
5910 Result.addMatch(OverriddenBuilder);
5911 }
5912 }
5913 *Builder = std::move(Result);
5914 return Matched;
5915}
5916
5917/// Matches declarations of virtual methods and C++ base specifers that specify
5918/// virtual inheritance.
5919///
5920/// Example:
5921/// \code
5922/// class A {
5923/// public:
5924/// virtual void x(); // matches x
5925/// };
5926/// \endcode
5927///
5928/// Example:
5929/// \code
5930/// class Base {};
5931/// class DirectlyDerived : virtual Base {}; // matches Base
5932/// class IndirectlyDerived : DirectlyDerived, Base {}; // matches Base
5933/// \endcode
5934///
5935/// Usable as: Matcher<CXXMethodDecl>, Matcher<CXXBaseSpecifier>
5936AST_POLYMORPHIC_MATCHER(isVirtual,namespace internal { template <typename NodeType> class
matcher_isVirtualMatcher : 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_isVirtualMatcher
, void(::clang::ast_matchers::internal::TypeList<CXXMethodDecl
, CXXBaseSpecifier>)> isVirtual() { return ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_isVirtualMatcher
, void(::clang::ast_matchers::internal::TypeList<CXXMethodDecl
, CXXBaseSpecifier>)>(); } template <typename NodeType
> bool internal::matcher_isVirtualMatcher<NodeType>::
matches( const NodeType &Node, ::clang::ast_matchers::internal
::ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
5937 AST_POLYMORPHIC_SUPPORTED_TYPES(CXXMethodDecl,namespace internal { template <typename NodeType> class
matcher_isVirtualMatcher : 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_isVirtualMatcher
, void(::clang::ast_matchers::internal::TypeList<CXXMethodDecl
, CXXBaseSpecifier>)> isVirtual() { return ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_isVirtualMatcher
, void(::clang::ast_matchers::internal::TypeList<CXXMethodDecl
, CXXBaseSpecifier>)>(); } template <typename NodeType
> bool internal::matcher_isVirtualMatcher<NodeType>::
matches( const NodeType &Node, ::clang::ast_matchers::internal
::ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
5938 CXXBaseSpecifier))namespace internal { template <typename NodeType> class
matcher_isVirtualMatcher : 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_isVirtualMatcher
, void(::clang::ast_matchers::internal::TypeList<CXXMethodDecl
, CXXBaseSpecifier>)> isVirtual() { return ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_isVirtualMatcher
, void(::clang::ast_matchers::internal::TypeList<CXXMethodDecl
, CXXBaseSpecifier>)>(); } template <typename NodeType
> bool internal::matcher_isVirtualMatcher<NodeType>::
matches( const NodeType &Node, ::clang::ast_matchers::internal
::ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
5939 return Node.isVirtual();
5940}
5941
5942/// Matches if the given method declaration has an explicit "virtual".
5943///
5944/// Given
5945/// \code
5946/// class A {
5947/// public:
5948/// virtual void x();
5949/// };
5950/// class B : public A {
5951/// public:
5952/// void x();
5953/// };
5954/// \endcode
5955/// matches A::x but not B::x
5956AST_MATCHER(CXXMethodDecl, isVirtualAsWritten)namespace internal { class matcher_isVirtualAsWrittenMatcher :
public ::clang::ast_matchers::internal::MatcherInterface<
CXXMethodDecl> { public: explicit matcher_isVirtualAsWrittenMatcher
() = default; bool matches(const CXXMethodDecl &Node, ::clang
::ast_matchers::internal::ASTMatchFinder *Finder, ::clang::ast_matchers
::internal::BoundNodesTreeBuilder *Builder) const override; }
; } inline ::clang::ast_matchers::internal::Matcher<CXXMethodDecl
> isVirtualAsWritten() { return ::clang::ast_matchers::internal
::makeMatcher( new internal::matcher_isVirtualAsWrittenMatcher
()); } inline bool internal::matcher_isVirtualAsWrittenMatcher
::matches( const CXXMethodDecl &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
{
5957 return Node.isVirtualAsWritten();
5958}
5959
5960AST_MATCHER(CXXConstructorDecl, isInheritingConstructor)namespace internal { class matcher_isInheritingConstructorMatcher
: public ::clang::ast_matchers::internal::MatcherInterface<
CXXConstructorDecl> { public: explicit matcher_isInheritingConstructorMatcher
() = default; bool matches(const CXXConstructorDecl &Node
, ::clang::ast_matchers::internal::ASTMatchFinder *Finder, ::
clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder
) const override; }; } inline ::clang::ast_matchers::internal
::Matcher<CXXConstructorDecl> isInheritingConstructor()
{ return ::clang::ast_matchers::internal::makeMatcher( new internal
::matcher_isInheritingConstructorMatcher()); } inline bool internal
::matcher_isInheritingConstructorMatcher::matches( const CXXConstructorDecl
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
5961 return Node.isInheritingConstructor();
5962}
5963
5964/// Matches if the given method or class declaration is final.
5965///
5966/// Given:
5967/// \code
5968/// class A final {};
5969///
5970/// struct B {
5971/// virtual void f();
5972/// };
5973///
5974/// struct C : B {
5975/// void f() final;
5976/// };
5977/// \endcode
5978/// matches A and C::f, but not B, C, or B::f
5979AST_POLYMORPHIC_MATCHER(isFinal,namespace internal { template <typename NodeType> class
matcher_isFinalMatcher : 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_isFinalMatcher
, void(::clang::ast_matchers::internal::TypeList<CXXRecordDecl
, CXXMethodDecl>)> isFinal() { return ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_isFinalMatcher
, void(::clang::ast_matchers::internal::TypeList<CXXRecordDecl
, CXXMethodDecl>)>(); } template <typename NodeType>
bool internal::matcher_isFinalMatcher<NodeType>::matches
( const NodeType &Node, ::clang::ast_matchers::internal::
ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
5980 AST_POLYMORPHIC_SUPPORTED_TYPES(CXXRecordDecl,namespace internal { template <typename NodeType> class
matcher_isFinalMatcher : 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_isFinalMatcher
, void(::clang::ast_matchers::internal::TypeList<CXXRecordDecl
, CXXMethodDecl>)> isFinal() { return ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_isFinalMatcher
, void(::clang::ast_matchers::internal::TypeList<CXXRecordDecl
, CXXMethodDecl>)>(); } template <typename NodeType>
bool internal::matcher_isFinalMatcher<NodeType>::matches
( const NodeType &Node, ::clang::ast_matchers::internal::
ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
5981 CXXMethodDecl))namespace internal { template <typename NodeType> class
matcher_isFinalMatcher : 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_isFinalMatcher
, void(::clang::ast_matchers::internal::TypeList<CXXRecordDecl
, CXXMethodDecl>)> isFinal() { return ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_isFinalMatcher
, void(::clang::ast_matchers::internal::TypeList<CXXRecordDecl
, CXXMethodDecl>)>(); } template <typename NodeType>
bool internal::matcher_isFinalMatcher<NodeType>::matches
( const NodeType &Node, ::clang::ast_matchers::internal::
ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
5982 return Node.template hasAttr<FinalAttr>();
5983}
5984
5985/// Matches if the given method declaration is pure.
5986///
5987/// Given
5988/// \code
5989/// class A {
5990/// public:
5991/// virtual void x() = 0;
5992/// };
5993/// \endcode
5994/// matches A::x
5995AST_MATCHER(CXXMethodDecl, isPure)namespace internal { class matcher_isPureMatcher : public ::clang
::ast_matchers::internal::MatcherInterface<CXXMethodDecl>
{ public: explicit matcher_isPureMatcher() = default; bool matches
(const CXXMethodDecl &Node, ::clang::ast_matchers::internal
::ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; }; } inline ::clang::ast_matchers::
internal::Matcher<CXXMethodDecl> isPure() { return ::clang
::ast_matchers::internal::makeMatcher( new internal::matcher_isPureMatcher
()); } inline bool internal::matcher_isPureMatcher::matches( const
CXXMethodDecl &Node, ::clang::ast_matchers::internal::ASTMatchFinder
*Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
5996 return Node.isPure();
5997}
5998
5999/// Matches if the given method declaration is const.
6000///
6001/// Given
6002/// \code
6003/// struct A {
6004/// void foo() const;
6005/// void bar();
6006/// };
6007/// \endcode
6008///
6009/// cxxMethodDecl(isConst()) matches A::foo() but not A::bar()
6010AST_MATCHER(CXXMethodDecl, isConst)namespace internal { class matcher_isConstMatcher : public ::
clang::ast_matchers::internal::MatcherInterface<CXXMethodDecl
> { public: explicit matcher_isConstMatcher() = default; bool
matches(const CXXMethodDecl &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const override; }; } inline
::clang::ast_matchers::internal::Matcher<CXXMethodDecl>
isConst() { return ::clang::ast_matchers::internal::makeMatcher
( new internal::matcher_isConstMatcher()); } inline bool internal
::matcher_isConstMatcher::matches( const CXXMethodDecl &Node
, ::clang::ast_matchers::internal::ASTMatchFinder *Finder, ::
clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder
) const
{
6011 return Node.isConst();
6012}
6013
6014/// Matches if the given method declaration declares a copy assignment
6015/// operator.
6016///
6017/// Given
6018/// \code
6019/// struct A {
6020/// A &operator=(const A &);
6021/// A &operator=(A &&);
6022/// };
6023/// \endcode
6024///
6025/// cxxMethodDecl(isCopyAssignmentOperator()) matches the first method but not
6026/// the second one.
6027AST_MATCHER(CXXMethodDecl, isCopyAssignmentOperator)namespace internal { class matcher_isCopyAssignmentOperatorMatcher
: public ::clang::ast_matchers::internal::MatcherInterface<
CXXMethodDecl> { public: explicit matcher_isCopyAssignmentOperatorMatcher
() = default; bool matches(const CXXMethodDecl &Node, ::clang
::ast_matchers::internal::ASTMatchFinder *Finder, ::clang::ast_matchers
::internal::BoundNodesTreeBuilder *Builder) const override; }
; } inline ::clang::ast_matchers::internal::Matcher<CXXMethodDecl
> isCopyAssignmentOperator() { return ::clang::ast_matchers
::internal::makeMatcher( new internal::matcher_isCopyAssignmentOperatorMatcher
()); } inline bool internal::matcher_isCopyAssignmentOperatorMatcher
::matches( const CXXMethodDecl &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
{
6028 return Node.isCopyAssignmentOperator();
6029}
6030
6031/// Matches if the given method declaration declares a move assignment
6032/// operator.
6033///
6034/// Given
6035/// \code
6036/// struct A {
6037/// A &operator=(const A &);
6038/// A &operator=(A &&);
6039/// };
6040/// \endcode
6041///
6042/// cxxMethodDecl(isMoveAssignmentOperator()) matches the second method but not
6043/// the first one.
6044AST_MATCHER(CXXMethodDecl, isMoveAssignmentOperator)namespace internal { class matcher_isMoveAssignmentOperatorMatcher
: public ::clang::ast_matchers::internal::MatcherInterface<
CXXMethodDecl> { public: explicit matcher_isMoveAssignmentOperatorMatcher
() = default; bool matches(const CXXMethodDecl &Node, ::clang
::ast_matchers::internal::ASTMatchFinder *Finder, ::clang::ast_matchers
::internal::BoundNodesTreeBuilder *Builder) const override; }
; } inline ::clang::ast_matchers::internal::Matcher<CXXMethodDecl
> isMoveAssignmentOperator() { return ::clang::ast_matchers
::internal::makeMatcher( new internal::matcher_isMoveAssignmentOperatorMatcher
()); } inline bool internal::matcher_isMoveAssignmentOperatorMatcher
::matches( const CXXMethodDecl &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
{
6045 return Node.isMoveAssignmentOperator();
6046}
6047
6048/// Matches if the given method declaration overrides another method.
6049///
6050/// Given
6051/// \code
6052/// class A {
6053/// public:
6054/// virtual void x();
6055/// };
6056/// class B : public A {
6057/// public:
6058/// virtual void x();
6059/// };
6060/// \endcode
6061/// matches B::x
6062AST_MATCHER(CXXMethodDecl, isOverride)namespace internal { class matcher_isOverrideMatcher : public
::clang::ast_matchers::internal::MatcherInterface<CXXMethodDecl
> { public: explicit matcher_isOverrideMatcher() = default
; bool matches(const CXXMethodDecl &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const override; }; } inline
::clang::ast_matchers::internal::Matcher<CXXMethodDecl>
isOverride() { return ::clang::ast_matchers::internal::makeMatcher
( new internal::matcher_isOverrideMatcher()); } inline bool internal
::matcher_isOverrideMatcher::matches( const CXXMethodDecl &
Node, ::clang::ast_matchers::internal::ASTMatchFinder *Finder
, ::clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder
) const
{
6063 return Node.size_overridden_methods() > 0 || Node.hasAttr<OverrideAttr>();
6064}
6065
6066/// Matches method declarations that are user-provided.
6067///
6068/// Given
6069/// \code
6070/// struct S {
6071/// S(); // #1
6072/// S(const S &) = default; // #2
6073/// S(S &&) = delete; // #3
6074/// };
6075/// \endcode
6076/// cxxConstructorDecl(isUserProvided()) will match #1, but not #2 or #3.
6077AST_MATCHER(CXXMethodDecl, isUserProvided)namespace internal { class matcher_isUserProvidedMatcher : public
::clang::ast_matchers::internal::MatcherInterface<CXXMethodDecl
> { public: explicit matcher_isUserProvidedMatcher() = default
; bool matches(const CXXMethodDecl &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const override; }; } inline
::clang::ast_matchers::internal::Matcher<CXXMethodDecl>
isUserProvided() { return ::clang::ast_matchers::internal::makeMatcher
( new internal::matcher_isUserProvidedMatcher()); } inline bool
internal::matcher_isUserProvidedMatcher::matches( const CXXMethodDecl
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
6078 return Node.isUserProvided();
6079}
6080
6081/// Matches member expressions that are called with '->' as opposed
6082/// to '.'.
6083///
6084/// Member calls on the implicit this pointer match as called with '->'.
6085///
6086/// Given
6087/// \code
6088/// class Y {
6089/// void x() { this->x(); x(); Y y; y.x(); a; this->b; Y::b; }
6090/// template <class T> void f() { this->f<T>(); f<T>(); }
6091/// int a;
6092/// static int b;
6093/// };
6094/// template <class T>
6095/// class Z {
6096/// void x() { this->m; }
6097/// };
6098/// \endcode
6099/// memberExpr(isArrow())
6100/// matches this->x, x, y.x, a, this->b
6101/// cxxDependentScopeMemberExpr(isArrow())
6102/// matches this->m
6103/// unresolvedMemberExpr(isArrow())
6104/// matches this->f<T>, f<T>
6105AST_POLYMORPHIC_MATCHER(namespace internal { template <typename NodeType> class
matcher_isArrowMatcher : 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_isArrowMatcher
, void(::clang::ast_matchers::internal::TypeList<MemberExpr
, UnresolvedMemberExpr, CXXDependentScopeMemberExpr>)> isArrow
() { return ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_isArrowMatcher, void(::clang::ast_matchers
::internal::TypeList<MemberExpr, UnresolvedMemberExpr, CXXDependentScopeMemberExpr
>)>(); } template <typename NodeType> bool internal
::matcher_isArrowMatcher<NodeType>::matches( const NodeType
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
6106 isArrow, AST_POLYMORPHIC_SUPPORTED_TYPES(MemberExpr, UnresolvedMemberExpr,namespace internal { template <typename NodeType> class
matcher_isArrowMatcher : 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_isArrowMatcher
, void(::clang::ast_matchers::internal::TypeList<MemberExpr
, UnresolvedMemberExpr, CXXDependentScopeMemberExpr>)> isArrow
() { return ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_isArrowMatcher, void(::clang::ast_matchers
::internal::TypeList<MemberExpr, UnresolvedMemberExpr, CXXDependentScopeMemberExpr
>)>(); } template <typename NodeType> bool internal
::matcher_isArrowMatcher<NodeType>::matches( const NodeType
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
6107 CXXDependentScopeMemberExpr))namespace internal { template <typename NodeType> class
matcher_isArrowMatcher : 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_isArrowMatcher
, void(::clang::ast_matchers::internal::TypeList<MemberExpr
, UnresolvedMemberExpr, CXXDependentScopeMemberExpr>)> isArrow
() { return ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_isArrowMatcher, void(::clang::ast_matchers
::internal::TypeList<MemberExpr, UnresolvedMemberExpr, CXXDependentScopeMemberExpr
>)>(); } template <typename NodeType> bool internal
::matcher_isArrowMatcher<NodeType>::matches( const NodeType
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
6108 return Node.isArrow();
6109}
6110
6111/// Matches QualType nodes that are of integer type.
6112///
6113/// Given
6114/// \code
6115/// void a(int);
6116/// void b(long);
6117/// void c(double);
6118/// \endcode
6119/// functionDecl(hasAnyParameter(hasType(isInteger())))
6120/// matches "a(int)", "b(long)", but not "c(double)".
6121AST_MATCHER(QualType, isInteger)namespace internal { class matcher_isIntegerMatcher : public ::
clang::ast_matchers::internal::MatcherInterface<QualType>
{ public: explicit matcher_isIntegerMatcher() = default; bool
matches(const QualType &Node, ::clang::ast_matchers::internal
::ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; }; } inline ::clang::ast_matchers::
internal::Matcher<QualType> isInteger() { return ::clang
::ast_matchers::internal::makeMatcher( new internal::matcher_isIntegerMatcher
()); } inline bool internal::matcher_isIntegerMatcher::matches
( const QualType &Node, ::clang::ast_matchers::internal::
ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
6122 return Node->isIntegerType();
6123}
6124
6125/// Matches QualType nodes that are of unsigned integer type.
6126///
6127/// Given
6128/// \code
6129/// void a(int);
6130/// void b(unsigned long);
6131/// void c(double);
6132/// \endcode
6133/// functionDecl(hasAnyParameter(hasType(isUnsignedInteger())))
6134/// matches "b(unsigned long)", but not "a(int)" and "c(double)".
6135AST_MATCHER(QualType, isUnsignedInteger)namespace internal { class matcher_isUnsignedIntegerMatcher :
public ::clang::ast_matchers::internal::MatcherInterface<
QualType> { public: explicit matcher_isUnsignedIntegerMatcher
() = default; bool matches(const QualType &Node, ::clang::
ast_matchers::internal::ASTMatchFinder *Finder, ::clang::ast_matchers
::internal::BoundNodesTreeBuilder *Builder) const override; }
; } inline ::clang::ast_matchers::internal::Matcher<QualType
> isUnsignedInteger() { return ::clang::ast_matchers::internal
::makeMatcher( new internal::matcher_isUnsignedIntegerMatcher
()); } inline bool internal::matcher_isUnsignedIntegerMatcher
::matches( const QualType &Node, ::clang::ast_matchers::internal
::ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
6136 return Node->isUnsignedIntegerType();
6137}
6138
6139/// Matches QualType nodes that are of signed integer type.
6140///
6141/// Given
6142/// \code
6143/// void a(int);
6144/// void b(unsigned long);
6145/// void c(double);
6146/// \endcode
6147/// functionDecl(hasAnyParameter(hasType(isSignedInteger())))
6148/// matches "a(int)", but not "b(unsigned long)" and "c(double)".
6149AST_MATCHER(QualType, isSignedInteger)namespace internal { class matcher_isSignedIntegerMatcher : public
::clang::ast_matchers::internal::MatcherInterface<QualType
> { public: explicit matcher_isSignedIntegerMatcher() = default
; bool matches(const QualType &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const override; }; } inline
::clang::ast_matchers::internal::Matcher<QualType> isSignedInteger
() { return ::clang::ast_matchers::internal::makeMatcher( new
internal::matcher_isSignedIntegerMatcher()); } inline bool internal
::matcher_isSignedIntegerMatcher::matches( const QualType &
Node, ::clang::ast_matchers::internal::ASTMatchFinder *Finder
, ::clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder
) const
{
6150 return Node->isSignedIntegerType();
6151}
6152
6153/// Matches QualType nodes that are of character type.
6154///
6155/// Given
6156/// \code
6157/// void a(char);
6158/// void b(wchar_t);
6159/// void c(double);
6160/// \endcode
6161/// functionDecl(hasAnyParameter(hasType(isAnyCharacter())))
6162/// matches "a(char)", "b(wchar_t)", but not "c(double)".
6163AST_MATCHER(QualType, isAnyCharacter)namespace internal { class matcher_isAnyCharacterMatcher : public
::clang::ast_matchers::internal::MatcherInterface<QualType
> { public: explicit matcher_isAnyCharacterMatcher() = default
; bool matches(const QualType &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const override; }; } inline
::clang::ast_matchers::internal::Matcher<QualType> isAnyCharacter
() { return ::clang::ast_matchers::internal::makeMatcher( new
internal::matcher_isAnyCharacterMatcher()); } inline bool internal
::matcher_isAnyCharacterMatcher::matches( const QualType &
Node, ::clang::ast_matchers::internal::ASTMatchFinder *Finder
, ::clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder
) const
{
6164 return Node->isAnyCharacterType();
6165}
6166
6167/// Matches QualType nodes that are of any pointer type; this includes
6168/// the Objective-C object pointer type, which is different despite being
6169/// syntactically similar.
6170///
6171/// Given
6172/// \code
6173/// int *i = nullptr;
6174///
6175/// @interface Foo
6176/// @end
6177/// Foo *f;
6178///
6179/// int j;
6180/// \endcode
6181/// varDecl(hasType(isAnyPointer()))
6182/// matches "int *i" and "Foo *f", but not "int j".
6183AST_MATCHER(QualType, isAnyPointer)namespace internal { class matcher_isAnyPointerMatcher : public
::clang::ast_matchers::internal::MatcherInterface<QualType
> { public: explicit matcher_isAnyPointerMatcher() = default
; bool matches(const QualType &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const override; }; } inline
::clang::ast_matchers::internal::Matcher<QualType> isAnyPointer
() { return ::clang::ast_matchers::internal::makeMatcher( new
internal::matcher_isAnyPointerMatcher()); } inline bool internal
::matcher_isAnyPointerMatcher::matches( const QualType &Node
, ::clang::ast_matchers::internal::ASTMatchFinder *Finder, ::
clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder
) const
{
6184 return Node->isAnyPointerType();
6185}
6186
6187/// Matches QualType nodes that are const-qualified, i.e., that
6188/// include "top-level" const.
6189///
6190/// Given
6191/// \code
6192/// void a(int);
6193/// void b(int const);
6194/// void c(const int);
6195/// void d(const int*);
6196/// void e(int const) {};
6197/// \endcode
6198/// functionDecl(hasAnyParameter(hasType(isConstQualified())))
6199/// matches "void b(int const)", "void c(const int)" and
6200/// "void e(int const) {}". It does not match d as there
6201/// is no top-level const on the parameter type "const int *".
6202AST_MATCHER(QualType, isConstQualified)namespace internal { class matcher_isConstQualifiedMatcher : public
::clang::ast_matchers::internal::MatcherInterface<QualType
> { public: explicit matcher_isConstQualifiedMatcher() = default
; bool matches(const QualType &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const override; }; } inline
::clang::ast_matchers::internal::Matcher<QualType> isConstQualified
() { return ::clang::ast_matchers::internal::makeMatcher( new
internal::matcher_isConstQualifiedMatcher()); } inline bool internal
::matcher_isConstQualifiedMatcher::matches( const QualType &
Node, ::clang::ast_matchers::internal::ASTMatchFinder *Finder
, ::clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder
) const
{
6203 return Node.isConstQualified();
6204}
6205
6206/// Matches QualType nodes that are volatile-qualified, i.e., that
6207/// include "top-level" volatile.
6208///
6209/// Given
6210/// \code
6211/// void a(int);
6212/// void b(int volatile);
6213/// void c(volatile int);
6214/// void d(volatile int*);
6215/// void e(int volatile) {};
6216/// \endcode
6217/// functionDecl(hasAnyParameter(hasType(isVolatileQualified())))
6218/// matches "void b(int volatile)", "void c(volatile int)" and
6219/// "void e(int volatile) {}". It does not match d as there
6220/// is no top-level volatile on the parameter type "volatile int *".
6221AST_MATCHER(QualType, isVolatileQualified)namespace internal { class matcher_isVolatileQualifiedMatcher
: public ::clang::ast_matchers::internal::MatcherInterface<
QualType> { public: explicit matcher_isVolatileQualifiedMatcher
() = default; bool matches(const QualType &Node, ::clang::
ast_matchers::internal::ASTMatchFinder *Finder, ::clang::ast_matchers
::internal::BoundNodesTreeBuilder *Builder) const override; }
; } inline ::clang::ast_matchers::internal::Matcher<QualType
> isVolatileQualified() { return ::clang::ast_matchers::internal
::makeMatcher( new internal::matcher_isVolatileQualifiedMatcher
()); } inline bool internal::matcher_isVolatileQualifiedMatcher
::matches( const QualType &Node, ::clang::ast_matchers::internal
::ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
6222 return Node.isVolatileQualified();
6223}
6224
6225/// Matches QualType nodes that have local CV-qualifiers attached to
6226/// the node, not hidden within a typedef.
6227///
6228/// Given
6229/// \code
6230/// typedef const int const_int;
6231/// const_int i;
6232/// int *const j;
6233/// int *volatile k;
6234/// int m;
6235/// \endcode
6236/// \c varDecl(hasType(hasLocalQualifiers())) matches only \c j and \c k.
6237/// \c i is const-qualified but the qualifier is not local.
6238AST_MATCHER(QualType, hasLocalQualifiers)namespace internal { class matcher_hasLocalQualifiersMatcher :
public ::clang::ast_matchers::internal::MatcherInterface<
QualType> { public: explicit matcher_hasLocalQualifiersMatcher
() = default; bool matches(const QualType &Node, ::clang::
ast_matchers::internal::ASTMatchFinder *Finder, ::clang::ast_matchers
::internal::BoundNodesTreeBuilder *Builder) const override; }
; } inline ::clang::ast_matchers::internal::Matcher<QualType
> hasLocalQualifiers() { return ::clang::ast_matchers::internal
::makeMatcher( new internal::matcher_hasLocalQualifiersMatcher
()); } inline bool internal::matcher_hasLocalQualifiersMatcher
::matches( const QualType &Node, ::clang::ast_matchers::internal
::ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
6239 return Node.hasLocalQualifiers();
6240}
6241
6242/// Matches a member expression where the member is matched by a
6243/// given matcher.
6244///
6245/// Given
6246/// \code
6247/// struct { int first, second; } first, second;
6248/// int i(second.first);
6249/// int j(first.second);
6250/// \endcode
6251/// memberExpr(member(hasName("first")))
6252/// matches second.first
6253/// but not first.second (because the member name there is "second").
6254AST_MATCHER_P(MemberExpr, member,namespace internal { class matcher_member0Matcher : public ::
clang::ast_matchers::internal::MatcherInterface<MemberExpr
> { public: explicit matcher_member0Matcher( internal::Matcher
<ValueDecl> const &AInnerMatcher) : InnerMatcher(AInnerMatcher
) {} bool matches(const MemberExpr &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const override; private: internal
::Matcher<ValueDecl> InnerMatcher; }; } inline ::clang::
ast_matchers::internal::Matcher<MemberExpr> member( internal
::Matcher<ValueDecl> const &InnerMatcher) { return ::
clang::ast_matchers::internal::makeMatcher( new internal::matcher_member0Matcher
(InnerMatcher)); } typedef ::clang::ast_matchers::internal::Matcher
<MemberExpr> ( &member_Type0)(internal::Matcher<
ValueDecl> const &InnerMatcher); inline bool internal::
matcher_member0Matcher::matches( const MemberExpr &Node, ::
clang::ast_matchers::internal::ASTMatchFinder *Finder, ::clang
::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
6255 internal::Matcher<ValueDecl>, InnerMatcher)namespace internal { class matcher_member0Matcher : public ::
clang::ast_matchers::internal::MatcherInterface<MemberExpr
> { public: explicit matcher_member0Matcher( internal::Matcher
<ValueDecl> const &AInnerMatcher) : InnerMatcher(AInnerMatcher
) {} bool matches(const MemberExpr &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const override; private: internal
::Matcher<ValueDecl> InnerMatcher; }; } inline ::clang::
ast_matchers::internal::Matcher<MemberExpr> member( internal
::Matcher<ValueDecl> const &InnerMatcher) { return ::
clang::ast_matchers::internal::makeMatcher( new internal::matcher_member0Matcher
(InnerMatcher)); } typedef ::clang::ast_matchers::internal::Matcher
<MemberExpr> ( &member_Type0)(internal::Matcher<
ValueDecl> const &InnerMatcher); inline bool internal::
matcher_member0Matcher::matches( const MemberExpr &Node, ::
clang::ast_matchers::internal::ASTMatchFinder *Finder, ::clang
::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
{
6256 return InnerMatcher.matches(*Node.getMemberDecl(), Finder, Builder);
6257}
6258
6259/// Matches a member expression where the object expression is matched by a
6260/// given matcher. Implicit object expressions are included; that is, it matches
6261/// use of implicit `this`.
6262///
6263/// Given
6264/// \code
6265/// struct X {
6266/// int m;
6267/// int f(X x) { x.m; return m; }
6268/// };
6269/// \endcode
6270/// memberExpr(hasObjectExpression(hasType(cxxRecordDecl(hasName("X")))))
6271/// matches `x.m`, but not `m`; however,
6272/// memberExpr(hasObjectExpression(hasType(pointsTo(
6273// cxxRecordDecl(hasName("X"))))))
6274/// matches `m` (aka. `this->m`), but not `x.m`.
6275AST_POLYMORPHIC_MATCHER_P(namespace internal { template <typename NodeType, typename
ParamT> class matcher_hasObjectExpression0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<NodeType
> { public: explicit matcher_hasObjectExpression0Matcher( internal
::Matcher<Expr> 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<Expr> InnerMatcher; }; } inline ::clang
::ast_matchers::internal::PolymorphicMatcher< internal::matcher_hasObjectExpression0Matcher
, void(::clang::ast_matchers::internal::TypeList<MemberExpr
, UnresolvedMemberExpr, CXXDependentScopeMemberExpr>), internal
::Matcher<Expr> > hasObjectExpression(internal::Matcher
<Expr> const &InnerMatcher) { return ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_hasObjectExpression0Matcher
, void(::clang::ast_matchers::internal::TypeList<MemberExpr
, UnresolvedMemberExpr, CXXDependentScopeMemberExpr>), internal
::Matcher<Expr> >(InnerMatcher); } typedef ::clang::
ast_matchers::internal::PolymorphicMatcher< internal::matcher_hasObjectExpression0Matcher
, void(::clang::ast_matchers::internal::TypeList<MemberExpr
, UnresolvedMemberExpr, CXXDependentScopeMemberExpr>), internal
::Matcher<Expr> > (&hasObjectExpression_Type0)(internal
::Matcher<Expr> const &InnerMatcher); template <
typename NodeType, typename ParamT> bool internal:: matcher_hasObjectExpression0Matcher
<NodeType, ParamT>::matches( const NodeType &Node, ::
clang::ast_matchers::internal::ASTMatchFinder *Finder, ::clang
::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
6276 hasObjectExpression,namespace internal { template <typename NodeType, typename
ParamT> class matcher_hasObjectExpression0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<NodeType
> { public: explicit matcher_hasObjectExpression0Matcher( internal
::Matcher<Expr> 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<Expr> InnerMatcher; }; } inline ::clang
::ast_matchers::internal::PolymorphicMatcher< internal::matcher_hasObjectExpression0Matcher
, void(::clang::ast_matchers::internal::TypeList<MemberExpr
, UnresolvedMemberExpr, CXXDependentScopeMemberExpr>), internal
::Matcher<Expr> > hasObjectExpression(internal::Matcher
<Expr> const &InnerMatcher) { return ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_hasObjectExpression0Matcher
, void(::clang::ast_matchers::internal::TypeList<MemberExpr
, UnresolvedMemberExpr, CXXDependentScopeMemberExpr>), internal
::Matcher<Expr> >(InnerMatcher); } typedef ::clang::
ast_matchers::internal::PolymorphicMatcher< internal::matcher_hasObjectExpression0Matcher
, void(::clang::ast_matchers::internal::TypeList<MemberExpr
, UnresolvedMemberExpr, CXXDependentScopeMemberExpr>), internal
::Matcher<Expr> > (&hasObjectExpression_Type0)(internal
::Matcher<Expr> const &InnerMatcher); template <
typename NodeType, typename ParamT> bool internal:: matcher_hasObjectExpression0Matcher
<NodeType, ParamT>::matches( const NodeType &Node, ::
clang::ast_matchers::internal::ASTMatchFinder *Finder, ::clang
::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
6277 AST_POLYMORPHIC_SUPPORTED_TYPES(MemberExpr, UnresolvedMemberExpr,namespace internal { template <typename NodeType, typename
ParamT> class matcher_hasObjectExpression0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<NodeType
> { public: explicit matcher_hasObjectExpression0Matcher( internal
::Matcher<Expr> 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<Expr> InnerMatcher; }; } inline ::clang
::ast_matchers::internal::PolymorphicMatcher< internal::matcher_hasObjectExpression0Matcher
, void(::clang::ast_matchers::internal::TypeList<MemberExpr
, UnresolvedMemberExpr, CXXDependentScopeMemberExpr>), internal
::Matcher<Expr> > hasObjectExpression(internal::Matcher
<Expr> const &InnerMatcher) { return ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_hasObjectExpression0Matcher
, void(::clang::ast_matchers::internal::TypeList<MemberExpr
, UnresolvedMemberExpr, CXXDependentScopeMemberExpr>), internal
::Matcher<Expr> >(InnerMatcher); } typedef ::clang::
ast_matchers::internal::PolymorphicMatcher< internal::matcher_hasObjectExpression0Matcher
, void(::clang::ast_matchers::internal::TypeList<MemberExpr
, UnresolvedMemberExpr, CXXDependentScopeMemberExpr>), internal
::Matcher<Expr> > (&hasObjectExpression_Type0)(internal
::Matcher<Expr> const &InnerMatcher); template <
typename NodeType, typename ParamT> bool internal:: matcher_hasObjectExpression0Matcher
<NodeType, ParamT>::matches( const NodeType &Node, ::
clang::ast_matchers::internal::ASTMatchFinder *Finder, ::clang
::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
6278 CXXDependentScopeMemberExpr),namespace internal { template <typename NodeType, typename
ParamT> class matcher_hasObjectExpression0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<NodeType
> { public: explicit matcher_hasObjectExpression0Matcher( internal
::Matcher<Expr> 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<Expr> InnerMatcher; }; } inline ::clang
::ast_matchers::internal::PolymorphicMatcher< internal::matcher_hasObjectExpression0Matcher
, void(::clang::ast_matchers::internal::TypeList<MemberExpr
, UnresolvedMemberExpr, CXXDependentScopeMemberExpr>), internal
::Matcher<Expr> > hasObjectExpression(internal::Matcher
<Expr> const &InnerMatcher) { return ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_hasObjectExpression0Matcher
, void(::clang::ast_matchers::internal::TypeList<MemberExpr
, UnresolvedMemberExpr, CXXDependentScopeMemberExpr>), internal
::Matcher<Expr> >(InnerMatcher); } typedef ::clang::
ast_matchers::internal::PolymorphicMatcher< internal::matcher_hasObjectExpression0Matcher
, void(::clang::ast_matchers::internal::TypeList<MemberExpr
, UnresolvedMemberExpr, CXXDependentScopeMemberExpr>), internal
::Matcher<Expr> > (&hasObjectExpression_Type0)(internal
::Matcher<Expr> const &InnerMatcher); template <
typename NodeType, typename ParamT> bool internal:: matcher_hasObjectExpression0Matcher
<NodeType, ParamT>::matches( const NodeType &Node, ::
clang::ast_matchers::internal::ASTMatchFinder *Finder, ::clang
::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
6279 internal::Matcher<Expr>, InnerMatcher)namespace internal { template <typename NodeType, typename
ParamT> class matcher_hasObjectExpression0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<NodeType
> { public: explicit matcher_hasObjectExpression0Matcher( internal
::Matcher<Expr> 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<Expr> InnerMatcher; }; } inline ::clang
::ast_matchers::internal::PolymorphicMatcher< internal::matcher_hasObjectExpression0Matcher
, void(::clang::ast_matchers::internal::TypeList<MemberExpr
, UnresolvedMemberExpr, CXXDependentScopeMemberExpr>), internal
::Matcher<Expr> > hasObjectExpression(internal::Matcher
<Expr> const &InnerMatcher) { return ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_hasObjectExpression0Matcher
, void(::clang::ast_matchers::internal::TypeList<MemberExpr
, UnresolvedMemberExpr, CXXDependentScopeMemberExpr>), internal
::Matcher<Expr> >(InnerMatcher); } typedef ::clang::
ast_matchers::internal::PolymorphicMatcher< internal::matcher_hasObjectExpression0Matcher
, void(::clang::ast_matchers::internal::TypeList<MemberExpr
, UnresolvedMemberExpr, CXXDependentScopeMemberExpr>), internal
::Matcher<Expr> > (&hasObjectExpression_Type0)(internal
::Matcher<Expr> const &InnerMatcher); template <
typename NodeType, typename ParamT> bool internal:: matcher_hasObjectExpression0Matcher
<NodeType, ParamT>::matches( const NodeType &Node, ::
clang::ast_matchers::internal::ASTMatchFinder *Finder, ::clang
::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
{
6280 if (const auto *E = dyn_cast<UnresolvedMemberExpr>(&Node))
6281 if (E->isImplicitAccess())
6282 return false;
6283 if (const auto *E = dyn_cast<CXXDependentScopeMemberExpr>(&Node))
6284 if (E->isImplicitAccess())
6285 return false;
6286 return InnerMatcher.matches(*Node.getBase(), Finder, Builder);
6287}
6288
6289/// Matches any using shadow declaration.
6290///
6291/// Given
6292/// \code
6293/// namespace X { void b(); }
6294/// using X::b;
6295/// \endcode
6296/// usingDecl(hasAnyUsingShadowDecl(hasName("b"))))
6297/// matches \code using X::b \endcode
6298AST_MATCHER_P(BaseUsingDecl, hasAnyUsingShadowDecl,namespace internal { class matcher_hasAnyUsingShadowDecl0Matcher
: public ::clang::ast_matchers::internal::MatcherInterface<
BaseUsingDecl> { public: explicit matcher_hasAnyUsingShadowDecl0Matcher
( internal::Matcher<UsingShadowDecl> const &AInnerMatcher
) : InnerMatcher(AInnerMatcher) {} bool matches(const BaseUsingDecl
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: internal::Matcher<UsingShadowDecl
> InnerMatcher; }; } inline ::clang::ast_matchers::internal
::Matcher<BaseUsingDecl> hasAnyUsingShadowDecl( internal
::Matcher<UsingShadowDecl> const &InnerMatcher) { return
::clang::ast_matchers::internal::makeMatcher( new internal::
matcher_hasAnyUsingShadowDecl0Matcher(InnerMatcher)); } typedef
::clang::ast_matchers::internal::Matcher<BaseUsingDecl>
( &hasAnyUsingShadowDecl_Type0)(internal::Matcher<UsingShadowDecl
> const &InnerMatcher); inline bool internal::matcher_hasAnyUsingShadowDecl0Matcher
::matches( const BaseUsingDecl &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
6299 internal::Matcher<UsingShadowDecl>, InnerMatcher)namespace internal { class matcher_hasAnyUsingShadowDecl0Matcher
: public ::clang::ast_matchers::internal::MatcherInterface<
BaseUsingDecl> { public: explicit matcher_hasAnyUsingShadowDecl0Matcher
( internal::Matcher<UsingShadowDecl> const &AInnerMatcher
) : InnerMatcher(AInnerMatcher) {} bool matches(const BaseUsingDecl
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: internal::Matcher<UsingShadowDecl
> InnerMatcher; }; } inline ::clang::ast_matchers::internal
::Matcher<BaseUsingDecl> hasAnyUsingShadowDecl( internal
::Matcher<UsingShadowDecl> const &InnerMatcher) { return
::clang::ast_matchers::internal::makeMatcher( new internal::
matcher_hasAnyUsingShadowDecl0Matcher(InnerMatcher)); } typedef
::clang::ast_matchers::internal::Matcher<BaseUsingDecl>
( &hasAnyUsingShadowDecl_Type0)(internal::Matcher<UsingShadowDecl
> const &InnerMatcher); inline bool internal::matcher_hasAnyUsingShadowDecl0Matcher
::matches( const BaseUsingDecl &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
{
6300 return matchesFirstInPointerRange(InnerMatcher, Node.shadow_begin(),
6301 Node.shadow_end(), Finder,
6302 Builder) != Node.shadow_end();
6303}
6304
6305/// Matches a using shadow declaration where the target declaration is
6306/// matched by the given matcher.
6307///
6308/// Given
6309/// \code
6310/// namespace X { int a; void b(); }
6311/// using X::a;
6312/// using X::b;
6313/// \endcode
6314/// usingDecl(hasAnyUsingShadowDecl(hasTargetDecl(functionDecl())))
6315/// matches \code using X::b \endcode
6316/// but not \code using X::a \endcode
6317AST_MATCHER_P(UsingShadowDecl, hasTargetDecl,namespace internal { class matcher_hasTargetDecl0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<UsingShadowDecl
> { public: explicit matcher_hasTargetDecl0Matcher( internal
::Matcher<NamedDecl> const &AInnerMatcher) : InnerMatcher
(AInnerMatcher) {} bool matches(const UsingShadowDecl &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
<UsingShadowDecl> hasTargetDecl( internal::Matcher<NamedDecl
> const &InnerMatcher) { return ::clang::ast_matchers::
internal::makeMatcher( new internal::matcher_hasTargetDecl0Matcher
(InnerMatcher)); } typedef ::clang::ast_matchers::internal::Matcher
<UsingShadowDecl> ( &hasTargetDecl_Type0)(internal::
Matcher<NamedDecl> const &InnerMatcher); inline bool
internal::matcher_hasTargetDecl0Matcher::matches( const UsingShadowDecl
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
6318 internal::Matcher<NamedDecl>, InnerMatcher)namespace internal { class matcher_hasTargetDecl0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<UsingShadowDecl
> { public: explicit matcher_hasTargetDecl0Matcher( internal
::Matcher<NamedDecl> const &AInnerMatcher) : InnerMatcher
(AInnerMatcher) {} bool matches(const UsingShadowDecl &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
<UsingShadowDecl> hasTargetDecl( internal::Matcher<NamedDecl
> const &InnerMatcher) { return ::clang::ast_matchers::
internal::makeMatcher( new internal::matcher_hasTargetDecl0Matcher
(InnerMatcher)); } typedef ::clang::ast_matchers::internal::Matcher
<UsingShadowDecl> ( &hasTargetDecl_Type0)(internal::
Matcher<NamedDecl> const &InnerMatcher); inline bool
internal::matcher_hasTargetDecl0Matcher::matches( const UsingShadowDecl
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
6319 return InnerMatcher.matches(*Node.getTargetDecl(), Finder, Builder);
6320}
6321
6322/// Matches template instantiations of function, class, or static
6323/// member variable template instantiations.
6324///
6325/// Given
6326/// \code
6327/// template <typename T> class X {}; class A {}; X<A> x;
6328/// \endcode
6329/// or
6330/// \code
6331/// template <typename T> class X {}; class A {}; template class X<A>;
6332/// \endcode
6333/// or
6334/// \code
6335/// template <typename T> class X {}; class A {}; extern template class X<A>;
6336/// \endcode
6337/// cxxRecordDecl(hasName("::X"), isTemplateInstantiation())
6338/// matches the template instantiation of X<A>.
6339///
6340/// But given
6341/// \code
6342/// template <typename T> class X {}; class A {};
6343/// template <> class X<A> {}; X<A> x;
6344/// \endcode
6345/// cxxRecordDecl(hasName("::X"), isTemplateInstantiation())
6346/// does not match, as X<A> is an explicit template specialization.
6347///
6348/// Usable as: Matcher<FunctionDecl>, Matcher<VarDecl>, Matcher<CXXRecordDecl>
6349AST_POLYMORPHIC_MATCHER(isTemplateInstantiation,namespace internal { template <typename NodeType> class
matcher_isTemplateInstantiationMatcher : 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_isTemplateInstantiationMatcher
, void(::clang::ast_matchers::internal::TypeList<FunctionDecl
, VarDecl, CXXRecordDecl>)> isTemplateInstantiation() {
return ::clang::ast_matchers::internal::PolymorphicMatcher<
internal::matcher_isTemplateInstantiationMatcher, void(::clang
::ast_matchers::internal::TypeList<FunctionDecl, VarDecl, CXXRecordDecl
>)>(); } template <typename NodeType> bool internal
::matcher_isTemplateInstantiationMatcher<NodeType>::matches
( const NodeType &Node, ::clang::ast_matchers::internal::
ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
6350 AST_POLYMORPHIC_SUPPORTED_TYPES(FunctionDecl, VarDecl,namespace internal { template <typename NodeType> class
matcher_isTemplateInstantiationMatcher : 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_isTemplateInstantiationMatcher
, void(::clang::ast_matchers::internal::TypeList<FunctionDecl
, VarDecl, CXXRecordDecl>)> isTemplateInstantiation() {
return ::clang::ast_matchers::internal::PolymorphicMatcher<
internal::matcher_isTemplateInstantiationMatcher, void(::clang
::ast_matchers::internal::TypeList<FunctionDecl, VarDecl, CXXRecordDecl
>)>(); } template <typename NodeType> bool internal
::matcher_isTemplateInstantiationMatcher<NodeType>::matches
( const NodeType &Node, ::clang::ast_matchers::internal::
ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
6351 CXXRecordDecl))namespace internal { template <typename NodeType> class
matcher_isTemplateInstantiationMatcher : 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_isTemplateInstantiationMatcher
, void(::clang::ast_matchers::internal::TypeList<FunctionDecl
, VarDecl, CXXRecordDecl>)> isTemplateInstantiation() {
return ::clang::ast_matchers::internal::PolymorphicMatcher<
internal::matcher_isTemplateInstantiationMatcher, void(::clang
::ast_matchers::internal::TypeList<FunctionDecl, VarDecl, CXXRecordDecl
>)>(); } template <typename NodeType> bool internal
::matcher_isTemplateInstantiationMatcher<NodeType>::matches
( const NodeType &Node, ::clang::ast_matchers::internal::
ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
6352 return (Node.getTemplateSpecializationKind() == TSK_ImplicitInstantiation ||
6353 Node.getTemplateSpecializationKind() ==
6354 TSK_ExplicitInstantiationDefinition ||
6355 Node.getTemplateSpecializationKind() ==
6356 TSK_ExplicitInstantiationDeclaration);
6357}
6358
6359/// Matches declarations that are template instantiations or are inside
6360/// template instantiations.
6361///
6362/// Given
6363/// \code
6364/// template<typename T> void A(T t) { T i; }
6365/// A(0);
6366/// A(0U);
6367/// \endcode
6368/// functionDecl(isInstantiated())
6369/// matches 'A(int) {...};' and 'A(unsigned) {...}'.
6370AST_MATCHER_FUNCTION(internal::Matcher<Decl>, isInstantiated)inline internal::Matcher<Decl> isInstantiated_getInstance
(); inline internal::Matcher<Decl> isInstantiated() { return
::clang::ast_matchers::internal::MemoizedMatcher< internal
::Matcher<Decl>, isInstantiated_getInstance>::getInstance
(); } inline internal::Matcher<Decl> isInstantiated_getInstance
()
{
6371 auto IsInstantiation = decl(anyOf(cxxRecordDecl(isTemplateInstantiation()),
6372 functionDecl(isTemplateInstantiation())));
6373 return decl(anyOf(IsInstantiation, hasAncestor(IsInstantiation)));
6374}
6375
6376/// Matches statements inside of a template instantiation.
6377///
6378/// Given
6379/// \code
6380/// int j;
6381/// template<typename T> void A(T t) { T i; j += 42;}
6382/// A(0);
6383/// A(0U);
6384/// \endcode
6385/// declStmt(isInTemplateInstantiation())
6386/// matches 'int i;' and 'unsigned i'.
6387/// unless(stmt(isInTemplateInstantiation()))
6388/// will NOT match j += 42; as it's shared between the template definition and
6389/// instantiation.
6390AST_MATCHER_FUNCTION(internal::Matcher<Stmt>, isInTemplateInstantiation)inline internal::Matcher<Stmt> isInTemplateInstantiation_getInstance
(); inline internal::Matcher<Stmt> isInTemplateInstantiation
() { return ::clang::ast_matchers::internal::MemoizedMatcher<
internal::Matcher<Stmt>, isInTemplateInstantiation_getInstance
>::getInstance(); } inline internal::Matcher<Stmt> isInTemplateInstantiation_getInstance
()
{
6391 return stmt(
6392 hasAncestor(decl(anyOf(cxxRecordDecl(isTemplateInstantiation()),
6393 functionDecl(isTemplateInstantiation())))));
6394}
6395
6396/// Matches explicit template specializations of function, class, or
6397/// static member variable template instantiations.
6398///
6399/// Given
6400/// \code
6401/// template<typename T> void A(T t) { }
6402/// template<> void A(int N) { }
6403/// \endcode
6404/// functionDecl(isExplicitTemplateSpecialization())
6405/// matches the specialization A<int>().
6406///
6407/// Usable as: Matcher<FunctionDecl>, Matcher<VarDecl>, Matcher<CXXRecordDecl>
6408AST_POLYMORPHIC_MATCHER(isExplicitTemplateSpecialization,namespace internal { template <typename NodeType> class
matcher_isExplicitTemplateSpecializationMatcher : 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_isExplicitTemplateSpecializationMatcher, void(::clang
::ast_matchers::internal::TypeList<FunctionDecl, VarDecl, CXXRecordDecl
>)> isExplicitTemplateSpecialization() { return ::clang
::ast_matchers::internal::PolymorphicMatcher< internal::matcher_isExplicitTemplateSpecializationMatcher
, void(::clang::ast_matchers::internal::TypeList<FunctionDecl
, VarDecl, CXXRecordDecl>)>(); } template <typename NodeType
> bool internal::matcher_isExplicitTemplateSpecializationMatcher
<NodeType>::matches( const NodeType &Node, ::clang::
ast_matchers::internal::ASTMatchFinder *Finder, ::clang::ast_matchers
::internal::BoundNodesTreeBuilder *Builder) const
6409 AST_POLYMORPHIC_SUPPORTED_TYPES(FunctionDecl, VarDecl,namespace internal { template <typename NodeType> class
matcher_isExplicitTemplateSpecializationMatcher : 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_isExplicitTemplateSpecializationMatcher, void(::clang
::ast_matchers::internal::TypeList<FunctionDecl, VarDecl, CXXRecordDecl
>)> isExplicitTemplateSpecialization() { return ::clang
::ast_matchers::internal::PolymorphicMatcher< internal::matcher_isExplicitTemplateSpecializationMatcher
, void(::clang::ast_matchers::internal::TypeList<FunctionDecl
, VarDecl, CXXRecordDecl>)>(); } template <typename NodeType
> bool internal::matcher_isExplicitTemplateSpecializationMatcher
<NodeType>::matches( const NodeType &Node, ::clang::
ast_matchers::internal::ASTMatchFinder *Finder, ::clang::ast_matchers
::internal::BoundNodesTreeBuilder *Builder) const
6410 CXXRecordDecl))namespace internal { template <typename NodeType> class
matcher_isExplicitTemplateSpecializationMatcher : 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_isExplicitTemplateSpecializationMatcher, void(::clang
::ast_matchers::internal::TypeList<FunctionDecl, VarDecl, CXXRecordDecl
>)> isExplicitTemplateSpecialization() { return ::clang
::ast_matchers::internal::PolymorphicMatcher< internal::matcher_isExplicitTemplateSpecializationMatcher
, void(::clang::ast_matchers::internal::TypeList<FunctionDecl
, VarDecl, CXXRecordDecl>)>(); } template <typename NodeType
> bool internal::matcher_isExplicitTemplateSpecializationMatcher
<NodeType>::matches( const NodeType &Node, ::clang::
ast_matchers::internal::ASTMatchFinder *Finder, ::clang::ast_matchers
::internal::BoundNodesTreeBuilder *Builder) const
{
6411 return (Node.getTemplateSpecializationKind() == TSK_ExplicitSpecialization);
6412}
6413
6414/// Matches \c TypeLocs for which the given inner
6415/// QualType-matcher matches.
6416AST_MATCHER_FUNCTION_P_OVERLOAD(internal::BindableMatcher<TypeLoc>, loc,inline internal::BindableMatcher<TypeLoc> loc(internal::
Matcher<QualType> const &InnerMatcher); typedef internal
::BindableMatcher<TypeLoc> (&loc_Type0)(internal::Matcher
<QualType> const &); inline internal::BindableMatcher
<TypeLoc> loc(internal::Matcher<QualType> const &
InnerMatcher)
6417 internal::Matcher<QualType>, InnerMatcher, 0)inline internal::BindableMatcher<TypeLoc> loc(internal::
Matcher<QualType> const &InnerMatcher); typedef internal
::BindableMatcher<TypeLoc> (&loc_Type0)(internal::Matcher
<QualType> const &); inline internal::BindableMatcher
<TypeLoc> loc(internal::Matcher<QualType> const &
InnerMatcher)
{
6418 return internal::BindableMatcher<TypeLoc>(
6419 new internal::TypeLocTypeMatcher(InnerMatcher));
6420}
6421
6422/// Matches `QualifiedTypeLoc`s in the clang AST.
6423///
6424/// Given
6425/// \code
6426/// const int x = 0;
6427/// \endcode
6428/// qualifiedTypeLoc()
6429/// matches `const int`.
6430extern const internal::VariadicDynCastAllOfMatcher<TypeLoc, QualifiedTypeLoc>
6431 qualifiedTypeLoc;
6432
6433/// Matches `QualifiedTypeLoc`s that have an unqualified `TypeLoc` matching
6434/// `InnerMatcher`.
6435///
6436/// Given
6437/// \code
6438/// int* const x;
6439/// const int y;
6440/// \endcode
6441/// qualifiedTypeLoc(hasUnqualifiedLoc(pointerTypeLoc()))
6442/// matches the `TypeLoc` of the variable declaration of `x`, but not `y`.
6443AST_MATCHER_P(QualifiedTypeLoc, hasUnqualifiedLoc, internal::Matcher<TypeLoc>,namespace internal { class matcher_hasUnqualifiedLoc0Matcher :
public ::clang::ast_matchers::internal::MatcherInterface<
QualifiedTypeLoc> { public: explicit matcher_hasUnqualifiedLoc0Matcher
( internal::Matcher<TypeLoc> const &AInnerMatcher) :
InnerMatcher(AInnerMatcher) {} bool matches(const QualifiedTypeLoc
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: internal::Matcher<TypeLoc
> InnerMatcher; }; } inline ::clang::ast_matchers::internal
::Matcher<QualifiedTypeLoc> hasUnqualifiedLoc( internal
::Matcher<TypeLoc> const &InnerMatcher) { return ::
clang::ast_matchers::internal::makeMatcher( new internal::matcher_hasUnqualifiedLoc0Matcher
(InnerMatcher)); } typedef ::clang::ast_matchers::internal::Matcher
<QualifiedTypeLoc> ( &hasUnqualifiedLoc_Type0)(internal
::Matcher<TypeLoc> const &InnerMatcher); inline bool
internal::matcher_hasUnqualifiedLoc0Matcher::matches( const QualifiedTypeLoc
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
6444 InnerMatcher)namespace internal { class matcher_hasUnqualifiedLoc0Matcher :
public ::clang::ast_matchers::internal::MatcherInterface<
QualifiedTypeLoc> { public: explicit matcher_hasUnqualifiedLoc0Matcher
( internal::Matcher<TypeLoc> const &AInnerMatcher) :
InnerMatcher(AInnerMatcher) {} bool matches(const QualifiedTypeLoc
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: internal::Matcher<TypeLoc
> InnerMatcher; }; } inline ::clang::ast_matchers::internal
::Matcher<QualifiedTypeLoc> hasUnqualifiedLoc( internal
::Matcher<TypeLoc> const &InnerMatcher) { return ::
clang::ast_matchers::internal::makeMatcher( new internal::matcher_hasUnqualifiedLoc0Matcher
(InnerMatcher)); } typedef ::clang::ast_matchers::internal::Matcher
<QualifiedTypeLoc> ( &hasUnqualifiedLoc_Type0)(internal
::Matcher<TypeLoc> const &InnerMatcher); inline bool
internal::matcher_hasUnqualifiedLoc0Matcher::matches( const QualifiedTypeLoc
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
6445 return InnerMatcher.matches(Node.getUnqualifiedLoc(), Finder, Builder);
6446}
6447
6448/// Matches a function declared with the specified return `TypeLoc`.
6449///
6450/// Given
6451/// \code
6452/// int f() { return 5; }
6453/// void g() {}
6454/// \endcode
6455/// functionDecl(hasReturnTypeLoc(loc(asString("int"))))
6456/// matches the declaration of `f`, but not `g`.
6457AST_MATCHER_P(FunctionDecl, hasReturnTypeLoc, internal::Matcher<TypeLoc>,namespace internal { class matcher_hasReturnTypeLoc0Matcher :
public ::clang::ast_matchers::internal::MatcherInterface<
FunctionDecl> { public: explicit matcher_hasReturnTypeLoc0Matcher
( internal::Matcher<TypeLoc> const &AReturnMatcher)
: ReturnMatcher(AReturnMatcher) {} bool matches(const FunctionDecl
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: internal::Matcher<TypeLoc
> ReturnMatcher; }; } inline ::clang::ast_matchers::internal
::Matcher<FunctionDecl> hasReturnTypeLoc( internal::Matcher
<TypeLoc> const &ReturnMatcher) { return ::clang::ast_matchers
::internal::makeMatcher( new internal::matcher_hasReturnTypeLoc0Matcher
(ReturnMatcher)); } typedef ::clang::ast_matchers::internal::
Matcher<FunctionDecl> ( &hasReturnTypeLoc_Type0)(internal
::Matcher<TypeLoc> const &ReturnMatcher); inline bool
internal::matcher_hasReturnTypeLoc0Matcher::matches( const FunctionDecl
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
6458 ReturnMatcher)namespace internal { class matcher_hasReturnTypeLoc0Matcher :
public ::clang::ast_matchers::internal::MatcherInterface<
FunctionDecl> { public: explicit matcher_hasReturnTypeLoc0Matcher
( internal::Matcher<TypeLoc> const &AReturnMatcher)
: ReturnMatcher(AReturnMatcher) {} bool matches(const FunctionDecl
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: internal::Matcher<TypeLoc
> ReturnMatcher; }; } inline ::clang::ast_matchers::internal
::Matcher<FunctionDecl> hasReturnTypeLoc( internal::Matcher
<TypeLoc> const &ReturnMatcher) { return ::clang::ast_matchers
::internal::makeMatcher( new internal::matcher_hasReturnTypeLoc0Matcher
(ReturnMatcher)); } typedef ::clang::ast_matchers::internal::
Matcher<FunctionDecl> ( &hasReturnTypeLoc_Type0)(internal
::Matcher<TypeLoc> const &ReturnMatcher); inline bool
internal::matcher_hasReturnTypeLoc0Matcher::matches( const FunctionDecl
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
6459 auto Loc = Node.getFunctionTypeLoc();
6460 return Loc && ReturnMatcher.matches(Loc.getReturnLoc(), Finder, Builder);
6461}
6462
6463/// Matches pointer `TypeLoc`s.
6464///
6465/// Given
6466/// \code
6467/// int* x;
6468/// \endcode
6469/// pointerTypeLoc()
6470/// matches `int*`.
6471extern const internal::VariadicDynCastAllOfMatcher<TypeLoc, PointerTypeLoc>
6472 pointerTypeLoc;
6473
6474/// Matches pointer `TypeLoc`s that have a pointee `TypeLoc` matching
6475/// `PointeeMatcher`.
6476///
6477/// Given
6478/// \code
6479/// int* x;
6480/// \endcode
6481/// pointerTypeLoc(hasPointeeLoc(loc(asString("int"))))
6482/// matches `int*`.
6483AST_MATCHER_P(PointerTypeLoc, hasPointeeLoc, internal::Matcher<TypeLoc>,namespace internal { class matcher_hasPointeeLoc0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<PointerTypeLoc
> { public: explicit matcher_hasPointeeLoc0Matcher( internal
::Matcher<TypeLoc> const &APointeeMatcher) : PointeeMatcher
(APointeeMatcher) {} bool matches(const PointerTypeLoc &Node
, ::clang::ast_matchers::internal::ASTMatchFinder *Finder, ::
clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder
) const override; private: internal::Matcher<TypeLoc> PointeeMatcher
; }; } inline ::clang::ast_matchers::internal::Matcher<PointerTypeLoc
> hasPointeeLoc( internal::Matcher<TypeLoc> const &
PointeeMatcher) { return ::clang::ast_matchers::internal::makeMatcher
( new internal::matcher_hasPointeeLoc0Matcher(PointeeMatcher)
); } typedef ::clang::ast_matchers::internal::Matcher<PointerTypeLoc
> ( &hasPointeeLoc_Type0)(internal::Matcher<TypeLoc
> const &PointeeMatcher); inline bool internal::matcher_hasPointeeLoc0Matcher
::matches( const PointerTypeLoc &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
6484 PointeeMatcher)namespace internal { class matcher_hasPointeeLoc0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<PointerTypeLoc
> { public: explicit matcher_hasPointeeLoc0Matcher( internal
::Matcher<TypeLoc> const &APointeeMatcher) : PointeeMatcher
(APointeeMatcher) {} bool matches(const PointerTypeLoc &Node
, ::clang::ast_matchers::internal::ASTMatchFinder *Finder, ::
clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder
) const override; private: internal::Matcher<TypeLoc> PointeeMatcher
; }; } inline ::clang::ast_matchers::internal::Matcher<PointerTypeLoc
> hasPointeeLoc( internal::Matcher<TypeLoc> const &
PointeeMatcher) { return ::clang::ast_matchers::internal::makeMatcher
( new internal::matcher_hasPointeeLoc0Matcher(PointeeMatcher)
); } typedef ::clang::ast_matchers::internal::Matcher<PointerTypeLoc
> ( &hasPointeeLoc_Type0)(internal::Matcher<TypeLoc
> const &PointeeMatcher); inline bool internal::matcher_hasPointeeLoc0Matcher
::matches( const PointerTypeLoc &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
{
6485 return PointeeMatcher.matches(Node.getPointeeLoc(), Finder, Builder);
6486}
6487
6488/// Matches reference `TypeLoc`s.
6489///
6490/// Given
6491/// \code
6492/// int x = 3;
6493/// int& l = x;
6494/// int&& r = 3;
6495/// \endcode
6496/// referenceTypeLoc()
6497/// matches `int&` and `int&&`.
6498extern const internal::VariadicDynCastAllOfMatcher<TypeLoc, ReferenceTypeLoc>
6499 referenceTypeLoc;
6500
6501/// Matches reference `TypeLoc`s that have a referent `TypeLoc` matching
6502/// `ReferentMatcher`.
6503///
6504/// Given
6505/// \code
6506/// int x = 3;
6507/// int& xx = x;
6508/// \endcode
6509/// referenceTypeLoc(hasReferentLoc(loc(asString("int"))))
6510/// matches `int&`.
6511AST_MATCHER_P(ReferenceTypeLoc, hasReferentLoc, internal::Matcher<TypeLoc>,namespace internal { class matcher_hasReferentLoc0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<ReferenceTypeLoc
> { public: explicit matcher_hasReferentLoc0Matcher( internal
::Matcher<TypeLoc> const &AReferentMatcher) : ReferentMatcher
(AReferentMatcher) {} bool matches(const ReferenceTypeLoc &
Node, ::clang::ast_matchers::internal::ASTMatchFinder *Finder
, ::clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder
) const override; private: internal::Matcher<TypeLoc> ReferentMatcher
; }; } inline ::clang::ast_matchers::internal::Matcher<ReferenceTypeLoc
> hasReferentLoc( internal::Matcher<TypeLoc> const &
ReferentMatcher) { return ::clang::ast_matchers::internal::makeMatcher
( new internal::matcher_hasReferentLoc0Matcher(ReferentMatcher
)); } typedef ::clang::ast_matchers::internal::Matcher<ReferenceTypeLoc
> ( &hasReferentLoc_Type0)(internal::Matcher<TypeLoc
> const &ReferentMatcher); inline bool internal::matcher_hasReferentLoc0Matcher
::matches( const ReferenceTypeLoc &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
6512 ReferentMatcher)namespace internal { class matcher_hasReferentLoc0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<ReferenceTypeLoc
> { public: explicit matcher_hasReferentLoc0Matcher( internal
::Matcher<TypeLoc> const &AReferentMatcher) : ReferentMatcher
(AReferentMatcher) {} bool matches(const ReferenceTypeLoc &
Node, ::clang::ast_matchers::internal::ASTMatchFinder *Finder
, ::clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder
) const override; private: internal::Matcher<TypeLoc> ReferentMatcher
; }; } inline ::clang::ast_matchers::internal::Matcher<ReferenceTypeLoc
> hasReferentLoc( internal::Matcher<TypeLoc> const &
ReferentMatcher) { return ::clang::ast_matchers::internal::makeMatcher
( new internal::matcher_hasReferentLoc0Matcher(ReferentMatcher
)); } typedef ::clang::ast_matchers::internal::Matcher<ReferenceTypeLoc
> ( &hasReferentLoc_Type0)(internal::Matcher<TypeLoc
> const &ReferentMatcher); inline bool internal::matcher_hasReferentLoc0Matcher
::matches( const ReferenceTypeLoc &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
{
6513 return ReferentMatcher.matches(Node.getPointeeLoc(), Finder, Builder);
6514}
6515
6516/// Matches template specialization `TypeLoc`s.
6517///
6518/// Given
6519/// \code
6520/// template <typename T> class C {};
6521/// C<char> var;
6522/// \endcode
6523/// varDecl(hasTypeLoc(templateSpecializationTypeLoc(typeLoc())))
6524/// matches `C<char> var`.
6525extern const internal::VariadicDynCastAllOfMatcher<
6526 TypeLoc, TemplateSpecializationTypeLoc>
6527 templateSpecializationTypeLoc;
6528
6529/// Matches template specialization `TypeLoc`s that have at least one
6530/// `TemplateArgumentLoc` matching the given `InnerMatcher`.
6531///
6532/// Given
6533/// \code
6534/// template<typename T> class A {};
6535/// A<int> a;
6536/// \endcode
6537/// varDecl(hasTypeLoc(templateSpecializationTypeLoc(hasAnyTemplateArgumentLoc(
6538/// hasTypeLoc(loc(asString("int")))))))
6539/// matches `A<int> a`.
6540AST_MATCHER_P(TemplateSpecializationTypeLoc, hasAnyTemplateArgumentLoc,namespace internal { class matcher_hasAnyTemplateArgumentLoc0Matcher
: public ::clang::ast_matchers::internal::MatcherInterface<
TemplateSpecializationTypeLoc> { public: explicit matcher_hasAnyTemplateArgumentLoc0Matcher
( internal::Matcher<TemplateArgumentLoc> const &AInnerMatcher
) : InnerMatcher(AInnerMatcher) {} bool matches(const TemplateSpecializationTypeLoc
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: internal::Matcher<TemplateArgumentLoc
> InnerMatcher; }; } inline ::clang::ast_matchers::internal
::Matcher<TemplateSpecializationTypeLoc> hasAnyTemplateArgumentLoc
( internal::Matcher<TemplateArgumentLoc> const &InnerMatcher
) { return ::clang::ast_matchers::internal::makeMatcher( new internal
::matcher_hasAnyTemplateArgumentLoc0Matcher(InnerMatcher)); }
typedef ::clang::ast_matchers::internal::Matcher<TemplateSpecializationTypeLoc
> ( &hasAnyTemplateArgumentLoc_Type0)(internal::Matcher
<TemplateArgumentLoc> const &InnerMatcher); inline bool
internal::matcher_hasAnyTemplateArgumentLoc0Matcher::matches
( const TemplateSpecializationTypeLoc &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
6541 internal::Matcher<TemplateArgumentLoc>, InnerMatcher)namespace internal { class matcher_hasAnyTemplateArgumentLoc0Matcher
: public ::clang::ast_matchers::internal::MatcherInterface<
TemplateSpecializationTypeLoc> { public: explicit matcher_hasAnyTemplateArgumentLoc0Matcher
( internal::Matcher<TemplateArgumentLoc> const &AInnerMatcher
) : InnerMatcher(AInnerMatcher) {} bool matches(const TemplateSpecializationTypeLoc
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: internal::Matcher<TemplateArgumentLoc
> InnerMatcher; }; } inline ::clang::ast_matchers::internal
::Matcher<TemplateSpecializationTypeLoc> hasAnyTemplateArgumentLoc
( internal::Matcher<TemplateArgumentLoc> const &InnerMatcher
) { return ::clang::ast_matchers::internal::makeMatcher( new internal
::matcher_hasAnyTemplateArgumentLoc0Matcher(InnerMatcher)); }
typedef ::clang::ast_matchers::internal::Matcher<TemplateSpecializationTypeLoc
> ( &hasAnyTemplateArgumentLoc_Type0)(internal::Matcher
<TemplateArgumentLoc> const &InnerMatcher); inline bool
internal::matcher_hasAnyTemplateArgumentLoc0Matcher::matches
( const TemplateSpecializationTypeLoc &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
{
6542 for (unsigned Index = 0, N = Node.getNumArgs(); Index < N; ++Index) {
6543 clang::ast_matchers::internal::BoundNodesTreeBuilder Result(*Builder);
6544 if (InnerMatcher.matches(Node.getArgLoc(Index), Finder, &Result)) {
6545 *Builder = std::move(Result);
6546 return true;
6547 }
6548 }
6549 return false;
6550}
6551
6552/// Matches template specialization `TypeLoc`s where the n'th
6553/// `TemplateArgumentLoc` matches the given `InnerMatcher`.
6554///
6555/// Given
6556/// \code
6557/// template<typename T, typename U> class A {};
6558/// A<double, int> b;
6559/// A<int, double> c;
6560/// \endcode
6561/// varDecl(hasTypeLoc(templateSpecializationTypeLoc(hasTemplateArgumentLoc(0,
6562/// hasTypeLoc(loc(asString("double")))))))
6563/// matches `A<double, int> b`, but not `A<int, double> c`.
6564AST_POLYMORPHIC_MATCHER_P2(namespace internal { template <typename NodeType, typename
ParamT1, typename ParamT2> class matcher_hasTemplateArgumentLoc0Matcher
: public ::clang::ast_matchers::internal::MatcherInterface<
NodeType> { public: matcher_hasTemplateArgumentLoc0Matcher
(unsigned const &AIndex, internal::Matcher<TemplateArgumentLoc
> const &AInnerMatcher) : Index(AIndex), InnerMatcher(
AInnerMatcher) {} bool matches(const NodeType &Node, ::clang
::ast_matchers::internal::ASTMatchFinder *Finder, ::clang::ast_matchers
::internal::BoundNodesTreeBuilder *Builder) const override; private
: unsigned Index; internal::Matcher<TemplateArgumentLoc>
InnerMatcher; }; } inline ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_hasTemplateArgumentLoc0Matcher, void(::
clang::ast_matchers::internal::TypeList<DeclRefExpr, TemplateSpecializationTypeLoc
>), unsigned, internal::Matcher<TemplateArgumentLoc>
> hasTemplateArgumentLoc(unsigned const &Index, internal
::Matcher<TemplateArgumentLoc> const &InnerMatcher)
{ return ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_hasTemplateArgumentLoc0Matcher, void(::
clang::ast_matchers::internal::TypeList<DeclRefExpr, TemplateSpecializationTypeLoc
>), unsigned, internal::Matcher<TemplateArgumentLoc>
>(Index, InnerMatcher); } typedef ::clang::ast_matchers::
internal::PolymorphicMatcher< internal::matcher_hasTemplateArgumentLoc0Matcher
, void(::clang::ast_matchers::internal::TypeList<DeclRefExpr
, TemplateSpecializationTypeLoc>), unsigned, internal::Matcher
<TemplateArgumentLoc> > (&hasTemplateArgumentLoc_Type0
)( unsigned const &Index, internal::Matcher<TemplateArgumentLoc
> const &InnerMatcher); template <typename NodeType
, typename ParamT1, typename ParamT2> bool internal::matcher_hasTemplateArgumentLoc0Matcher
< NodeType, ParamT1, ParamT2>:: matches(const NodeType &
Node, ::clang::ast_matchers::internal::ASTMatchFinder *Finder
, ::clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder
) const
6565 hasTemplateArgumentLoc,namespace internal { template <typename NodeType, typename
ParamT1, typename ParamT2> class matcher_hasTemplateArgumentLoc0Matcher
: public ::clang::ast_matchers::internal::MatcherInterface<
NodeType> { public: matcher_hasTemplateArgumentLoc0Matcher
(unsigned const &AIndex, internal::Matcher<TemplateArgumentLoc
> const &AInnerMatcher) : Index(AIndex), InnerMatcher(
AInnerMatcher) {} bool matches(const NodeType &Node, ::clang
::ast_matchers::internal::ASTMatchFinder *Finder, ::clang::ast_matchers
::internal::BoundNodesTreeBuilder *Builder) const override; private
: unsigned Index; internal::Matcher<TemplateArgumentLoc>
InnerMatcher; }; } inline ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_hasTemplateArgumentLoc0Matcher, void(::
clang::ast_matchers::internal::TypeList<DeclRefExpr, TemplateSpecializationTypeLoc
>), unsigned, internal::Matcher<TemplateArgumentLoc>
> hasTemplateArgumentLoc(unsigned const &Index, internal
::Matcher<TemplateArgumentLoc> const &InnerMatcher)
{ return ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_hasTemplateArgumentLoc0Matcher, void(::
clang::ast_matchers::internal::TypeList<DeclRefExpr, TemplateSpecializationTypeLoc
>), unsigned, internal::Matcher<TemplateArgumentLoc>
>(Index, InnerMatcher); } typedef ::clang::ast_matchers::
internal::PolymorphicMatcher< internal::matcher_hasTemplateArgumentLoc0Matcher
, void(::clang::ast_matchers::internal::TypeList<DeclRefExpr
, TemplateSpecializationTypeLoc>), unsigned, internal::Matcher
<TemplateArgumentLoc> > (&hasTemplateArgumentLoc_Type0
)( unsigned const &Index, internal::Matcher<TemplateArgumentLoc
> const &InnerMatcher); template <typename NodeType
, typename ParamT1, typename ParamT2> bool internal::matcher_hasTemplateArgumentLoc0Matcher
< NodeType, ParamT1, ParamT2>:: matches(const NodeType &
Node, ::clang::ast_matchers::internal::ASTMatchFinder *Finder
, ::clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder
) const
6566 AST_POLYMORPHIC_SUPPORTED_TYPES(DeclRefExpr, TemplateSpecializationTypeLoc),namespace internal { template <typename NodeType, typename
ParamT1, typename ParamT2> class matcher_hasTemplateArgumentLoc0Matcher
: public ::clang::ast_matchers::internal::MatcherInterface<
NodeType> { public: matcher_hasTemplateArgumentLoc0Matcher
(unsigned const &AIndex, internal::Matcher<TemplateArgumentLoc
> const &AInnerMatcher) : Index(AIndex), InnerMatcher(
AInnerMatcher) {} bool matches(const NodeType &Node, ::clang
::ast_matchers::internal::ASTMatchFinder *Finder, ::clang::ast_matchers
::internal::BoundNodesTreeBuilder *Builder) const override; private
: unsigned Index; internal::Matcher<TemplateArgumentLoc>
InnerMatcher; }; } inline ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_hasTemplateArgumentLoc0Matcher, void(::
clang::ast_matchers::internal::TypeList<DeclRefExpr, TemplateSpecializationTypeLoc
>), unsigned, internal::Matcher<TemplateArgumentLoc>
> hasTemplateArgumentLoc(unsigned const &Index, internal
::Matcher<TemplateArgumentLoc> const &InnerMatcher)
{ return ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_hasTemplateArgumentLoc0Matcher, void(::
clang::ast_matchers::internal::TypeList<DeclRefExpr, TemplateSpecializationTypeLoc
>), unsigned, internal::Matcher<TemplateArgumentLoc>
>(Index, InnerMatcher); } typedef ::clang::ast_matchers::
internal::PolymorphicMatcher< internal::matcher_hasTemplateArgumentLoc0Matcher
, void(::clang::ast_matchers::internal::TypeList<DeclRefExpr
, TemplateSpecializationTypeLoc>), unsigned, internal::Matcher
<TemplateArgumentLoc> > (&hasTemplateArgumentLoc_Type0
)( unsigned const &Index, internal::Matcher<TemplateArgumentLoc
> const &InnerMatcher); template <typename NodeType
, typename ParamT1, typename ParamT2> bool internal::matcher_hasTemplateArgumentLoc0Matcher
< NodeType, ParamT1, ParamT2>:: matches(const NodeType &
Node, ::clang::ast_matchers::internal::ASTMatchFinder *Finder
, ::clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder
) const
6567 unsigned, Index, internal::Matcher<TemplateArgumentLoc>, InnerMatcher)namespace internal { template <typename NodeType, typename
ParamT1, typename ParamT2> class matcher_hasTemplateArgumentLoc0Matcher
: public ::clang::ast_matchers::internal::MatcherInterface<
NodeType> { public: matcher_hasTemplateArgumentLoc0Matcher
(unsigned const &AIndex, internal::Matcher<TemplateArgumentLoc
> const &AInnerMatcher) : Index(AIndex), InnerMatcher(
AInnerMatcher) {} bool matches(const NodeType &Node, ::clang
::ast_matchers::internal::ASTMatchFinder *Finder, ::clang::ast_matchers
::internal::BoundNodesTreeBuilder *Builder) const override; private
: unsigned Index; internal::Matcher<TemplateArgumentLoc>
InnerMatcher; }; } inline ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_hasTemplateArgumentLoc0Matcher, void(::
clang::ast_matchers::internal::TypeList<DeclRefExpr, TemplateSpecializationTypeLoc
>), unsigned, internal::Matcher<TemplateArgumentLoc>
> hasTemplateArgumentLoc(unsigned const &Index, internal
::Matcher<TemplateArgumentLoc> const &InnerMatcher)
{ return ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_hasTemplateArgumentLoc0Matcher, void(::
clang::ast_matchers::internal::TypeList<DeclRefExpr, TemplateSpecializationTypeLoc
>), unsigned, internal::Matcher<TemplateArgumentLoc>
>(Index, InnerMatcher); } typedef ::clang::ast_matchers::
internal::PolymorphicMatcher< internal::matcher_hasTemplateArgumentLoc0Matcher
, void(::clang::ast_matchers::internal::TypeList<DeclRefExpr
, TemplateSpecializationTypeLoc>), unsigned, internal::Matcher
<TemplateArgumentLoc> > (&hasTemplateArgumentLoc_Type0
)( unsigned const &Index, internal::Matcher<TemplateArgumentLoc
> const &InnerMatcher); template <typename NodeType
, typename ParamT1, typename ParamT2> bool internal::matcher_hasTemplateArgumentLoc0Matcher
< NodeType, ParamT1, ParamT2>:: matches(const NodeType &
Node, ::clang::ast_matchers::internal::ASTMatchFinder *Finder
, ::clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder
) const
{
6568 return internal::MatchTemplateArgLocAt(Node, Index, InnerMatcher, Finder,
6569 Builder);
6570}
6571
6572/// Matches C or C++ elaborated `TypeLoc`s.
6573///
6574/// Given
6575/// \code
6576/// struct s {};
6577/// struct s ss;
6578/// \endcode
6579/// elaboratedTypeLoc()
6580/// matches the `TypeLoc` of the variable declaration of `ss`.
6581extern const internal::VariadicDynCastAllOfMatcher<TypeLoc, ElaboratedTypeLoc>
6582 elaboratedTypeLoc;
6583
6584/// Matches elaborated `TypeLoc`s that have a named `TypeLoc` matching
6585/// `InnerMatcher`.
6586///
6587/// Given
6588/// \code
6589/// template <typename T>
6590/// class C {};
6591/// class C<int> c;
6592///
6593/// class D {};
6594/// class D d;
6595/// \endcode
6596/// elaboratedTypeLoc(hasNamedTypeLoc(templateSpecializationTypeLoc()));
6597/// matches the `TypeLoc` of the variable declaration of `c`, but not `d`.
6598AST_MATCHER_P(ElaboratedTypeLoc, hasNamedTypeLoc, internal::Matcher<TypeLoc>,namespace internal { class matcher_hasNamedTypeLoc0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<ElaboratedTypeLoc
> { public: explicit matcher_hasNamedTypeLoc0Matcher( internal
::Matcher<TypeLoc> const &AInnerMatcher) : InnerMatcher
(AInnerMatcher) {} bool matches(const ElaboratedTypeLoc &
Node, ::clang::ast_matchers::internal::ASTMatchFinder *Finder
, ::clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder
) const override; private: internal::Matcher<TypeLoc> InnerMatcher
; }; } inline ::clang::ast_matchers::internal::Matcher<ElaboratedTypeLoc
> hasNamedTypeLoc( internal::Matcher<TypeLoc> const &
InnerMatcher) { return ::clang::ast_matchers::internal::makeMatcher
( new internal::matcher_hasNamedTypeLoc0Matcher(InnerMatcher)
); } typedef ::clang::ast_matchers::internal::Matcher<ElaboratedTypeLoc
> ( &hasNamedTypeLoc_Type0)(internal::Matcher<TypeLoc
> const &InnerMatcher); inline bool internal::matcher_hasNamedTypeLoc0Matcher
::matches( const ElaboratedTypeLoc &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
6599 InnerMatcher)namespace internal { class matcher_hasNamedTypeLoc0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<ElaboratedTypeLoc
> { public: explicit matcher_hasNamedTypeLoc0Matcher( internal
::Matcher<TypeLoc> const &AInnerMatcher) : InnerMatcher
(AInnerMatcher) {} bool matches(const ElaboratedTypeLoc &
Node, ::clang::ast_matchers::internal::ASTMatchFinder *Finder
, ::clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder
) const override; private: internal::Matcher<TypeLoc> InnerMatcher
; }; } inline ::clang::ast_matchers::internal::Matcher<ElaboratedTypeLoc
> hasNamedTypeLoc( internal::Matcher<TypeLoc> const &
InnerMatcher) { return ::clang::ast_matchers::internal::makeMatcher
( new internal::matcher_hasNamedTypeLoc0Matcher(InnerMatcher)
); } typedef ::clang::ast_matchers::internal::Matcher<ElaboratedTypeLoc
> ( &hasNamedTypeLoc_Type0)(internal::Matcher<TypeLoc
> const &InnerMatcher); inline bool internal::matcher_hasNamedTypeLoc0Matcher
::matches( const ElaboratedTypeLoc &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
{
6600 return InnerMatcher.matches(Node.getNamedTypeLoc(), Finder, Builder);
6601}
6602
6603/// Matches type \c bool.
6604///
6605/// Given
6606/// \code
6607/// struct S { bool func(); };
6608/// \endcode
6609/// functionDecl(returns(booleanType()))
6610/// matches "bool func();"
6611AST_MATCHER(Type, booleanType)namespace internal { class matcher_booleanTypeMatcher : public
::clang::ast_matchers::internal::MatcherInterface<Type>
{ public: explicit matcher_booleanTypeMatcher() = default; bool
matches(const Type &Node, ::clang::ast_matchers::internal
::ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; }; } inline ::clang::ast_matchers::
internal::Matcher<Type> booleanType() { return ::clang::
ast_matchers::internal::makeMatcher( new internal::matcher_booleanTypeMatcher
()); } inline bool internal::matcher_booleanTypeMatcher::matches
( const Type &Node, ::clang::ast_matchers::internal::ASTMatchFinder
*Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
6612 return Node.isBooleanType();
6613}
6614
6615/// Matches type \c void.
6616///
6617/// Given
6618/// \code
6619/// struct S { void func(); };
6620/// \endcode
6621/// functionDecl(returns(voidType()))
6622/// matches "void func();"
6623AST_MATCHER(Type, voidType)namespace internal { class matcher_voidTypeMatcher : public ::
clang::ast_matchers::internal::MatcherInterface<Type> {
public: explicit matcher_voidTypeMatcher() = default; bool matches
(const Type &Node, ::clang::ast_matchers::internal::ASTMatchFinder
*Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; }; } inline ::clang::ast_matchers::
internal::Matcher<Type> voidType() { return ::clang::ast_matchers
::internal::makeMatcher( new internal::matcher_voidTypeMatcher
()); } inline bool internal::matcher_voidTypeMatcher::matches
( const Type &Node, ::clang::ast_matchers::internal::ASTMatchFinder
*Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
6624 return Node.isVoidType();
6625}
6626
6627template <typename NodeType>
6628using AstTypeMatcher = internal::VariadicDynCastAllOfMatcher<Type, NodeType>;
6629
6630/// Matches builtin Types.
6631///
6632/// Given
6633/// \code
6634/// struct A {};
6635/// A a;
6636/// int b;
6637/// float c;
6638/// bool d;
6639/// \endcode
6640/// builtinType()
6641/// matches "int b", "float c" and "bool d"
6642extern const AstTypeMatcher<BuiltinType> builtinType;
6643
6644/// Matches all kinds of arrays.
6645///
6646/// Given
6647/// \code
6648/// int a[] = { 2, 3 };
6649/// int b[4];
6650/// void f() { int c[a[0]]; }
6651/// \endcode
6652/// arrayType()
6653/// matches "int a[]", "int b[4]" and "int c[a[0]]";
6654extern const AstTypeMatcher<ArrayType> arrayType;
6655
6656/// Matches C99 complex types.
6657///
6658/// Given
6659/// \code
6660/// _Complex float f;
6661/// \endcode
6662/// complexType()
6663/// matches "_Complex float f"
6664extern const AstTypeMatcher<ComplexType> complexType;
6665
6666/// Matches any real floating-point type (float, double, long double).
6667///
6668/// Given
6669/// \code
6670/// int i;
6671/// float f;
6672/// \endcode
6673/// realFloatingPointType()
6674/// matches "float f" but not "int i"
6675AST_MATCHER(Type, realFloatingPointType)namespace internal { class matcher_realFloatingPointTypeMatcher
: public ::clang::ast_matchers::internal::MatcherInterface<
Type> { public: explicit matcher_realFloatingPointTypeMatcher
() = default; bool matches(const Type &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const override; }; } inline
::clang::ast_matchers::internal::Matcher<Type> realFloatingPointType
() { return ::clang::ast_matchers::internal::makeMatcher( new
internal::matcher_realFloatingPointTypeMatcher()); } inline bool
internal::matcher_realFloatingPointTypeMatcher::matches( const
Type &Node, ::clang::ast_matchers::internal::ASTMatchFinder
*Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
6676 return Node.isRealFloatingType();
6677}
6678
6679/// Matches arrays and C99 complex types that have a specific element
6680/// type.
6681///
6682/// Given
6683/// \code
6684/// struct A {};
6685/// A a[7];
6686/// int b[7];
6687/// \endcode
6688/// arrayType(hasElementType(builtinType()))
6689/// matches "int b[7]"
6690///
6691/// Usable as: Matcher<ArrayType>, Matcher<ComplexType>
6692AST_TYPELOC_TRAVERSE_MATCHER_DECL(hasElementType, getElement,namespace internal { template <typename T> struct TypeLocMatcherhasElementTypeGetter
{ static TypeLoc (T::*value())() const { return &T::getElementLoc
; } }; } extern const ::clang::ast_matchers::internal:: TypeTraversePolymorphicMatcher
< TypeLoc, ::clang::ast_matchers::internal:: TypeLocMatcherhasElementTypeGetter
, ::clang::ast_matchers::internal::TypeLocTraverseMatcher, void
(::clang::ast_matchers::internal::TypeList<ArrayType, ComplexType
>)>::Func hasElementTypeLoc; namespace internal { template
<typename T> struct TypeMatcherhasElementTypeGetter { static
QualType (T::*value())() const { return &T::getElementType
; } }; } extern const ::clang::ast_matchers::internal:: TypeTraversePolymorphicMatcher
< QualType, ::clang::ast_matchers::internal::TypeMatcherhasElementTypeGetter
, ::clang::ast_matchers::internal::TypeTraverseMatcher, void(
::clang::ast_matchers::internal::TypeList<ArrayType, ComplexType
>)>::Func hasElementType
6693 AST_POLYMORPHIC_SUPPORTED_TYPES(ArrayType,namespace internal { template <typename T> struct TypeLocMatcherhasElementTypeGetter
{ static TypeLoc (T::*value())() const { return &T::getElementLoc
; } }; } extern const ::clang::ast_matchers::internal:: TypeTraversePolymorphicMatcher
< TypeLoc, ::clang::ast_matchers::internal:: TypeLocMatcherhasElementTypeGetter
, ::clang::ast_matchers::internal::TypeLocTraverseMatcher, void
(::clang::ast_matchers::internal::TypeList<ArrayType, ComplexType
>)>::Func hasElementTypeLoc; namespace internal { template
<typename T> struct TypeMatcherhasElementTypeGetter { static
QualType (T::*value())() const { return &T::getElementType
; } }; } extern const ::clang::ast_matchers::internal:: TypeTraversePolymorphicMatcher
< QualType, ::clang::ast_matchers::internal::TypeMatcherhasElementTypeGetter
, ::clang::ast_matchers::internal::TypeTraverseMatcher, void(
::clang::ast_matchers::internal::TypeList<ArrayType, ComplexType
>)>::Func hasElementType
6694 ComplexType))namespace internal { template <typename T> struct TypeLocMatcherhasElementTypeGetter
{ static TypeLoc (T::*value())() const { return &T::getElementLoc
; } }; } extern const ::clang::ast_matchers::internal:: TypeTraversePolymorphicMatcher
< TypeLoc, ::clang::ast_matchers::internal:: TypeLocMatcherhasElementTypeGetter
, ::clang::ast_matchers::internal::TypeLocTraverseMatcher, void
(::clang::ast_matchers::internal::TypeList<ArrayType, ComplexType
>)>::Func hasElementTypeLoc; namespace internal { template
<typename T> struct TypeMatcherhasElementTypeGetter { static
QualType (T::*value())() const { return &T::getElementType
; } }; } extern const ::clang::ast_matchers::internal:: TypeTraversePolymorphicMatcher
< QualType, ::clang::ast_matchers::internal::TypeMatcherhasElementTypeGetter
, ::clang::ast_matchers::internal::TypeTraverseMatcher, void(
::clang::ast_matchers::internal::TypeList<ArrayType, ComplexType
>)>::Func hasElementType
;
6695
6696/// Matches C arrays with a specified constant size.
6697///
6698/// Given
6699/// \code
6700/// void() {
6701/// int a[2];
6702/// int b[] = { 2, 3 };
6703/// int c[b[0]];
6704/// }
6705/// \endcode
6706/// constantArrayType()
6707/// matches "int a[2]"
6708extern const AstTypeMatcher<ConstantArrayType> constantArrayType;
6709
6710/// Matches nodes that have the specified size.
6711///
6712/// Given
6713/// \code
6714/// int a[42];
6715/// int b[2 * 21];
6716/// int c[41], d[43];
6717/// char *s = "abcd";
6718/// wchar_t *ws = L"abcd";
6719/// char *w = "a";
6720/// \endcode
6721/// constantArrayType(hasSize(42))
6722/// matches "int a[42]" and "int b[2 * 21]"
6723/// stringLiteral(hasSize(4))
6724/// matches "abcd", L"abcd"
6725AST_POLYMORPHIC_MATCHER_P(hasSize,namespace internal { template <typename NodeType, typename
ParamT> class matcher_hasSize0Matcher : public ::clang::ast_matchers
::internal::MatcherInterface<NodeType> { public: explicit
matcher_hasSize0Matcher( 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_hasSize0Matcher, void(::clang::ast_matchers::internal
::TypeList<ConstantArrayType, StringLiteral>), unsigned
> hasSize(unsigned const &N) { return ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_hasSize0Matcher
, void(::clang::ast_matchers::internal::TypeList<ConstantArrayType
, StringLiteral>), unsigned>(N); } typedef ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_hasSize0Matcher
, void(::clang::ast_matchers::internal::TypeList<ConstantArrayType
, StringLiteral>), unsigned> (&hasSize_Type0)(unsigned
const &N); template <typename NodeType, typename ParamT
> bool internal:: matcher_hasSize0Matcher<NodeType, ParamT
>::matches( const NodeType &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
6726 AST_POLYMORPHIC_SUPPORTED_TYPES(ConstantArrayType,namespace internal { template <typename NodeType, typename
ParamT> class matcher_hasSize0Matcher : public ::clang::ast_matchers
::internal::MatcherInterface<NodeType> { public: explicit
matcher_hasSize0Matcher( 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_hasSize0Matcher, void(::clang::ast_matchers::internal
::TypeList<ConstantArrayType, StringLiteral>), unsigned
> hasSize(unsigned const &N) { return ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_hasSize0Matcher
, void(::clang::ast_matchers::internal::TypeList<ConstantArrayType
, StringLiteral>), unsigned>(N); } typedef ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_hasSize0Matcher
, void(::clang::ast_matchers::internal::TypeList<ConstantArrayType
, StringLiteral>), unsigned> (&hasSize_Type0)(unsigned
const &N); template <typename NodeType, typename ParamT
> bool internal:: matcher_hasSize0Matcher<NodeType, ParamT
>::matches( const NodeType &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
6727 StringLiteral),namespace internal { template <typename NodeType, typename
ParamT> class matcher_hasSize0Matcher : public ::clang::ast_matchers
::internal::MatcherInterface<NodeType> { public: explicit
matcher_hasSize0Matcher( 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_hasSize0Matcher, void(::clang::ast_matchers::internal
::TypeList<ConstantArrayType, StringLiteral>), unsigned
> hasSize(unsigned const &N) { return ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_hasSize0Matcher
, void(::clang::ast_matchers::internal::TypeList<ConstantArrayType
, StringLiteral>), unsigned>(N); } typedef ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_hasSize0Matcher
, void(::clang::ast_matchers::internal::TypeList<ConstantArrayType
, StringLiteral>), unsigned> (&hasSize_Type0)(unsigned
const &N); template <typename NodeType, typename ParamT
> bool internal:: matcher_hasSize0Matcher<NodeType, ParamT
>::matches( const NodeType &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
6728 unsigned, N)namespace internal { template <typename NodeType, typename
ParamT> class matcher_hasSize0Matcher : public ::clang::ast_matchers
::internal::MatcherInterface<NodeType> { public: explicit
matcher_hasSize0Matcher( 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_hasSize0Matcher, void(::clang::ast_matchers::internal
::TypeList<ConstantArrayType, StringLiteral>), unsigned
> hasSize(unsigned const &N) { return ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_hasSize0Matcher
, void(::clang::ast_matchers::internal::TypeList<ConstantArrayType
, StringLiteral>), unsigned>(N); } typedef ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_hasSize0Matcher
, void(::clang::ast_matchers::internal::TypeList<ConstantArrayType
, StringLiteral>), unsigned> (&hasSize_Type0)(unsigned
const &N); template <typename NodeType, typename ParamT
> bool internal:: matcher_hasSize0Matcher<NodeType, ParamT
>::matches( const NodeType &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
{
6729 return internal::HasSizeMatcher<NodeType>::hasSize(Node, N);
6730}
6731
6732/// Matches C++ arrays whose size is a value-dependent expression.
6733///
6734/// Given
6735/// \code
6736/// template<typename T, int Size>
6737/// class array {
6738/// T data[Size];
6739/// };
6740/// \endcode
6741/// dependentSizedArrayType
6742/// matches "T data[Size]"
6743extern const AstTypeMatcher<DependentSizedArrayType> dependentSizedArrayType;
6744
6745/// Matches C arrays with unspecified size.
6746///
6747/// Given
6748/// \code
6749/// int a[] = { 2, 3 };
6750/// int b[42];
6751/// void f(int c[]) { int d[a[0]]; };
6752/// \endcode
6753/// incompleteArrayType()
6754/// matches "int a[]" and "int c[]"
6755extern const AstTypeMatcher<IncompleteArrayType> incompleteArrayType;
6756
6757/// Matches C arrays with a specified size that is not an
6758/// integer-constant-expression.
6759///
6760/// Given
6761/// \code
6762/// void f() {
6763/// int a[] = { 2, 3 }
6764/// int b[42];
6765/// int c[a[0]];
6766/// }
6767/// \endcode
6768/// variableArrayType()
6769/// matches "int c[a[0]]"
6770extern const AstTypeMatcher<VariableArrayType> variableArrayType;
6771
6772/// Matches \c VariableArrayType nodes that have a specific size
6773/// expression.
6774///
6775/// Given
6776/// \code
6777/// void f(int b) {
6778/// int a[b];
6779/// }
6780/// \endcode
6781/// variableArrayType(hasSizeExpr(ignoringImpCasts(declRefExpr(to(
6782/// varDecl(hasName("b")))))))
6783/// matches "int a[b]"
6784AST_MATCHER_P(VariableArrayType, hasSizeExpr,namespace internal { class matcher_hasSizeExpr0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<VariableArrayType
> { public: explicit matcher_hasSizeExpr0Matcher( internal
::Matcher<Expr> const &AInnerMatcher) : InnerMatcher
(AInnerMatcher) {} bool matches(const VariableArrayType &
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<VariableArrayType
> hasSizeExpr( internal::Matcher<Expr> const &InnerMatcher
) { return ::clang::ast_matchers::internal::makeMatcher( new internal
::matcher_hasSizeExpr0Matcher(InnerMatcher)); } typedef ::clang
::ast_matchers::internal::Matcher<VariableArrayType> ( &
hasSizeExpr_Type0)(internal::Matcher<Expr> const &InnerMatcher
); inline bool internal::matcher_hasSizeExpr0Matcher::matches
( const VariableArrayType &Node, ::clang::ast_matchers::internal
::ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
6785 internal::Matcher<Expr>, InnerMatcher)namespace internal { class matcher_hasSizeExpr0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<VariableArrayType
> { public: explicit matcher_hasSizeExpr0Matcher( internal
::Matcher<Expr> const &AInnerMatcher) : InnerMatcher
(AInnerMatcher) {} bool matches(const VariableArrayType &
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<VariableArrayType
> hasSizeExpr( internal::Matcher<Expr> const &InnerMatcher
) { return ::clang::ast_matchers::internal::makeMatcher( new internal
::matcher_hasSizeExpr0Matcher(InnerMatcher)); } typedef ::clang
::ast_matchers::internal::Matcher<VariableArrayType> ( &
hasSizeExpr_Type0)(internal::Matcher<Expr> const &InnerMatcher
); inline bool internal::matcher_hasSizeExpr0Matcher::matches
( const VariableArrayType &Node, ::clang::ast_matchers::internal
::ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
6786 return InnerMatcher.matches(*Node.getSizeExpr(), Finder, Builder);
6787}
6788
6789/// Matches atomic types.
6790///
6791/// Given
6792/// \code
6793/// _Atomic(int) i;
6794/// \endcode
6795/// atomicType()
6796/// matches "_Atomic(int) i"
6797extern const AstTypeMatcher<AtomicType> atomicType;
6798
6799/// Matches atomic types with a specific value type.
6800///
6801/// Given
6802/// \code
6803/// _Atomic(int) i;
6804/// _Atomic(float) f;
6805/// \endcode
6806/// atomicType(hasValueType(isInteger()))
6807/// matches "_Atomic(int) i"
6808///
6809/// Usable as: Matcher<AtomicType>
6810AST_TYPELOC_TRAVERSE_MATCHER_DECL(hasValueType, getValue,namespace internal { template <typename T> struct TypeLocMatcherhasValueTypeGetter
{ static TypeLoc (T::*value())() const { return &T::getValueLoc
; } }; } extern const ::clang::ast_matchers::internal:: TypeTraversePolymorphicMatcher
< TypeLoc, ::clang::ast_matchers::internal:: TypeLocMatcherhasValueTypeGetter
, ::clang::ast_matchers::internal::TypeLocTraverseMatcher, void
(::clang::ast_matchers::internal::TypeList<AtomicType>)
>::Func hasValueTypeLoc; namespace internal { template <
typename T> struct TypeMatcherhasValueTypeGetter { static QualType
(T::*value())() const { return &T::getValueType; } }; } extern
const ::clang::ast_matchers::internal:: TypeTraversePolymorphicMatcher
< QualType, ::clang::ast_matchers::internal::TypeMatcherhasValueTypeGetter
, ::clang::ast_matchers::internal::TypeTraverseMatcher, void(
::clang::ast_matchers::internal::TypeList<AtomicType>)>
::Func hasValueType
6811 AST_POLYMORPHIC_SUPPORTED_TYPES(AtomicType))namespace internal { template <typename T> struct TypeLocMatcherhasValueTypeGetter
{ static TypeLoc (T::*value())() const { return &T::getValueLoc
; } }; } extern const ::clang::ast_matchers::internal:: TypeTraversePolymorphicMatcher
< TypeLoc, ::clang::ast_matchers::internal:: TypeLocMatcherhasValueTypeGetter
, ::clang::ast_matchers::internal::TypeLocTraverseMatcher, void
(::clang::ast_matchers::internal::TypeList<AtomicType>)
>::Func hasValueTypeLoc; namespace internal { template <
typename T> struct TypeMatcherhasValueTypeGetter { static QualType
(T::*value())() const { return &T::getValueType; } }; } extern
const ::clang::ast_matchers::internal:: TypeTraversePolymorphicMatcher
< QualType, ::clang::ast_matchers::internal::TypeMatcherhasValueTypeGetter
, ::clang::ast_matchers::internal::TypeTraverseMatcher, void(
::clang::ast_matchers::internal::TypeList<AtomicType>)>
::Func hasValueType
;
6812
6813/// Matches types nodes representing C++11 auto types.
6814///
6815/// Given:
6816/// \code
6817/// auto n = 4;
6818/// int v[] = { 2, 3 }
6819/// for (auto i : v) { }
6820/// \endcode
6821/// autoType()
6822/// matches "auto n" and "auto i"
6823extern const AstTypeMatcher<AutoType> autoType;
6824
6825/// Matches types nodes representing C++11 decltype(<expr>) types.
6826///
6827/// Given:
6828/// \code
6829/// short i = 1;
6830/// int j = 42;
6831/// decltype(i + j) result = i + j;
6832/// \endcode
6833/// decltypeType()
6834/// matches "decltype(i + j)"
6835extern const AstTypeMatcher<DecltypeType> decltypeType;
6836
6837/// Matches \c AutoType nodes where the deduced type is a specific type.
6838///
6839/// Note: There is no \c TypeLoc for the deduced type and thus no
6840/// \c getDeducedLoc() matcher.
6841///
6842/// Given
6843/// \code
6844/// auto a = 1;
6845/// auto b = 2.0;
6846/// \endcode
6847/// autoType(hasDeducedType(isInteger()))
6848/// matches "auto a"
6849///
6850/// Usable as: Matcher<AutoType>
6851AST_TYPE_TRAVERSE_MATCHER(hasDeducedType, getDeducedType,namespace internal { template <typename T> struct TypeMatcherhasDeducedTypeGetter
{ static QualType (T::*value())() const { return &T::getDeducedType
; } }; } const ::clang::ast_matchers::internal::TypeTraversePolymorphicMatcher
< QualType, ::clang::ast_matchers::internal::TypeMatcherhasDeducedTypeGetter
, ::clang::ast_matchers::internal::TypeTraverseMatcher, void(
::clang::ast_matchers::internal::TypeList<AutoType>)>
::Func hasDeducedType
6852 AST_POLYMORPHIC_SUPPORTED_TYPES(AutoType))namespace internal { template <typename T> struct TypeMatcherhasDeducedTypeGetter
{ static QualType (T::*value())() const { return &T::getDeducedType
; } }; } const ::clang::ast_matchers::internal::TypeTraversePolymorphicMatcher
< QualType, ::clang::ast_matchers::internal::TypeMatcherhasDeducedTypeGetter
, ::clang::ast_matchers::internal::TypeTraverseMatcher, void(
::clang::ast_matchers::internal::TypeList<AutoType>)>
::Func hasDeducedType
;
6853
6854/// Matches \c DecltypeType or \c UsingType nodes to find the underlying type.
6855///
6856/// Given
6857/// \code
6858/// decltype(1) a = 1;
6859/// decltype(2.0) b = 2.0;
6860/// \endcode
6861/// decltypeType(hasUnderlyingType(isInteger()))
6862/// matches the type of "a"
6863///
6864/// Usable as: Matcher<DecltypeType>, Matcher<UsingType>
6865AST_TYPE_TRAVERSE_MATCHER(hasUnderlyingType, getUnderlyingType,namespace internal { template <typename T> struct TypeMatcherhasUnderlyingTypeGetter
{ static QualType (T::*value())() const { return &T::getUnderlyingType
; } }; } const ::clang::ast_matchers::internal::TypeTraversePolymorphicMatcher
< QualType, ::clang::ast_matchers::internal::TypeMatcherhasUnderlyingTypeGetter
, ::clang::ast_matchers::internal::TypeTraverseMatcher, void(
::clang::ast_matchers::internal::TypeList<DecltypeType, UsingType
>)>::Func hasUnderlyingType
6866 AST_POLYMORPHIC_SUPPORTED_TYPES(DecltypeType,namespace internal { template <typename T> struct TypeMatcherhasUnderlyingTypeGetter
{ static QualType (T::*value())() const { return &T::getUnderlyingType
; } }; } const ::clang::ast_matchers::internal::TypeTraversePolymorphicMatcher
< QualType, ::clang::ast_matchers::internal::TypeMatcherhasUnderlyingTypeGetter
, ::clang::ast_matchers::internal::TypeTraverseMatcher, void(
::clang::ast_matchers::internal::TypeList<DecltypeType, UsingType
>)>::Func hasUnderlyingType
6867 UsingType))namespace internal { template <typename T> struct TypeMatcherhasUnderlyingTypeGetter
{ static QualType (T::*value())() const { return &T::getUnderlyingType
; } }; } const ::clang::ast_matchers::internal::TypeTraversePolymorphicMatcher
< QualType, ::clang::ast_matchers::internal::TypeMatcherhasUnderlyingTypeGetter
, ::clang::ast_matchers::internal::TypeTraverseMatcher, void(
::clang::ast_matchers::internal::TypeList<DecltypeType, UsingType
>)>::Func hasUnderlyingType
;
6868
6869/// Matches \c FunctionType nodes.
6870///
6871/// Given
6872/// \code
6873/// int (*f)(int);
6874/// void g();
6875/// \endcode
6876/// functionType()
6877/// matches "int (*f)(int)" and the type of "g".
6878extern const AstTypeMatcher<FunctionType> functionType;
6879
6880/// Matches \c FunctionProtoType nodes.
6881///
6882/// Given
6883/// \code
6884/// int (*f)(int);
6885/// void g();
6886/// \endcode
6887/// functionProtoType()
6888/// matches "int (*f)(int)" and the type of "g" in C++ mode.
6889/// In C mode, "g" is not matched because it does not contain a prototype.
6890extern const AstTypeMatcher<FunctionProtoType> functionProtoType;
6891
6892/// Matches \c ParenType nodes.
6893///
6894/// Given
6895/// \code
6896/// int (*ptr_to_array)[4];
6897/// int *array_of_ptrs[4];
6898/// \endcode
6899///
6900/// \c varDecl(hasType(pointsTo(parenType()))) matches \c ptr_to_array but not
6901/// \c array_of_ptrs.
6902extern const AstTypeMatcher<ParenType> parenType;
6903
6904/// Matches \c ParenType nodes where the inner type is a specific type.
6905///
6906/// Given
6907/// \code
6908/// int (*ptr_to_array)[4];
6909/// int (*ptr_to_func)(int);
6910/// \endcode
6911///
6912/// \c varDecl(hasType(pointsTo(parenType(innerType(functionType()))))) matches
6913/// \c ptr_to_func but not \c ptr_to_array.
6914///
6915/// Usable as: Matcher<ParenType>
6916AST_TYPE_TRAVERSE_MATCHER(innerType, getInnerType,namespace internal { template <typename T> struct TypeMatcherinnerTypeGetter
{ static QualType (T::*value())() const { return &T::getInnerType
; } }; } const ::clang::ast_matchers::internal::TypeTraversePolymorphicMatcher
< QualType, ::clang::ast_matchers::internal::TypeMatcherinnerTypeGetter
, ::clang::ast_matchers::internal::TypeTraverseMatcher, void(
::clang::ast_matchers::internal::TypeList<ParenType>)>
::Func innerType
6917 AST_POLYMORPHIC_SUPPORTED_TYPES(ParenType))namespace internal { template <typename T> struct TypeMatcherinnerTypeGetter
{ static QualType (T::*value())() const { return &T::getInnerType
; } }; } const ::clang::ast_matchers::internal::TypeTraversePolymorphicMatcher
< QualType, ::clang::ast_matchers::internal::TypeMatcherinnerTypeGetter
, ::clang::ast_matchers::internal::TypeTraverseMatcher, void(
::clang::ast_matchers::internal::TypeList<ParenType>)>
::Func innerType
;
6918
6919/// Matches block pointer types, i.e. types syntactically represented as
6920/// "void (^)(int)".
6921///
6922/// The \c pointee is always required to be a \c FunctionType.
6923extern const AstTypeMatcher<BlockPointerType> blockPointerType;
6924
6925/// Matches member pointer types.
6926/// Given
6927/// \code
6928/// struct A { int i; }
6929/// A::* ptr = A::i;
6930/// \endcode
6931/// memberPointerType()
6932/// matches "A::* ptr"
6933extern const AstTypeMatcher<MemberPointerType> memberPointerType;
6934
6935/// Matches pointer types, but does not match Objective-C object pointer
6936/// types.
6937///
6938/// Given
6939/// \code
6940/// int *a;
6941/// int &b = *a;
6942/// int c = 5;
6943///
6944/// @interface Foo
6945/// @end
6946/// Foo *f;
6947/// \endcode
6948/// pointerType()
6949/// matches "int *a", but does not match "Foo *f".
6950extern const AstTypeMatcher<PointerType> pointerType;
6951
6952/// Matches an Objective-C object pointer type, which is different from
6953/// a pointer type, despite being syntactically similar.
6954///
6955/// Given
6956/// \code
6957/// int *a;
6958///
6959/// @interface Foo
6960/// @end
6961/// Foo *f;
6962/// \endcode
6963/// pointerType()
6964/// matches "Foo *f", but does not match "int *a".
6965extern const AstTypeMatcher<ObjCObjectPointerType> objcObjectPointerType;
6966
6967/// Matches both lvalue and rvalue reference types.
6968///
6969/// Given
6970/// \code
6971/// int *a;
6972/// int &b = *a;
6973/// int &&c = 1;
6974/// auto &d = b;
6975/// auto &&e = c;
6976/// auto &&f = 2;
6977/// int g = 5;
6978/// \endcode
6979///
6980/// \c referenceType() matches the types of \c b, \c c, \c d, \c e, and \c f.
6981extern const AstTypeMatcher<ReferenceType> referenceType;
6982
6983/// Matches lvalue reference types.
6984///
6985/// Given:
6986/// \code
6987/// int *a;
6988/// int &b = *a;
6989/// int &&c = 1;
6990/// auto &d = b;
6991/// auto &&e = c;
6992/// auto &&f = 2;
6993/// int g = 5;
6994/// \endcode
6995///
6996/// \c lValueReferenceType() matches the types of \c b, \c d, and \c e. \c e is
6997/// matched since the type is deduced as int& by reference collapsing rules.
6998extern const AstTypeMatcher<LValueReferenceType> lValueReferenceType;
6999
7000/// Matches rvalue reference types.
7001///
7002/// Given:
7003/// \code
7004/// int *a;
7005/// int &b = *a;
7006/// int &&c = 1;
7007/// auto &d = b;
7008/// auto &&e = c;
7009/// auto &&f = 2;
7010/// int g = 5;
7011/// \endcode
7012///
7013/// \c rValueReferenceType() matches the types of \c c and \c f. \c e is not
7014/// matched as it is deduced to int& by reference collapsing rules.
7015extern const AstTypeMatcher<RValueReferenceType> rValueReferenceType;
7016
7017/// Narrows PointerType (and similar) matchers to those where the
7018/// \c pointee matches a given matcher.
7019///
7020/// Given
7021/// \code
7022/// int *a;
7023/// int const *b;
7024/// float const *f;
7025/// \endcode
7026/// pointerType(pointee(isConstQualified(), isInteger()))
7027/// matches "int const *b"
7028///
7029/// Usable as: Matcher<BlockPointerType>, Matcher<MemberPointerType>,
7030/// Matcher<PointerType>, Matcher<ReferenceType>
7031AST_TYPELOC_TRAVERSE_MATCHER_DECL(namespace internal { template <typename T> struct TypeLocMatcherpointeeGetter
{ static TypeLoc (T::*value())() const { return &T::getPointeeLoc
; } }; } extern const ::clang::ast_matchers::internal:: TypeTraversePolymorphicMatcher
< TypeLoc, ::clang::ast_matchers::internal:: TypeLocMatcherpointeeGetter
, ::clang::ast_matchers::internal::TypeLocTraverseMatcher, void
(::clang::ast_matchers::internal::TypeList<BlockPointerType
, MemberPointerType, PointerType, ReferenceType>)>::Func
pointeeLoc; namespace internal { template <typename T>
struct TypeMatcherpointeeGetter { static QualType (T::*value
())() const { return &T::getPointeeType; } }; } extern const
::clang::ast_matchers::internal:: TypeTraversePolymorphicMatcher
< QualType, ::clang::ast_matchers::internal::TypeMatcherpointeeGetter
, ::clang::ast_matchers::internal::TypeTraverseMatcher, void(
::clang::ast_matchers::internal::TypeList<BlockPointerType
, MemberPointerType, PointerType, ReferenceType>)>::Func
pointee
7032 pointee, getPointee,namespace internal { template <typename T> struct TypeLocMatcherpointeeGetter
{ static TypeLoc (T::*value())() const { return &T::getPointeeLoc
; } }; } extern const ::clang::ast_matchers::internal:: TypeTraversePolymorphicMatcher
< TypeLoc, ::clang::ast_matchers::internal:: TypeLocMatcherpointeeGetter
, ::clang::ast_matchers::internal::TypeLocTraverseMatcher, void
(::clang::ast_matchers::internal::TypeList<BlockPointerType
, MemberPointerType, PointerType, ReferenceType>)>::Func
pointeeLoc; namespace internal { template <typename T>
struct TypeMatcherpointeeGetter { static QualType (T::*value
())() const { return &T::getPointeeType; } }; } extern const
::clang::ast_matchers::internal:: TypeTraversePolymorphicMatcher
< QualType, ::clang::ast_matchers::internal::TypeMatcherpointeeGetter
, ::clang::ast_matchers::internal::TypeTraverseMatcher, void(
::clang::ast_matchers::internal::TypeList<BlockPointerType
, MemberPointerType, PointerType, ReferenceType>)>::Func
pointee
7033 AST_POLYMORPHIC_SUPPORTED_TYPES(BlockPointerType, MemberPointerType,namespace internal { template <typename T> struct TypeLocMatcherpointeeGetter
{ static TypeLoc (T::*value())() const { return &T::getPointeeLoc
; } }; } extern const ::clang::ast_matchers::internal:: TypeTraversePolymorphicMatcher
< TypeLoc, ::clang::ast_matchers::internal:: TypeLocMatcherpointeeGetter
, ::clang::ast_matchers::internal::TypeLocTraverseMatcher, void
(::clang::ast_matchers::internal::TypeList<BlockPointerType
, MemberPointerType, PointerType, ReferenceType>)>::Func
pointeeLoc; namespace internal { template <typename T>
struct TypeMatcherpointeeGetter { static QualType (T::*value
())() const { return &T::getPointeeType; } }; } extern const
::clang::ast_matchers::internal:: TypeTraversePolymorphicMatcher
< QualType, ::clang::ast_matchers::internal::TypeMatcherpointeeGetter
, ::clang::ast_matchers::internal::TypeTraverseMatcher, void(
::clang::ast_matchers::internal::TypeList<BlockPointerType
, MemberPointerType, PointerType, ReferenceType>)>::Func
pointee
7034 PointerType, ReferenceType))namespace internal { template <typename T> struct TypeLocMatcherpointeeGetter
{ static TypeLoc (T::*value())() const { return &T::getPointeeLoc
; } }; } extern const ::clang::ast_matchers::internal:: TypeTraversePolymorphicMatcher
< TypeLoc, ::clang::ast_matchers::internal:: TypeLocMatcherpointeeGetter
, ::clang::ast_matchers::internal::TypeLocTraverseMatcher, void
(::clang::ast_matchers::internal::TypeList<BlockPointerType
, MemberPointerType, PointerType, ReferenceType>)>::Func
pointeeLoc; namespace internal { template <typename T>
struct TypeMatcherpointeeGetter { static QualType (T::*value
())() const { return &T::getPointeeType; } }; } extern const
::clang::ast_matchers::internal:: TypeTraversePolymorphicMatcher
< QualType, ::clang::ast_matchers::internal::TypeMatcherpointeeGetter
, ::clang::ast_matchers::internal::TypeTraverseMatcher, void(
::clang::ast_matchers::internal::TypeList<BlockPointerType
, MemberPointerType, PointerType, ReferenceType>)>::Func
pointee
;
7035
7036/// Matches typedef types.
7037///
7038/// Given
7039/// \code
7040/// typedef int X;
7041/// \endcode
7042/// typedefType()
7043/// matches "typedef int X"
7044extern const AstTypeMatcher<TypedefType> typedefType;
7045
7046/// Matches enum types.
7047///
7048/// Given
7049/// \code
7050/// enum C { Green };
7051/// enum class S { Red };
7052///
7053/// C c;
7054/// S s;
7055/// \endcode
7056//
7057/// \c enumType() matches the type of the variable declarations of both \c c and
7058/// \c s.
7059extern const AstTypeMatcher<EnumType> enumType;
7060
7061/// Matches template specialization types.
7062///
7063/// Given
7064/// \code
7065/// template <typename T>
7066/// class C { };
7067///
7068/// template class C<int>; // A
7069/// C<char> var; // B
7070/// \endcode
7071///
7072/// \c templateSpecializationType() matches the type of the explicit
7073/// instantiation in \c A and the type of the variable declaration in \c B.
7074extern const AstTypeMatcher<TemplateSpecializationType>
7075 templateSpecializationType;
7076
7077/// Matches C++17 deduced template specialization types, e.g. deduced class
7078/// template types.
7079///
7080/// Given
7081/// \code
7082/// template <typename T>
7083/// class C { public: C(T); };
7084///
7085/// C c(123);
7086/// \endcode
7087/// \c deducedTemplateSpecializationType() matches the type in the declaration
7088/// of the variable \c c.
7089extern const AstTypeMatcher<DeducedTemplateSpecializationType>
7090 deducedTemplateSpecializationType;
7091
7092/// Matches types nodes representing unary type transformations.
7093///
7094/// Given:
7095/// \code
7096/// typedef __underlying_type(T) type;
7097/// \endcode
7098/// unaryTransformType()
7099/// matches "__underlying_type(T)"
7100extern const AstTypeMatcher<UnaryTransformType> unaryTransformType;
7101
7102/// Matches record types (e.g. structs, classes).
7103///
7104/// Given
7105/// \code
7106/// class C {};
7107/// struct S {};
7108///
7109/// C c;
7110/// S s;
7111/// \endcode
7112///
7113/// \c recordType() matches the type of the variable declarations of both \c c
7114/// and \c s.
7115extern const AstTypeMatcher<RecordType> recordType;
7116
7117/// Matches tag types (record and enum types).
7118///
7119/// Given
7120/// \code
7121/// enum E {};
7122/// class C {};
7123///
7124/// E e;
7125/// C c;
7126/// \endcode
7127///
7128/// \c tagType() matches the type of the variable declarations of both \c e
7129/// and \c c.
7130extern const AstTypeMatcher<TagType> tagType;
7131
7132/// Matches types specified with an elaborated type keyword or with a
7133/// qualified name.
7134///
7135/// Given
7136/// \code
7137/// namespace N {
7138/// namespace M {
7139/// class D {};
7140/// }
7141/// }
7142/// class C {};
7143///
7144/// class C c;
7145/// N::M::D d;
7146/// \endcode
7147///
7148/// \c elaboratedType() matches the type of the variable declarations of both
7149/// \c c and \c d.
7150extern const AstTypeMatcher<ElaboratedType> elaboratedType;
7151
7152/// Matches ElaboratedTypes whose qualifier, a NestedNameSpecifier,
7153/// matches \c InnerMatcher if the qualifier exists.
7154///
7155/// Given
7156/// \code
7157/// namespace N {
7158/// namespace M {
7159/// class D {};
7160/// }
7161/// }
7162/// N::M::D d;
7163/// \endcode
7164///
7165/// \c elaboratedType(hasQualifier(hasPrefix(specifiesNamespace(hasName("N"))))
7166/// matches the type of the variable declaration of \c d.
7167AST_MATCHER_P(ElaboratedType, hasQualifier,namespace internal { class matcher_hasQualifier0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<ElaboratedType
> { public: explicit matcher_hasQualifier0Matcher( internal
::Matcher<NestedNameSpecifier> const &AInnerMatcher
) : InnerMatcher(AInnerMatcher) {} bool matches(const ElaboratedType
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: internal::Matcher<NestedNameSpecifier
> InnerMatcher; }; } inline ::clang::ast_matchers::internal
::Matcher<ElaboratedType> hasQualifier( internal::Matcher
<NestedNameSpecifier> const &InnerMatcher) { return
::clang::ast_matchers::internal::makeMatcher( new internal::
matcher_hasQualifier0Matcher(InnerMatcher)); } typedef ::clang
::ast_matchers::internal::Matcher<ElaboratedType> ( &
hasQualifier_Type0)(internal::Matcher<NestedNameSpecifier>
const &InnerMatcher); inline bool internal::matcher_hasQualifier0Matcher
::matches( const ElaboratedType &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
7168 internal::Matcher<NestedNameSpecifier>, InnerMatcher)namespace internal { class matcher_hasQualifier0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<ElaboratedType
> { public: explicit matcher_hasQualifier0Matcher( internal
::Matcher<NestedNameSpecifier> const &AInnerMatcher
) : InnerMatcher(AInnerMatcher) {} bool matches(const ElaboratedType
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: internal::Matcher<NestedNameSpecifier
> InnerMatcher; }; } inline ::clang::ast_matchers::internal
::Matcher<ElaboratedType> hasQualifier( internal::Matcher
<NestedNameSpecifier> const &InnerMatcher) { return
::clang::ast_matchers::internal::makeMatcher( new internal::
matcher_hasQualifier0Matcher(InnerMatcher)); } typedef ::clang
::ast_matchers::internal::Matcher<ElaboratedType> ( &
hasQualifier_Type0)(internal::Matcher<NestedNameSpecifier>
const &InnerMatcher); inline bool internal::matcher_hasQualifier0Matcher
::matches( const ElaboratedType &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
{
7169 if (const NestedNameSpecifier *Qualifier = Node.getQualifier())
7170 return InnerMatcher.matches(*Qualifier, Finder, Builder);
7171
7172 return false;
7173}
7174
7175/// Matches ElaboratedTypes whose named type matches \c InnerMatcher.
7176///
7177/// Given
7178/// \code
7179/// namespace N {
7180/// namespace M {
7181/// class D {};
7182/// }
7183/// }
7184/// N::M::D d;
7185/// \endcode
7186///
7187/// \c elaboratedType(namesType(recordType(
7188/// hasDeclaration(namedDecl(hasName("D")))))) matches the type of the variable
7189/// declaration of \c d.
7190AST_MATCHER_P(ElaboratedType, namesType, internal::Matcher<QualType>,namespace internal { class matcher_namesType0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<ElaboratedType
> { public: explicit matcher_namesType0Matcher( internal::
Matcher<QualType> const &AInnerMatcher) : InnerMatcher
(AInnerMatcher) {} bool matches(const ElaboratedType &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<ElaboratedType
> namesType( internal::Matcher<QualType> const &
InnerMatcher) { return ::clang::ast_matchers::internal::makeMatcher
( new internal::matcher_namesType0Matcher(InnerMatcher)); } typedef
::clang::ast_matchers::internal::Matcher<ElaboratedType>
( &namesType_Type0)(internal::Matcher<QualType> const
&InnerMatcher); inline bool internal::matcher_namesType0Matcher
::matches( const ElaboratedType &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
7191 InnerMatcher)namespace internal { class matcher_namesType0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<ElaboratedType
> { public: explicit matcher_namesType0Matcher( internal::
Matcher<QualType> const &AInnerMatcher) : InnerMatcher
(AInnerMatcher) {} bool matches(const ElaboratedType &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<ElaboratedType
> namesType( internal::Matcher<QualType> const &
InnerMatcher) { return ::clang::ast_matchers::internal::makeMatcher
( new internal::matcher_namesType0Matcher(InnerMatcher)); } typedef
::clang::ast_matchers::internal::Matcher<ElaboratedType>
( &namesType_Type0)(internal::Matcher<QualType> const
&InnerMatcher); inline bool internal::matcher_namesType0Matcher
::matches( const ElaboratedType &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
{
7192 return InnerMatcher.matches(Node.getNamedType(), Finder, Builder);
7193}
7194
7195/// Matches types specified through a using declaration.
7196///
7197/// Given
7198/// \code
7199/// namespace a { struct S {}; }
7200/// using a::S;
7201/// S s;
7202/// \endcode
7203///
7204/// \c usingType() matches the type of the variable declaration of \c s.
7205extern const AstTypeMatcher<UsingType> usingType;
7206
7207/// Matches types that represent the result of substituting a type for a
7208/// template type parameter.
7209///
7210/// Given
7211/// \code
7212/// template <typename T>
7213/// void F(T t) {
7214/// int i = 1 + t;
7215/// }
7216/// \endcode
7217///
7218/// \c substTemplateTypeParmType() matches the type of 't' but not '1'
7219extern const AstTypeMatcher<SubstTemplateTypeParmType>
7220 substTemplateTypeParmType;
7221
7222/// Matches template type parameter substitutions that have a replacement
7223/// type that matches the provided matcher.
7224///
7225/// Given
7226/// \code
7227/// template <typename T>
7228/// double F(T t);
7229/// int i;
7230/// double j = F(i);
7231/// \endcode
7232///
7233/// \c substTemplateTypeParmType(hasReplacementType(type())) matches int
7234AST_TYPE_TRAVERSE_MATCHER(namespace internal { template <typename T> struct TypeMatcherhasReplacementTypeGetter
{ static QualType (T::*value())() const { return &T::getReplacementType
; } }; } const ::clang::ast_matchers::internal::TypeTraversePolymorphicMatcher
< QualType, ::clang::ast_matchers::internal::TypeMatcherhasReplacementTypeGetter
, ::clang::ast_matchers::internal::TypeTraverseMatcher, void(
::clang::ast_matchers::internal::TypeList<SubstTemplateTypeParmType
>)>::Func hasReplacementType
7235 hasReplacementType, getReplacementType,namespace internal { template <typename T> struct TypeMatcherhasReplacementTypeGetter
{ static QualType (T::*value())() const { return &T::getReplacementType
; } }; } const ::clang::ast_matchers::internal::TypeTraversePolymorphicMatcher
< QualType, ::clang::ast_matchers::internal::TypeMatcherhasReplacementTypeGetter
, ::clang::ast_matchers::internal::TypeTraverseMatcher, void(
::clang::ast_matchers::internal::TypeList<SubstTemplateTypeParmType
>)>::Func hasReplacementType
7236 AST_POLYMORPHIC_SUPPORTED_TYPES(SubstTemplateTypeParmType))namespace internal { template <typename T> struct TypeMatcherhasReplacementTypeGetter
{ static QualType (T::*value())() const { return &T::getReplacementType
; } }; } const ::clang::ast_matchers::internal::TypeTraversePolymorphicMatcher
< QualType, ::clang::ast_matchers::internal::TypeMatcherhasReplacementTypeGetter
, ::clang::ast_matchers::internal::TypeTraverseMatcher, void(
::clang::ast_matchers::internal::TypeList<SubstTemplateTypeParmType
>)>::Func hasReplacementType
;
7237
7238/// Matches template type parameter types.
7239///
7240/// Example matches T, but not int.
7241/// (matcher = templateTypeParmType())
7242/// \code
7243/// template <typename T> void f(int i);
7244/// \endcode
7245extern const AstTypeMatcher<TemplateTypeParmType> templateTypeParmType;
7246
7247/// Matches injected class name types.
7248///
7249/// Example matches S s, but not S<T> s.
7250/// (matcher = parmVarDecl(hasType(injectedClassNameType())))
7251/// \code
7252/// template <typename T> struct S {
7253/// void f(S s);
7254/// void g(S<T> s);
7255/// };
7256/// \endcode
7257extern const AstTypeMatcher<InjectedClassNameType> injectedClassNameType;
7258
7259/// Matches decayed type
7260/// Example matches i[] in declaration of f.
7261/// (matcher = valueDecl(hasType(decayedType(hasDecayedType(pointerType())))))
7262/// Example matches i[1].
7263/// (matcher = expr(hasType(decayedType(hasDecayedType(pointerType())))))
7264/// \code
7265/// void f(int i[]) {
7266/// i[1] = 0;
7267/// }
7268/// \endcode
7269extern const AstTypeMatcher<DecayedType> decayedType;
7270
7271/// Matches the decayed type, whoes decayed type matches \c InnerMatcher
7272AST_MATCHER_P(DecayedType, hasDecayedType, internal::Matcher<QualType>,namespace internal { class matcher_hasDecayedType0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<DecayedType
> { public: explicit matcher_hasDecayedType0Matcher( internal
::Matcher<QualType> const &AInnerType) : InnerType(
AInnerType) {} bool matches(const DecayedType &Node, ::clang
::ast_matchers::internal::ASTMatchFinder *Finder, ::clang::ast_matchers
::internal::BoundNodesTreeBuilder *Builder) const override; private
: internal::Matcher<QualType> InnerType; }; } inline ::
clang::ast_matchers::internal::Matcher<DecayedType> hasDecayedType
( internal::Matcher<QualType> const &InnerType) { return
::clang::ast_matchers::internal::makeMatcher( new internal::
matcher_hasDecayedType0Matcher(InnerType)); } typedef ::clang
::ast_matchers::internal::Matcher<DecayedType> ( &hasDecayedType_Type0
)(internal::Matcher<QualType> const &InnerType); inline
bool internal::matcher_hasDecayedType0Matcher::matches( const
DecayedType &Node, ::clang::ast_matchers::internal::ASTMatchFinder
*Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
7273 InnerType)namespace internal { class matcher_hasDecayedType0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<DecayedType
> { public: explicit matcher_hasDecayedType0Matcher( internal
::Matcher<QualType> const &AInnerType) : InnerType(
AInnerType) {} bool matches(const DecayedType &Node, ::clang
::ast_matchers::internal::ASTMatchFinder *Finder, ::clang::ast_matchers
::internal::BoundNodesTreeBuilder *Builder) const override; private
: internal::Matcher<QualType> InnerType; }; } inline ::
clang::ast_matchers::internal::Matcher<DecayedType> hasDecayedType
( internal::Matcher<QualType> const &InnerType) { return
::clang::ast_matchers::internal::makeMatcher( new internal::
matcher_hasDecayedType0Matcher(InnerType)); } typedef ::clang
::ast_matchers::internal::Matcher<DecayedType> ( &hasDecayedType_Type0
)(internal::Matcher<QualType> const &InnerType); inline
bool internal::matcher_hasDecayedType0Matcher::matches( const
DecayedType &Node, ::clang::ast_matchers::internal::ASTMatchFinder
*Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
7274 return InnerType.matches(Node.getDecayedType(), Finder, Builder);
7275}
7276
7277/// Matches declarations whose declaration context, interpreted as a
7278/// Decl, matches \c InnerMatcher.
7279///
7280/// Given
7281/// \code
7282/// namespace N {
7283/// namespace M {
7284/// class D {};
7285/// }
7286/// }
7287/// \endcode
7288///
7289/// \c cxxRcordDecl(hasDeclContext(namedDecl(hasName("M")))) matches the
7290/// declaration of \c class \c D.
7291AST_MATCHER_P(Decl, hasDeclContext, internal::Matcher<Decl>, InnerMatcher)namespace internal { class matcher_hasDeclContext0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<Decl>
{ public: explicit matcher_hasDeclContext0Matcher( internal::
Matcher<Decl> const &AInnerMatcher) : InnerMatcher(
AInnerMatcher) {} bool matches(const Decl &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<Decl> hasDeclContext(
internal::Matcher<Decl> const &InnerMatcher) { return
::clang::ast_matchers::internal::makeMatcher( new internal::
matcher_hasDeclContext0Matcher(InnerMatcher)); } typedef ::clang
::ast_matchers::internal::Matcher<Decl> ( &hasDeclContext_Type0
)(internal::Matcher<Decl> const &InnerMatcher); inline
bool internal::matcher_hasDeclContext0Matcher::matches( const
Decl &Node, ::clang::ast_matchers::internal::ASTMatchFinder
*Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
7292 const DeclContext *DC = Node.getDeclContext();
7293 if (!DC) return false;
7294 return InnerMatcher.matches(*Decl::castFromDeclContext(DC), Finder, Builder);
7295}
7296
7297/// Matches nested name specifiers.
7298///
7299/// Given
7300/// \code
7301/// namespace ns {
7302/// struct A { static void f(); };
7303/// void A::f() {}
7304/// void g() { A::f(); }
7305/// }
7306/// ns::A a;
7307/// \endcode
7308/// nestedNameSpecifier()
7309/// matches "ns::" and both "A::"
7310extern const internal::VariadicAllOfMatcher<NestedNameSpecifier>
7311 nestedNameSpecifier;
7312
7313/// Same as \c nestedNameSpecifier but matches \c NestedNameSpecifierLoc.
7314extern const internal::VariadicAllOfMatcher<NestedNameSpecifierLoc>
7315 nestedNameSpecifierLoc;
7316
7317/// Matches \c NestedNameSpecifierLocs for which the given inner
7318/// NestedNameSpecifier-matcher matches.
7319AST_MATCHER_FUNCTION_P_OVERLOAD(inline internal::BindableMatcher<NestedNameSpecifierLoc>
loc(internal::Matcher<NestedNameSpecifier> const &
InnerMatcher); typedef internal::BindableMatcher<NestedNameSpecifierLoc
> (&loc_Type1)(internal::Matcher<NestedNameSpecifier
> const &); inline internal::BindableMatcher<NestedNameSpecifierLoc
> loc(internal::Matcher<NestedNameSpecifier> const &
InnerMatcher)
7320 internal::BindableMatcher<NestedNameSpecifierLoc>, loc,inline internal::BindableMatcher<NestedNameSpecifierLoc>
loc(internal::Matcher<NestedNameSpecifier> const &
InnerMatcher); typedef internal::BindableMatcher<NestedNameSpecifierLoc
> (&loc_Type1)(internal::Matcher<NestedNameSpecifier
> const &); inline internal::BindableMatcher<NestedNameSpecifierLoc
> loc(internal::Matcher<NestedNameSpecifier> const &
InnerMatcher)
7321 internal::Matcher<NestedNameSpecifier>, InnerMatcher, 1)inline internal::BindableMatcher<NestedNameSpecifierLoc>
loc(internal::Matcher<NestedNameSpecifier> const &
InnerMatcher); typedef internal::BindableMatcher<NestedNameSpecifierLoc
> (&loc_Type1)(internal::Matcher<NestedNameSpecifier
> const &); inline internal::BindableMatcher<NestedNameSpecifierLoc
> loc(internal::Matcher<NestedNameSpecifier> const &
InnerMatcher)
{
7322 return internal::BindableMatcher<NestedNameSpecifierLoc>(
7323 new internal::LocMatcher<NestedNameSpecifierLoc, NestedNameSpecifier>(
7324 InnerMatcher));
7325}
7326
7327/// Matches nested name specifiers that specify a type matching the
7328/// given \c QualType matcher without qualifiers.
7329///
7330/// Given
7331/// \code
7332/// struct A { struct B { struct C {}; }; };
7333/// A::B::C c;
7334/// \endcode
7335/// nestedNameSpecifier(specifiesType(
7336/// hasDeclaration(cxxRecordDecl(hasName("A")))
7337/// ))
7338/// matches "A::"
7339AST_MATCHER_P(NestedNameSpecifier, specifiesType,namespace internal { class matcher_specifiesType0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<NestedNameSpecifier
> { public: explicit matcher_specifiesType0Matcher( internal
::Matcher<QualType> const &AInnerMatcher) : InnerMatcher
(AInnerMatcher) {} bool matches(const NestedNameSpecifier &
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<NestedNameSpecifier
> specifiesType( internal::Matcher<QualType> const &
InnerMatcher) { return ::clang::ast_matchers::internal::makeMatcher
( new internal::matcher_specifiesType0Matcher(InnerMatcher));
} typedef ::clang::ast_matchers::internal::Matcher<NestedNameSpecifier
> ( &specifiesType_Type0)(internal::Matcher<QualType
> const &InnerMatcher); inline bool internal::matcher_specifiesType0Matcher
::matches( const NestedNameSpecifier &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
7340 internal::Matcher<QualType>, InnerMatcher)namespace internal { class matcher_specifiesType0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<NestedNameSpecifier
> { public: explicit matcher_specifiesType0Matcher( internal
::Matcher<QualType> const &AInnerMatcher) : InnerMatcher
(AInnerMatcher) {} bool matches(const NestedNameSpecifier &
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<NestedNameSpecifier
> specifiesType( internal::Matcher<QualType> const &
InnerMatcher) { return ::clang::ast_matchers::internal::makeMatcher
( new internal::matcher_specifiesType0Matcher(InnerMatcher));
} typedef ::clang::ast_matchers::internal::Matcher<NestedNameSpecifier
> ( &specifiesType_Type0)(internal::Matcher<QualType
> const &InnerMatcher); inline bool internal::matcher_specifiesType0Matcher
::matches( const NestedNameSpecifier &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
{
7341 if (!Node.getAsType())
7342 return false;
7343 return InnerMatcher.matches(QualType(Node.getAsType(), 0), Finder, Builder);
7344}
7345
7346/// Matches nested name specifier locs that specify a type matching the
7347/// given \c TypeLoc.
7348///
7349/// Given
7350/// \code
7351/// struct A { struct B { struct C {}; }; };
7352/// A::B::C c;
7353/// \endcode
7354/// nestedNameSpecifierLoc(specifiesTypeLoc(loc(type(
7355/// hasDeclaration(cxxRecordDecl(hasName("A")))))))
7356/// matches "A::"
7357AST_MATCHER_P(NestedNameSpecifierLoc, specifiesTypeLoc,namespace internal { class matcher_specifiesTypeLoc0Matcher :
public ::clang::ast_matchers::internal::MatcherInterface<
NestedNameSpecifierLoc> { public: explicit matcher_specifiesTypeLoc0Matcher
( internal::Matcher<TypeLoc> const &AInnerMatcher) :
InnerMatcher(AInnerMatcher) {} bool matches(const NestedNameSpecifierLoc
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: internal::Matcher<TypeLoc
> InnerMatcher; }; } inline ::clang::ast_matchers::internal
::Matcher<NestedNameSpecifierLoc> specifiesTypeLoc( internal
::Matcher<TypeLoc> const &InnerMatcher) { return ::
clang::ast_matchers::internal::makeMatcher( new internal::matcher_specifiesTypeLoc0Matcher
(InnerMatcher)); } typedef ::clang::ast_matchers::internal::Matcher
<NestedNameSpecifierLoc> ( &specifiesTypeLoc_Type0)
(internal::Matcher<TypeLoc> const &InnerMatcher); inline
bool internal::matcher_specifiesTypeLoc0Matcher::matches( const
NestedNameSpecifierLoc &Node, ::clang::ast_matchers::internal
::ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
7358 internal::Matcher<TypeLoc>, InnerMatcher)namespace internal { class matcher_specifiesTypeLoc0Matcher :
public ::clang::ast_matchers::internal::MatcherInterface<
NestedNameSpecifierLoc> { public: explicit matcher_specifiesTypeLoc0Matcher
( internal::Matcher<TypeLoc> const &AInnerMatcher) :
InnerMatcher(AInnerMatcher) {} bool matches(const NestedNameSpecifierLoc
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: internal::Matcher<TypeLoc
> InnerMatcher; }; } inline ::clang::ast_matchers::internal
::Matcher<NestedNameSpecifierLoc> specifiesTypeLoc( internal
::Matcher<TypeLoc> const &InnerMatcher) { return ::
clang::ast_matchers::internal::makeMatcher( new internal::matcher_specifiesTypeLoc0Matcher
(InnerMatcher)); } typedef ::clang::ast_matchers::internal::Matcher
<NestedNameSpecifierLoc> ( &specifiesTypeLoc_Type0)
(internal::Matcher<TypeLoc> const &InnerMatcher); inline
bool internal::matcher_specifiesTypeLoc0Matcher::matches( const
NestedNameSpecifierLoc &Node, ::clang::ast_matchers::internal
::ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
7359 return Node && Node.getNestedNameSpecifier()->getAsType() &&
7360 InnerMatcher.matches(Node.getTypeLoc(), Finder, Builder);
7361}
7362
7363/// Matches on the prefix of a \c NestedNameSpecifier.
7364///
7365/// Given
7366/// \code
7367/// struct A { struct B { struct C {}; }; };
7368/// A::B::C c;
7369/// \endcode
7370/// nestedNameSpecifier(hasPrefix(specifiesType(asString("struct A")))) and
7371/// matches "A::"
7372AST_MATCHER_P_OVERLOAD(NestedNameSpecifier, hasPrefix,namespace internal { class matcher_hasPrefix0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<NestedNameSpecifier
> { public: explicit matcher_hasPrefix0Matcher( internal::
Matcher<NestedNameSpecifier> const &AInnerMatcher) :
InnerMatcher(AInnerMatcher) {} bool matches(const NestedNameSpecifier
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: internal::Matcher<NestedNameSpecifier
> InnerMatcher; }; } inline ::clang::ast_matchers::internal
::Matcher<NestedNameSpecifier> hasPrefix( internal::Matcher
<NestedNameSpecifier> const &InnerMatcher) { return
::clang::ast_matchers::internal::makeMatcher( new internal::
matcher_hasPrefix0Matcher(InnerMatcher)); } typedef ::clang::
ast_matchers::internal::Matcher<NestedNameSpecifier> ( &
hasPrefix_Type0)(internal::Matcher<NestedNameSpecifier>
const &InnerMatcher); inline bool internal::matcher_hasPrefix0Matcher
::matches( const NestedNameSpecifier &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
7373 internal::Matcher<NestedNameSpecifier>, InnerMatcher,namespace internal { class matcher_hasPrefix0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<NestedNameSpecifier
> { public: explicit matcher_hasPrefix0Matcher( internal::
Matcher<NestedNameSpecifier> const &AInnerMatcher) :
InnerMatcher(AInnerMatcher) {} bool matches(const NestedNameSpecifier
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: internal::Matcher<NestedNameSpecifier
> InnerMatcher; }; } inline ::clang::ast_matchers::internal
::Matcher<NestedNameSpecifier> hasPrefix( internal::Matcher
<NestedNameSpecifier> const &InnerMatcher) { return
::clang::ast_matchers::internal::makeMatcher( new internal::
matcher_hasPrefix0Matcher(InnerMatcher)); } typedef ::clang::
ast_matchers::internal::Matcher<NestedNameSpecifier> ( &
hasPrefix_Type0)(internal::Matcher<NestedNameSpecifier>
const &InnerMatcher); inline bool internal::matcher_hasPrefix0Matcher
::matches( const NestedNameSpecifier &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
7374 0)namespace internal { class matcher_hasPrefix0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<NestedNameSpecifier
> { public: explicit matcher_hasPrefix0Matcher( internal::
Matcher<NestedNameSpecifier> const &AInnerMatcher) :
InnerMatcher(AInnerMatcher) {} bool matches(const NestedNameSpecifier
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: internal::Matcher<NestedNameSpecifier
> InnerMatcher; }; } inline ::clang::ast_matchers::internal
::Matcher<NestedNameSpecifier> hasPrefix( internal::Matcher
<NestedNameSpecifier> const &InnerMatcher) { return
::clang::ast_matchers::internal::makeMatcher( new internal::
matcher_hasPrefix0Matcher(InnerMatcher)); } typedef ::clang::
ast_matchers::internal::Matcher<NestedNameSpecifier> ( &
hasPrefix_Type0)(internal::Matcher<NestedNameSpecifier>
const &InnerMatcher); inline bool internal::matcher_hasPrefix0Matcher
::matches( const NestedNameSpecifier &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
{
7375 const NestedNameSpecifier *NextNode = Node.getPrefix();
7376 if (!NextNode)
7377 return false;
7378 return InnerMatcher.matches(*NextNode, Finder, Builder);
7379}
7380
7381/// Matches on the prefix of a \c NestedNameSpecifierLoc.
7382///
7383/// Given
7384/// \code
7385/// struct A { struct B { struct C {}; }; };
7386/// A::B::C c;
7387/// \endcode
7388/// nestedNameSpecifierLoc(hasPrefix(loc(specifiesType(asString("struct A")))))
7389/// matches "A::"
7390AST_MATCHER_P_OVERLOAD(NestedNameSpecifierLoc, hasPrefix,namespace internal { class matcher_hasPrefix1Matcher : public
::clang::ast_matchers::internal::MatcherInterface<NestedNameSpecifierLoc
> { public: explicit matcher_hasPrefix1Matcher( internal::
Matcher<NestedNameSpecifierLoc> const &AInnerMatcher
) : InnerMatcher(AInnerMatcher) {} bool matches(const NestedNameSpecifierLoc
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: internal::Matcher<NestedNameSpecifierLoc
> InnerMatcher; }; } inline ::clang::ast_matchers::internal
::Matcher<NestedNameSpecifierLoc> hasPrefix( internal::
Matcher<NestedNameSpecifierLoc> const &InnerMatcher
) { return ::clang::ast_matchers::internal::makeMatcher( new internal
::matcher_hasPrefix1Matcher(InnerMatcher)); } typedef ::clang
::ast_matchers::internal::Matcher<NestedNameSpecifierLoc>
( &hasPrefix_Type1)(internal::Matcher<NestedNameSpecifierLoc
> const &InnerMatcher); inline bool internal::matcher_hasPrefix1Matcher
::matches( const NestedNameSpecifierLoc &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
7391 internal::Matcher<NestedNameSpecifierLoc>, InnerMatcher,namespace internal { class matcher_hasPrefix1Matcher : public
::clang::ast_matchers::internal::MatcherInterface<NestedNameSpecifierLoc
> { public: explicit matcher_hasPrefix1Matcher( internal::
Matcher<NestedNameSpecifierLoc> const &AInnerMatcher
) : InnerMatcher(AInnerMatcher) {} bool matches(const NestedNameSpecifierLoc
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: internal::Matcher<NestedNameSpecifierLoc
> InnerMatcher; }; } inline ::clang::ast_matchers::internal
::Matcher<NestedNameSpecifierLoc> hasPrefix( internal::
Matcher<NestedNameSpecifierLoc> const &InnerMatcher
) { return ::clang::ast_matchers::internal::makeMatcher( new internal
::matcher_hasPrefix1Matcher(InnerMatcher)); } typedef ::clang
::ast_matchers::internal::Matcher<NestedNameSpecifierLoc>
( &hasPrefix_Type1)(internal::Matcher<NestedNameSpecifierLoc
> const &InnerMatcher); inline bool internal::matcher_hasPrefix1Matcher
::matches( const NestedNameSpecifierLoc &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
7392 1)namespace internal { class matcher_hasPrefix1Matcher : public
::clang::ast_matchers::internal::MatcherInterface<NestedNameSpecifierLoc
> { public: explicit matcher_hasPrefix1Matcher( internal::
Matcher<NestedNameSpecifierLoc> const &AInnerMatcher
) : InnerMatcher(AInnerMatcher) {} bool matches(const NestedNameSpecifierLoc
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: internal::Matcher<NestedNameSpecifierLoc
> InnerMatcher; }; } inline ::clang::ast_matchers::internal
::Matcher<NestedNameSpecifierLoc> hasPrefix( internal::
Matcher<NestedNameSpecifierLoc> const &InnerMatcher
) { return ::clang::ast_matchers::internal::makeMatcher( new internal
::matcher_hasPrefix1Matcher(InnerMatcher)); } typedef ::clang
::ast_matchers::internal::Matcher<NestedNameSpecifierLoc>
( &hasPrefix_Type1)(internal::Matcher<NestedNameSpecifierLoc
> const &InnerMatcher); inline bool internal::matcher_hasPrefix1Matcher
::matches( const NestedNameSpecifierLoc &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
{
7393 NestedNameSpecifierLoc NextNode = Node.getPrefix();
7394 if (!NextNode)
7395 return false;
7396 return InnerMatcher.matches(NextNode, Finder, Builder);
7397}
7398
7399/// Matches nested name specifiers that specify a namespace matching the
7400/// given namespace matcher.
7401///
7402/// Given
7403/// \code
7404/// namespace ns { struct A {}; }
7405/// ns::A a;
7406/// \endcode
7407/// nestedNameSpecifier(specifiesNamespace(hasName("ns")))
7408/// matches "ns::"
7409AST_MATCHER_P(NestedNameSpecifier, specifiesNamespace,namespace internal { class matcher_specifiesNamespace0Matcher
: public ::clang::ast_matchers::internal::MatcherInterface<
NestedNameSpecifier> { public: explicit matcher_specifiesNamespace0Matcher
( internal::Matcher<NamespaceDecl> const &AInnerMatcher
) : InnerMatcher(AInnerMatcher) {} bool matches(const NestedNameSpecifier
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: internal::Matcher<NamespaceDecl
> InnerMatcher; }; } inline ::clang::ast_matchers::internal
::Matcher<NestedNameSpecifier> specifiesNamespace( internal
::Matcher<NamespaceDecl> const &InnerMatcher) { return
::clang::ast_matchers::internal::makeMatcher( new internal::
matcher_specifiesNamespace0Matcher(InnerMatcher)); } typedef ::
clang::ast_matchers::internal::Matcher<NestedNameSpecifier
> ( &specifiesNamespace_Type0)(internal::Matcher<NamespaceDecl
> const &InnerMatcher); inline bool internal::matcher_specifiesNamespace0Matcher
::matches( const NestedNameSpecifier &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
7410 internal::Matcher<NamespaceDecl>, InnerMatcher)namespace internal { class matcher_specifiesNamespace0Matcher
: public ::clang::ast_matchers::internal::MatcherInterface<
NestedNameSpecifier> { public: explicit matcher_specifiesNamespace0Matcher
( internal::Matcher<NamespaceDecl> const &AInnerMatcher
) : InnerMatcher(AInnerMatcher) {} bool matches(const NestedNameSpecifier
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: internal::Matcher<NamespaceDecl
> InnerMatcher; }; } inline ::clang::ast_matchers::internal
::Matcher<NestedNameSpecifier> specifiesNamespace( internal
::Matcher<NamespaceDecl> const &InnerMatcher) { return
::clang::ast_matchers::internal::makeMatcher( new internal::
matcher_specifiesNamespace0Matcher(InnerMatcher)); } typedef ::
clang::ast_matchers::internal::Matcher<NestedNameSpecifier
> ( &specifiesNamespace_Type0)(internal::Matcher<NamespaceDecl
> const &InnerMatcher); inline bool internal::matcher_specifiesNamespace0Matcher
::matches( const NestedNameSpecifier &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
{
7411 if (!Node.getAsNamespace())
7412 return false;
7413 return InnerMatcher.matches(*Node.getAsNamespace(), Finder, Builder);
7414}
7415
7416/// Matches attributes.
7417/// Attributes may be attached with a variety of different syntaxes (including
7418/// keywords, C++11 attributes, GNU ``__attribute``` and MSVC `__declspec``,
7419/// and ``#pragma``s). They may also be implicit.
7420///
7421/// Given
7422/// \code
7423/// struct [[nodiscard]] Foo{};
7424/// void bar(int * __attribute__((nonnull)) );
7425/// __declspec(noinline) void baz();
7426///
7427/// #pragma omp declare simd
7428/// int min();
7429/// \endcode
7430/// attr()
7431/// matches "nodiscard", "nonnull", "noinline", and the whole "#pragma" line.
7432extern const internal::VariadicAllOfMatcher<Attr> attr;
7433
7434/// Overloads for the \c equalsNode matcher.
7435/// FIXME: Implement for other node types.
7436/// @{
7437
7438/// Matches if a node equals another node.
7439///
7440/// \c Decl has pointer identity in the AST.
7441AST_MATCHER_P_OVERLOAD(Decl, equalsNode, const Decl*, Other, 0)namespace internal { class matcher_equalsNode0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<Decl>
{ public: explicit matcher_equalsNode0Matcher( const Decl* const
&AOther) : Other(AOther) {} bool matches(const Decl &
Node, ::clang::ast_matchers::internal::ASTMatchFinder *Finder
, ::clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder
) const override; private: const Decl* Other; }; } inline ::clang
::ast_matchers::internal::Matcher<Decl> equalsNode( const
Decl* const &Other) { return ::clang::ast_matchers::internal
::makeMatcher( new internal::matcher_equalsNode0Matcher(Other
)); } typedef ::clang::ast_matchers::internal::Matcher<Decl
> ( &equalsNode_Type0)(const Decl* const &Other); inline
bool internal::matcher_equalsNode0Matcher::matches( const Decl
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
7442 return &Node == Other;
7443}
7444/// Matches if a node equals another node.
7445///
7446/// \c Stmt has pointer identity in the AST.
7447AST_MATCHER_P_OVERLOAD(Stmt, equalsNode, const Stmt*, Other, 1)namespace internal { class matcher_equalsNode1Matcher : public
::clang::ast_matchers::internal::MatcherInterface<Stmt>
{ public: explicit matcher_equalsNode1Matcher( const Stmt* const
&AOther) : Other(AOther) {} bool matches(const Stmt &
Node, ::clang::ast_matchers::internal::ASTMatchFinder *Finder
, ::clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder
) const override; private: const Stmt* Other; }; } inline ::clang
::ast_matchers::internal::Matcher<Stmt> equalsNode( const
Stmt* const &Other) { return ::clang::ast_matchers::internal
::makeMatcher( new internal::matcher_equalsNode1Matcher(Other
)); } typedef ::clang::ast_matchers::internal::Matcher<Stmt
> ( &equalsNode_Type1)(const Stmt* const &Other); inline
bool internal::matcher_equalsNode1Matcher::matches( const Stmt
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
7448 return &Node == Other;
7449}
7450/// Matches if a node equals another node.
7451///
7452/// \c Type has pointer identity in the AST.
7453AST_MATCHER_P_OVERLOAD(Type, equalsNode, const Type*, Other, 2)namespace internal { class matcher_equalsNode2Matcher : public
::clang::ast_matchers::internal::MatcherInterface<Type>
{ public: explicit matcher_equalsNode2Matcher( const Type* const
&AOther) : Other(AOther) {} bool matches(const Type &
Node, ::clang::ast_matchers::internal::ASTMatchFinder *Finder
, ::clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder
) const override; private: const Type* Other; }; } inline ::clang
::ast_matchers::internal::Matcher<Type> equalsNode( const
Type* const &Other) { return ::clang::ast_matchers::internal
::makeMatcher( new internal::matcher_equalsNode2Matcher(Other
)); } typedef ::clang::ast_matchers::internal::Matcher<Type
> ( &equalsNode_Type2)(const Type* const &Other); inline
bool internal::matcher_equalsNode2Matcher::matches( const Type
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
7454 return &Node == Other;
7455}
7456
7457/// @}
7458
7459/// Matches each case or default statement belonging to the given switch
7460/// statement. This matcher may produce multiple matches.
7461///
7462/// Given
7463/// \code
7464/// switch (1) { case 1: case 2: default: switch (2) { case 3: case 4: ; } }
7465/// \endcode
7466/// switchStmt(forEachSwitchCase(caseStmt().bind("c"))).bind("s")
7467/// matches four times, with "c" binding each of "case 1:", "case 2:",
7468/// "case 3:" and "case 4:", and "s" respectively binding "switch (1)",
7469/// "switch (1)", "switch (2)" and "switch (2)".
7470AST_MATCHER_P(SwitchStmt, forEachSwitchCase, internal::Matcher<SwitchCase>,namespace internal { class matcher_forEachSwitchCase0Matcher :
public ::clang::ast_matchers::internal::MatcherInterface<
SwitchStmt> { public: explicit matcher_forEachSwitchCase0Matcher
( internal::Matcher<SwitchCase> const &AInnerMatcher
) : InnerMatcher(AInnerMatcher) {} bool matches(const SwitchStmt
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: internal::Matcher<SwitchCase
> InnerMatcher; }; } inline ::clang::ast_matchers::internal
::Matcher<SwitchStmt> forEachSwitchCase( internal::Matcher
<SwitchCase> const &InnerMatcher) { return ::clang::
ast_matchers::internal::makeMatcher( new internal::matcher_forEachSwitchCase0Matcher
(InnerMatcher)); } typedef ::clang::ast_matchers::internal::Matcher
<SwitchStmt> ( &forEachSwitchCase_Type0)(internal::
Matcher<SwitchCase> const &InnerMatcher); inline bool
internal::matcher_forEachSwitchCase0Matcher::matches( const SwitchStmt
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
7471 InnerMatcher)namespace internal { class matcher_forEachSwitchCase0Matcher :
public ::clang::ast_matchers::internal::MatcherInterface<
SwitchStmt> { public: explicit matcher_forEachSwitchCase0Matcher
( internal::Matcher<SwitchCase> const &AInnerMatcher
) : InnerMatcher(AInnerMatcher) {} bool matches(const SwitchStmt
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: internal::Matcher<SwitchCase
> InnerMatcher; }; } inline ::clang::ast_matchers::internal
::Matcher<SwitchStmt> forEachSwitchCase( internal::Matcher
<SwitchCase> const &InnerMatcher) { return ::clang::
ast_matchers::internal::makeMatcher( new internal::matcher_forEachSwitchCase0Matcher
(InnerMatcher)); } typedef ::clang::ast_matchers::internal::Matcher
<SwitchStmt> ( &forEachSwitchCase_Type0)(internal::
Matcher<SwitchCase> const &InnerMatcher); inline bool
internal::matcher_forEachSwitchCase0Matcher::matches( const SwitchStmt
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
7472 BoundNodesTreeBuilder Result;
7473 // FIXME: getSwitchCaseList() does not necessarily guarantee a stable
7474 // iteration order. We should use the more general iterating matchers once
7475 // they are capable of expressing this matcher (for example, it should ignore
7476 // case statements belonging to nested switch statements).
7477 bool Matched = false;
7478 for (const SwitchCase *SC = Node.getSwitchCaseList(); SC;
7479 SC = SC->getNextSwitchCase()) {
7480 BoundNodesTreeBuilder CaseBuilder(*Builder);
7481 bool CaseMatched = InnerMatcher.matches(*SC, Finder, &CaseBuilder);
7482 if (CaseMatched) {
7483 Matched = true;
7484 Result.addMatch(CaseBuilder);
7485 }
7486 }
7487 *Builder = std::move(Result);
7488 return Matched;
7489}
7490
7491/// Matches each constructor initializer in a constructor definition.
7492///
7493/// Given
7494/// \code
7495/// class A { A() : i(42), j(42) {} int i; int j; };
7496/// \endcode
7497/// cxxConstructorDecl(forEachConstructorInitializer(
7498/// forField(decl().bind("x"))
7499/// ))
7500/// will trigger two matches, binding for 'i' and 'j' respectively.
7501AST_MATCHER_P(CXXConstructorDecl, forEachConstructorInitializer,namespace internal { class matcher_forEachConstructorInitializer0Matcher
: public ::clang::ast_matchers::internal::MatcherInterface<
CXXConstructorDecl> { public: explicit matcher_forEachConstructorInitializer0Matcher
( internal::Matcher<CXXCtorInitializer> const &AInnerMatcher
) : InnerMatcher(AInnerMatcher) {} bool matches(const CXXConstructorDecl
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: internal::Matcher<CXXCtorInitializer
> InnerMatcher; }; } inline ::clang::ast_matchers::internal
::Matcher<CXXConstructorDecl> forEachConstructorInitializer
( internal::Matcher<CXXCtorInitializer> const &InnerMatcher
) { return ::clang::ast_matchers::internal::makeMatcher( new internal
::matcher_forEachConstructorInitializer0Matcher(InnerMatcher)
); } typedef ::clang::ast_matchers::internal::Matcher<CXXConstructorDecl
> ( &forEachConstructorInitializer_Type0)(internal::Matcher
<CXXCtorInitializer> const &InnerMatcher); inline bool
internal::matcher_forEachConstructorInitializer0Matcher::matches
( const CXXConstructorDecl &Node, ::clang::ast_matchers::
internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
7502 internal::Matcher<CXXCtorInitializer>, InnerMatcher)namespace internal { class matcher_forEachConstructorInitializer0Matcher
: public ::clang::ast_matchers::internal::MatcherInterface<
CXXConstructorDecl> { public: explicit matcher_forEachConstructorInitializer0Matcher
( internal::Matcher<CXXCtorInitializer> const &AInnerMatcher
) : InnerMatcher(AInnerMatcher) {} bool matches(const CXXConstructorDecl
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: internal::Matcher<CXXCtorInitializer
> InnerMatcher; }; } inline ::clang::ast_matchers::internal
::Matcher<CXXConstructorDecl> forEachConstructorInitializer
( internal::Matcher<CXXCtorInitializer> const &InnerMatcher
) { return ::clang::ast_matchers::internal::makeMatcher( new internal
::matcher_forEachConstructorInitializer0Matcher(InnerMatcher)
); } typedef ::clang::ast_matchers::internal::Matcher<CXXConstructorDecl
> ( &forEachConstructorInitializer_Type0)(internal::Matcher
<CXXCtorInitializer> const &InnerMatcher); inline bool
internal::matcher_forEachConstructorInitializer0Matcher::matches
( const CXXConstructorDecl &Node, ::clang::ast_matchers::
internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
{
7503 BoundNodesTreeBuilder Result;
7504 bool Matched = false;
7505 for (const auto *I : Node.inits()) {
7506 if (Finder->isTraversalIgnoringImplicitNodes() && !I->isWritten())
7507 continue;
7508 BoundNodesTreeBuilder InitBuilder(*Builder);
7509 if (InnerMatcher.matches(*I, Finder, &InitBuilder)) {
7510 Matched = true;
7511 Result.addMatch(InitBuilder);
7512 }
7513 }
7514 *Builder = std::move(Result);
7515 return Matched;
7516}
7517
7518/// Matches constructor declarations that are copy constructors.
7519///
7520/// Given
7521/// \code
7522/// struct S {
7523/// S(); // #1
7524/// S(const S &); // #2
7525/// S(S &&); // #3
7526/// };
7527/// \endcode
7528/// cxxConstructorDecl(isCopyConstructor()) will match #2, but not #1 or #3.
7529AST_MATCHER(CXXConstructorDecl, isCopyConstructor)namespace internal { class matcher_isCopyConstructorMatcher :
public ::clang::ast_matchers::internal::MatcherInterface<
CXXConstructorDecl> { public: explicit matcher_isCopyConstructorMatcher
() = default; bool matches(const CXXConstructorDecl &Node
, ::clang::ast_matchers::internal::ASTMatchFinder *Finder, ::
clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder
) const override; }; } inline ::clang::ast_matchers::internal
::Matcher<CXXConstructorDecl> isCopyConstructor() { return
::clang::ast_matchers::internal::makeMatcher( new internal::
matcher_isCopyConstructorMatcher()); } inline bool internal::
matcher_isCopyConstructorMatcher::matches( const CXXConstructorDecl
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
7530 return Node.isCopyConstructor();
7531}
7532
7533/// Matches constructor declarations that are move constructors.
7534///
7535/// Given
7536/// \code
7537/// struct S {
7538/// S(); // #1
7539/// S(const S &); // #2
7540/// S(S &&); // #3
7541/// };
7542/// \endcode
7543/// cxxConstructorDecl(isMoveConstructor()) will match #3, but not #1 or #2.
7544AST_MATCHER(CXXConstructorDecl, isMoveConstructor)namespace internal { class matcher_isMoveConstructorMatcher :
public ::clang::ast_matchers::internal::MatcherInterface<
CXXConstructorDecl> { public: explicit matcher_isMoveConstructorMatcher
() = default; bool matches(const CXXConstructorDecl &Node
, ::clang::ast_matchers::internal::ASTMatchFinder *Finder, ::
clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder
) const override; }; } inline ::clang::ast_matchers::internal
::Matcher<CXXConstructorDecl> isMoveConstructor() { return
::clang::ast_matchers::internal::makeMatcher( new internal::
matcher_isMoveConstructorMatcher()); } inline bool internal::
matcher_isMoveConstructorMatcher::matches( const CXXConstructorDecl
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
7545 return Node.isMoveConstructor();
7546}
7547
7548/// Matches constructor declarations that are default constructors.
7549///
7550/// Given
7551/// \code
7552/// struct S {
7553/// S(); // #1
7554/// S(const S &); // #2
7555/// S(S &&); // #3
7556/// };
7557/// \endcode
7558/// cxxConstructorDecl(isDefaultConstructor()) will match #1, but not #2 or #3.
7559AST_MATCHER(CXXConstructorDecl, isDefaultConstructor)namespace internal { class matcher_isDefaultConstructorMatcher
: public ::clang::ast_matchers::internal::MatcherInterface<
CXXConstructorDecl> { public: explicit matcher_isDefaultConstructorMatcher
() = default; bool matches(const CXXConstructorDecl &Node
, ::clang::ast_matchers::internal::ASTMatchFinder *Finder, ::
clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder
) const override; }; } inline ::clang::ast_matchers::internal
::Matcher<CXXConstructorDecl> isDefaultConstructor() { return
::clang::ast_matchers::internal::makeMatcher( new internal::
matcher_isDefaultConstructorMatcher()); } inline bool internal
::matcher_isDefaultConstructorMatcher::matches( const CXXConstructorDecl
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
7560 return Node.isDefaultConstructor();
7561}
7562
7563/// Matches constructors that delegate to another constructor.
7564///
7565/// Given
7566/// \code
7567/// struct S {
7568/// S(); // #1
7569/// S(int) {} // #2
7570/// S(S &&) : S() {} // #3
7571/// };
7572/// S::S() : S(0) {} // #4
7573/// \endcode
7574/// cxxConstructorDecl(isDelegatingConstructor()) will match #3 and #4, but not
7575/// #1 or #2.
7576AST_MATCHER(CXXConstructorDecl, isDelegatingConstructor)namespace internal { class matcher_isDelegatingConstructorMatcher
: public ::clang::ast_matchers::internal::MatcherInterface<
CXXConstructorDecl> { public: explicit matcher_isDelegatingConstructorMatcher
() = default; bool matches(const CXXConstructorDecl &Node
, ::clang::ast_matchers::internal::ASTMatchFinder *Finder, ::
clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder
) const override; }; } inline ::clang::ast_matchers::internal
::Matcher<CXXConstructorDecl> isDelegatingConstructor()
{ return ::clang::ast_matchers::internal::makeMatcher( new internal
::matcher_isDelegatingConstructorMatcher()); } inline bool internal
::matcher_isDelegatingConstructorMatcher::matches( const CXXConstructorDecl
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
7577 return Node.isDelegatingConstructor();
7578}
7579
7580/// Matches constructor, conversion function, and deduction guide declarations
7581/// that have an explicit specifier if this explicit specifier is resolved to
7582/// true.
7583///
7584/// Given
7585/// \code
7586/// template<bool b>
7587/// struct S {
7588/// S(int); // #1
7589/// explicit S(double); // #2
7590/// operator int(); // #3
7591/// explicit operator bool(); // #4
7592/// explicit(false) S(bool) // # 7
7593/// explicit(true) S(char) // # 8
7594/// explicit(b) S(S) // # 9
7595/// };
7596/// S(int) -> S<true> // #5
7597/// explicit S(double) -> S<false> // #6
7598/// \endcode
7599/// cxxConstructorDecl(isExplicit()) will match #2 and #8, but not #1, #7 or #9.
7600/// cxxConversionDecl(isExplicit()) will match #4, but not #3.
7601/// cxxDeductionGuideDecl(isExplicit()) will match #6, but not #5.
7602AST_POLYMORPHIC_MATCHER(isExplicit, AST_POLYMORPHIC_SUPPORTED_TYPES(namespace internal { template <typename NodeType> class
matcher_isExplicitMatcher : 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_isExplicitMatcher
, void(::clang::ast_matchers::internal::TypeList<CXXConstructorDecl
, CXXConversionDecl, CXXDeductionGuideDecl>)> isExplicit
() { return ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_isExplicitMatcher, void(::clang::ast_matchers
::internal::TypeList<CXXConstructorDecl, CXXConversionDecl
, CXXDeductionGuideDecl>)>(); } template <typename NodeType
> bool internal::matcher_isExplicitMatcher<NodeType>
::matches( const NodeType &Node, ::clang::ast_matchers::internal
::ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
7603 CXXConstructorDecl, CXXConversionDecl,namespace internal { template <typename NodeType> class
matcher_isExplicitMatcher : 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_isExplicitMatcher
, void(::clang::ast_matchers::internal::TypeList<CXXConstructorDecl
, CXXConversionDecl, CXXDeductionGuideDecl>)> isExplicit
() { return ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_isExplicitMatcher, void(::clang::ast_matchers
::internal::TypeList<CXXConstructorDecl, CXXConversionDecl
, CXXDeductionGuideDecl>)>(); } template <typename NodeType
> bool internal::matcher_isExplicitMatcher<NodeType>
::matches( const NodeType &Node, ::clang::ast_matchers::internal
::ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
7604 CXXDeductionGuideDecl))namespace internal { template <typename NodeType> class
matcher_isExplicitMatcher : 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_isExplicitMatcher
, void(::clang::ast_matchers::internal::TypeList<CXXConstructorDecl
, CXXConversionDecl, CXXDeductionGuideDecl>)> isExplicit
() { return ::clang::ast_matchers::internal::PolymorphicMatcher
< internal::matcher_isExplicitMatcher, void(::clang::ast_matchers
::internal::TypeList<CXXConstructorDecl, CXXConversionDecl
, CXXDeductionGuideDecl>)>(); } template <typename NodeType
> bool internal::matcher_isExplicitMatcher<NodeType>
::matches( const NodeType &Node, ::clang::ast_matchers::internal
::ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
7605 return Node.isExplicit();
7606}
7607
7608/// Matches the expression in an explicit specifier if present in the given
7609/// declaration.
7610///
7611/// Given
7612/// \code
7613/// template<bool b>
7614/// struct S {
7615/// S(int); // #1
7616/// explicit S(double); // #2
7617/// operator int(); // #3
7618/// explicit operator bool(); // #4
7619/// explicit(false) S(bool) // # 7
7620/// explicit(true) S(char) // # 8
7621/// explicit(b) S(S) // # 9
7622/// };
7623/// S(int) -> S<true> // #5
7624/// explicit S(double) -> S<false> // #6
7625/// \endcode
7626/// cxxConstructorDecl(hasExplicitSpecifier(constantExpr())) will match #7, #8 and #9, but not #1 or #2.
7627/// cxxConversionDecl(hasExplicitSpecifier(constantExpr())) will not match #3 or #4.
7628/// cxxDeductionGuideDecl(hasExplicitSpecifier(constantExpr())) will not match #5 or #6.
7629AST_MATCHER_P(FunctionDecl, hasExplicitSpecifier, internal::Matcher<Expr>,namespace internal { class matcher_hasExplicitSpecifier0Matcher
: public ::clang::ast_matchers::internal::MatcherInterface<
FunctionDecl> { public: explicit matcher_hasExplicitSpecifier0Matcher
( internal::Matcher<Expr> const &AInnerMatcher) : InnerMatcher
(AInnerMatcher) {} bool matches(const FunctionDecl &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<FunctionDecl
> hasExplicitSpecifier( internal::Matcher<Expr> const
&InnerMatcher) { return ::clang::ast_matchers::internal::
makeMatcher( new internal::matcher_hasExplicitSpecifier0Matcher
(InnerMatcher)); } typedef ::clang::ast_matchers::internal::Matcher
<FunctionDecl> ( &hasExplicitSpecifier_Type0)(internal
::Matcher<Expr> const &InnerMatcher); inline bool internal
::matcher_hasExplicitSpecifier0Matcher::matches( const FunctionDecl
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
7630 InnerMatcher)namespace internal { class matcher_hasExplicitSpecifier0Matcher
: public ::clang::ast_matchers::internal::MatcherInterface<
FunctionDecl> { public: explicit matcher_hasExplicitSpecifier0Matcher
( internal::Matcher<Expr> const &AInnerMatcher) : InnerMatcher
(AInnerMatcher) {} bool matches(const FunctionDecl &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<FunctionDecl
> hasExplicitSpecifier( internal::Matcher<Expr> const
&InnerMatcher) { return ::clang::ast_matchers::internal::
makeMatcher( new internal::matcher_hasExplicitSpecifier0Matcher
(InnerMatcher)); } typedef ::clang::ast_matchers::internal::Matcher
<FunctionDecl> ( &hasExplicitSpecifier_Type0)(internal
::Matcher<Expr> const &InnerMatcher); inline bool internal
::matcher_hasExplicitSpecifier0Matcher::matches( const FunctionDecl
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
7631 ExplicitSpecifier ES = ExplicitSpecifier::getFromDecl(&Node);
7632 if (!ES.getExpr())
7633 return false;
7634
7635 ASTChildrenNotSpelledInSourceScope RAII(Finder, false);
7636
7637 return InnerMatcher.matches(*ES.getExpr(), Finder, Builder);
7638}
7639
7640/// Matches function and namespace declarations that are marked with
7641/// the inline keyword.
7642///
7643/// Given
7644/// \code
7645/// inline void f();
7646/// void g();
7647/// namespace n {
7648/// inline namespace m {}
7649/// }
7650/// \endcode
7651/// functionDecl(isInline()) will match ::f().
7652/// namespaceDecl(isInline()) will match n::m.
7653AST_POLYMORPHIC_MATCHER(isInline,namespace internal { template <typename NodeType> class
matcher_isInlineMatcher : 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_isInlineMatcher
, void(::clang::ast_matchers::internal::TypeList<NamespaceDecl
, FunctionDecl>)> isInline() { return ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_isInlineMatcher
, void(::clang::ast_matchers::internal::TypeList<NamespaceDecl
, FunctionDecl>)>(); } template <typename NodeType>
bool internal::matcher_isInlineMatcher<NodeType>::matches
( const NodeType &Node, ::clang::ast_matchers::internal::
ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
7654 AST_POLYMORPHIC_SUPPORTED_TYPES(NamespaceDecl,namespace internal { template <typename NodeType> class
matcher_isInlineMatcher : 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_isInlineMatcher
, void(::clang::ast_matchers::internal::TypeList<NamespaceDecl
, FunctionDecl>)> isInline() { return ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_isInlineMatcher
, void(::clang::ast_matchers::internal::TypeList<NamespaceDecl
, FunctionDecl>)>(); } template <typename NodeType>
bool internal::matcher_isInlineMatcher<NodeType>::matches
( const NodeType &Node, ::clang::ast_matchers::internal::
ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
7655 FunctionDecl))namespace internal { template <typename NodeType> class
matcher_isInlineMatcher : 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_isInlineMatcher
, void(::clang::ast_matchers::internal::TypeList<NamespaceDecl
, FunctionDecl>)> isInline() { return ::clang::ast_matchers
::internal::PolymorphicMatcher< internal::matcher_isInlineMatcher
, void(::clang::ast_matchers::internal::TypeList<NamespaceDecl
, FunctionDecl>)>(); } template <typename NodeType>
bool internal::matcher_isInlineMatcher<NodeType>::matches
( const NodeType &Node, ::clang::ast_matchers::internal::
ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
7656 // This is required because the spelling of the function used to determine
7657 // whether inline is specified or not differs between the polymorphic types.
7658 if (const auto *FD = dyn_cast<FunctionDecl>(&Node))
7659 return FD->isInlineSpecified();
7660 else if (const auto *NSD = dyn_cast<NamespaceDecl>(&Node))
7661 return NSD->isInline();
7662 llvm_unreachable("Not a valid polymorphic type")::llvm::llvm_unreachable_internal("Not a valid polymorphic type"
, "clang/include/clang/ASTMatchers/ASTMatchers.h", 7662)
;
7663}
7664
7665/// Matches anonymous namespace declarations.
7666///
7667/// Given
7668/// \code
7669/// namespace n {
7670/// namespace {} // #1
7671/// }
7672/// \endcode
7673/// namespaceDecl(isAnonymous()) will match #1 but not ::n.
7674AST_MATCHER(NamespaceDecl, isAnonymous)namespace internal { class matcher_isAnonymousMatcher : public
::clang::ast_matchers::internal::MatcherInterface<NamespaceDecl
> { public: explicit matcher_isAnonymousMatcher() = default
; bool matches(const NamespaceDecl &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const override; }; } inline
::clang::ast_matchers::internal::Matcher<NamespaceDecl>
isAnonymous() { return ::clang::ast_matchers::internal::makeMatcher
( new internal::matcher_isAnonymousMatcher()); } inline bool internal
::matcher_isAnonymousMatcher::matches( const NamespaceDecl &
Node, ::clang::ast_matchers::internal::ASTMatchFinder *Finder
, ::clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder
) const
{
7675 return Node.isAnonymousNamespace();
7676}
7677
7678/// Matches declarations in the namespace `std`, but not in nested namespaces.
7679///
7680/// Given
7681/// \code
7682/// class vector {};
7683/// namespace foo {
7684/// class vector {};
7685/// namespace std {
7686/// class vector {};
7687/// }
7688/// }
7689/// namespace std {
7690/// inline namespace __1 {
7691/// class vector {}; // #1
7692/// namespace experimental {
7693/// class vector {};
7694/// }
7695/// }
7696/// }
7697/// \endcode
7698/// cxxRecordDecl(hasName("vector"), isInStdNamespace()) will match only #1.
7699AST_MATCHER(Decl, isInStdNamespace)namespace internal { class matcher_isInStdNamespaceMatcher : public
::clang::ast_matchers::internal::MatcherInterface<Decl>
{ public: explicit matcher_isInStdNamespaceMatcher() = default
; bool matches(const Decl &Node, ::clang::ast_matchers::internal
::ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; }; } inline ::clang::ast_matchers::
internal::Matcher<Decl> isInStdNamespace() { return ::clang
::ast_matchers::internal::makeMatcher( new internal::matcher_isInStdNamespaceMatcher
()); } inline bool internal::matcher_isInStdNamespaceMatcher::
matches( const Decl &Node, ::clang::ast_matchers::internal
::ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{ return Node.isInStdNamespace(); }
7700
7701/// If the given case statement does not use the GNU case range
7702/// extension, matches the constant given in the statement.
7703///
7704/// Given
7705/// \code
7706/// switch (1) { case 1: case 1+1: case 3 ... 4: ; }
7707/// \endcode
7708/// caseStmt(hasCaseConstant(integerLiteral()))
7709/// matches "case 1:"
7710AST_MATCHER_P(CaseStmt, hasCaseConstant, internal::Matcher<Expr>,namespace internal { class matcher_hasCaseConstant0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<CaseStmt
> { public: explicit matcher_hasCaseConstant0Matcher( internal
::Matcher<Expr> const &AInnerMatcher) : InnerMatcher
(AInnerMatcher) {} bool matches(const CaseStmt &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<CaseStmt> hasCaseConstant
( internal::Matcher<Expr> const &InnerMatcher) { return
::clang::ast_matchers::internal::makeMatcher( new internal::
matcher_hasCaseConstant0Matcher(InnerMatcher)); } typedef ::clang
::ast_matchers::internal::Matcher<CaseStmt> ( &hasCaseConstant_Type0
)(internal::Matcher<Expr> const &InnerMatcher); inline
bool internal::matcher_hasCaseConstant0Matcher::matches( const
CaseStmt &Node, ::clang::ast_matchers::internal::ASTMatchFinder
*Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
7711 InnerMatcher)namespace internal { class matcher_hasCaseConstant0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<CaseStmt
> { public: explicit matcher_hasCaseConstant0Matcher( internal
::Matcher<Expr> const &AInnerMatcher) : InnerMatcher
(AInnerMatcher) {} bool matches(const CaseStmt &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<CaseStmt> hasCaseConstant
( internal::Matcher<Expr> const &InnerMatcher) { return
::clang::ast_matchers::internal::makeMatcher( new internal::
matcher_hasCaseConstant0Matcher(InnerMatcher)); } typedef ::clang
::ast_matchers::internal::Matcher<CaseStmt> ( &hasCaseConstant_Type0
)(internal::Matcher<Expr> const &InnerMatcher); inline
bool internal::matcher_hasCaseConstant0Matcher::matches( const
CaseStmt &Node, ::clang::ast_matchers::internal::ASTMatchFinder
*Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
7712 if (Node.getRHS())
7713 return false;
7714
7715 return InnerMatcher.matches(*Node.getLHS(), Finder, Builder);
7716}
7717
7718/// Matches declaration that has a given attribute.
7719///
7720/// Given
7721/// \code
7722/// __attribute__((device)) void f() { ... }
7723/// \endcode
7724/// decl(hasAttr(clang::attr::CUDADevice)) matches the function declaration of
7725/// f. If the matcher is used from clang-query, attr::Kind parameter should be
7726/// passed as a quoted string. e.g., hasAttr("attr::CUDADevice").
7727AST_MATCHER_P(Decl, hasAttr, attr::Kind, AttrKind)namespace internal { class matcher_hasAttr0Matcher : public ::
clang::ast_matchers::internal::MatcherInterface<Decl> {
public: explicit matcher_hasAttr0Matcher( attr::Kind const &
AAttrKind) : AttrKind(AAttrKind) {} bool matches(const Decl &
Node, ::clang::ast_matchers::internal::ASTMatchFinder *Finder
, ::clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder
) const override; private: attr::Kind AttrKind; }; } inline ::
clang::ast_matchers::internal::Matcher<Decl> hasAttr( attr
::Kind const &AttrKind) { return ::clang::ast_matchers::internal
::makeMatcher( new internal::matcher_hasAttr0Matcher(AttrKind
)); } typedef ::clang::ast_matchers::internal::Matcher<Decl
> ( &hasAttr_Type0)(attr::Kind const &AttrKind); inline
bool internal::matcher_hasAttr0Matcher::matches( const Decl &
Node, ::clang::ast_matchers::internal::ASTMatchFinder *Finder
, ::clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder
) const
{
7728 for (const auto *Attr : Node.attrs()) {
7729 if (Attr->getKind() == AttrKind)
7730 return true;
7731 }
7732 return false;
7733}
7734
7735/// Matches the return value expression of a return statement
7736///
7737/// Given
7738/// \code
7739/// return a + b;
7740/// \endcode
7741/// hasReturnValue(binaryOperator())
7742/// matches 'return a + b'
7743/// with binaryOperator()
7744/// matching 'a + b'
7745AST_MATCHER_P(ReturnStmt, hasReturnValue, internal::Matcher<Expr>,namespace internal { class matcher_hasReturnValue0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<ReturnStmt
> { public: explicit matcher_hasReturnValue0Matcher( internal
::Matcher<Expr> const &AInnerMatcher) : InnerMatcher
(AInnerMatcher) {} bool matches(const ReturnStmt &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<ReturnStmt
> hasReturnValue( internal::Matcher<Expr> const &
InnerMatcher) { return ::clang::ast_matchers::internal::makeMatcher
( new internal::matcher_hasReturnValue0Matcher(InnerMatcher))
; } typedef ::clang::ast_matchers::internal::Matcher<ReturnStmt
> ( &hasReturnValue_Type0)(internal::Matcher<Expr>
const &InnerMatcher); inline bool internal::matcher_hasReturnValue0Matcher
::matches( const ReturnStmt &Node, ::clang::ast_matchers::
internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
7746 InnerMatcher)namespace internal { class matcher_hasReturnValue0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<ReturnStmt
> { public: explicit matcher_hasReturnValue0Matcher( internal
::Matcher<Expr> const &AInnerMatcher) : InnerMatcher
(AInnerMatcher) {} bool matches(const ReturnStmt &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<ReturnStmt
> hasReturnValue( internal::Matcher<Expr> const &
InnerMatcher) { return ::clang::ast_matchers::internal::makeMatcher
( new internal::matcher_hasReturnValue0Matcher(InnerMatcher))
; } typedef ::clang::ast_matchers::internal::Matcher<ReturnStmt
> ( &hasReturnValue_Type0)(internal::Matcher<Expr>
const &InnerMatcher); inline bool internal::matcher_hasReturnValue0Matcher
::matches( const ReturnStmt &Node, ::clang::ast_matchers::
internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
{
7747 if (const auto *RetValue = Node.getRetValue())
7748 return InnerMatcher.matches(*RetValue, Finder, Builder);
7749 return false;
7750}
7751
7752/// Matches CUDA kernel call expression.
7753///
7754/// Example matches,
7755/// \code
7756/// kernel<<<i,j>>>();
7757/// \endcode
7758extern const internal::VariadicDynCastAllOfMatcher<Stmt, CUDAKernelCallExpr>
7759 cudaKernelCallExpr;
7760
7761/// Matches expressions that resolve to a null pointer constant, such as
7762/// GNU's __null, C++11's nullptr, or C's NULL macro.
7763///
7764/// Given:
7765/// \code
7766/// void *v1 = NULL;
7767/// void *v2 = nullptr;
7768/// void *v3 = __null; // GNU extension
7769/// char *cp = (char *)0;
7770/// int *ip = 0;
7771/// int i = 0;
7772/// \endcode
7773/// expr(nullPointerConstant())
7774/// matches the initializer for v1, v2, v3, cp, and ip. Does not match the
7775/// initializer for i.
7776AST_MATCHER_FUNCTION(internal::Matcher<Expr>, nullPointerConstant)inline internal::Matcher<Expr> nullPointerConstant_getInstance
(); inline internal::Matcher<Expr> nullPointerConstant(
) { return ::clang::ast_matchers::internal::MemoizedMatcher<
internal::Matcher<Expr>, nullPointerConstant_getInstance
>::getInstance(); } inline internal::Matcher<Expr> nullPointerConstant_getInstance
()
{
7777 return anyOf(
7778 gnuNullExpr(), cxxNullPtrLiteralExpr(),
7779 integerLiteral(equals(0), hasParent(expr(hasType(pointerType())))));
7780}
7781
7782/// Matches the DecompositionDecl the binding belongs to.
7783///
7784/// For example, in:
7785/// \code
7786/// void foo()
7787/// {
7788/// int arr[3];
7789/// auto &[f, s, t] = arr;
7790///
7791/// f = 42;
7792/// }
7793/// \endcode
7794/// The matcher:
7795/// \code
7796/// bindingDecl(hasName("f"),
7797/// forDecomposition(decompositionDecl())
7798/// \endcode
7799/// matches 'f' in 'auto &[f, s, t]'.
7800AST_MATCHER_P(BindingDecl, forDecomposition, internal::Matcher<ValueDecl>,namespace internal { class matcher_forDecomposition0Matcher :
public ::clang::ast_matchers::internal::MatcherInterface<
BindingDecl> { public: explicit matcher_forDecomposition0Matcher
( internal::Matcher<ValueDecl> const &AInnerMatcher
) : InnerMatcher(AInnerMatcher) {} bool matches(const BindingDecl
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: internal::Matcher<ValueDecl
> InnerMatcher; }; } inline ::clang::ast_matchers::internal
::Matcher<BindingDecl> forDecomposition( internal::Matcher
<ValueDecl> const &InnerMatcher) { return ::clang::
ast_matchers::internal::makeMatcher( new internal::matcher_forDecomposition0Matcher
(InnerMatcher)); } typedef ::clang::ast_matchers::internal::Matcher
<BindingDecl> ( &forDecomposition_Type0)(internal::
Matcher<ValueDecl> const &InnerMatcher); inline bool
internal::matcher_forDecomposition0Matcher::matches( const BindingDecl
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
7801 InnerMatcher)namespace internal { class matcher_forDecomposition0Matcher :
public ::clang::ast_matchers::internal::MatcherInterface<
BindingDecl> { public: explicit matcher_forDecomposition0Matcher
( internal::Matcher<ValueDecl> const &AInnerMatcher
) : InnerMatcher(AInnerMatcher) {} bool matches(const BindingDecl
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: internal::Matcher<ValueDecl
> InnerMatcher; }; } inline ::clang::ast_matchers::internal
::Matcher<BindingDecl> forDecomposition( internal::Matcher
<ValueDecl> const &InnerMatcher) { return ::clang::
ast_matchers::internal::makeMatcher( new internal::matcher_forDecomposition0Matcher
(InnerMatcher)); } typedef ::clang::ast_matchers::internal::Matcher
<BindingDecl> ( &forDecomposition_Type0)(internal::
Matcher<ValueDecl> const &InnerMatcher); inline bool
internal::matcher_forDecomposition0Matcher::matches( const BindingDecl
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
7802 if (const ValueDecl *VD = Node.getDecomposedDecl())
7803 return InnerMatcher.matches(*VD, Finder, Builder);
7804 return false;
7805}
7806
7807/// Matches the Nth binding of a DecompositionDecl.
7808///
7809/// For example, in:
7810/// \code
7811/// void foo()
7812/// {
7813/// int arr[3];
7814/// auto &[f, s, t] = arr;
7815///
7816/// f = 42;
7817/// }
7818/// \endcode
7819/// The matcher:
7820/// \code
7821/// decompositionDecl(hasBinding(0,
7822/// bindingDecl(hasName("f").bind("fBinding"))))
7823/// \endcode
7824/// matches the decomposition decl with 'f' bound to "fBinding".
7825AST_MATCHER_P2(DecompositionDecl, hasBinding, unsigned, N,namespace internal { class matcher_hasBinding0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<DecompositionDecl
> { public: matcher_hasBinding0Matcher(unsigned const &
AN, internal::Matcher<BindingDecl> const &AInnerMatcher
) : N(AN), InnerMatcher(AInnerMatcher) {} bool matches(const DecompositionDecl
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: unsigned N; internal::Matcher
<BindingDecl> InnerMatcher; }; } inline ::clang::ast_matchers
::internal::Matcher<DecompositionDecl> hasBinding( unsigned
const &N, internal::Matcher<BindingDecl> const &
InnerMatcher) { return ::clang::ast_matchers::internal::makeMatcher
( new internal::matcher_hasBinding0Matcher(N, InnerMatcher));
} typedef ::clang::ast_matchers::internal::Matcher<DecompositionDecl
> ( &hasBinding_Type0)(unsigned const &N, internal
::Matcher<BindingDecl> const &InnerMatcher); inline
bool internal::matcher_hasBinding0Matcher::matches( const DecompositionDecl
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
7826 internal::Matcher<BindingDecl>, InnerMatcher)namespace internal { class matcher_hasBinding0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<DecompositionDecl
> { public: matcher_hasBinding0Matcher(unsigned const &
AN, internal::Matcher<BindingDecl> const &AInnerMatcher
) : N(AN), InnerMatcher(AInnerMatcher) {} bool matches(const DecompositionDecl
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: unsigned N; internal::Matcher
<BindingDecl> InnerMatcher; }; } inline ::clang::ast_matchers
::internal::Matcher<DecompositionDecl> hasBinding( unsigned
const &N, internal::Matcher<BindingDecl> const &
InnerMatcher) { return ::clang::ast_matchers::internal::makeMatcher
( new internal::matcher_hasBinding0Matcher(N, InnerMatcher));
} typedef ::clang::ast_matchers::internal::Matcher<DecompositionDecl
> ( &hasBinding_Type0)(unsigned const &N, internal
::Matcher<BindingDecl> const &InnerMatcher); inline
bool internal::matcher_hasBinding0Matcher::matches( const DecompositionDecl
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
7827 if (Node.bindings().size() <= N)
7828 return false;
7829 return InnerMatcher.matches(*Node.bindings()[N], Finder, Builder);
7830}
7831
7832/// Matches any binding of a DecompositionDecl.
7833///
7834/// For example, in:
7835/// \code
7836/// void foo()
7837/// {
7838/// int arr[3];
7839/// auto &[f, s, t] = arr;
7840///
7841/// f = 42;
7842/// }
7843/// \endcode
7844/// The matcher:
7845/// \code
7846/// decompositionDecl(hasAnyBinding(bindingDecl(hasName("f").bind("fBinding"))))
7847/// \endcode
7848/// matches the decomposition decl with 'f' bound to "fBinding".
7849AST_MATCHER_P(DecompositionDecl, hasAnyBinding, internal::Matcher<BindingDecl>,namespace internal { class matcher_hasAnyBinding0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<DecompositionDecl
> { public: explicit matcher_hasAnyBinding0Matcher( internal
::Matcher<BindingDecl> const &AInnerMatcher) : InnerMatcher
(AInnerMatcher) {} bool matches(const DecompositionDecl &
Node, ::clang::ast_matchers::internal::ASTMatchFinder *Finder
, ::clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder
) const override; private: internal::Matcher<BindingDecl>
InnerMatcher; }; } inline ::clang::ast_matchers::internal::Matcher
<DecompositionDecl> hasAnyBinding( internal::Matcher<
BindingDecl> const &InnerMatcher) { return ::clang::ast_matchers
::internal::makeMatcher( new internal::matcher_hasAnyBinding0Matcher
(InnerMatcher)); } typedef ::clang::ast_matchers::internal::Matcher
<DecompositionDecl> ( &hasAnyBinding_Type0)(internal
::Matcher<BindingDecl> const &InnerMatcher); inline
bool internal::matcher_hasAnyBinding0Matcher::matches( const
DecompositionDecl &Node, ::clang::ast_matchers::internal
::ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
7850 InnerMatcher)namespace internal { class matcher_hasAnyBinding0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<DecompositionDecl
> { public: explicit matcher_hasAnyBinding0Matcher( internal
::Matcher<BindingDecl> const &AInnerMatcher) : InnerMatcher
(AInnerMatcher) {} bool matches(const DecompositionDecl &
Node, ::clang::ast_matchers::internal::ASTMatchFinder *Finder
, ::clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder
) const override; private: internal::Matcher<BindingDecl>
InnerMatcher; }; } inline ::clang::ast_matchers::internal::Matcher
<DecompositionDecl> hasAnyBinding( internal::Matcher<
BindingDecl> const &InnerMatcher) { return ::clang::ast_matchers
::internal::makeMatcher( new internal::matcher_hasAnyBinding0Matcher
(InnerMatcher)); } typedef ::clang::ast_matchers::internal::Matcher
<DecompositionDecl> ( &hasAnyBinding_Type0)(internal
::Matcher<BindingDecl> const &InnerMatcher); inline
bool internal::matcher_hasAnyBinding0Matcher::matches( const
DecompositionDecl &Node, ::clang::ast_matchers::internal
::ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
7851 return llvm::any_of(Node.bindings(), [&](const auto *Binding) {
7852 return InnerMatcher.matches(*Binding, Finder, Builder);
7853 });
7854}
7855
7856/// Matches declaration of the function the statement belongs to.
7857///
7858/// Deprecated. Use forCallable() to correctly handle the situation when
7859/// the declaration is not a function (but a block or an Objective-C method).
7860/// forFunction() not only fails to take non-functions into account but also
7861/// may match the wrong declaration in their presence.
7862///
7863/// Given:
7864/// \code
7865/// F& operator=(const F& o) {
7866/// std::copy_if(o.begin(), o.end(), begin(), [](V v) { return v > 0; });
7867/// return *this;
7868/// }
7869/// \endcode
7870/// returnStmt(forFunction(hasName("operator=")))
7871/// matches 'return *this'
7872/// but does not match 'return v > 0'
7873AST_MATCHER_P(Stmt, forFunction, internal::Matcher<FunctionDecl>,namespace internal { class matcher_forFunction0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<Stmt>
{ public: explicit matcher_forFunction0Matcher( internal::Matcher
<FunctionDecl> const &AInnerMatcher) : InnerMatcher
(AInnerMatcher) {} bool matches(const Stmt &Node, ::clang
::ast_matchers::internal::ASTMatchFinder *Finder, ::clang::ast_matchers
::internal::BoundNodesTreeBuilder *Builder) const override; private
: internal::Matcher<FunctionDecl> InnerMatcher; }; } inline
::clang::ast_matchers::internal::Matcher<Stmt> forFunction
( internal::Matcher<FunctionDecl> const &InnerMatcher
) { return ::clang::ast_matchers::internal::makeMatcher( new internal
::matcher_forFunction0Matcher(InnerMatcher)); } typedef ::clang
::ast_matchers::internal::Matcher<Stmt> ( &forFunction_Type0
)(internal::Matcher<FunctionDecl> const &InnerMatcher
); inline bool internal::matcher_forFunction0Matcher::matches
( const Stmt &Node, ::clang::ast_matchers::internal::ASTMatchFinder
*Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
7874 InnerMatcher)namespace internal { class matcher_forFunction0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<Stmt>
{ public: explicit matcher_forFunction0Matcher( internal::Matcher
<FunctionDecl> const &AInnerMatcher) : InnerMatcher
(AInnerMatcher) {} bool matches(const Stmt &Node, ::clang
::ast_matchers::internal::ASTMatchFinder *Finder, ::clang::ast_matchers
::internal::BoundNodesTreeBuilder *Builder) const override; private
: internal::Matcher<FunctionDecl> InnerMatcher; }; } inline
::clang::ast_matchers::internal::Matcher<Stmt> forFunction
( internal::Matcher<FunctionDecl> const &InnerMatcher
) { return ::clang::ast_matchers::internal::makeMatcher( new internal
::matcher_forFunction0Matcher(InnerMatcher)); } typedef ::clang
::ast_matchers::internal::Matcher<Stmt> ( &forFunction_Type0
)(internal::Matcher<FunctionDecl> const &InnerMatcher
); inline bool internal::matcher_forFunction0Matcher::matches
( const Stmt &Node, ::clang::ast_matchers::internal::ASTMatchFinder
*Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
7875 const auto &Parents = Finder->getASTContext().getParents(Node);
7876
7877 llvm::SmallVector<DynTypedNode, 8> Stack(Parents.begin(), Parents.end());
7878 while (!Stack.empty()) {
7879 const auto &CurNode = Stack.back();
7880 Stack.pop_back();
7881 if (const auto *FuncDeclNode = CurNode.get<FunctionDecl>()) {
7882 if (InnerMatcher.matches(*FuncDeclNode, Finder, Builder)) {
7883 return true;
7884 }
7885 } else if (const auto *LambdaExprNode = CurNode.get<LambdaExpr>()) {
7886 if (InnerMatcher.matches(*LambdaExprNode->getCallOperator(), Finder,
7887 Builder)) {
7888 return true;
7889 }
7890 } else {
7891 for (const auto &Parent : Finder->getASTContext().getParents(CurNode))
7892 Stack.push_back(Parent);
7893 }
7894 }
7895 return false;
7896}
7897
7898/// Matches declaration of the function, method, or block the statement
7899/// belongs to.
7900///
7901/// Given:
7902/// \code
7903/// F& operator=(const F& o) {
7904/// std::copy_if(o.begin(), o.end(), begin(), [](V v) { return v > 0; });
7905/// return *this;
7906/// }
7907/// \endcode
7908/// returnStmt(forCallable(functionDecl(hasName("operator="))))
7909/// matches 'return *this'
7910/// but does not match 'return v > 0'
7911///
7912/// Given:
7913/// \code
7914/// -(void) foo {
7915/// int x = 1;
7916/// dispatch_sync(queue, ^{ int y = 2; });
7917/// }
7918/// \endcode
7919/// declStmt(forCallable(objcMethodDecl()))
7920/// matches 'int x = 1'
7921/// but does not match 'int y = 2'.
7922/// whereas declStmt(forCallable(blockDecl()))
7923/// matches 'int y = 2'
7924/// but does not match 'int x = 1'.
7925AST_MATCHER_P(Stmt, forCallable, internal::Matcher<Decl>, InnerMatcher)namespace internal { class matcher_forCallable0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<Stmt>
{ public: explicit matcher_forCallable0Matcher( internal::Matcher
<Decl> const &AInnerMatcher) : InnerMatcher(AInnerMatcher
) {} bool matches(const Stmt &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<Stmt> forCallable( internal::Matcher
<Decl> const &InnerMatcher) { return ::clang::ast_matchers
::internal::makeMatcher( new internal::matcher_forCallable0Matcher
(InnerMatcher)); } typedef ::clang::ast_matchers::internal::Matcher
<Stmt> ( &forCallable_Type0)(internal::Matcher<Decl
> const &InnerMatcher); inline bool internal::matcher_forCallable0Matcher
::matches( const Stmt &Node, ::clang::ast_matchers::internal
::ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
7926 const auto &Parents = Finder->getASTContext().getParents(Node);
7927
7928 llvm::SmallVector<DynTypedNode, 8> Stack(Parents.begin(), Parents.end());
7929 while (!Stack.empty()) {
7930 const auto &CurNode = Stack.back();
7931 Stack.pop_back();
7932 if (const auto *FuncDeclNode = CurNode.get<FunctionDecl>()) {
7933 if (InnerMatcher.matches(*FuncDeclNode, Finder, Builder)) {
7934 return true;
7935 }
7936 } else if (const auto *LambdaExprNode = CurNode.get<LambdaExpr>()) {
7937 if (InnerMatcher.matches(*LambdaExprNode->getCallOperator(), Finder,
7938 Builder)) {
7939 return true;
7940 }
7941 } else if (const auto *ObjCMethodDeclNode = CurNode.get<ObjCMethodDecl>()) {
7942 if (InnerMatcher.matches(*ObjCMethodDeclNode, Finder, Builder)) {
7943 return true;
7944 }
7945 } else if (const auto *BlockDeclNode = CurNode.get<BlockDecl>()) {
7946 if (InnerMatcher.matches(*BlockDeclNode, Finder, Builder)) {
7947 return true;
7948 }
7949 } else {
7950 for (const auto &Parent : Finder->getASTContext().getParents(CurNode))
7951 Stack.push_back(Parent);
7952 }
7953 }
7954 return false;
7955}
7956
7957/// Matches a declaration that has external formal linkage.
7958///
7959/// Example matches only z (matcher = varDecl(hasExternalFormalLinkage()))
7960/// \code
7961/// void f() {
7962/// int x;
7963/// static int y;
7964/// }
7965/// int z;
7966/// \endcode
7967///
7968/// Example matches f() because it has external formal linkage despite being
7969/// unique to the translation unit as though it has internal likage
7970/// (matcher = functionDecl(hasExternalFormalLinkage()))
7971///
7972/// \code
7973/// namespace {
7974/// void f() {}
7975/// }
7976/// \endcode
7977AST_MATCHER(NamedDecl, hasExternalFormalLinkage)namespace internal { class matcher_hasExternalFormalLinkageMatcher
: public ::clang::ast_matchers::internal::MatcherInterface<
NamedDecl> { public: explicit matcher_hasExternalFormalLinkageMatcher
() = default; bool matches(const NamedDecl &Node, ::clang
::ast_matchers::internal::ASTMatchFinder *Finder, ::clang::ast_matchers
::internal::BoundNodesTreeBuilder *Builder) const override; }
; } inline ::clang::ast_matchers::internal::Matcher<NamedDecl
> hasExternalFormalLinkage() { return ::clang::ast_matchers
::internal::makeMatcher( new internal::matcher_hasExternalFormalLinkageMatcher
()); } inline bool internal::matcher_hasExternalFormalLinkageMatcher
::matches( const NamedDecl &Node, ::clang::ast_matchers::
internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
{
7978 return Node.hasExternalFormalLinkage();
7979}
7980
7981/// Matches a declaration that has default arguments.
7982///
7983/// Example matches y (matcher = parmVarDecl(hasDefaultArgument()))
7984/// \code
7985/// void x(int val) {}
7986/// void y(int val = 0) {}
7987/// \endcode
7988///
7989/// Deprecated. Use hasInitializer() instead to be able to
7990/// match on the contents of the default argument. For example:
7991///
7992/// \code
7993/// void x(int val = 7) {}
7994/// void y(int val = 42) {}
7995/// \endcode
7996/// parmVarDecl(hasInitializer(integerLiteral(equals(42))))
7997/// matches the parameter of y
7998///
7999/// A matcher such as
8000/// parmVarDecl(hasInitializer(anything()))
8001/// is equivalent to parmVarDecl(hasDefaultArgument()).
8002AST_MATCHER(ParmVarDecl, hasDefaultArgument)namespace internal { class matcher_hasDefaultArgumentMatcher :
public ::clang::ast_matchers::internal::MatcherInterface<
ParmVarDecl> { public: explicit matcher_hasDefaultArgumentMatcher
() = default; bool matches(const ParmVarDecl &Node, ::clang
::ast_matchers::internal::ASTMatchFinder *Finder, ::clang::ast_matchers
::internal::BoundNodesTreeBuilder *Builder) const override; }
; } inline ::clang::ast_matchers::internal::Matcher<ParmVarDecl
> hasDefaultArgument() { return ::clang::ast_matchers::internal
::makeMatcher( new internal::matcher_hasDefaultArgumentMatcher
()); } inline bool internal::matcher_hasDefaultArgumentMatcher
::matches( const ParmVarDecl &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
{
8003 return Node.hasDefaultArg();
8004}
8005
8006/// Matches array new expressions.
8007///
8008/// Given:
8009/// \code
8010/// MyClass *p1 = new MyClass[10];
8011/// \endcode
8012/// cxxNewExpr(isArray())
8013/// matches the expression 'new MyClass[10]'.
8014AST_MATCHER(CXXNewExpr, isArray)namespace internal { class matcher_isArrayMatcher : public ::
clang::ast_matchers::internal::MatcherInterface<CXXNewExpr
> { public: explicit matcher_isArrayMatcher() = default; bool
matches(const CXXNewExpr &Node, ::clang::ast_matchers::internal
::ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; }; } inline ::clang::ast_matchers::
internal::Matcher<CXXNewExpr> isArray() { return ::clang
::ast_matchers::internal::makeMatcher( new internal::matcher_isArrayMatcher
()); } inline bool internal::matcher_isArrayMatcher::matches(
const CXXNewExpr &Node, ::clang::ast_matchers::internal::
ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
8015 return Node.isArray();
8016}
8017
8018/// Matches placement new expression arguments.
8019///
8020/// Given:
8021/// \code
8022/// MyClass *p1 = new (Storage, 16) MyClass();
8023/// \endcode
8024/// cxxNewExpr(hasPlacementArg(1, integerLiteral(equals(16))))
8025/// matches the expression 'new (Storage, 16) MyClass()'.
8026AST_MATCHER_P2(CXXNewExpr, hasPlacementArg, unsigned, Index,namespace internal { class matcher_hasPlacementArg0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<CXXNewExpr
> { public: matcher_hasPlacementArg0Matcher(unsigned const
&AIndex, internal::Matcher<Expr> const &AInnerMatcher
) : Index(AIndex), InnerMatcher(AInnerMatcher) {} bool matches
(const CXXNewExpr &Node, ::clang::ast_matchers::internal::
ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: unsigned Index; internal::
Matcher<Expr> InnerMatcher; }; } inline ::clang::ast_matchers
::internal::Matcher<CXXNewExpr> hasPlacementArg( unsigned
const &Index, internal::Matcher<Expr> const &InnerMatcher
) { return ::clang::ast_matchers::internal::makeMatcher( new internal
::matcher_hasPlacementArg0Matcher(Index, InnerMatcher)); } typedef
::clang::ast_matchers::internal::Matcher<CXXNewExpr> (
&hasPlacementArg_Type0)(unsigned const &Index, internal
::Matcher<Expr> const &InnerMatcher); inline bool internal
::matcher_hasPlacementArg0Matcher::matches( const CXXNewExpr &
Node, ::clang::ast_matchers::internal::ASTMatchFinder *Finder
, ::clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder
) const
8027 internal::Matcher<Expr>, InnerMatcher)namespace internal { class matcher_hasPlacementArg0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<CXXNewExpr
> { public: matcher_hasPlacementArg0Matcher(unsigned const
&AIndex, internal::Matcher<Expr> const &AInnerMatcher
) : Index(AIndex), InnerMatcher(AInnerMatcher) {} bool matches
(const CXXNewExpr &Node, ::clang::ast_matchers::internal::
ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; private: unsigned Index; internal::
Matcher<Expr> InnerMatcher; }; } inline ::clang::ast_matchers
::internal::Matcher<CXXNewExpr> hasPlacementArg( unsigned
const &Index, internal::Matcher<Expr> const &InnerMatcher
) { return ::clang::ast_matchers::internal::makeMatcher( new internal
::matcher_hasPlacementArg0Matcher(Index, InnerMatcher)); } typedef
::clang::ast_matchers::internal::Matcher<CXXNewExpr> (
&hasPlacementArg_Type0)(unsigned const &Index, internal
::Matcher<Expr> const &InnerMatcher); inline bool internal
::matcher_hasPlacementArg0Matcher::matches( const CXXNewExpr &
Node, ::clang::ast_matchers::internal::ASTMatchFinder *Finder
, ::clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder
) const
{
8028 return Node.getNumPlacementArgs() > Index &&
8029 InnerMatcher.matches(*Node.getPlacementArg(Index), Finder, Builder);
8030}
8031
8032/// Matches any placement new expression arguments.
8033///
8034/// Given:
8035/// \code
8036/// MyClass *p1 = new (Storage) MyClass();
8037/// \endcode
8038/// cxxNewExpr(hasAnyPlacementArg(anything()))
8039/// matches the expression 'new (Storage, 16) MyClass()'.
8040AST_MATCHER_P(CXXNewExpr, hasAnyPlacementArg, internal::Matcher<Expr>,namespace internal { class matcher_hasAnyPlacementArg0Matcher
: public ::clang::ast_matchers::internal::MatcherInterface<
CXXNewExpr> { public: explicit matcher_hasAnyPlacementArg0Matcher
( internal::Matcher<Expr> const &AInnerMatcher) : InnerMatcher
(AInnerMatcher) {} bool matches(const CXXNewExpr &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<CXXNewExpr
> hasAnyPlacementArg( internal::Matcher<Expr> const &
InnerMatcher) { return ::clang::ast_matchers::internal::makeMatcher
( new internal::matcher_hasAnyPlacementArg0Matcher(InnerMatcher
)); } typedef ::clang::ast_matchers::internal::Matcher<CXXNewExpr
> ( &hasAnyPlacementArg_Type0)(internal::Matcher<Expr
> const &InnerMatcher); inline bool internal::matcher_hasAnyPlacementArg0Matcher
::matches( const CXXNewExpr &Node, ::clang::ast_matchers::
internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
8041 InnerMatcher)namespace internal { class matcher_hasAnyPlacementArg0Matcher
: public ::clang::ast_matchers::internal::MatcherInterface<
CXXNewExpr> { public: explicit matcher_hasAnyPlacementArg0Matcher
( internal::Matcher<Expr> const &AInnerMatcher) : InnerMatcher
(AInnerMatcher) {} bool matches(const CXXNewExpr &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<CXXNewExpr
> hasAnyPlacementArg( internal::Matcher<Expr> const &
InnerMatcher) { return ::clang::ast_matchers::internal::makeMatcher
( new internal::matcher_hasAnyPlacementArg0Matcher(InnerMatcher
)); } typedef ::clang::ast_matchers::internal::Matcher<CXXNewExpr
> ( &hasAnyPlacementArg_Type0)(internal::Matcher<Expr
> const &InnerMatcher); inline bool internal::matcher_hasAnyPlacementArg0Matcher
::matches( const CXXNewExpr &Node, ::clang::ast_matchers::
internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
{
8042 return llvm::any_of(Node.placement_arguments(), [&](const Expr *Arg) {
8043 return InnerMatcher.matches(*Arg, Finder, Builder);
8044 });
8045}
8046
8047/// Matches array new expressions with a given array size.
8048///
8049/// Given:
8050/// \code
8051/// MyClass *p1 = new MyClass[10];
8052/// \endcode
8053/// cxxNewExpr(hasArraySize(integerLiteral(equals(10))))
8054/// matches the expression 'new MyClass[10]'.
8055AST_MATCHER_P(CXXNewExpr, hasArraySize, internal::Matcher<Expr>, InnerMatcher)namespace internal { class matcher_hasArraySize0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<CXXNewExpr
> { public: explicit matcher_hasArraySize0Matcher( internal
::Matcher<Expr> const &AInnerMatcher) : InnerMatcher
(AInnerMatcher) {} bool matches(const CXXNewExpr &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<CXXNewExpr
> hasArraySize( internal::Matcher<Expr> const &InnerMatcher
) { return ::clang::ast_matchers::internal::makeMatcher( new internal
::matcher_hasArraySize0Matcher(InnerMatcher)); } typedef ::clang
::ast_matchers::internal::Matcher<CXXNewExpr> ( &hasArraySize_Type0
)(internal::Matcher<Expr> const &InnerMatcher); inline
bool internal::matcher_hasArraySize0Matcher::matches( const CXXNewExpr
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
8056 return Node.isArray() && *Node.getArraySize() &&
8057 InnerMatcher.matches(**Node.getArraySize(), Finder, Builder);
8058}
8059
8060/// Matches a class declaration that is defined.
8061///
8062/// Example matches x (matcher = cxxRecordDecl(hasDefinition()))
8063/// \code
8064/// class x {};
8065/// class y;
8066/// \endcode
8067AST_MATCHER(CXXRecordDecl, hasDefinition)namespace internal { class matcher_hasDefinitionMatcher : public
::clang::ast_matchers::internal::MatcherInterface<CXXRecordDecl
> { public: explicit matcher_hasDefinitionMatcher() = 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>
hasDefinition() { return ::clang::ast_matchers::internal::makeMatcher
( new internal::matcher_hasDefinitionMatcher()); } inline bool
internal::matcher_hasDefinitionMatcher::matches( const CXXRecordDecl
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
8068 return Node.hasDefinition();
8069}
8070
8071/// Matches C++11 scoped enum declaration.
8072///
8073/// Example matches Y (matcher = enumDecl(isScoped()))
8074/// \code
8075/// enum X {};
8076/// enum class Y {};
8077/// \endcode
8078AST_MATCHER(EnumDecl, isScoped)namespace internal { class matcher_isScopedMatcher : public ::
clang::ast_matchers::internal::MatcherInterface<EnumDecl>
{ public: explicit matcher_isScopedMatcher() = default; bool
matches(const EnumDecl &Node, ::clang::ast_matchers::internal
::ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const override; }; } inline ::clang::ast_matchers::
internal::Matcher<EnumDecl> isScoped() { return ::clang
::ast_matchers::internal::makeMatcher( new internal::matcher_isScopedMatcher
()); } inline bool internal::matcher_isScopedMatcher::matches
( const EnumDecl &Node, ::clang::ast_matchers::internal::
ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
8079 return Node.isScoped();
8080}
8081
8082/// Matches a function declared with a trailing return type.
8083///
8084/// Example matches Y (matcher = functionDecl(hasTrailingReturn()))
8085/// \code
8086/// int X() {}
8087/// auto Y() -> int {}
8088/// \endcode
8089AST_MATCHER(FunctionDecl, hasTrailingReturn)namespace internal { class matcher_hasTrailingReturnMatcher :
public ::clang::ast_matchers::internal::MatcherInterface<
FunctionDecl> { public: explicit matcher_hasTrailingReturnMatcher
() = 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
> hasTrailingReturn() { return ::clang::ast_matchers::internal
::makeMatcher( new internal::matcher_hasTrailingReturnMatcher
()); } inline bool internal::matcher_hasTrailingReturnMatcher
::matches( const FunctionDecl &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
{
8090 if (const auto *F = Node.getType()->getAs<FunctionProtoType>())
8091 return F->hasTrailingReturn();
8092 return false;
8093}
8094
8095/// Matches expressions that match InnerMatcher that are possibly wrapped in an
8096/// elidable constructor and other corresponding bookkeeping nodes.
8097///
8098/// In C++17, elidable copy constructors are no longer being generated in the
8099/// AST as it is not permitted by the standard. They are, however, part of the
8100/// AST in C++14 and earlier. So, a matcher must abstract over these differences
8101/// to work in all language modes. This matcher skips elidable constructor-call
8102/// AST nodes, `ExprWithCleanups` nodes wrapping elidable constructor-calls and
8103/// various implicit nodes inside the constructor calls, all of which will not
8104/// appear in the C++17 AST.
8105///
8106/// Given
8107///
8108/// \code
8109/// struct H {};
8110/// H G();
8111/// void f() {
8112/// H D = G();
8113/// }
8114/// \endcode
8115///
8116/// ``varDecl(hasInitializer(ignoringElidableConstructorCall(callExpr())))``
8117/// matches ``H D = G()`` in C++11 through C++17 (and beyond).
8118AST_MATCHER_P(Expr, ignoringElidableConstructorCall,namespace internal { class matcher_ignoringElidableConstructorCall0Matcher
: public ::clang::ast_matchers::internal::MatcherInterface<
Expr> { public: explicit matcher_ignoringElidableConstructorCall0Matcher
( ast_matchers::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: ast_matchers::internal::Matcher<
Expr> InnerMatcher; }; } inline ::clang::ast_matchers::internal
::Matcher<Expr> ignoringElidableConstructorCall( ast_matchers
::internal::Matcher<Expr> const &InnerMatcher) { return
::clang::ast_matchers::internal::makeMatcher( new internal::
matcher_ignoringElidableConstructorCall0Matcher(InnerMatcher)
); } typedef ::clang::ast_matchers::internal::Matcher<Expr
> ( &ignoringElidableConstructorCall_Type0)(ast_matchers
::internal::Matcher<Expr> const &InnerMatcher); inline
bool internal::matcher_ignoringElidableConstructorCall0Matcher
::matches( const Expr &Node, ::clang::ast_matchers::internal
::ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
8119 ast_matchers::internal::Matcher<Expr>, InnerMatcher)namespace internal { class matcher_ignoringElidableConstructorCall0Matcher
: public ::clang::ast_matchers::internal::MatcherInterface<
Expr> { public: explicit matcher_ignoringElidableConstructorCall0Matcher
( ast_matchers::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: ast_matchers::internal::Matcher<
Expr> InnerMatcher; }; } inline ::clang::ast_matchers::internal
::Matcher<Expr> ignoringElidableConstructorCall( ast_matchers
::internal::Matcher<Expr> const &InnerMatcher) { return
::clang::ast_matchers::internal::makeMatcher( new internal::
matcher_ignoringElidableConstructorCall0Matcher(InnerMatcher)
); } typedef ::clang::ast_matchers::internal::Matcher<Expr
> ( &ignoringElidableConstructorCall_Type0)(ast_matchers
::internal::Matcher<Expr> const &InnerMatcher); inline
bool internal::matcher_ignoringElidableConstructorCall0Matcher
::matches( const Expr &Node, ::clang::ast_matchers::internal
::ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
8120 // E tracks the node that we are examining.
8121 const Expr *E = &Node;
8122 // If present, remove an outer `ExprWithCleanups` corresponding to the
8123 // underlying `CXXConstructExpr`. This check won't cover all cases of added
8124 // `ExprWithCleanups` corresponding to `CXXConstructExpr` nodes (because the
8125 // EWC is placed on the outermost node of the expression, which this may not
8126 // be), but, it still improves the coverage of this matcher.
8127 if (const auto *CleanupsExpr = dyn_cast<ExprWithCleanups>(&Node))
8128 E = CleanupsExpr->getSubExpr();
8129 if (const auto *CtorExpr = dyn_cast<CXXConstructExpr>(E)) {
8130 if (CtorExpr->isElidable()) {
8131 if (const auto *MaterializeTemp =
8132 dyn_cast<MaterializeTemporaryExpr>(CtorExpr->getArg(0))) {
8133 return InnerMatcher.matches(*MaterializeTemp->getSubExpr(), Finder,
8134 Builder);
8135 }
8136 }
8137 }
8138 return InnerMatcher.matches(Node, Finder, Builder);
8139}
8140
8141//----------------------------------------------------------------------------//
8142// OpenMP handling.
8143//----------------------------------------------------------------------------//
8144
8145/// Matches any ``#pragma omp`` executable directive.
8146///
8147/// Given
8148///
8149/// \code
8150/// #pragma omp parallel
8151/// #pragma omp parallel default(none)
8152/// #pragma omp taskyield
8153/// \endcode
8154///
8155/// ``ompExecutableDirective()`` matches ``omp parallel``,
8156/// ``omp parallel default(none)`` and ``omp taskyield``.
8157extern const internal::VariadicDynCastAllOfMatcher<Stmt, OMPExecutableDirective>
8158 ompExecutableDirective;
8159
8160/// Matches standalone OpenMP directives,
8161/// i.e., directives that can't have a structured block.
8162///
8163/// Given
8164///
8165/// \code
8166/// #pragma omp parallel
8167/// {}
8168/// #pragma omp taskyield
8169/// \endcode
8170///
8171/// ``ompExecutableDirective(isStandaloneDirective()))`` matches
8172/// ``omp taskyield``.
8173AST_MATCHER(OMPExecutableDirective, isStandaloneDirective)namespace internal { class matcher_isStandaloneDirectiveMatcher
: public ::clang::ast_matchers::internal::MatcherInterface<
OMPExecutableDirective> { public: explicit matcher_isStandaloneDirectiveMatcher
() = default; bool matches(const OMPExecutableDirective &
Node, ::clang::ast_matchers::internal::ASTMatchFinder *Finder
, ::clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder
) const override; }; } inline ::clang::ast_matchers::internal
::Matcher<OMPExecutableDirective> isStandaloneDirective
() { return ::clang::ast_matchers::internal::makeMatcher( new
internal::matcher_isStandaloneDirectiveMatcher()); } inline bool
internal::matcher_isStandaloneDirectiveMatcher::matches( const
OMPExecutableDirective &Node, ::clang::ast_matchers::internal
::ASTMatchFinder *Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
8174 return Node.isStandaloneDirective();
8175}
8176
8177/// Matches the structured-block of the OpenMP executable directive
8178///
8179/// Prerequisite: the executable directive must not be standalone directive.
8180/// If it is, it will never match.
8181///
8182/// Given
8183///
8184/// \code
8185/// #pragma omp parallel
8186/// ;
8187/// #pragma omp parallel
8188/// {}
8189/// \endcode
8190///
8191/// ``ompExecutableDirective(hasStructuredBlock(nullStmt()))`` will match ``;``
8192AST_MATCHER_P(OMPExecutableDirective, hasStructuredBlock,namespace internal { class matcher_hasStructuredBlock0Matcher
: public ::clang::ast_matchers::internal::MatcherInterface<
OMPExecutableDirective> { public: explicit matcher_hasStructuredBlock0Matcher
( internal::Matcher<Stmt> const &AInnerMatcher) : InnerMatcher
(AInnerMatcher) {} bool matches(const OMPExecutableDirective &
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<OMPExecutableDirective
> hasStructuredBlock( internal::Matcher<Stmt> const &
InnerMatcher) { return ::clang::ast_matchers::internal::makeMatcher
( new internal::matcher_hasStructuredBlock0Matcher(InnerMatcher
)); } typedef ::clang::ast_matchers::internal::Matcher<OMPExecutableDirective
> ( &hasStructuredBlock_Type0)(internal::Matcher<Stmt
> const &InnerMatcher); inline bool internal::matcher_hasStructuredBlock0Matcher
::matches( const OMPExecutableDirective &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
8193 internal::Matcher<Stmt>, InnerMatcher)namespace internal { class matcher_hasStructuredBlock0Matcher
: public ::clang::ast_matchers::internal::MatcherInterface<
OMPExecutableDirective> { public: explicit matcher_hasStructuredBlock0Matcher
( internal::Matcher<Stmt> const &AInnerMatcher) : InnerMatcher
(AInnerMatcher) {} bool matches(const OMPExecutableDirective &
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<OMPExecutableDirective
> hasStructuredBlock( internal::Matcher<Stmt> const &
InnerMatcher) { return ::clang::ast_matchers::internal::makeMatcher
( new internal::matcher_hasStructuredBlock0Matcher(InnerMatcher
)); } typedef ::clang::ast_matchers::internal::Matcher<OMPExecutableDirective
> ( &hasStructuredBlock_Type0)(internal::Matcher<Stmt
> const &InnerMatcher); inline bool internal::matcher_hasStructuredBlock0Matcher
::matches( const OMPExecutableDirective &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
{
8194 if (Node.isStandaloneDirective())
8195 return false; // Standalone directives have no structured blocks.
8196 return InnerMatcher.matches(*Node.getStructuredBlock(), Finder, Builder);
8197}
8198
8199/// Matches any clause in an OpenMP directive.
8200///
8201/// Given
8202///
8203/// \code
8204/// #pragma omp parallel
8205/// #pragma omp parallel default(none)
8206/// \endcode
8207///
8208/// ``ompExecutableDirective(hasAnyClause(anything()))`` matches
8209/// ``omp parallel default(none)``.
8210AST_MATCHER_P(OMPExecutableDirective, hasAnyClause,namespace internal { class matcher_hasAnyClause0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<OMPExecutableDirective
> { public: explicit matcher_hasAnyClause0Matcher( internal
::Matcher<OMPClause> const &AInnerMatcher) : InnerMatcher
(AInnerMatcher) {} bool matches(const OMPExecutableDirective &
Node, ::clang::ast_matchers::internal::ASTMatchFinder *Finder
, ::clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder
) const override; private: internal::Matcher<OMPClause>
InnerMatcher; }; } inline ::clang::ast_matchers::internal::Matcher
<OMPExecutableDirective> hasAnyClause( internal::Matcher
<OMPClause> const &InnerMatcher) { return ::clang::
ast_matchers::internal::makeMatcher( new internal::matcher_hasAnyClause0Matcher
(InnerMatcher)); } typedef ::clang::ast_matchers::internal::Matcher
<OMPExecutableDirective> ( &hasAnyClause_Type0)(internal
::Matcher<OMPClause> const &InnerMatcher); inline bool
internal::matcher_hasAnyClause0Matcher::matches( const OMPExecutableDirective
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
8211 internal::Matcher<OMPClause>, InnerMatcher)namespace internal { class matcher_hasAnyClause0Matcher : public
::clang::ast_matchers::internal::MatcherInterface<OMPExecutableDirective
> { public: explicit matcher_hasAnyClause0Matcher( internal
::Matcher<OMPClause> const &AInnerMatcher) : InnerMatcher
(AInnerMatcher) {} bool matches(const OMPExecutableDirective &
Node, ::clang::ast_matchers::internal::ASTMatchFinder *Finder
, ::clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder
) const override; private: internal::Matcher<OMPClause>
InnerMatcher; }; } inline ::clang::ast_matchers::internal::Matcher
<OMPExecutableDirective> hasAnyClause( internal::Matcher
<OMPClause> const &InnerMatcher) { return ::clang::
ast_matchers::internal::makeMatcher( new internal::matcher_hasAnyClause0Matcher
(InnerMatcher)); } typedef ::clang::ast_matchers::internal::Matcher
<OMPExecutableDirective> ( &hasAnyClause_Type0)(internal
::Matcher<OMPClause> const &InnerMatcher); inline bool
internal::matcher_hasAnyClause0Matcher::matches( const OMPExecutableDirective
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
8212 ArrayRef<OMPClause *> Clauses = Node.clauses();
8213 return matchesFirstInPointerRange(InnerMatcher, Clauses.begin(),
8214 Clauses.end(), Finder,
8215 Builder) != Clauses.end();
8216}
8217
8218/// Matches OpenMP ``default`` clause.
8219///
8220/// Given
8221///
8222/// \code
8223/// #pragma omp parallel default(none)
8224/// #pragma omp parallel default(shared)
8225/// #pragma omp parallel default(firstprivate)
8226/// #pragma omp parallel
8227/// \endcode
8228///
8229/// ``ompDefaultClause()`` matches ``default(none)``, ``default(shared)``, and
8230/// ``default(firstprivate)``
8231extern const internal::VariadicDynCastAllOfMatcher<OMPClause, OMPDefaultClause>
8232 ompDefaultClause;
8233
8234/// Matches if the OpenMP ``default`` clause has ``none`` kind specified.
8235///
8236/// Given
8237///
8238/// \code
8239/// #pragma omp parallel
8240/// #pragma omp parallel default(none)
8241/// #pragma omp parallel default(shared)
8242/// #pragma omp parallel default(firstprivate)
8243/// \endcode
8244///
8245/// ``ompDefaultClause(isNoneKind())`` matches only ``default(none)``.
8246AST_MATCHER(OMPDefaultClause, isNoneKind)namespace internal { class matcher_isNoneKindMatcher : public
::clang::ast_matchers::internal::MatcherInterface<OMPDefaultClause
> { public: explicit matcher_isNoneKindMatcher() = default
; bool matches(const OMPDefaultClause &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const override; }; } inline
::clang::ast_matchers::internal::Matcher<OMPDefaultClause
> isNoneKind() { return ::clang::ast_matchers::internal::makeMatcher
( new internal::matcher_isNoneKindMatcher()); } inline bool internal
::matcher_isNoneKindMatcher::matches( const OMPDefaultClause &
Node, ::clang::ast_matchers::internal::ASTMatchFinder *Finder
, ::clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder
) const
{
8247 return Node.getDefaultKind() == llvm::omp::OMP_DEFAULT_none;
8248}
8249
8250/// Matches if the OpenMP ``default`` clause has ``shared`` kind specified.
8251///
8252/// Given
8253///
8254/// \code
8255/// #pragma omp parallel
8256/// #pragma omp parallel default(none)
8257/// #pragma omp parallel default(shared)
8258/// #pragma omp parallel default(firstprivate)
8259/// \endcode
8260///
8261/// ``ompDefaultClause(isSharedKind())`` matches only ``default(shared)``.
8262AST_MATCHER(OMPDefaultClause, isSharedKind)namespace internal { class matcher_isSharedKindMatcher : public
::clang::ast_matchers::internal::MatcherInterface<OMPDefaultClause
> { public: explicit matcher_isSharedKindMatcher() = default
; bool matches(const OMPDefaultClause &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const override; }; } inline
::clang::ast_matchers::internal::Matcher<OMPDefaultClause
> isSharedKind() { return ::clang::ast_matchers::internal::
makeMatcher( new internal::matcher_isSharedKindMatcher()); } inline
bool internal::matcher_isSharedKindMatcher::matches( const OMPDefaultClause
&Node, ::clang::ast_matchers::internal::ASTMatchFinder *
Finder, ::clang::ast_matchers::internal::BoundNodesTreeBuilder
*Builder) const
{
8263 return Node.getDefaultKind() == llvm::omp::OMP_DEFAULT_shared;
8264}
8265
8266/// Matches if the OpenMP ``default`` clause has ``firstprivate`` kind
8267/// specified.
8268///
8269/// Given
8270///
8271/// \code
8272/// #pragma omp parallel
8273/// #pragma omp parallel default(none)
8274/// #pragma omp parallel default(shared)
8275/// #pragma omp parallel default(firstprivate)
8276/// \endcode
8277///
8278/// ``ompDefaultClause(isFirstPrivateKind())`` matches only
8279/// ``default(firstprivate)``.
8280AST_MATCHER(OMPDefaultClause, isFirstPrivateKind)namespace internal { class matcher_isFirstPrivateKindMatcher :
public ::clang::ast_matchers::internal::MatcherInterface<
OMPDefaultClause> { public: explicit matcher_isFirstPrivateKindMatcher
() = default; bool matches(const OMPDefaultClause &Node, ::
clang::ast_matchers::internal::ASTMatchFinder *Finder, ::clang
::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
override; }; } inline ::clang::ast_matchers::internal::Matcher
<OMPDefaultClause> isFirstPrivateKind() { return ::clang
::ast_matchers::internal::makeMatcher( new internal::matcher_isFirstPrivateKindMatcher
()); } inline bool internal::matcher_isFirstPrivateKindMatcher
::matches( const OMPDefaultClause &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
{
8281 return Node.getDefaultKind() == llvm::omp::OMP_DEFAULT_firstprivate;
8282}
8283
8284/// Matches if the OpenMP directive is allowed to contain the specified OpenMP
8285/// clause kind.
8286///
8287/// Given
8288///
8289/// \code
8290/// #pragma omp parallel
8291/// #pragma omp parallel for
8292/// #pragma omp for
8293/// \endcode
8294///
8295/// `ompExecutableDirective(isAllowedToContainClause(OMPC_default))`` matches
8296/// ``omp parallel`` and ``omp parallel for``.
8297///
8298/// If the matcher is use from clang-query, ``OpenMPClauseKind`` parameter
8299/// should be passed as a quoted string. e.g.,
8300/// ``isAllowedToContainClauseKind("OMPC_default").``
8301AST_MATCHER_P(OMPExecutableDirective, isAllowedToContainClauseKind,namespace internal { class matcher_isAllowedToContainClauseKind0Matcher
: public ::clang::ast_matchers::internal::MatcherInterface<
OMPExecutableDirective> { public: explicit matcher_isAllowedToContainClauseKind0Matcher
( OpenMPClauseKind const &ACKind) : CKind(ACKind) {} bool
matches(const OMPExecutableDirective &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const override; private: OpenMPClauseKind
CKind; }; } inline ::clang::ast_matchers::internal::Matcher<
OMPExecutableDirective> isAllowedToContainClauseKind( OpenMPClauseKind
const &CKind) { return ::clang::ast_matchers::internal::
makeMatcher( new internal::matcher_isAllowedToContainClauseKind0Matcher
(CKind)); } typedef ::clang::ast_matchers::internal::Matcher<
OMPExecutableDirective> ( &isAllowedToContainClauseKind_Type0
)(OpenMPClauseKind const &CKind); inline bool internal::matcher_isAllowedToContainClauseKind0Matcher
::matches( const OMPExecutableDirective &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
8302 OpenMPClauseKind, CKind)namespace internal { class matcher_isAllowedToContainClauseKind0Matcher
: public ::clang::ast_matchers::internal::MatcherInterface<
OMPExecutableDirective> { public: explicit matcher_isAllowedToContainClauseKind0Matcher
( OpenMPClauseKind const &ACKind) : CKind(ACKind) {} bool
matches(const OMPExecutableDirective &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const override; private: OpenMPClauseKind
CKind; }; } inline ::clang::ast_matchers::internal::Matcher<
OMPExecutableDirective> isAllowedToContainClauseKind( OpenMPClauseKind
const &CKind) { return ::clang::ast_matchers::internal::
makeMatcher( new internal::matcher_isAllowedToContainClauseKind0Matcher
(CKind)); } typedef ::clang::ast_matchers::internal::Matcher<
OMPExecutableDirective> ( &isAllowedToContainClauseKind_Type0
)(OpenMPClauseKind const &CKind); inline bool internal::matcher_isAllowedToContainClauseKind0Matcher
::matches( const OMPExecutableDirective &Node, ::clang::ast_matchers
::internal::ASTMatchFinder *Finder, ::clang::ast_matchers::internal
::BoundNodesTreeBuilder *Builder) const
{
8303 return llvm::omp::isAllowedClauseForDirective(
8304 Node.getDirectiveKind(), CKind,
8305 Finder->getASTContext().getLangOpts().OpenMP);
8306}
8307
8308//----------------------------------------------------------------------------//
8309// End OpenMP handling.
8310//----------------------------------------------------------------------------//
8311
8312} // namespace ast_matchers
8313} // namespace clang
8314
8315#endif // LLVM_CLANG_ASTMATCHERS_ASTMATCHERS_H

/build/llvm-toolchain-snapshot-14~++20220119111520+da61cb019eb2/clang/include/clang/ASTMatchers/ASTMatchersInternal.h

1//===- ASTMatchersInternal.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// Implements the base layer of the matcher framework.
10//
11// Matchers are methods that return a Matcher<T> which provides a method
12// Matches(...) which is a predicate on an AST node. The Matches method's
13// parameters define the context of the match, which allows matchers to recurse
14// or store the current node as bound to a specific string, so that it can be
15// retrieved later.
16//
17// In general, matchers have two parts:
18// 1. A function Matcher<T> MatcherName(<arguments>) which returns a Matcher<T>
19// based on the arguments and optionally on template type deduction based
20// on the arguments. Matcher<T>s form an implicit reverse hierarchy
21// to clang's AST class hierarchy, meaning that you can use a Matcher<Base>
22// everywhere a Matcher<Derived> is required.
23// 2. An implementation of a class derived from MatcherInterface<T>.
24//
25// The matcher functions are defined in ASTMatchers.h. To make it possible
26// to implement both the matcher function and the implementation of the matcher
27// interface in one place, ASTMatcherMacros.h defines macros that allow
28// implementing a matcher in a single place.
29//
30// This file contains the base classes needed to construct the actual matchers.
31//
32//===----------------------------------------------------------------------===//
33
34#ifndef LLVM_CLANG_ASTMATCHERS_ASTMATCHERSINTERNAL_H
35#define LLVM_CLANG_ASTMATCHERS_ASTMATCHERSINTERNAL_H
36
37#include "clang/AST/ASTTypeTraits.h"
38#include "clang/AST/Decl.h"
39#include "clang/AST/DeclCXX.h"
40#include "clang/AST/DeclFriend.h"
41#include "clang/AST/DeclTemplate.h"
42#include "clang/AST/Expr.h"
43#include "clang/AST/ExprCXX.h"
44#include "clang/AST/ExprObjC.h"
45#include "clang/AST/NestedNameSpecifier.h"
46#include "clang/AST/Stmt.h"
47#include "clang/AST/TemplateName.h"
48#include "clang/AST/Type.h"
49#include "clang/AST/TypeLoc.h"
50#include "clang/Basic/LLVM.h"
51#include "clang/Basic/OperatorKinds.h"
52#include "llvm/ADT/APFloat.h"
53#include "llvm/ADT/ArrayRef.h"
54#include "llvm/ADT/IntrusiveRefCntPtr.h"
55#include "llvm/ADT/None.h"
56#include "llvm/ADT/Optional.h"
57#include "llvm/ADT/STLExtras.h"
58#include "llvm/ADT/SmallVector.h"
59#include "llvm/ADT/StringRef.h"
60#include "llvm/ADT/iterator.h"
61#include "llvm/Support/Casting.h"
62#include "llvm/Support/ManagedStatic.h"
63#include "llvm/Support/Regex.h"
64#include <algorithm>
65#include <cassert>
66#include <cstddef>
67#include <cstdint>
68#include <map>
69#include <memory>
70#include <string>
71#include <tuple>
72#include <type_traits>
73#include <utility>
74#include <vector>
75
76namespace clang {
77
78class ASTContext;
79
80namespace ast_matchers {
81
82class BoundNodes;
83
84namespace internal {
85
86/// A type-list implementation.
87///
88/// A "linked list" of types, accessible by using the ::head and ::tail
89/// typedefs.
90template <typename... Ts> struct TypeList {}; // Empty sentinel type list.
91
92template <typename T1, typename... Ts> struct TypeList<T1, Ts...> {
93 /// The first type on the list.
94 using head = T1;
95
96 /// A sublist with the tail. ie everything but the head.
97 ///
98 /// This type is used to do recursion. TypeList<>/EmptyTypeList indicates the
99 /// end of the list.
100 using tail = TypeList<Ts...>;
101};
102
103/// The empty type list.
104using EmptyTypeList = TypeList<>;
105
106/// Helper meta-function to determine if some type \c T is present or
107/// a parent type in the list.
108template <typename AnyTypeList, typename T> struct TypeListContainsSuperOf {
109 static const bool value =
110 std::is_base_of<typename AnyTypeList::head, T>::value ||
111 TypeListContainsSuperOf<typename AnyTypeList::tail, T>::value;
112};
113template <typename T> struct TypeListContainsSuperOf<EmptyTypeList, T> {
114 static const bool value = false;
115};
116
117/// Variadic function object.
118///
119/// Most of the functions below that use VariadicFunction could be implemented
120/// using plain C++11 variadic functions, but the function object allows us to
121/// capture it on the dynamic matcher registry.
122template <typename ResultT, typename ArgT,
123 ResultT (*Func)(ArrayRef<const ArgT *>)>
124struct VariadicFunction {
125 ResultT operator()() const { return Func(None); }
126
127 template <typename... ArgsT>
128 ResultT operator()(const ArgT &Arg1, const ArgsT &... Args) const {
129 return Execute(Arg1, static_cast<const ArgT &>(Args)...);
130 }
131
132 // We also allow calls with an already created array, in case the caller
133 // already had it.
134 ResultT operator()(ArrayRef<ArgT> Args) const {
135 SmallVector<const ArgT*, 8> InnerArgs;
136 for (const ArgT &Arg : Args)
137 InnerArgs.push_back(&Arg);
138 return Func(InnerArgs);
139 }
140
141private:
142 // Trampoline function to allow for implicit conversions to take place
143 // before we make the array.
144 template <typename... ArgsT> ResultT Execute(const ArgsT &... Args) const {
145 const ArgT *const ArgsArray[] = {&Args...};
146 return Func(ArrayRef<const ArgT *>(ArgsArray, sizeof...(ArgsT)));
147 }
148};
149
150/// Unifies obtaining the underlying type of a regular node through
151/// `getType` and a TypedefNameDecl node through `getUnderlyingType`.
152inline QualType getUnderlyingType(const Expr &Node) { return Node.getType(); }
153
154inline QualType getUnderlyingType(const ValueDecl &Node) {
155 return Node.getType();
156}
157inline QualType getUnderlyingType(const TypedefNameDecl &Node) {
158 return Node.getUnderlyingType();
159}
160inline QualType getUnderlyingType(const FriendDecl &Node) {
161 if (const TypeSourceInfo *TSI = Node.getFriendType())
162 return TSI->getType();
163 return QualType();
164}
165inline QualType getUnderlyingType(const CXXBaseSpecifier &Node) {
166 return Node.getType();
167}
168
169/// Unifies obtaining a `TypeSourceInfo` from different node types.
170template <typename T,
171 std::enable_if_t<TypeListContainsSuperOf<
172 TypeList<CXXBaseSpecifier, CXXCtorInitializer,
173 CXXTemporaryObjectExpr, CXXUnresolvedConstructExpr,
174 CompoundLiteralExpr, DeclaratorDecl, ObjCPropertyDecl,
175 TemplateArgumentLoc, TypedefNameDecl>,
176 T>::value> * = nullptr>
177inline TypeSourceInfo *GetTypeSourceInfo(const T &Node) {
178 return Node.getTypeSourceInfo();
179}
180template <typename T,
181 std::enable_if_t<TypeListContainsSuperOf<
182 TypeList<CXXFunctionalCastExpr, ExplicitCastExpr>, T>::value> * =
183 nullptr>
184inline TypeSourceInfo *GetTypeSourceInfo(const T &Node) {
185 return Node.getTypeInfoAsWritten();
186}
187inline TypeSourceInfo *GetTypeSourceInfo(const BlockDecl &Node) {
188 return Node.getSignatureAsWritten();
189}
190inline TypeSourceInfo *GetTypeSourceInfo(const CXXNewExpr &Node) {
191 return Node.getAllocatedTypeSourceInfo();
192}
193inline TypeSourceInfo *
194GetTypeSourceInfo(const ClassTemplateSpecializationDecl &Node) {
195 return Node.getTypeAsWritten();
196}
197
198/// Unifies obtaining the FunctionProtoType pointer from both
199/// FunctionProtoType and FunctionDecl nodes..
200inline const FunctionProtoType *
201getFunctionProtoType(const FunctionProtoType &Node) {
202 return &Node;
203}
204
205inline const FunctionProtoType *getFunctionProtoType(const FunctionDecl &Node) {
206 return Node.getType()->getAs<FunctionProtoType>();
207}
208
209/// Unifies obtaining the access specifier from Decl and CXXBaseSpecifier nodes.
210inline clang::AccessSpecifier getAccessSpecifier(const Decl &Node) {
211 return Node.getAccess();
212}
213
214inline clang::AccessSpecifier getAccessSpecifier(const CXXBaseSpecifier &Node) {
215 return Node.getAccessSpecifier();
216}
217
218/// Internal version of BoundNodes. Holds all the bound nodes.
219class BoundNodesMap {
220public:
221 /// Adds \c Node to the map with key \c ID.
222 ///
223 /// The node's base type should be in NodeBaseType or it will be unaccessible.
224 void addNode(StringRef ID, const DynTypedNode &DynNode) {
225 NodeMap[std::string(ID)] = DynNode;
226 }
227
228 /// Returns the AST node bound to \c ID.
229 ///
230 /// Returns NULL if there was no node bound to \c ID or if there is a node but
231 /// it cannot be converted to the specified type.
232 template <typename T>
233 const T *getNodeAs(StringRef ID) const {
234 IDToNodeMap::const_iterator It = NodeMap.find(ID);
235 if (It == NodeMap.end()) {
25
Calling 'operator=='
28
Returning from 'operator=='
29
Taking true branch
37
Calling 'operator=='
40
Returning from 'operator=='
41
Taking false branch
236 return nullptr;
30
Returning null pointer, which participates in a condition later
237 }
238 return It->second.get<T>();
42
Calling 'DynTypedNode::get'
49
Returning from 'DynTypedNode::get'
50
Returning pointer, which participates in a condition later
239 }
240
241 DynTypedNode getNode(StringRef ID) const {
242 IDToNodeMap::const_iterator It = NodeMap.find(ID);
243 if (It == NodeMap.end()) {
244 return DynTypedNode();
245 }
246 return It->second;
247 }
248
249 /// Imposes an order on BoundNodesMaps.
250 bool operator<(const BoundNodesMap &Other) const {
251 return NodeMap < Other.NodeMap;
252 }
253
254 /// A map from IDs to the bound nodes.
255 ///
256 /// Note that we're using std::map here, as for memoization:
257 /// - we need a comparison operator
258 /// - we need an assignment operator
259 using IDToNodeMap = std::map<std::string, DynTypedNode, std::less<>>;
260
261 const IDToNodeMap &getMap() const {
262 return NodeMap;
263 }
264
265 /// Returns \c true if this \c BoundNodesMap can be compared, i.e. all
266 /// stored nodes have memoization data.
267 bool isComparable() const {
268 for (const auto &IDAndNode : NodeMap) {
269 if (!IDAndNode.second.getMemoizationData())
270 return false;
271 }
272 return true;
273 }
274
275private:
276 IDToNodeMap NodeMap;
277};
278
279/// Creates BoundNodesTree objects.
280///
281/// The tree builder is used during the matching process to insert the bound
282/// nodes from the Id matcher.
283class BoundNodesTreeBuilder {
284public:
285 /// A visitor interface to visit all BoundNodes results for a
286 /// BoundNodesTree.
287 class Visitor {
288 public:
289 virtual ~Visitor() = default;
290
291 /// Called multiple times during a single call to VisitMatches(...).
292 ///
293 /// 'BoundNodesView' contains the bound nodes for a single match.
294 virtual void visitMatch(const BoundNodes& BoundNodesView) = 0;
295 };
296
297 /// Add a binding from an id to a node.
298 void setBinding(StringRef Id, const DynTypedNode &DynNode) {
299 if (Bindings.empty())
300 Bindings.emplace_back();
301 for (BoundNodesMap &Binding : Bindings)
302 Binding.addNode(Id, DynNode);
303 }
304
305 /// Adds a branch in the tree.
306 void addMatch(const BoundNodesTreeBuilder &Bindings);
307
308 /// Visits all matches that this BoundNodesTree represents.
309 ///
310 /// The ownership of 'ResultVisitor' remains at the caller.
311 void visitMatches(Visitor* ResultVisitor);
312
313 template <typename ExcludePredicate>
314 bool removeBindings(const ExcludePredicate &Predicate) {
315 llvm::erase_if(Bindings, Predicate);
316 return !Bindings.empty();
317 }
318
319 /// Imposes an order on BoundNodesTreeBuilders.
320 bool operator<(const BoundNodesTreeBuilder &Other) const {
321 return Bindings < Other.Bindings;
322 }
323
324 /// Returns \c true if this \c BoundNodesTreeBuilder can be compared,
325 /// i.e. all stored node maps have memoization data.
326 bool isComparable() const {
327 for (const BoundNodesMap &NodesMap : Bindings) {
328 if (!NodesMap.isComparable())
329 return false;
330 }
331 return true;
332 }
333
334private:
335 SmallVector<BoundNodesMap, 1> Bindings;
336};
337
338class ASTMatchFinder;
339
340/// Generic interface for all matchers.
341///
342/// Used by the implementation of Matcher<T> and DynTypedMatcher.
343/// In general, implement MatcherInterface<T> or SingleNodeMatcherInterface<T>
344/// instead.
345class DynMatcherInterface
346 : public llvm::ThreadSafeRefCountedBase<DynMatcherInterface> {
347public:
348 virtual ~DynMatcherInterface() = default;
349
350 /// Returns true if \p DynNode can be matched.
351 ///
352 /// May bind \p DynNode to an ID via \p Builder, or recurse into
353 /// the AST via \p Finder.
354 virtual bool dynMatches(const DynTypedNode &DynNode, ASTMatchFinder *Finder,
355 BoundNodesTreeBuilder *Builder) const = 0;
356
357 virtual llvm::Optional<clang::TraversalKind> TraversalKind() const {
358 return llvm::None;
359 }
360};
361
362/// Generic interface for matchers on an AST node of type T.
363///
364/// Implement this if your matcher may need to inspect the children or
365/// descendants of the node or bind matched nodes to names. If you are
366/// writing a simple matcher that only inspects properties of the
367/// current node and doesn't care about its children or descendants,
368/// implement SingleNodeMatcherInterface instead.
369template <typename T>
370class MatcherInterface : public DynMatcherInterface {
371public:
372 /// Returns true if 'Node' can be matched.
373 ///
374 /// May bind 'Node' to an ID via 'Builder', or recurse into
375 /// the AST via 'Finder'.
376 virtual bool matches(const T &Node,
377 ASTMatchFinder *Finder,
378 BoundNodesTreeBuilder *Builder) const = 0;
379
380 bool dynMatches(const DynTypedNode &DynNode, ASTMatchFinder *Finder,
381 BoundNodesTreeBuilder *Builder) const override {
382 return matches(DynNode.getUnchecked<T>(), Finder, Builder);
383 }
384};
385
386/// Interface for matchers that only evaluate properties on a single
387/// node.
388template <typename T>
389class SingleNodeMatcherInterface : public MatcherInterface<T> {
390public:
391 /// Returns true if the matcher matches the provided node.
392 ///
393 /// A subclass must implement this instead of Matches().
394 virtual bool matchesNode(const T &Node) const = 0;
395
396private:
397 /// Implements MatcherInterface::Matches.
398 bool matches(const T &Node,
399 ASTMatchFinder * /* Finder */,
400 BoundNodesTreeBuilder * /* Builder */) const override {
401 return matchesNode(Node);
402 }
403};
404
405template <typename> class Matcher;
406
407/// Matcher that works on a \c DynTypedNode.
408///
409/// It is constructed from a \c Matcher<T> object and redirects most calls to
410/// underlying matcher.
411/// It checks whether the \c DynTypedNode is convertible into the type of the
412/// underlying matcher and then do the actual match on the actual node, or
413/// return false if it is not convertible.
414class DynTypedMatcher {
415public:
416 /// Takes ownership of the provided implementation pointer.
417 template <typename T>
418 DynTypedMatcher(MatcherInterface<T> *Implementation)
419 : SupportedKind(ASTNodeKind::getFromNodeKind<T>()),
420 RestrictKind(SupportedKind), Implementation(Implementation) {}
421
422 /// Construct from a variadic function.
423 enum VariadicOperator {
424 /// Matches nodes for which all provided matchers match.
425 VO_AllOf,
426
427 /// Matches nodes for which at least one of the provided matchers
428 /// matches.
429 VO_AnyOf,
430
431 /// Matches nodes for which at least one of the provided matchers
432 /// matches, but doesn't stop at the first match.
433 VO_EachOf,
434
435 /// Matches any node but executes all inner matchers to find result
436 /// bindings.
437 VO_Optionally,
438
439 /// Matches nodes that do not match the provided matcher.
440 ///
441 /// Uses the variadic matcher interface, but fails if
442 /// InnerMatchers.size() != 1.
443 VO_UnaryNot
444 };
445
446 static DynTypedMatcher
447 constructVariadic(VariadicOperator Op, ASTNodeKind SupportedKind,
448 std::vector<DynTypedMatcher> InnerMatchers);
449
450 static DynTypedMatcher
451 constructRestrictedWrapper(const DynTypedMatcher &InnerMatcher,
452 ASTNodeKind RestrictKind);
453
454 /// Get a "true" matcher for \p NodeKind.
455 ///
456 /// It only checks that the node is of the right kind.
457 static DynTypedMatcher trueMatcher(ASTNodeKind NodeKind);
458
459 void setAllowBind(bool AB) { AllowBind = AB; }
460
461 /// Check whether this matcher could ever match a node of kind \p Kind.
462 /// \return \c false if this matcher will never match such a node. Otherwise,
463 /// return \c true.
464 bool canMatchNodesOfKind(ASTNodeKind Kind) const;
465
466 /// Return a matcher that points to the same implementation, but
467 /// restricts the node types for \p Kind.
468 DynTypedMatcher dynCastTo(const ASTNodeKind Kind) const;
469
470 /// Return a matcher that that points to the same implementation, but sets the
471 /// traversal kind.
472 ///
473 /// If the traversal kind is already set, then \c TK overrides it.
474 DynTypedMatcher withTraversalKind(TraversalKind TK);
475
476 /// Returns true if the matcher matches the given \c DynNode.
477 bool matches(const DynTypedNode &DynNode, ASTMatchFinder *Finder,
478 BoundNodesTreeBuilder *Builder) const;
479
480 /// Same as matches(), but skips the kind check.
481 ///
482 /// It is faster, but the caller must ensure the node is valid for the
483 /// kind of this matcher.
484 bool matchesNoKindCheck(const DynTypedNode &DynNode, ASTMatchFinder *Finder,
485 BoundNodesTreeBuilder *Builder) const;
486
487 /// Bind the specified \p ID to the matcher.
488 /// \return A new matcher with the \p ID bound to it if this matcher supports
489 /// binding. Otherwise, returns an empty \c Optional<>.
490 llvm::Optional<DynTypedMatcher> tryBind(StringRef ID) const;
491
492 /// Returns a unique \p ID for the matcher.
493 ///
494 /// Casting a Matcher<T> to Matcher<U> creates a matcher that has the
495 /// same \c Implementation pointer, but different \c RestrictKind. We need to
496 /// include both in the ID to make it unique.
497 ///
498 /// \c MatcherIDType supports operator< and provides strict weak ordering.
499 using MatcherIDType = std::pair<ASTNodeKind, uint64_t>;
500 MatcherIDType getID() const {
501 /// FIXME: Document the requirements this imposes on matcher
502 /// implementations (no new() implementation_ during a Matches()).
503 return std::make_pair(RestrictKind,
504 reinterpret_cast<uint64_t>(Implementation.get()));
505 }
506
507 /// Returns the type this matcher works on.
508 ///
509 /// \c matches() will always return false unless the node passed is of this
510 /// or a derived type.
511 ASTNodeKind getSupportedKind() const { return SupportedKind; }
512
513 /// Returns \c true if the passed \c DynTypedMatcher can be converted
514 /// to a \c Matcher<T>.
515 ///
516 /// This method verifies that the underlying matcher in \c Other can process
517 /// nodes of types T.
518 template <typename T> bool canConvertTo() const {
519 return canConvertTo(ASTNodeKind::getFromNodeKind<T>());
520 }
521 bool canConvertTo(ASTNodeKind To) const;
522
523 /// Construct a \c Matcher<T> interface around the dynamic matcher.
524 ///
525 /// This method asserts that \c canConvertTo() is \c true. Callers
526 /// should call \c canConvertTo() first to make sure that \c this is
527 /// compatible with T.
528 template <typename T> Matcher<T> convertTo() const {
529 assert(canConvertTo<T>())(static_cast <bool> (canConvertTo<T>()) ? void (0
) : __assert_fail ("canConvertTo<T>()", "clang/include/clang/ASTMatchers/ASTMatchersInternal.h"
, 529, __extension__ __PRETTY_FUNCTION__))
;
530 return unconditionalConvertTo<T>();
531 }
532
533 /// Same as \c convertTo(), but does not check that the underlying
534 /// matcher can handle a value of T.
535 ///
536 /// If it is not compatible, then this matcher will never match anything.
537 template <typename T> Matcher<T> unconditionalConvertTo() const;
538
539 /// Returns the \c TraversalKind respected by calls to `match()`, if any.
540 ///
541 /// Most matchers will not have a traversal kind set, instead relying on the
542 /// surrounding context. For those, \c llvm::None is returned.
543 llvm::Optional<clang::TraversalKind> getTraversalKind() const {
544 return Implementation->TraversalKind();
545 }
546
547private:
548 DynTypedMatcher(ASTNodeKind SupportedKind, ASTNodeKind RestrictKind,
549 IntrusiveRefCntPtr<DynMatcherInterface> Implementation)
550 : SupportedKind(SupportedKind), RestrictKind(RestrictKind),
551 Implementation(std::move(Implementation)) {}
552
553 bool AllowBind = false;
554 ASTNodeKind SupportedKind;
555
556 /// A potentially stricter node kind.
557 ///
558 /// It allows to perform implicit and dynamic cast of matchers without
559 /// needing to change \c Implementation.
560 ASTNodeKind RestrictKind;
561 IntrusiveRefCntPtr<DynMatcherInterface> Implementation;
562};
563
564/// Wrapper of a MatcherInterface<T> *that allows copying.
565///
566/// A Matcher<Base> can be used anywhere a Matcher<Derived> is
567/// required. This establishes an is-a relationship which is reverse
568/// to the AST hierarchy. In other words, Matcher<T> is contravariant
569/// with respect to T. The relationship is built via a type conversion
570/// operator rather than a type hierarchy to be able to templatize the
571/// type hierarchy instead of spelling it out.
572template <typename T>
573class Matcher {
574public:
575 /// Takes ownership of the provided implementation pointer.
576 explicit Matcher(MatcherInterface<T> *Implementation)
577 : Implementation(Implementation) {}
578
579 /// Implicitly converts \c Other to a Matcher<T>.
580 ///
581 /// Requires \c T to be derived from \c From.
582 template <typename From>
583 Matcher(const Matcher<From> &Other,
584 std::enable_if_t<std::is_base_of<From, T>::value &&
585 !std::is_same<From, T>::value> * = nullptr)
586 : Implementation(restrictMatcher(Other.Implementation)) {
587 assert(Implementation.getSupportedKind().isSame((static_cast <bool> (Implementation.getSupportedKind().
isSame( ASTNodeKind::getFromNodeKind<T>())) ? void (0) :
__assert_fail ("Implementation.getSupportedKind().isSame( ASTNodeKind::getFromNodeKind<T>())"
, "clang/include/clang/ASTMatchers/ASTMatchersInternal.h", 588
, __extension__ __PRETTY_FUNCTION__))
588 ASTNodeKind::getFromNodeKind<T>()))(static_cast <bool> (Implementation.getSupportedKind().
isSame( ASTNodeKind::getFromNodeKind<T>())) ? void (0) :
__assert_fail ("Implementation.getSupportedKind().isSame( ASTNodeKind::getFromNodeKind<T>())"
, "clang/include/clang/ASTMatchers/ASTMatchersInternal.h", 588
, __extension__ __PRETTY_FUNCTION__))
;
589 }
590
591 /// Implicitly converts \c Matcher<Type> to \c Matcher<QualType>.
592 ///
593 /// The resulting matcher is not strict, i.e. ignores qualifiers.
594 template <typename TypeT>
595 Matcher(const Matcher<TypeT> &Other,
596 std::enable_if_t<std::is_same<T, QualType>::value &&
597 std::is_same<TypeT, Type>::value> * = nullptr)
598 : Implementation(new TypeToQualType<TypeT>(Other)) {}
599
600 /// Convert \c this into a \c Matcher<T> by applying dyn_cast<> to the
601 /// argument.
602 /// \c To must be a base class of \c T.
603 template <typename To> Matcher<To> dynCastTo() const LLVM_LVALUE_FUNCTION& {
604 static_assert(std::is_base_of<To, T>::value, "Invalid dynCast call.");
605 return Matcher<To>(Implementation);
606 }
607
608#if LLVM_HAS_RVALUE_REFERENCE_THIS1
609 template <typename To> Matcher<To> dynCastTo() && {
610 static_assert(std::is_base_of<To, T>::value, "Invalid dynCast call.");
611 return Matcher<To>(std::move(Implementation));
612 }
613#endif
614
615 /// Forwards the call to the underlying MatcherInterface<T> pointer.
616 bool matches(const T &Node,
617 ASTMatchFinder *Finder,
618 BoundNodesTreeBuilder *Builder) const {
619 return Implementation.matches(DynTypedNode::create(Node), Finder, Builder);
620 }
621
622 /// Returns an ID that uniquely identifies the matcher.
623 DynTypedMatcher::MatcherIDType getID() const {
624 return Implementation.getID();
625 }
626
627 /// Extract the dynamic matcher.
628 ///
629 /// The returned matcher keeps the same restrictions as \c this and remembers
630 /// that it is meant to support nodes of type \c T.
631 operator DynTypedMatcher() const LLVM_LVALUE_FUNCTION& {
632 return Implementation;
633 }
634
635#if LLVM_HAS_RVALUE_REFERENCE_THIS1
636 operator DynTypedMatcher() && { return std::move(Implementation); }
637#endif
638
639 /// Allows the conversion of a \c Matcher<Type> to a \c
640 /// Matcher<QualType>.
641 ///
642 /// Depending on the constructor argument, the matcher is either strict, i.e.
643 /// does only matches in the absence of qualifiers, or not, i.e. simply
644 /// ignores any qualifiers.
645 template <typename TypeT>
646 class TypeToQualType : public MatcherInterface<QualType> {
647 const DynTypedMatcher InnerMatcher;
648
649 public:
650 TypeToQualType(const Matcher<TypeT> &InnerMatcher)
651 : InnerMatcher(InnerMatcher) {}
652
653 bool matches(const QualType &Node, ASTMatchFinder *Finder,
654 BoundNodesTreeBuilder *Builder) const override {
655 if (Node.isNull())
656 return false;
657 return this->InnerMatcher.matches(DynTypedNode::create(*Node), Finder,
658 Builder);
659 }
660
661 llvm::Optional<clang::TraversalKind> TraversalKind() const override {
662 return this->InnerMatcher.getTraversalKind();
663 }
664 };
665
666private:
667 // For Matcher<T> <=> Matcher<U> conversions.
668 template <typename U> friend class Matcher;
669
670 // For DynTypedMatcher::unconditionalConvertTo<T>.
671 friend class DynTypedMatcher;
672
673 static DynTypedMatcher restrictMatcher(const DynTypedMatcher &Other) {
674 return Other.dynCastTo(ASTNodeKind::getFromNodeKind<T>());
675 }
676
677 explicit Matcher(const DynTypedMatcher &Implementation)
678 : Implementation(restrictMatcher(Implementation)) {
679 assert(this->Implementation.getSupportedKind().isSame((static_cast <bool> (this->Implementation.getSupportedKind
().isSame( ASTNodeKind::getFromNodeKind<T>())) ? void (
0) : __assert_fail ("this->Implementation.getSupportedKind().isSame( ASTNodeKind::getFromNodeKind<T>())"
, "clang/include/clang/ASTMatchers/ASTMatchersInternal.h", 680
, __extension__ __PRETTY_FUNCTION__))
680 ASTNodeKind::getFromNodeKind<T>()))(static_cast <bool> (this->Implementation.getSupportedKind
().isSame( ASTNodeKind::getFromNodeKind<T>())) ? void (
0) : __assert_fail ("this->Implementation.getSupportedKind().isSame( ASTNodeKind::getFromNodeKind<T>())"
, "clang/include/clang/ASTMatchers/ASTMatchersInternal.h", 680
, __extension__ __PRETTY_FUNCTION__))
;
681 }
682
683 DynTypedMatcher Implementation;
684}; // class Matcher
685
686/// A convenient helper for creating a Matcher<T> without specifying
687/// the template type argument.
688template <typename T>
689inline Matcher<T> makeMatcher(MatcherInterface<T> *Implementation) {
690 return Matcher<T>(Implementation);
691}
692
693/// Interface that allows matchers to traverse the AST.
694/// FIXME: Find a better name.
695///
696/// This provides three entry methods for each base node type in the AST:
697/// - \c matchesChildOf:
698/// Matches a matcher on every child node of the given node. Returns true
699/// if at least one child node could be matched.
700/// - \c matchesDescendantOf:
701/// Matches a matcher on all descendant nodes of the given node. Returns true
702/// if at least one descendant matched.
703/// - \c matchesAncestorOf:
704/// Matches a matcher on all ancestors of the given node. Returns true if
705/// at least one ancestor matched.
706///
707/// FIXME: Currently we only allow Stmt and Decl nodes to start a traversal.
708/// In the future, we want to implement this for all nodes for which it makes
709/// sense. In the case of matchesAncestorOf, we'll want to implement it for
710/// all nodes, as all nodes have ancestors.
711class ASTMatchFinder {
712public:
713 /// Defines how bindings are processed on recursive matches.
714 enum BindKind {
715 /// Stop at the first match and only bind the first match.
716 BK_First,
717
718 /// Create results for all combinations of bindings that match.
719 BK_All
720 };
721
722 /// Defines which ancestors are considered for a match.
723 enum AncestorMatchMode {
724 /// All ancestors.
725 AMM_All,
726
727 /// Direct parent only.
728 AMM_ParentOnly
729 };
730
731 virtual ~ASTMatchFinder() = default;
732
733 /// Returns true if the given C++ class is directly or indirectly derived
734 /// from a base type matching \c base.
735 ///
736 /// A class is not considered to be derived from itself.
737 virtual bool classIsDerivedFrom(const CXXRecordDecl *Declaration,
738 const Matcher<NamedDecl> &Base,
739 BoundNodesTreeBuilder *Builder,
740 bool Directly) = 0;
741
742 /// Returns true if the given Objective-C class is directly or indirectly
743 /// derived from a base class matching \c base.
744 ///
745 /// A class is not considered to be derived from itself.
746 virtual bool objcClassIsDerivedFrom(const ObjCInterfaceDecl *Declaration,
747 const Matcher<NamedDecl> &Base,
748 BoundNodesTreeBuilder *Builder,
749 bool Directly) = 0;
750
751 template <typename T>
752 bool matchesChildOf(const T &Node, const DynTypedMatcher &Matcher,
753 BoundNodesTreeBuilder *Builder, BindKind Bind) {
754 static_assert(std::is_base_of<Decl, T>::value ||
755 std::is_base_of<Stmt, T>::value ||
756 std::is_base_of<NestedNameSpecifier, T>::value ||
757 std::is_base_of<NestedNameSpecifierLoc, T>::value ||
758 std::is_base_of<TypeLoc, T>::value ||
759 std::is_base_of<QualType, T>::value ||
760 std::is_base_of<Attr, T>::value,
761 "unsupported type for recursive matching");
762 return matchesChildOf(DynTypedNode::create(Node), getASTContext(), Matcher,
763 Builder, Bind);
764 }
765
766 template <typename T>
767 bool matchesDescendantOf(const T &Node, const DynTypedMatcher &Matcher,
768 BoundNodesTreeBuilder *Builder, BindKind Bind) {
769 static_assert(std::is_base_of<Decl, T>::value ||
770 std::is_base_of<Stmt, T>::value ||
771 std::is_base_of<NestedNameSpecifier, T>::value ||
772 std::is_base_of<NestedNameSpecifierLoc, T>::value ||
773 std::is_base_of<TypeLoc, T>::value ||
774 std::is_base_of<QualType, T>::value ||
775 std::is_base_of<Attr, T>::value,
776 "unsupported type for recursive matching");
777 return matchesDescendantOf(DynTypedNode::create(Node), getASTContext(),
778 Matcher, Builder, Bind);
779 }
780
781 // FIXME: Implement support for BindKind.
782 template <typename T>
783 bool matchesAncestorOf(const T &Node, const DynTypedMatcher &Matcher,
784 BoundNodesTreeBuilder *Builder,
785 AncestorMatchMode MatchMode) {
786 static_assert(std::is_base_of<Decl, T>::value ||
787 std::is_base_of<NestedNameSpecifierLoc, T>::value ||
788 std::is_base_of<Stmt, T>::value ||
789 std::is_base_of<TypeLoc, T>::value ||
790 std::is_base_of<Attr, T>::value,
791 "type not allowed for recursive matching");
792 return matchesAncestorOf(DynTypedNode::create(Node), getASTContext(),
793 Matcher, Builder, MatchMode);
794 }
795
796 virtual ASTContext &getASTContext() const = 0;
797
798 virtual bool IsMatchingInASTNodeNotSpelledInSource() const = 0;
799
800 virtual bool IsMatchingInASTNodeNotAsIs() const = 0;
801
802 bool isTraversalIgnoringImplicitNodes() const;
803
804protected:
805 virtual bool matchesChildOf(const DynTypedNode &Node, ASTContext &Ctx,
806 const DynTypedMatcher &Matcher,
807 BoundNodesTreeBuilder *Builder,
808 BindKind Bind) = 0;
809
810 virtual bool matchesDescendantOf(const DynTypedNode &Node, ASTContext &Ctx,
811 const DynTypedMatcher &Matcher,
812 BoundNodesTreeBuilder *Builder,
813 BindKind Bind) = 0;
814
815 virtual bool matchesAncestorOf(const DynTypedNode &Node, ASTContext &Ctx,
816 const DynTypedMatcher &Matcher,
817 BoundNodesTreeBuilder *Builder,
818 AncestorMatchMode MatchMode) = 0;
819private:
820 friend struct ASTChildrenNotSpelledInSourceScope;
821 virtual bool isMatchingChildrenNotSpelledInSource() const = 0;
822 virtual void setMatchingChildrenNotSpelledInSource(bool Set) = 0;
823};
824
825struct ASTChildrenNotSpelledInSourceScope {
826 ASTChildrenNotSpelledInSourceScope(ASTMatchFinder *V, bool B)
827 : MV(V), MB(V->isMatchingChildrenNotSpelledInSource()) {
828 V->setMatchingChildrenNotSpelledInSource(B);
829 }
830 ~ASTChildrenNotSpelledInSourceScope() {
831 MV->setMatchingChildrenNotSpelledInSource(MB);
832 }
833
834private:
835 ASTMatchFinder *MV;
836 bool MB;
837};
838
839/// Specialization of the conversion functions for QualType.
840///
841/// This specialization provides the Matcher<Type>->Matcher<QualType>
842/// conversion that the static API does.
843template <>
844inline Matcher<QualType> DynTypedMatcher::convertTo<QualType>() const {
845 assert(canConvertTo<QualType>())(static_cast <bool> (canConvertTo<QualType>()) ? void
(0) : __assert_fail ("canConvertTo<QualType>()", "clang/include/clang/ASTMatchers/ASTMatchersInternal.h"
, 845, __extension__ __PRETTY_FUNCTION__))
;
846 const ASTNodeKind SourceKind = getSupportedKind();
847 if (SourceKind.isSame(ASTNodeKind::getFromNodeKind<Type>())) {
848 // We support implicit conversion from Matcher<Type> to Matcher<QualType>
849 return unconditionalConvertTo<Type>();
850 }
851 return unconditionalConvertTo<QualType>();
852}
853
854/// Finds the first node in a range that matches the given matcher.
855template <typename MatcherT, typename IteratorT>
856IteratorT matchesFirstInRange(const MatcherT &Matcher, IteratorT Start,
857 IteratorT End, ASTMatchFinder *Finder,
858 BoundNodesTreeBuilder *Builder) {
859 for (IteratorT I = Start; I != End; ++I) {
860 BoundNodesTreeBuilder Result(*Builder);
861 if (Matcher.matches(*I, Finder, &Result)) {
862 *Builder = std::move(Result);
863 return I;
864 }
865 }
866 return End;
867}
868
869/// Finds the first node in a pointer range that matches the given
870/// matcher.
871template <typename MatcherT, typename IteratorT>
872IteratorT matchesFirstInPointerRange(const MatcherT &Matcher, IteratorT Start,
873 IteratorT End, ASTMatchFinder *Finder,
874 BoundNodesTreeBuilder *Builder) {
875 for (IteratorT I = Start; I != End; ++I) {
876 BoundNodesTreeBuilder Result(*Builder);
877 if (Matcher.matches(**I, Finder, &Result)) {
878 *Builder = std::move(Result);
879 return I;
880 }
881 }
882 return End;
883}
884
885template <typename T, std::enable_if_t<!std::is_base_of<FunctionDecl, T>::value>
886 * = nullptr>
887inline bool isDefaultedHelper(const T *) {
888 return false;
889}
890inline bool isDefaultedHelper(const FunctionDecl *FD) {
891 return FD->isDefaulted();
892}
893
894// Metafunction to determine if type T has a member called getDecl.
895template <typename Ty>
896class has_getDecl {
897 using yes = char[1];
898 using no = char[2];
899
900 template <typename Inner>
901 static yes& test(Inner *I, decltype(I->getDecl()) * = nullptr);
902
903 template <typename>
904 static no& test(...);
905
906public:
907 static const bool value = sizeof(test<Ty>(nullptr)) == sizeof(yes);
908};
909
910/// Matches overloaded operators with a specific name.
911///
912/// The type argument ArgT is not used by this matcher but is used by
913/// PolymorphicMatcher and should be StringRef.
914template <typename T, typename ArgT>
915class HasOverloadedOperatorNameMatcher : public SingleNodeMatcherInterface<T> {
916 static_assert(std::is_same<T, CXXOperatorCallExpr>::value ||
917 std::is_base_of<FunctionDecl, T>::value,
918 "unsupported class for matcher");
919 static_assert(std::is_same<ArgT, std::vector<std::string>>::value,
920 "argument type must be std::vector<std::string>");
921
922public:
923 explicit HasOverloadedOperatorNameMatcher(std::vector<std::string> Names)
924 : SingleNodeMatcherInterface<T>(), Names(std::move(Names)) {}
925
926 bool matchesNode(const T &Node) const override {
927 return matchesSpecialized(Node);
928 }
929
930private:
931
932 /// CXXOperatorCallExpr exist only for calls to overloaded operators
933 /// so this function returns true if the call is to an operator of the given
934 /// name.
935 bool matchesSpecialized(const CXXOperatorCallExpr &Node) const {
936 return llvm::is_contained(Names, getOperatorSpelling(Node.getOperator()));
937 }
938
939 /// Returns true only if CXXMethodDecl represents an overloaded
940 /// operator and has the given operator name.
941 bool matchesSpecialized(const FunctionDecl &Node) const {
942 return Node.isOverloadedOperator() &&
943 llvm::is_contained(
944 Names, getOperatorSpelling(Node.getOverloadedOperator()));
945 }
946
947 std::vector<std::string> Names;
948};
949
950/// Matches named declarations with a specific name.
951///
952/// See \c hasName() and \c hasAnyName() in ASTMatchers.h for details.
953class HasNameMatcher : public SingleNodeMatcherInterface<NamedDecl> {
954 public:
955 explicit HasNameMatcher(std::vector<std::string> Names);
956
957 bool matchesNode(const NamedDecl &Node) const override;
958
959private:
960 /// Unqualified match routine.
961 ///
962 /// It is much faster than the full match, but it only works for unqualified
963 /// matches.
964 bool matchesNodeUnqualified(const NamedDecl &Node) const;
965
966 /// Full match routine
967 ///
968 /// Fast implementation for the simple case of a named declaration at
969 /// namespace or RecordDecl scope.
970 /// It is slower than matchesNodeUnqualified, but faster than
971 /// matchesNodeFullSlow.
972 bool matchesNodeFullFast(const NamedDecl &Node) const;
973
974 /// Full match routine
975 ///
976 /// It generates the fully qualified name of the declaration (which is
977 /// expensive) before trying to match.
978 /// It is slower but simple and works on all cases.
979 bool matchesNodeFullSlow(const NamedDecl &Node) const;
980
981 bool UseUnqualifiedMatch;
982 std::vector<std::string> Names;
983};
984
985/// Trampoline function to use VariadicFunction<> to construct a
986/// HasNameMatcher.
987Matcher<NamedDecl> hasAnyNameFunc(ArrayRef<const StringRef *> NameRefs);
988
989/// Trampoline function to use VariadicFunction<> to construct a
990/// hasAnySelector matcher.
991Matcher<ObjCMessageExpr> hasAnySelectorFunc(
992 ArrayRef<const StringRef *> NameRefs);
993
994/// Matches declarations for QualType and CallExpr.
995///
996/// Type argument DeclMatcherT is required by PolymorphicMatcher but
997/// not actually used.
998template <typename T, typename DeclMatcherT>
999class HasDeclarationMatcher : public MatcherInterface<T> {
1000 static_assert(std::is_same<DeclMatcherT, Matcher<Decl>>::value,
1001 "instantiated with wrong types");
1002
1003 DynTypedMatcher InnerMatcher;
1004
1005public:
1006 explicit HasDeclarationMatcher(const Matcher<Decl> &InnerMatcher)
1007 : InnerMatcher(InnerMatcher) {}
1008
1009 bool matches(const T &Node, ASTMatchFinder *Finder,
1010 BoundNodesTreeBuilder *Builder) const override {
1011 return matchesSpecialized(Node, Finder, Builder);
1012 }
1013
1014private:
1015 /// Forwards to matching on the underlying type of the QualType.
1016 bool matchesSpecialized(const QualType &Node, ASTMatchFinder *Finder,
1017 BoundNodesTreeBuilder *Builder) const {
1018 if (Node.isNull())
1019 return false;
1020
1021 return matchesSpecialized(*Node, Finder, Builder);
1022 }
1023
1024 /// Finds the best declaration for a type and returns whether the inner
1025 /// matcher matches on it.
1026 bool matchesSpecialized(const Type &Node, ASTMatchFinder *Finder,
1027 BoundNodesTreeBuilder *Builder) const {
1028 // DeducedType does not have declarations of its own, so
1029 // match the deduced type instead.
1030 if (const auto *S = dyn_cast<DeducedType>(&Node)) {
1031 QualType DT = S->getDeducedType();
1032 return !DT.isNull() ? matchesSpecialized(*DT, Finder, Builder) : false;
1033 }
1034
1035 // First, for any types that have a declaration, extract the declaration and
1036 // match on it.
1037 if (const auto *S = dyn_cast<TagType>(&Node)) {
1038 return matchesDecl(S->getDecl(), Finder, Builder);
1039 }
1040 if (const auto *S = dyn_cast<InjectedClassNameType>(&Node)) {
1041 return matchesDecl(S->getDecl(), Finder, Builder);
1042 }
1043 if (const auto *S = dyn_cast<TemplateTypeParmType>(&Node)) {
1044 return matchesDecl(S->getDecl(), Finder, Builder);
1045 }
1046 if (const auto *S = dyn_cast<TypedefType>(&Node)) {
1047 return matchesDecl(S->getDecl(), Finder, Builder);
1048 }
1049 if (const auto *S = dyn_cast<UnresolvedUsingType>(&Node)) {
1050 return matchesDecl(S->getDecl(), Finder, Builder);
1051 }
1052 if (const auto *S = dyn_cast<ObjCObjectType>(&Node)) {
1053 return matchesDecl(S->getInterface(), Finder, Builder);
1054 }
1055
1056 // A SubstTemplateTypeParmType exists solely to mark a type substitution
1057 // on the instantiated template. As users usually want to match the
1058 // template parameter on the uninitialized template, we can always desugar
1059 // one level without loss of expressivness.
1060 // For example, given:
1061 // template<typename T> struct X { T t; } class A {}; X<A> a;
1062 // The following matcher will match, which otherwise would not:
1063 // fieldDecl(hasType(pointerType())).
1064 if (const auto *S = dyn_cast<SubstTemplateTypeParmType>(&Node)) {
1065 return matchesSpecialized(S->getReplacementType(), Finder, Builder);
1066 }
1067
1068 // For template specialization types, we want to match the template
1069 // declaration, as long as the type is still dependent, and otherwise the
1070 // declaration of the instantiated tag type.
1071 if (const auto *S = dyn_cast<TemplateSpecializationType>(&Node)) {
1072 if (!S->isTypeAlias() && S->isSugared()) {
1073 // If the template is non-dependent, we want to match the instantiated
1074 // tag type.
1075 // For example, given:
1076 // template<typename T> struct X {}; X<int> a;
1077 // The following matcher will match, which otherwise would not:
1078 // templateSpecializationType(hasDeclaration(cxxRecordDecl())).
1079 return matchesSpecialized(*S->desugar(), Finder, Builder);
1080 }
1081 // If the template is dependent or an alias, match the template
1082 // declaration.
1083 return matchesDecl(S->getTemplateName().getAsTemplateDecl(), Finder,
1084 Builder);
1085 }
1086
1087 // FIXME: We desugar elaborated types. This makes the assumption that users
1088 // do never want to match on whether a type is elaborated - there are
1089 // arguments for both sides; for now, continue desugaring.
1090 if (const auto *S = dyn_cast<ElaboratedType>(&Node)) {
1091 return matchesSpecialized(S->desugar(), Finder, Builder);
1092 }
1093 // Similarly types found via using declarations.
1094 // These are *usually* meaningless sugar, and this matches the historical
1095 // behavior prior to the introduction of UsingType.
1096 if (const auto *S = dyn_cast<UsingType>(&Node)) {
1097 return matchesSpecialized(S->desugar(), Finder, Builder);
1098 }
1099 return false;
1100 }
1101
1102 /// Extracts the Decl the DeclRefExpr references and returns whether
1103 /// the inner matcher matches on it.
1104 bool matchesSpecialized(const DeclRefExpr &Node, ASTMatchFinder *Finder,
1105 BoundNodesTreeBuilder *Builder) const {
1106 return matchesDecl(Node.getDecl(), Finder, Builder);
1107 }
1108
1109 /// Extracts the Decl of the callee of a CallExpr and returns whether
1110 /// the inner matcher matches on it.
1111 bool matchesSpecialized(const CallExpr &Node, ASTMatchFinder *Finder,
1112 BoundNodesTreeBuilder *Builder) const {
1113 return matchesDecl(Node.getCalleeDecl(), Finder, Builder);
1114 }
1115
1116 /// Extracts the Decl of the constructor call and returns whether the
1117 /// inner matcher matches on it.
1118 bool matchesSpecialized(const CXXConstructExpr &Node,
1119 ASTMatchFinder *Finder,
1120 BoundNodesTreeBuilder *Builder) const {
1121 return matchesDecl(Node.getConstructor(), Finder, Builder);
1122 }
1123
1124 bool matchesSpecialized(const ObjCIvarRefExpr &Node,
1125 ASTMatchFinder *Finder,
1126 BoundNodesTreeBuilder *Builder) const {
1127 return matchesDecl(Node.getDecl(), Finder, Builder);
1128 }
1129
1130 /// Extracts the operator new of the new call and returns whether the
1131 /// inner matcher matches on it.
1132 bool matchesSpecialized(const CXXNewExpr &Node,
1133 ASTMatchFinder *Finder,
1134 BoundNodesTreeBuilder *Builder) const {
1135 return matchesDecl(Node.getOperatorNew(), Finder, Builder);
1136 }
1137
1138 /// Extracts the \c ValueDecl a \c MemberExpr refers to and returns
1139 /// whether the inner matcher matches on it.
1140 bool matchesSpecialized(const MemberExpr &Node,
1141 ASTMatchFinder *Finder,
1142 BoundNodesTreeBuilder *Builder) const {
1143 return matchesDecl(Node.getMemberDecl(), Finder, Builder);
1144 }
1145
1146 /// Extracts the \c LabelDecl a \c AddrLabelExpr refers to and returns
1147 /// whether the inner matcher matches on it.
1148 bool matchesSpecialized(const AddrLabelExpr &Node,
1149 ASTMatchFinder *Finder,
1150 BoundNodesTreeBuilder *Builder) const {
1151 return matchesDecl(Node.getLabel(), Finder, Builder);
1152 }
1153
1154 /// Extracts the declaration of a LabelStmt and returns whether the
1155 /// inner matcher matches on it.
1156 bool matchesSpecialized(const LabelStmt &Node, ASTMatchFinder *Finder,
1157 BoundNodesTreeBuilder *Builder) const {
1158 return matchesDecl(Node.getDecl(), Finder, Builder);
1159 }
1160
1161 /// Returns whether the inner matcher \c Node. Returns false if \c Node
1162 /// is \c NULL.
1163 bool matchesDecl(const Decl *Node, ASTMatchFinder *Finder,
1164 BoundNodesTreeBuilder *Builder) const {
1165 return Node != nullptr &&
1166 !(Finder->isTraversalIgnoringImplicitNodes() &&
1167 Node->isImplicit()) &&
1168 this->InnerMatcher.matches(DynTypedNode::create(*Node), Finder,
1169 Builder);
1170 }
1171};
1172
1173/// IsBaseType<T>::value is true if T is a "base" type in the AST
1174/// node class hierarchies.
1175template <typename T>
1176struct IsBaseType {
1177 static const bool value =
1178 std::is_same<T, Decl>::value || std::is_same<T, Stmt>::value ||
1179 std::is_same<T, QualType>::value || std::is_same<T, Type>::value ||
1180 std::is_same<T, TypeLoc>::value ||
1181 std::is_same<T, NestedNameSpecifier>::value ||
1182 std::is_same<T, NestedNameSpecifierLoc>::value ||
1183 std::is_same<T, CXXCtorInitializer>::value ||
1184 std::is_same<T, TemplateArgumentLoc>::value ||
1185 std::is_same<T, Attr>::value;
1186};
1187template <typename T>
1188const bool IsBaseType<T>::value;
1189
1190/// A "type list" that contains all types.
1191///
1192/// Useful for matchers like \c anything and \c unless.
1193using AllNodeBaseTypes =
1194 TypeList<Decl, Stmt, NestedNameSpecifier, NestedNameSpecifierLoc, QualType,
1195 Type, TypeLoc, CXXCtorInitializer, Attr>;
1196
1197/// Helper meta-function to extract the argument out of a function of
1198/// type void(Arg).
1199///
1200/// See AST_POLYMORPHIC_SUPPORTED_TYPES for details.
1201template <class T> struct ExtractFunctionArgMeta;
1202template <class T> struct ExtractFunctionArgMeta<void(T)> {
1203 using type = T;
1204};
1205
1206template <class T, class Tuple, std::size_t... I>
1207constexpr T *new_from_tuple_impl(Tuple &&t, std::index_sequence<I...>) {
1208 return new T(std::get<I>(std::forward<Tuple>(t))...);
1209}
1210
1211template <class T, class Tuple> constexpr T *new_from_tuple(Tuple &&t) {
1212 return new_from_tuple_impl<T>(
1213 std::forward<Tuple>(t),
1214 std::make_index_sequence<
1215 std::tuple_size<std::remove_reference_t<Tuple>>::value>{});
1216}
1217
1218/// Default type lists for ArgumentAdaptingMatcher matchers.
1219using AdaptativeDefaultFromTypes = AllNodeBaseTypes;
1220using AdaptativeDefaultToTypes =
1221 TypeList<Decl, Stmt, NestedNameSpecifier, NestedNameSpecifierLoc, TypeLoc,
1222 QualType, Attr>;
1223
1224/// All types that are supported by HasDeclarationMatcher above.
1225using HasDeclarationSupportedTypes =
1226 TypeList<CallExpr, CXXConstructExpr, CXXNewExpr, DeclRefExpr, EnumType,
1227 ElaboratedType, InjectedClassNameType, LabelStmt, AddrLabelExpr,
1228 MemberExpr, QualType, RecordType, TagType,
1229 TemplateSpecializationType, TemplateTypeParmType, TypedefType,
1230 UnresolvedUsingType, ObjCIvarRefExpr>;
1231
1232/// A Matcher that allows binding the node it matches to an id.
1233///
1234/// BindableMatcher provides a \a bind() method that allows binding the
1235/// matched node to an id if the match was successful.
1236template <typename T> class BindableMatcher : public Matcher<T> {
1237public:
1238 explicit BindableMatcher(const Matcher<T> &M) : Matcher<T>(M) {}
1239 explicit BindableMatcher(MatcherInterface<T> *Implementation)
1240 : Matcher<T>(Implementation) {}
1241
1242 /// Returns a matcher that will bind the matched node on a match.
1243 ///
1244 /// The returned matcher is equivalent to this matcher, but will
1245 /// bind the matched node on a match.
1246 Matcher<T> bind(StringRef ID) const {
1247 return DynTypedMatcher(*this)
1248 .tryBind(ID)
1249 ->template unconditionalConvertTo<T>();
1250 }
1251
1252 /// Same as Matcher<T>'s conversion operator, but enables binding on
1253 /// the returned matcher.
1254 operator DynTypedMatcher() const {
1255 DynTypedMatcher Result = static_cast<const Matcher<T> &>(*this);
1256 Result.setAllowBind(true);
1257 return Result;
1258 }
1259};
1260
1261/// Matches any instance of the given NodeType.
1262///
1263/// This is useful when a matcher syntactically requires a child matcher,
1264/// but the context doesn't care. See for example: anything().
1265class TrueMatcher {
1266public:
1267 using ReturnTypes = AllNodeBaseTypes;
1268
1269 template <typename T> operator Matcher<T>() const {
1270 return DynTypedMatcher::trueMatcher(ASTNodeKind::getFromNodeKind<T>())
1271 .template unconditionalConvertTo<T>();
1272 }
1273};
1274
1275/// Creates a Matcher<T> that matches if all inner matchers match.
1276template <typename T>
1277BindableMatcher<T>
1278makeAllOfComposite(ArrayRef<const Matcher<T> *> InnerMatchers) {
1279 // For the size() == 0 case, we return a "true" matcher.
1280 if (InnerMatchers.empty()) {
1281 return BindableMatcher<T>(TrueMatcher());
1282 }
1283 // For the size() == 1 case, we simply return that one matcher.
1284 // No need to wrap it in a variadic operation.
1285 if (InnerMatchers.size() == 1) {
1286 return BindableMatcher<T>(*InnerMatchers[0]);
1287 }
1288
1289 using PI = llvm::pointee_iterator<const Matcher<T> *const *>;
1290
1291 std::vector<DynTypedMatcher> DynMatchers(PI(InnerMatchers.begin()),
1292 PI(InnerMatchers.end()));
1293 return BindableMatcher<T>(
1294 DynTypedMatcher::constructVariadic(DynTypedMatcher::VO_AllOf,
1295 ASTNodeKind::getFromNodeKind<T>(),
1296 std::move(DynMatchers))
1297 .template unconditionalConvertTo<T>());
1298}
1299
1300/// Creates a Matcher<T> that matches if
1301/// T is dyn_cast'able into InnerT and all inner matchers match.
1302///
1303/// Returns BindableMatcher, as matchers that use dyn_cast have
1304/// the same object both to match on and to run submatchers on,
1305/// so there is no ambiguity with what gets bound.
1306template <typename T, typename InnerT>
1307BindableMatcher<T>
1308makeDynCastAllOfComposite(ArrayRef<const Matcher<InnerT> *> InnerMatchers) {
1309 return BindableMatcher<T>(
1310 makeAllOfComposite(InnerMatchers).template dynCastTo<T>());
1311}
1312
1313/// A VariadicDynCastAllOfMatcher<SourceT, TargetT> object is a
1314/// variadic functor that takes a number of Matcher<TargetT> and returns a
1315/// Matcher<SourceT> that matches TargetT nodes that are matched by all of the
1316/// given matchers, if SourceT can be dynamically casted into TargetT.
1317///
1318/// For example:
1319/// const VariadicDynCastAllOfMatcher<Decl, CXXRecordDecl> record;
1320/// Creates a functor record(...) that creates a Matcher<Decl> given
1321/// a variable number of arguments of type Matcher<CXXRecordDecl>.
1322/// The returned matcher matches if the given Decl can by dynamically
1323/// casted to CXXRecordDecl and all given matchers match.
1324template <typename SourceT, typename TargetT>
1325class VariadicDynCastAllOfMatcher
1326 : public VariadicFunction<BindableMatcher<SourceT>, Matcher<TargetT>,
1327 makeDynCastAllOfComposite<SourceT, TargetT>> {
1328public:
1329 VariadicDynCastAllOfMatcher() {}
1330};
1331
1332/// A \c VariadicAllOfMatcher<T> object is a variadic functor that takes
1333/// a number of \c Matcher<T> and returns a \c Matcher<T> that matches \c T
1334/// nodes that are matched by all of the given matchers.
1335///
1336/// For example:
1337/// const VariadicAllOfMatcher<NestedNameSpecifier> nestedNameSpecifier;
1338/// Creates a functor nestedNameSpecifier(...) that creates a
1339/// \c Matcher<NestedNameSpecifier> given a variable number of arguments of type
1340/// \c Matcher<NestedNameSpecifier>.
1341/// The returned matcher matches if all given matchers match.
1342template <typename T>
1343class VariadicAllOfMatcher
1344 : public VariadicFunction<BindableMatcher<T>, Matcher<T>,
1345 makeAllOfComposite<T>> {
1346public:
1347 VariadicAllOfMatcher() {}
1348};
1349
1350/// VariadicOperatorMatcher related types.
1351/// @{
1352
1353/// Polymorphic matcher object that uses a \c
1354/// DynTypedMatcher::VariadicOperator operator.
1355///
1356/// Input matchers can have any type (including other polymorphic matcher
1357/// types), and the actual Matcher<T> is generated on demand with an implicit
1358/// conversion operator.
1359template <typename... Ps> class VariadicOperatorMatcher {
1360public:
1361 VariadicOperatorMatcher(DynTypedMatcher::VariadicOperator Op, Ps &&... Params)
1362 : Op(Op), Params(std::forward<Ps>(Params)...) {}
1363
1364 template <typename T> operator Matcher<T>() const LLVM_LVALUE_FUNCTION& {
1365 return DynTypedMatcher::constructVariadic(
1366 Op, ASTNodeKind::getFromNodeKind<T>(),
1367 getMatchers<T>(std::index_sequence_for<Ps...>()))
1368 .template unconditionalConvertTo<T>();
1369 }
1370
1371#if LLVM_HAS_RVALUE_REFERENCE_THIS1
1372 template <typename T> operator Matcher<T>() && {
1373 return DynTypedMatcher::constructVariadic(
1374 Op, ASTNodeKind::getFromNodeKind<T>(),
1375 getMatchers<T>(std::index_sequence_for<Ps...>()))
1376 .template unconditionalConvertTo<T>();
1377 }
1378#endif
1379private:
1380 // Helper method to unpack the tuple into a vector.
1381 template <typename T, std::size_t... Is>
1382 std::vector<DynTypedMatcher>
1383 getMatchers(std::index_sequence<Is...>) const LLVM_LVALUE_FUNCTION& {
1384 return {Matcher<T>(std::get<Is>(Params))...};
1385 }
1386
1387#if LLVM_HAS_RVALUE_REFERENCE_THIS1
1388 template <typename T, std::size_t... Is>
1389 std::vector<DynTypedMatcher> getMatchers(std::index_sequence<Is...>) && {
1390 return {Matcher<T>(std::get<Is>(std::move(Params)))...};
1391 }
1392#endif
1393
1394 const DynTypedMatcher::VariadicOperator Op;
1395 std::tuple<Ps...> Params;
1396};
1397
1398/// Overloaded function object to generate VariadicOperatorMatcher
1399/// objects from arbitrary matchers.
1400template <unsigned MinCount, unsigned MaxCount>
1401struct VariadicOperatorMatcherFunc {
1402 DynTypedMatcher::VariadicOperator Op;
1403
1404 template <typename... Ms>
1405 VariadicOperatorMatcher<Ms...> operator()(Ms &&... Ps) const {
1406 static_assert(MinCount <= sizeof...(Ms) && sizeof...(Ms) <= MaxCount,
1407 "invalid number of parameters for variadic matcher");
1408 return VariadicOperatorMatcher<Ms...>(Op, std::forward<Ms>(Ps)...);
1409 }
1410};
1411
1412template <typename F, typename Tuple, std::size_t... I>
1413constexpr auto applyMatcherImpl(F &&f, Tuple &&args,
1414 std::index_sequence<I...>) {
1415 return std::forward<F>(f)(std::get<I>(std::forward<Tuple>(args))...);
1416}
1417
1418template <typename F, typename Tuple>
1419constexpr auto applyMatcher(F &&f, Tuple &&args) {
1420 return applyMatcherImpl(
1421 std::forward<F>(f), std::forward<Tuple>(args),
1422 std::make_index_sequence<
1423 std::tuple_size<typename std::decay<Tuple>::type>::value>());
1424}
1425
1426template <typename T, bool IsBaseOf, typename Head, typename Tail>
1427struct GetCladeImpl {
1428 using Type = Head;
1429};
1430template <typename T, typename Head, typename Tail>
1431struct GetCladeImpl<T, false, Head, Tail>
1432 : GetCladeImpl<T, std::is_base_of<typename Tail::head, T>::value,
1433 typename Tail::head, typename Tail::tail> {};
1434
1435template <typename T, typename... U>
1436struct GetClade : GetCladeImpl<T, false, T, AllNodeBaseTypes> {};
1437
1438template <typename CladeType, typename... MatcherTypes>
1439struct MapAnyOfMatcherImpl {
1440
1441 template <typename... InnerMatchers>
1442 BindableMatcher<CladeType>
1443 operator()(InnerMatchers &&... InnerMatcher) const {
1444 // TODO: Use std::apply from c++17
1445 return VariadicAllOfMatcher<CladeType>()(applyMatcher(
1446 internal::VariadicOperatorMatcherFunc<
1447 0, std::numeric_limits<unsigned>::max()>{
1448 internal::DynTypedMatcher::VO_AnyOf},
1449 applyMatcher(
1450 [&](auto... Matcher) {
1451 return std::make_tuple(Matcher(InnerMatcher...)...);
1452 },
1453 std::tuple<
1454 VariadicDynCastAllOfMatcher<CladeType, MatcherTypes>...>())));
1455 }
1456};
1457
1458template <typename... MatcherTypes>
1459using MapAnyOfMatcher =
1460 MapAnyOfMatcherImpl<typename GetClade<MatcherTypes...>::Type,
1461 MatcherTypes...>;
1462
1463template <typename... MatcherTypes> struct MapAnyOfHelper {
1464 using CladeType = typename GetClade<MatcherTypes...>::Type;
1465
1466 MapAnyOfMatcher<MatcherTypes...> with;
1467
1468 operator BindableMatcher<CladeType>() const { return with(); }
1469
1470 Matcher<CladeType> bind(StringRef ID) const { return with().bind(ID); }
1471};
1472
1473template <template <typename ToArg, typename FromArg> class ArgumentAdapterT,
1474 typename T, typename ToTypes>
1475class ArgumentAdaptingMatcherFuncAdaptor {
1476public:
1477 explicit ArgumentAdaptingMatcherFuncAdaptor(const Matcher<T> &InnerMatcher)
1478 : InnerMatcher(InnerMatcher) {}
1479
1480 using ReturnTypes = ToTypes;
1481
1482 template <typename To> operator Matcher<To>() const LLVM_LVALUE_FUNCTION& {
1483 return Matcher<To>(new ArgumentAdapterT<To, T>(InnerMatcher));
1484 }
1485
1486#if LLVM_HAS_RVALUE_REFERENCE_THIS1
1487 template <typename To> operator Matcher<To>() && {
1488 return Matcher<To>(new ArgumentAdapterT<To, T>(std::move(InnerMatcher)));
1489 }
1490#endif
1491
1492private:
1493 Matcher<T> InnerMatcher;
1494};
1495
1496/// Converts a \c Matcher<T> to a matcher of desired type \c To by
1497/// "adapting" a \c To into a \c T.
1498///
1499/// The \c ArgumentAdapterT argument specifies how the adaptation is done.
1500///
1501/// For example:
1502/// \c ArgumentAdaptingMatcher<HasMatcher, T>(InnerMatcher);
1503/// Given that \c InnerMatcher is of type \c Matcher<T>, this returns a matcher
1504/// that is convertible into any matcher of type \c To by constructing
1505/// \c HasMatcher<To, T>(InnerMatcher).
1506///
1507/// If a matcher does not need knowledge about the inner type, prefer to use
1508/// PolymorphicMatcher.
1509template <template <typename ToArg, typename FromArg> class ArgumentAdapterT,
1510 typename FromTypes = AdaptativeDefaultFromTypes,
1511 typename ToTypes = AdaptativeDefaultToTypes>
1512struct ArgumentAdaptingMatcherFunc {
1513 template <typename T>
1514 static ArgumentAdaptingMatcherFuncAdaptor<ArgumentAdapterT, T, ToTypes>
1515 create(const Matcher<T> &InnerMatcher) {
1516 return ArgumentAdaptingMatcherFuncAdaptor<ArgumentAdapterT, T, ToTypes>(
1517 InnerMatcher);
1518 }
1519
1520 template <typename T>
1521 ArgumentAdaptingMatcherFuncAdaptor<ArgumentAdapterT, T, ToTypes>
1522 operator()(const Matcher<T> &InnerMatcher) const {
1523 return create(InnerMatcher);
1524 }
1525
1526 template <typename... T>
1527 ArgumentAdaptingMatcherFuncAdaptor<ArgumentAdapterT,
1528 typename GetClade<T...>::Type, ToTypes>
1529 operator()(const MapAnyOfHelper<T...> &InnerMatcher) const {
1530 return create(InnerMatcher.with());
1531 }
1532};
1533
1534template <typename T> class TraversalMatcher : public MatcherInterface<T> {
1535 DynTypedMatcher InnerMatcher;
1536 clang::TraversalKind Traversal;
1537
1538public:
1539 explicit TraversalMatcher(clang::TraversalKind TK,
1540 const Matcher<T> &InnerMatcher)
1541 : InnerMatcher(InnerMatcher), Traversal(TK) {}
1542
1543 bool matches(const T &Node, ASTMatchFinder *Finder,
1544 BoundNodesTreeBuilder *Builder) const override {
1545 return this->InnerMatcher.matches(DynTypedNode::create(Node), Finder,
1546 Builder);
1547 }
1548
1549 llvm::Optional<clang::TraversalKind> TraversalKind() const override {
1550 if (auto NestedKind = this->InnerMatcher.getTraversalKind())
1551 return NestedKind;
1552 return Traversal;
1553 }
1554};
1555
1556template <typename MatcherType> class TraversalWrapper {
1557public:
1558 TraversalWrapper(TraversalKind TK, const MatcherType &InnerMatcher)
1559 : TK(TK), InnerMatcher(InnerMatcher) {}
1560
1561 template <typename T> operator Matcher<T>() const LLVM_LVALUE_FUNCTION& {
1562 return internal::DynTypedMatcher::constructRestrictedWrapper(
1563 new internal::TraversalMatcher<T>(TK, InnerMatcher),
1564 ASTNodeKind::getFromNodeKind<T>())
1565 .template unconditionalConvertTo<T>();
1566 }
1567
1568#if LLVM_HAS_RVALUE_REFERENCE_THIS1
1569 template <typename T> operator Matcher<T>() && {
1570 return internal::DynTypedMatcher::constructRestrictedWrapper(
1571 new internal::TraversalMatcher<T>(TK, std::move(InnerMatcher)),
1572 ASTNodeKind::getFromNodeKind<T>())
1573 .template unconditionalConvertTo<T>();
1574 }
1575#endif
1576
1577private:
1578 TraversalKind TK;
1579 MatcherType InnerMatcher;
1580};
1581
1582/// A PolymorphicMatcher<MatcherT, P1, ..., PN> object can be
1583/// created from N parameters p1, ..., pN (of type P1, ..., PN) and
1584/// used as a Matcher<T> where a MatcherT<T, P1, ..., PN>(p1, ..., pN)
1585/// can be constructed.
1586///
1587/// For example:
1588/// - PolymorphicMatcher<IsDefinitionMatcher>()
1589/// creates an object that can be used as a Matcher<T> for any type T
1590/// where an IsDefinitionMatcher<T>() can be constructed.
1591/// - PolymorphicMatcher<ValueEqualsMatcher, int>(42)
1592/// creates an object that can be used as a Matcher<T> for any type T
1593/// where a ValueEqualsMatcher<T, int>(42) can be constructed.
1594template <template <typename T, typename... Params> class MatcherT,
1595 typename ReturnTypesF, typename... ParamTypes>
1596class PolymorphicMatcher {
1597public:
1598 PolymorphicMatcher(const ParamTypes &... Params) : Params(Params...) {}
1599
1600 using ReturnTypes = typename ExtractFunctionArgMeta<ReturnTypesF>::type;
1601
1602 template <typename T> operator Matcher<T>() const LLVM_LVALUE_FUNCTION& {
1603 static_assert(TypeListContainsSuperOf<ReturnTypes, T>::value,
1604 "right polymorphic conversion");
1605 return Matcher<T>(new_from_tuple<MatcherT<T, ParamTypes...>>(Params));
1606 }
1607
1608#if LLVM_HAS_RVALUE_REFERENCE_THIS1
1609 template <typename T> operator Matcher<T>() && {
1610 static_assert(TypeListContainsSuperOf<ReturnTypes, T>::value,
1611 "right polymorphic conversion");
1612 return Matcher<T>(
1613 new_from_tuple<MatcherT<T, ParamTypes...>>(std::move(Params)));
1614 }
1615#endif
1616
1617private:
1618 std::tuple<ParamTypes...> Params;
1619};
1620
1621/// Matches nodes of type T that have child nodes of type ChildT for
1622/// which a specified child matcher matches.
1623///
1624/// ChildT must be an AST base type.
1625template <typename T, typename ChildT>
1626class HasMatcher : public MatcherInterface<T> {
1627 DynTypedMatcher InnerMatcher;
1628
1629public:
1630 explicit HasMatcher(const Matcher<ChildT> &InnerMatcher)
1631 : InnerMatcher(InnerMatcher) {}
1632
1633 bool matches(const T &Node, ASTMatchFinder *Finder,
1634 BoundNodesTreeBuilder *Builder) const override {
1635 return Finder->matchesChildOf(Node, this->InnerMatcher, Builder,
1636 ASTMatchFinder::BK_First);
1637 }
1638};
1639
1640/// Matches nodes of type T that have child nodes of type ChildT for
1641/// which a specified child matcher matches. ChildT must be an AST base
1642/// type.
1643/// As opposed to the HasMatcher, the ForEachMatcher will produce a match
1644/// for each child that matches.
1645template <typename T, typename ChildT>
1646class ForEachMatcher : public MatcherInterface<T> {
1647 static_assert(IsBaseType<ChildT>::value,
1648 "for each only accepts base type matcher");
1649
1650 DynTypedMatcher InnerMatcher;
1651
1652public:
1653 explicit ForEachMatcher(const Matcher<ChildT> &InnerMatcher)
1654 : InnerMatcher(InnerMatcher) {}
1655
1656 bool matches(const T &Node, ASTMatchFinder *Finder,
1657 BoundNodesTreeBuilder *Builder) const override {
1658 return Finder->matchesChildOf(
1659 Node, this->InnerMatcher, Builder,
1660 ASTMatchFinder::BK_All);
1661 }
1662};
1663
1664/// @}
1665
1666template <typename T>
1667inline Matcher<T> DynTypedMatcher::unconditionalConvertTo() const {
1668 return Matcher<T>(*this);
1669}
1670
1671/// Matches nodes of type T that have at least one descendant node of
1672/// type DescendantT for which the given inner matcher matches.
1673///
1674/// DescendantT must be an AST base type.
1675template <typename T, typename DescendantT>
1676class HasDescendantMatcher : public MatcherInterface<T> {
1677 static_assert(IsBaseType<DescendantT>::value,
1678 "has descendant only accepts base type matcher");
1679
1680 DynTypedMatcher DescendantMatcher;
1681
1682public:
1683 explicit HasDescendantMatcher(const Matcher<DescendantT> &DescendantMatcher)
1684 : DescendantMatcher(DescendantMatcher) {}
1685
1686 bool matches(const T &Node, ASTMatchFinder *Finder,
1687 BoundNodesTreeBuilder *Builder) const override {
1688 return Finder->matchesDescendantOf(Node, this->DescendantMatcher, Builder,
1689 ASTMatchFinder::BK_First);
1690 }
1691};
1692
1693/// Matches nodes of type \c T that have a parent node of type \c ParentT
1694/// for which the given inner matcher matches.
1695///
1696/// \c ParentT must be an AST base type.
1697template <typename T, typename ParentT>
1698class HasParentMatcher : public MatcherInterface<T> {
1699 static_assert(IsBaseType<ParentT>::value,
1700 "has parent only accepts base type matcher");
1701
1702 DynTypedMatcher ParentMatcher;
1703
1704public:
1705 explicit HasParentMatcher(const Matcher<ParentT> &ParentMatcher)
1706 : ParentMatcher(ParentMatcher) {}
1707
1708 bool matches(const T &Node, ASTMatchFinder *Finder,
1709 BoundNodesTreeBuilder *Builder) const override {
1710 return Finder->matchesAncestorOf(Node, this->ParentMatcher, Builder,
1711 ASTMatchFinder::AMM_ParentOnly);
1712 }
1713};
1714
1715/// Matches nodes of type \c T that have at least one ancestor node of
1716/// type \c AncestorT for which the given inner matcher matches.
1717///
1718/// \c AncestorT must be an AST base type.
1719template <typename T, typename AncestorT>
1720class HasAncestorMatcher : public MatcherInterface<T> {
1721 static_assert(IsBaseType<AncestorT>::value,
1722 "has ancestor only accepts base type matcher");
1723
1724 DynTypedMatcher AncestorMatcher;
1725
1726public:
1727 explicit HasAncestorMatcher(const Matcher<AncestorT> &AncestorMatcher)
1728 : AncestorMatcher(AncestorMatcher) {}
1729
1730 bool matches(const T &Node, ASTMatchFinder *Finder,
1731 BoundNodesTreeBuilder *Builder) const override {
1732 return Finder->matchesAncestorOf(Node, this->AncestorMatcher, Builder,
1733 ASTMatchFinder::AMM_All);
1734 }
1735};
1736
1737/// Matches nodes of type T that have at least one descendant node of
1738/// type DescendantT for which the given inner matcher matches.
1739///
1740/// DescendantT must be an AST base type.
1741/// As opposed to HasDescendantMatcher, ForEachDescendantMatcher will match
1742/// for each descendant node that matches instead of only for the first.
1743template <typename T, typename DescendantT>
1744class ForEachDescendantMatcher : public MatcherInterface<T> {
1745 static_assert(IsBaseType<DescendantT>::value,
1746 "for each descendant only accepts base type matcher");
1747
1748 DynTypedMatcher DescendantMatcher;
1749
1750public:
1751 explicit ForEachDescendantMatcher(
1752 const Matcher<DescendantT> &DescendantMatcher)
1753 : DescendantMatcher(DescendantMatcher) {}
1754
1755 bool matches(const T &Node, ASTMatchFinder *Finder,
1756 BoundNodesTreeBuilder *Builder) const override {
1757 return Finder->matchesDescendantOf(Node, this->DescendantMatcher, Builder,
1758 ASTMatchFinder::BK_All);
1759 }
1760};
1761
1762/// Matches on nodes that have a getValue() method if getValue() equals
1763/// the value the ValueEqualsMatcher was constructed with.
1764template <typename T, typename ValueT>
1765class ValueEqualsMatcher : public SingleNodeMatcherInterface<T> {
1766 static_assert(std::is_base_of<CharacterLiteral, T>::value ||
1767 std::is_base_of<CXXBoolLiteralExpr, T>::value ||
1768 std::is_base_of<FloatingLiteral, T>::value ||
1769 std::is_base_of<IntegerLiteral, T>::value,
1770 "the node must have a getValue method");
1771
1772public:
1773 explicit ValueEqualsMatcher(const ValueT &ExpectedValue)
1774 : ExpectedValue(ExpectedValue) {}
1775
1776 bool matchesNode(const T &Node) const override {
1777 return Node.getValue() == ExpectedValue;
1778 }
1779
1780private:
1781 ValueT ExpectedValue;
1782};
1783
1784/// Template specializations to easily write matchers for floating point
1785/// literals.
1786template <>
1787inline bool ValueEqualsMatcher<FloatingLiteral, double>::matchesNode(
1788 const FloatingLiteral &Node) const {
1789 if ((&Node.getSemantics()) == &llvm::APFloat::IEEEsingle())
1790 return Node.getValue().convertToFloat() == ExpectedValue;
1791 if ((&Node.getSemantics()) == &llvm::APFloat::IEEEdouble())
1792 return Node.getValue().convertToDouble() == ExpectedValue;
1793 return false;
1794}
1795template <>
1796inline bool ValueEqualsMatcher<FloatingLiteral, float>::matchesNode(
1797 const FloatingLiteral &Node) const {
1798 if ((&Node.getSemantics()) == &llvm::APFloat::IEEEsingle())
1799 return Node.getValue().convertToFloat() == ExpectedValue;
1800 if ((&Node.getSemantics()) == &llvm::APFloat::IEEEdouble())
1801 return Node.getValue().convertToDouble() == ExpectedValue;
1802 return false;
1803}
1804template <>
1805inline bool ValueEqualsMatcher<FloatingLiteral, llvm::APFloat>::matchesNode(
1806 const FloatingLiteral &Node) const {
1807 return ExpectedValue.compare(Node.getValue()) == llvm::APFloat::cmpEqual;
1808}
1809
1810/// Matches nodes of type \c TLoc for which the inner
1811/// \c Matcher<T> matches.
1812template <typename TLoc, typename T>
1813class LocMatcher : public MatcherInterface<TLoc> {
1814 DynTypedMatcher InnerMatcher;
1815
1816public:
1817 explicit LocMatcher(const Matcher<T> &InnerMatcher)
1818 : InnerMatcher(InnerMatcher) {}
1819
1820 bool matches(const TLoc &Node, ASTMatchFinder *Finder,
1821 BoundNodesTreeBuilder *Builder) const override {
1822 if (!Node)
1823 return false;
1824 return this->InnerMatcher.matches(extract(Node), Finder, Builder);
1825 }
1826
1827private:
1828 static DynTypedNode extract(const NestedNameSpecifierLoc &Loc) {
1829 return DynTypedNode::create(*Loc.getNestedNameSpecifier());
1830 }
1831};
1832
1833/// Matches \c TypeLocs based on an inner matcher matching a certain
1834/// \c QualType.
1835///
1836/// Used to implement the \c loc() matcher.
1837class TypeLocTypeMatcher : public MatcherInterface<TypeLoc> {
1838 DynTypedMatcher InnerMatcher;
1839
1840public:
1841 explicit TypeLocTypeMatcher(const Matcher<QualType> &InnerMatcher)
1842 : InnerMatcher(InnerMatcher) {}
1843
1844 bool matches(const TypeLoc &Node, ASTMatchFinder *Finder,
1845 BoundNodesTreeBuilder *Builder) const override {
1846 if (!Node)
1847 return false;
1848 return this->InnerMatcher.matches(DynTypedNode::create(Node.getType()),
1849 Finder, Builder);
1850 }
1851};
1852
1853/// Matches nodes of type \c T for which the inner matcher matches on a
1854/// another node of type \c T that can be reached using a given traverse
1855/// function.
1856template <typename T> class TypeTraverseMatcher : public MatcherInterface<T> {
1857 DynTypedMatcher InnerMatcher;
1858
1859public:
1860 explicit TypeTraverseMatcher(const Matcher<QualType> &InnerMatcher,
1861 QualType (T::*TraverseFunction)() const)
1862 : InnerMatcher(InnerMatcher), TraverseFunction(TraverseFunction) {}
1863
1864 bool matches(const T &Node, ASTMatchFinder *Finder,
1865 BoundNodesTreeBuilder *Builder) const override {
1866 QualType NextNode = (Node.*TraverseFunction)();
1867 if (NextNode.isNull())
1868 return false;
1869 return this->InnerMatcher.matches(DynTypedNode::create(NextNode), Finder,
1870 Builder);
1871 }
1872
1873private:
1874 QualType (T::*TraverseFunction)() const;
1875};
1876
1877/// Matches nodes of type \c T in a ..Loc hierarchy, for which the inner
1878/// matcher matches on a another node of type \c T that can be reached using a
1879/// given traverse function.
1880template <typename T>
1881class TypeLocTraverseMatcher : public MatcherInterface<T> {
1882 DynTypedMatcher InnerMatcher;
1883
1884public:
1885 explicit TypeLocTraverseMatcher(const Matcher<TypeLoc> &InnerMatcher,
1886 TypeLoc (T::*TraverseFunction)() const)
1887 : InnerMatcher(InnerMatcher), TraverseFunction(TraverseFunction) {}
1888
1889 bool matches(const T &Node, ASTMatchFinder *Finder,
1890 BoundNodesTreeBuilder *Builder) const override {
1891 TypeLoc NextNode = (Node.*TraverseFunction)();
1892 if (!NextNode)
1893 return false;
1894 return this->InnerMatcher.matches(DynTypedNode::create(NextNode), Finder,
1895 Builder);
1896 }
1897
1898private:
1899 TypeLoc (T::*TraverseFunction)() const;
1900};
1901
1902/// Converts a \c Matcher<InnerT> to a \c Matcher<OuterT>, where
1903/// \c OuterT is any type that is supported by \c Getter.
1904///
1905/// \code Getter<OuterT>::value() \endcode returns a
1906/// \code InnerTBase (OuterT::*)() \endcode, which is used to adapt a \c OuterT
1907/// object into a \c InnerT
1908template <typename InnerTBase,
1909 template <typename OuterT> class Getter,
1910 template <typename OuterT> class MatcherImpl,
1911 typename ReturnTypesF>
1912class TypeTraversePolymorphicMatcher {
1913private:
1914 using Self = TypeTraversePolymorphicMatcher<InnerTBase, Getter, MatcherImpl,
1915 ReturnTypesF>;
1916
1917 static Self create(ArrayRef<const Matcher<InnerTBase> *> InnerMatchers);
1918
1919public:
1920 using ReturnTypes = typename ExtractFunctionArgMeta<ReturnTypesF>::type;
1921
1922 explicit TypeTraversePolymorphicMatcher(
1923 ArrayRef<const Matcher<InnerTBase> *> InnerMatchers)
1924 : InnerMatcher(makeAllOfComposite(InnerMatchers)) {}
1925
1926 template <typename OuterT> operator Matcher<OuterT>() const {
1927 return Matcher<OuterT>(
1928 new MatcherImpl<OuterT>(InnerMatcher, Getter<OuterT>::value()));
1929 }
1930
1931 struct Func
1932 : public VariadicFunction<Self, Matcher<InnerTBase>, &Self::create> {
1933 Func() {}
1934 };
1935
1936private:
1937 Matcher<InnerTBase> InnerMatcher;
1938};
1939
1940/// A simple memoizer of T(*)() functions.
1941///
1942/// It will call the passed 'Func' template parameter at most once.
1943/// Used to support AST_MATCHER_FUNCTION() macro.
1944template <typename Matcher, Matcher (*Func)()> class MemoizedMatcher {
1945 struct Wrapper {
1946 Wrapper() : M(Func()) {}
1947
1948 Matcher M;
1949 };
1950
1951public:
1952 static const Matcher &getInstance() {
1953 static llvm::ManagedStatic<Wrapper> Instance;
1954 return Instance->M;
1955 }
1956};
1957
1958// Define the create() method out of line to silence a GCC warning about
1959// the struct "Func" having greater visibility than its base, which comes from
1960// using the flag -fvisibility-inlines-hidden.
1961template <typename InnerTBase, template <typename OuterT> class Getter,
1962 template <typename OuterT> class MatcherImpl, typename ReturnTypesF>
1963TypeTraversePolymorphicMatcher<InnerTBase, Getter, MatcherImpl, ReturnTypesF>
1964TypeTraversePolymorphicMatcher<
1965 InnerTBase, Getter, MatcherImpl,
1966 ReturnTypesF>::create(ArrayRef<const Matcher<InnerTBase> *> InnerMatchers) {
1967 return Self(InnerMatchers);
1968}
1969
1970// FIXME: unify ClassTemplateSpecializationDecl and TemplateSpecializationType's
1971// APIs for accessing the template argument list.
1972inline ArrayRef<TemplateArgument>
1973getTemplateSpecializationArgs(const ClassTemplateSpecializationDecl &D) {
1974 return D.getTemplateArgs().asArray();
1975}
1976
1977inline ArrayRef<TemplateArgument>
1978getTemplateSpecializationArgs(const TemplateSpecializationType &T) {
1979 return llvm::makeArrayRef(T.getArgs(), T.getNumArgs());
1980}
1981
1982inline ArrayRef<TemplateArgument>
1983getTemplateSpecializationArgs(const FunctionDecl &FD) {
1984 if (const auto* TemplateArgs = FD.getTemplateSpecializationArgs())
1985 return TemplateArgs->asArray();
1986 return ArrayRef<TemplateArgument>();
1987}
1988
1989struct NotEqualsBoundNodePredicate {
1990 bool operator()(const internal::BoundNodesMap &Nodes) const {
1991 return Nodes.getNode(ID) != Node;
1992 }
1993
1994 std::string ID;
1995 DynTypedNode Node;
1996};
1997
1998template <typename Ty, typename Enable = void> struct GetBodyMatcher {
1999 static const Stmt *get(const Ty &Node) { return Node.getBody(); }
2000};
2001
2002template <typename Ty>
2003struct GetBodyMatcher<Ty, typename std::enable_if<
2004 std::is_base_of<FunctionDecl, Ty>::value>::type> {
2005 static const Stmt *get(const Ty &Node) {
2006 return Node.doesThisDeclarationHaveABody() ? Node.getBody() : nullptr;
2007 }
2008};
2009
2010template <typename NodeType>
2011inline Optional<BinaryOperatorKind>
2012equivalentBinaryOperator(const NodeType &Node) {
2013 return Node.getOpcode();
2014}
2015
2016template <>
2017inline Optional<BinaryOperatorKind>
2018equivalentBinaryOperator<CXXOperatorCallExpr>(const CXXOperatorCallExpr &Node) {
2019 if (Node.getNumArgs() != 2)
2020 return None;
2021 switch (Node.getOperator()) {
2022 default:
2023 return None;
2024 case OO_ArrowStar:
2025 return BO_PtrMemI;
2026 case OO_Star:
2027 return BO_Mul;
2028 case OO_Slash:
2029 return BO_Div;
2030 case OO_Percent:
2031 return BO_Rem;
2032 case OO_Plus:
2033 return BO_Add;
2034 case OO_Minus:
2035 return BO_Sub;
2036 case OO_LessLess:
2037 return BO_Shl;
2038 case OO_GreaterGreater:
2039 return BO_Shr;
2040 case OO_Spaceship:
2041 return BO_Cmp;
2042 case OO_Less:
2043 return BO_LT;
2044 case OO_Greater:
2045 return BO_GT;
2046 case OO_LessEqual:
2047 return BO_LE;
2048 case OO_GreaterEqual:
2049 return BO_GE;
2050 case OO_EqualEqual:
2051 return BO_EQ;
2052 case OO_ExclaimEqual:
2053 return BO_NE;
2054 case OO_Amp:
2055 return BO_And;
2056 case OO_Caret:
2057 return BO_Xor;
2058 case OO_Pipe:
2059 return BO_Or;
2060 case OO_AmpAmp:
2061 return BO_LAnd;
2062 case OO_PipePipe:
2063 return BO_LOr;
2064 case OO_Equal:
2065 return BO_Assign;
2066 case OO_StarEqual:
2067 return BO_MulAssign;
2068 case OO_SlashEqual:
2069 return BO_DivAssign;
2070 case OO_PercentEqual:
2071 return BO_RemAssign;
2072 case OO_PlusEqual:
2073 return BO_AddAssign;
2074 case OO_MinusEqual:
2075 return BO_SubAssign;
2076 case OO_LessLessEqual:
2077 return BO_ShlAssign;
2078 case OO_GreaterGreaterEqual:
2079 return BO_ShrAssign;
2080 case OO_AmpEqual:
2081 return BO_AndAssign;
2082 case OO_CaretEqual:
2083 return BO_XorAssign;
2084 case OO_PipeEqual:
2085 return BO_OrAssign;
2086 case OO_Comma:
2087 return BO_Comma;
2088 }
2089}
2090
2091template <typename NodeType>
2092inline Optional<UnaryOperatorKind>
2093equivalentUnaryOperator(const NodeType &Node) {
2094 return Node.getOpcode();
2095}
2096
2097template <>
2098inline Optional<UnaryOperatorKind>
2099equivalentUnaryOperator<CXXOperatorCallExpr>(const CXXOperatorCallExpr &Node) {
2100 if (Node.getNumArgs() != 1 && Node.getOperator() != OO_PlusPlus &&
2101 Node.getOperator() != OO_MinusMinus)
2102 return None;
2103 switch (Node.getOperator()) {
2104 default:
2105 return None;
2106 case OO_Plus:
2107 return UO_Plus;
2108 case OO_Minus:
2109 return UO_Minus;
2110 case OO_Amp:
2111 return UO_AddrOf;
2112 case OO_Star:
2113 return UO_Deref;
2114 case OO_Tilde:
2115 return UO_Not;
2116 case OO_Exclaim:
2117 return UO_LNot;
2118 case OO_PlusPlus: {
2119 const auto *FD = Node.getDirectCallee();
2120 if (!FD)
2121 return None;
2122 return FD->getNumParams() > 0 ? UO_PostInc : UO_PreInc;
2123 }
2124 case OO_MinusMinus: {
2125 const auto *FD = Node.getDirectCallee();
2126 if (!FD)
2127 return None;
2128 return FD->getNumParams() > 0 ? UO_PostDec : UO_PreDec;
2129 }
2130 case OO_Coawait:
2131 return UO_Coawait;
2132 }
2133}
2134
2135template <typename NodeType> inline const Expr *getLHS(const NodeType &Node) {
2136 return Node.getLHS();
2137}
2138template <>
2139inline const Expr *
2140getLHS<CXXOperatorCallExpr>(const CXXOperatorCallExpr &Node) {
2141 if (!internal::equivalentBinaryOperator(Node))
2142 return nullptr;
2143 return Node.getArg(0);
2144}
2145template <typename NodeType> inline const Expr *getRHS(const NodeType &Node) {
2146 return Node.getRHS();
2147}
2148template <>
2149inline const Expr *
2150getRHS<CXXOperatorCallExpr>(const CXXOperatorCallExpr &Node) {
2151 if (!internal::equivalentBinaryOperator(Node))
2152 return nullptr;
2153 return Node.getArg(1);
2154}
2155template <typename NodeType>
2156inline const Expr *getSubExpr(const NodeType &Node) {
2157 return Node.getSubExpr();
2158}
2159template <>
2160inline const Expr *
2161getSubExpr<CXXOperatorCallExpr>(const CXXOperatorCallExpr &Node) {
2162 if (!internal::equivalentUnaryOperator(Node))
2163 return nullptr;
2164 return Node.getArg(0);
2165}
2166
2167template <typename Ty>
2168struct HasSizeMatcher {
2169 static bool hasSize(const Ty &Node, unsigned int N) {
2170 return Node.getSize() == N;
2171 }
2172};
2173
2174template <>
2175inline bool HasSizeMatcher<StringLiteral>::hasSize(
2176 const StringLiteral &Node, unsigned int N) {
2177 return Node.getLength() == N;
2178}
2179
2180template <typename Ty>
2181struct GetSourceExpressionMatcher {
2182 static const Expr *get(const Ty &Node) {
2183 return Node.getSubExpr();
2184 }
2185};
2186
2187template <>
2188inline const Expr *GetSourceExpressionMatcher<OpaqueValueExpr>::get(
2189 const OpaqueValueExpr &Node) {
2190 return Node.getSourceExpr();
2191}
2192
2193template <typename Ty>
2194struct CompoundStmtMatcher {
2195 static const CompoundStmt *get(const Ty &Node) {
2196 return &Node;
2197 }
2198};
2199
2200template <>
2201inline const CompoundStmt *
2202CompoundStmtMatcher<StmtExpr>::get(const StmtExpr &Node) {
2203 return Node.getSubStmt();
2204}
2205
2206/// If \p Loc is (transitively) expanded from macro \p MacroName, returns the
2207/// location (in the chain of expansions) at which \p MacroName was
2208/// expanded. Since the macro may have been expanded inside a series of
2209/// expansions, that location may itself be a MacroID.
2210llvm::Optional<SourceLocation>
2211getExpansionLocOfMacro(StringRef MacroName, SourceLocation Loc,
2212 const ASTContext &Context);
2213
2214inline Optional<StringRef> getOpName(const UnaryOperator &Node) {
2215 return Node.getOpcodeStr(Node.getOpcode());
2216}
2217inline Optional<StringRef> getOpName(const BinaryOperator &Node) {
2218 return Node.getOpcodeStr();
2219}
2220inline StringRef getOpName(const CXXRewrittenBinaryOperator &Node) {
2221 return Node.getOpcodeStr();
2222}
2223inline Optional<StringRef> getOpName(const CXXOperatorCallExpr &Node) {
2224 auto optBinaryOpcode = equivalentBinaryOperator(Node);
2225 if (!optBinaryOpcode) {
2226 auto optUnaryOpcode = equivalentUnaryOperator(Node);
2227 if (!optUnaryOpcode)
2228 return None;
2229 return UnaryOperator::getOpcodeStr(*optUnaryOpcode);
2230 }
2231 return BinaryOperator::getOpcodeStr(*optBinaryOpcode);
2232}
2233
2234/// Matches overloaded operators with a specific name.
2235///
2236/// The type argument ArgT is not used by this matcher but is used by
2237/// PolymorphicMatcher and should be std::vector<std::string>>.
2238template <typename T, typename ArgT = std::vector<std::string>>
2239class HasAnyOperatorNameMatcher : public SingleNodeMatcherInterface<T> {
2240 static_assert(std::is_same<T, BinaryOperator>::value ||
2241 std::is_same<T, CXXOperatorCallExpr>::value ||
2242 std::is_same<T, CXXRewrittenBinaryOperator>::value ||
2243 std::is_same<T, UnaryOperator>::value,
2244 "Matcher only supports `BinaryOperator`, `UnaryOperator`, "
2245 "`CXXOperatorCallExpr` and `CXXRewrittenBinaryOperator`");
2246 static_assert(std::is_same<ArgT, std::vector<std::string>>::value,
2247 "Matcher ArgT must be std::vector<std::string>");
2248
2249public:
2250 explicit HasAnyOperatorNameMatcher(std::vector<std::string> Names)
2251 : SingleNodeMatcherInterface<T>(), Names(std::move(Names)) {}
2252
2253 bool matchesNode(const T &Node) const override {
2254 Optional<StringRef> OptOpName = getOpName(Node);
2255 return OptOpName && llvm::is_contained(Names, *OptOpName);
2256 }
2257
2258private:
2259 static Optional<StringRef> getOpName(const UnaryOperator &Node) {
2260 return Node.getOpcodeStr(Node.getOpcode());
2261 }
2262 static Optional<StringRef> getOpName(const BinaryOperator &Node) {
2263 return Node.getOpcodeStr();
2264 }
2265 static StringRef getOpName(const CXXRewrittenBinaryOperator &Node) {
2266 return Node.getOpcodeStr();
2267 }
2268 static Optional<StringRef> getOpName(const CXXOperatorCallExpr &Node) {
2269 auto optBinaryOpcode = equivalentBinaryOperator(Node);
2270 if (!optBinaryOpcode) {
2271 auto optUnaryOpcode = equivalentUnaryOperator(Node);
2272 if (!optUnaryOpcode)
2273 return None;
2274 return UnaryOperator::getOpcodeStr(*optUnaryOpcode);
2275 }
2276 return BinaryOperator::getOpcodeStr(*optBinaryOpcode);
2277 }
2278
2279 std::vector<std::string> Names;
2280};
2281
2282using HasOpNameMatcher =
2283 PolymorphicMatcher<HasAnyOperatorNameMatcher,
2284 void(
2285 TypeList<BinaryOperator, CXXOperatorCallExpr,
2286 CXXRewrittenBinaryOperator, UnaryOperator>),
2287 std::vector<std::string>>;
2288
2289HasOpNameMatcher hasAnyOperatorNameFunc(ArrayRef<const StringRef *> NameRefs);
2290
2291using HasOverloadOpNameMatcher =
2292 PolymorphicMatcher<HasOverloadedOperatorNameMatcher,
2293 void(TypeList<CXXOperatorCallExpr, FunctionDecl>),
2294 std::vector<std::string>>;
2295
2296HasOverloadOpNameMatcher
2297hasAnyOverloadedOperatorNameFunc(ArrayRef<const StringRef *> NameRefs);
2298
2299/// Returns true if \p Node has a base specifier matching \p BaseSpec.
2300///
2301/// A class is not considered to be derived from itself.
2302bool matchesAnyBase(const CXXRecordDecl &Node,
2303 const Matcher<CXXBaseSpecifier> &BaseSpecMatcher,
2304 ASTMatchFinder *Finder, BoundNodesTreeBuilder *Builder);
2305
2306std::shared_ptr<llvm::Regex> createAndVerifyRegex(StringRef Regex,
2307 llvm::Regex::RegexFlags Flags,
2308 StringRef MatcherID);
2309
2310inline bool
2311MatchTemplateArgLocAt(const DeclRefExpr &Node, unsigned int Index,
2312 internal::Matcher<TemplateArgumentLoc> InnerMatcher,
2313 internal::ASTMatchFinder *Finder,
2314 internal::BoundNodesTreeBuilder *Builder) {
2315 llvm::ArrayRef<TemplateArgumentLoc> ArgLocs = Node.template_arguments();
2316 return Index < ArgLocs.size() &&
2317 InnerMatcher.matches(ArgLocs[Index], Finder, Builder);
2318}
2319
2320inline bool
2321MatchTemplateArgLocAt(const TemplateSpecializationTypeLoc &Node,
2322 unsigned int Index,
2323 internal::Matcher<TemplateArgumentLoc> InnerMatcher,
2324 internal::ASTMatchFinder *Finder,
2325 internal::BoundNodesTreeBuilder *Builder) {
2326 return !Node.isNull() && Index < Node.getNumArgs() &&
2327 InnerMatcher.matches(Node.getArgLoc(Index), Finder, Builder);
2328}
2329
2330} // namespace internal
2331
2332} // namespace ast_matchers
2333
2334} // namespace clang
2335
2336#endif // LLVM_CLANG_ASTMATCHERS_ASTMATCHERSINTERNAL_H

/usr/lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/stl_tree.h

1// RB tree implementation -*- C++ -*-
2
3// Copyright (C) 2001-2020 Free Software Foundation, Inc.
4//
5// This file is part of the GNU ISO C++ Library. This library is free
6// software; you can redistribute it and/or modify it under the
7// terms of the GNU General Public License as published by the
8// Free Software Foundation; either version 3, or (at your option)
9// any later version.
10
11// This library is distributed in the hope that it will be useful,
12// but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14// GNU General Public License for more details.
15
16// Under Section 7 of GPL version 3, you are granted additional
17// permissions described in the GCC Runtime Library Exception, version
18// 3.1, as published by the Free Software Foundation.
19
20// You should have received a copy of the GNU General Public License and
21// a copy of the GCC Runtime Library Exception along with this program;
22// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
23// <http://www.gnu.org/licenses/>.
24
25/*
26 *
27 * Copyright (c) 1996,1997
28 * Silicon Graphics Computer Systems, Inc.
29 *
30 * Permission to use, copy, modify, distribute and sell this software
31 * and its documentation for any purpose is hereby granted without fee,
32 * provided that the above copyright notice appear in all copies and
33 * that both that copyright notice and this permission notice appear
34 * in supporting documentation. Silicon Graphics makes no
35 * representations about the suitability of this software for any
36 * purpose. It is provided "as is" without express or implied warranty.
37 *
38 *
39 * Copyright (c) 1994
40 * Hewlett-Packard Company
41 *
42 * Permission to use, copy, modify, distribute and sell this software
43 * and its documentation for any purpose is hereby granted without fee,
44 * provided that the above copyright notice appear in all copies and
45 * that both that copyright notice and this permission notice appear
46 * in supporting documentation. Hewlett-Packard Company makes no
47 * representations about the suitability of this software for any
48 * purpose. It is provided "as is" without express or implied warranty.
49 *
50 *
51 */
52
53/** @file bits/stl_tree.h
54 * This is an internal header file, included by other library headers.
55 * Do not attempt to use it directly. @headername{map,set}
56 */
57
58#ifndef _STL_TREE_H1
59#define _STL_TREE_H1 1
60
61#pragma GCC system_header
62
63#include <bits/stl_algobase.h>
64#include <bits/allocator.h>
65#include <bits/stl_function.h>
66#include <bits/cpp_type_traits.h>
67#include <ext/alloc_traits.h>
68#if __cplusplus201402L >= 201103L
69# include <ext/aligned_buffer.h>
70#endif
71#if __cplusplus201402L > 201402L
72# include <bits/node_handle.h>
73#endif
74
75namespace std _GLIBCXX_VISIBILITY(default)__attribute__ ((__visibility__ ("default")))
76{
77_GLIBCXX_BEGIN_NAMESPACE_VERSION
78
79#if __cplusplus201402L > 201103L
80# define __cpp_lib_generic_associative_lookup201304 201304
81#endif
82
83 // Red-black tree class, designed for use in implementing STL
84 // associative containers (set, multiset, map, and multimap). The
85 // insertion and deletion algorithms are based on those in Cormen,
86 // Leiserson, and Rivest, Introduction to Algorithms (MIT Press,
87 // 1990), except that
88 //
89 // (1) the header cell is maintained with links not only to the root
90 // but also to the leftmost node of the tree, to enable constant
91 // time begin(), and to the rightmost node of the tree, to enable
92 // linear time performance when used with the generic set algorithms
93 // (set_union, etc.)
94 //
95 // (2) when a node being deleted has two children its successor node
96 // is relinked into its place, rather than copied, so that the only
97 // iterators invalidated are those referring to the deleted node.
98
99 enum _Rb_tree_color { _S_red = false, _S_black = true };
100
101 struct _Rb_tree_node_base
102 {
103 typedef _Rb_tree_node_base* _Base_ptr;
104 typedef const _Rb_tree_node_base* _Const_Base_ptr;
105
106 _Rb_tree_color _M_color;
107 _Base_ptr _M_parent;
108 _Base_ptr _M_left;
109 _Base_ptr _M_right;
110
111 static _Base_ptr
112 _S_minimum(_Base_ptr __x) _GLIBCXX_NOEXCEPTnoexcept
113 {
114 while (__x->_M_left != 0) __x = __x->_M_left;
115 return __x;
116 }
117
118 static _Const_Base_ptr
119 _S_minimum(_Const_Base_ptr __x) _GLIBCXX_NOEXCEPTnoexcept
120 {
121 while (__x->_M_left != 0) __x = __x->_M_left;
122 return __x;
123 }
124
125 static _Base_ptr
126 _S_maximum(_Base_ptr __x) _GLIBCXX_NOEXCEPTnoexcept
127 {
128 while (__x->_M_right != 0) __x = __x->_M_right;
129 return __x;
130 }
131
132 static _Const_Base_ptr
133 _S_maximum(_Const_Base_ptr __x) _GLIBCXX_NOEXCEPTnoexcept
134 {
135 while (__x->_M_right != 0) __x = __x->_M_right;
136 return __x;
137 }
138 };
139
140 // Helper type offering value initialization guarantee on the compare functor.
141 template<typename _Key_compare>
142 struct _Rb_tree_key_compare
143 {
144 _Key_compare _M_key_compare;
145
146 _Rb_tree_key_compare()
147 _GLIBCXX_NOEXCEPT_IF(noexcept(is_nothrow_default_constructible<_Key_compare>
::value)
148 is_nothrow_default_constructible<_Key_compare>::value)noexcept(is_nothrow_default_constructible<_Key_compare>
::value)
149 : _M_key_compare()
150 { }
151
152 _Rb_tree_key_compare(const _Key_compare& __comp)
153 : _M_key_compare(__comp)
154 { }
155
156#if __cplusplus201402L >= 201103L
157 // Copy constructor added for consistency with C++98 mode.
158 _Rb_tree_key_compare(const _Rb_tree_key_compare&) = default;
159
160 _Rb_tree_key_compare(_Rb_tree_key_compare&& __x)
161 noexcept(is_nothrow_copy_constructible<_Key_compare>::value)
162 : _M_key_compare(__x._M_key_compare)
163 { }
164#endif
165 };
166
167 // Helper type to manage default initialization of node count and header.
168 struct _Rb_tree_header
169 {
170 _Rb_tree_node_base _M_header;
171 size_t _M_node_count; // Keeps track of size of tree.
172
173 _Rb_tree_header() _GLIBCXX_NOEXCEPTnoexcept
174 {
175 _M_header._M_color = _S_red;
176 _M_reset();
177 }
178
179#if __cplusplus201402L >= 201103L
180 _Rb_tree_header(_Rb_tree_header&& __x) noexcept
181 {
182 if (__x._M_header._M_parent != nullptr)
183 _M_move_data(__x);
184 else
185 {
186 _M_header._M_color = _S_red;
187 _M_reset();
188 }
189 }
190#endif
191
192 void
193 _M_move_data(_Rb_tree_header& __from)
194 {
195 _M_header._M_color = __from._M_header._M_color;
196 _M_header._M_parent = __from._M_header._M_parent;
197 _M_header._M_left = __from._M_header._M_left;
198 _M_header._M_right = __from._M_header._M_right;
199 _M_header._M_parent->_M_parent = &_M_header;
200 _M_node_count = __from._M_node_count;
201
202 __from._M_reset();
203 }
204
205 void
206 _M_reset()
207 {
208 _M_header._M_parent = 0;
209 _M_header._M_left = &_M_header;
210 _M_header._M_right = &_M_header;
211 _M_node_count = 0;
212 }
213 };
214
215 template<typename _Val>
216 struct _Rb_tree_node : public _Rb_tree_node_base
217 {
218 typedef _Rb_tree_node<_Val>* _Link_type;
219
220#if __cplusplus201402L < 201103L
221 _Val _M_value_field;
222
223 _Val*
224 _M_valptr()
225 { return std::__addressof(_M_value_field); }
226
227 const _Val*
228 _M_valptr() const
229 { return std::__addressof(_M_value_field); }
230#else
231 __gnu_cxx::__aligned_membuf<_Val> _M_storage;
232
233 _Val*
234 _M_valptr()
235 { return _M_storage._M_ptr(); }
236
237 const _Val*
238 _M_valptr() const
239 { return _M_storage._M_ptr(); }
240#endif
241 };
242
243 _GLIBCXX_PURE__attribute__ ((__pure__)) _Rb_tree_node_base*
244 _Rb_tree_increment(_Rb_tree_node_base* __x) throw ();
245
246 _GLIBCXX_PURE__attribute__ ((__pure__)) const _Rb_tree_node_base*
247 _Rb_tree_increment(const _Rb_tree_node_base* __x) throw ();
248
249 _GLIBCXX_PURE__attribute__ ((__pure__)) _Rb_tree_node_base*
250 _Rb_tree_decrement(_Rb_tree_node_base* __x) throw ();
251
252 _GLIBCXX_PURE__attribute__ ((__pure__)) const _Rb_tree_node_base*
253 _Rb_tree_decrement(const _Rb_tree_node_base* __x) throw ();
254
255 template<typename _Tp>
256 struct _Rb_tree_iterator
257 {
258 typedef _Tp value_type;
259 typedef _Tp& reference;
260 typedef _Tp* pointer;
261
262 typedef bidirectional_iterator_tag iterator_category;
263 typedef ptrdiff_t difference_type;
264
265 typedef _Rb_tree_iterator<_Tp> _Self;
266 typedef _Rb_tree_node_base::_Base_ptr _Base_ptr;
267 typedef _Rb_tree_node<_Tp>* _Link_type;
268
269 _Rb_tree_iterator() _GLIBCXX_NOEXCEPTnoexcept
270 : _M_node() { }
271
272 explicit
273 _Rb_tree_iterator(_Base_ptr __x) _GLIBCXX_NOEXCEPTnoexcept
274 : _M_node(__x) { }
275
276 reference
277 operator*() const _GLIBCXX_NOEXCEPTnoexcept
278 { return *static_cast<_Link_type>(_M_node)->_M_valptr(); }
279
280 pointer
281 operator->() const _GLIBCXX_NOEXCEPTnoexcept
282 { return static_cast<_Link_type> (_M_node)->_M_valptr(); }
283
284 _Self&
285 operator++() _GLIBCXX_NOEXCEPTnoexcept
286 {
287 _M_node = _Rb_tree_increment(_M_node);
288 return *this;
289 }
290
291 _Self
292 operator++(int) _GLIBCXX_NOEXCEPTnoexcept
293 {
294 _Self __tmp = *this;
295 _M_node = _Rb_tree_increment(_M_node);
296 return __tmp;
297 }
298
299 _Self&
300 operator--() _GLIBCXX_NOEXCEPTnoexcept
301 {
302 _M_node = _Rb_tree_decrement(_M_node);
303 return *this;
304 }
305
306 _Self
307 operator--(int) _GLIBCXX_NOEXCEPTnoexcept
308 {
309 _Self __tmp = *this;
310 _M_node = _Rb_tree_decrement(_M_node);
311 return __tmp;
312 }
313
314 friend bool
315 operator==(const _Self& __x, const _Self& __y) _GLIBCXX_NOEXCEPTnoexcept
316 { return __x._M_node == __y._M_node; }
317
318#if ! __cpp_lib_three_way_comparison
319 friend bool
320 operator!=(const _Self& __x, const _Self& __y) _GLIBCXX_NOEXCEPTnoexcept
321 { return __x._M_node != __y._M_node; }
322#endif
323
324 _Base_ptr _M_node;
325 };
326
327 template<typename _Tp>
328 struct _Rb_tree_const_iterator
329 {
330 typedef _Tp value_type;
331 typedef const _Tp& reference;
332 typedef const _Tp* pointer;
333
334 typedef _Rb_tree_iterator<_Tp> iterator;
335
336 typedef bidirectional_iterator_tag iterator_category;
337 typedef ptrdiff_t difference_type;
338
339 typedef _Rb_tree_const_iterator<_Tp> _Self;
340 typedef _Rb_tree_node_base::_Const_Base_ptr _Base_ptr;
341 typedef const _Rb_tree_node<_Tp>* _Link_type;
342
343 _Rb_tree_const_iterator() _GLIBCXX_NOEXCEPTnoexcept
344 : _M_node() { }
345
346 explicit
347 _Rb_tree_const_iterator(_Base_ptr __x) _GLIBCXX_NOEXCEPTnoexcept
348 : _M_node(__x) { }
349
350 _Rb_tree_const_iterator(const iterator& __it) _GLIBCXX_NOEXCEPTnoexcept
351 : _M_node(__it._M_node) { }
352
353 iterator
354 _M_const_cast() const _GLIBCXX_NOEXCEPTnoexcept
355 { return iterator(const_cast<typename iterator::_Base_ptr>(_M_node)); }
356
357 reference
358 operator*() const _GLIBCXX_NOEXCEPTnoexcept
359 { return *static_cast<_Link_type>(_M_node)->_M_valptr(); }
360
361 pointer
362 operator->() const _GLIBCXX_NOEXCEPTnoexcept
363 { return static_cast<_Link_type>(_M_node)->_M_valptr(); }
364
365 _Self&
366 operator++() _GLIBCXX_NOEXCEPTnoexcept
367 {
368 _M_node = _Rb_tree_increment(_M_node);
369 return *this;
370 }
371
372 _Self
373 operator++(int) _GLIBCXX_NOEXCEPTnoexcept
374 {
375 _Self __tmp = *this;
376 _M_node = _Rb_tree_increment(_M_node);
377 return __tmp;
378 }
379
380 _Self&
381 operator--() _GLIBCXX_NOEXCEPTnoexcept
382 {
383 _M_node = _Rb_tree_decrement(_M_node);
384 return *this;
385 }
386
387 _Self
388 operator--(int) _GLIBCXX_NOEXCEPTnoexcept
389 {
390 _Self __tmp = *this;
391 _M_node = _Rb_tree_decrement(_M_node);
392 return __tmp;
393 }
394
395 friend bool
396 operator==(const _Self& __x, const _Self& __y) _GLIBCXX_NOEXCEPTnoexcept
397 { return __x._M_node == __y._M_node; }
26
Assuming '__x._M_node' is equal to '__y._M_node'
27
Returning the value 1, which participates in a condition later
38
Assuming '__x._M_node' is not equal to '__y._M_node'
39
Returning zero, which participates in a condition later
398
399#if ! __cpp_lib_three_way_comparison
400 friend bool
401 operator!=(const _Self& __x, const _Self& __y) _GLIBCXX_NOEXCEPTnoexcept
402 { return __x._M_node != __y._M_node; }
403#endif
404
405 _Base_ptr _M_node;
406 };
407
408 void
409 _Rb_tree_insert_and_rebalance(const bool __insert_left,
410 _Rb_tree_node_base* __x,
411 _Rb_tree_node_base* __p,
412 _Rb_tree_node_base& __header) throw ();
413
414 _Rb_tree_node_base*
415 _Rb_tree_rebalance_for_erase(_Rb_tree_node_base* const __z,
416 _Rb_tree_node_base& __header) throw ();
417
418#if __cplusplus201402L >= 201402L
419 template<typename _Cmp, typename _SfinaeType, typename = __void_t<>>
420 struct __has_is_transparent
421 { };
422
423 template<typename _Cmp, typename _SfinaeType>
424 struct __has_is_transparent<_Cmp, _SfinaeType,
425 __void_t<typename _Cmp::is_transparent>>
426 { typedef void type; };
427
428 template<typename _Cmp, typename _SfinaeType>
429 using __has_is_transparent_t
430 = typename __has_is_transparent<_Cmp, _SfinaeType>::type;
431#endif
432
433#if __cplusplus201402L > 201402L
434 template<typename _Tree1, typename _Cmp2>
435 struct _Rb_tree_merge_helper { };
436#endif
437
438 template<typename _Key, typename _Val, typename _KeyOfValue,
439 typename _Compare, typename _Alloc = allocator<_Val> >
440 class _Rb_tree
441 {
442 typedef typename __gnu_cxx::__alloc_traits<_Alloc>::template
443 rebind<_Rb_tree_node<_Val> >::other _Node_allocator;
444
445 typedef __gnu_cxx::__alloc_traits<_Node_allocator> _Alloc_traits;
446
447 protected:
448 typedef _Rb_tree_node_base* _Base_ptr;
449 typedef const _Rb_tree_node_base* _Const_Base_ptr;
450 typedef _Rb_tree_node<_Val>* _Link_type;
451 typedef const _Rb_tree_node<_Val>* _Const_Link_type;
452
453 private:
454 // Functor recycling a pool of nodes and using allocation once the pool
455 // is empty.
456 struct _Reuse_or_alloc_node
457 {
458 _Reuse_or_alloc_node(_Rb_tree& __t)
459 : _M_root(__t._M_root()), _M_nodes(__t._M_rightmost()), _M_t(__t)
460 {
461 if (_M_root)
462 {
463 _M_root->_M_parent = 0;
464
465 if (_M_nodes->_M_left)
466 _M_nodes = _M_nodes->_M_left;
467 }
468 else
469 _M_nodes = 0;
470 }
471
472#if __cplusplus201402L >= 201103L
473 _Reuse_or_alloc_node(const _Reuse_or_alloc_node&) = delete;
474#endif
475
476 ~_Reuse_or_alloc_node()
477 { _M_t._M_erase(static_cast<_Link_type>(_M_root)); }
478
479 template<typename _Arg>
480 _Link_type
481#if __cplusplus201402L < 201103L
482 operator()(const _Arg& __arg)
483#else
484 operator()(_Arg&& __arg)
485#endif
486 {
487 _Link_type __node = static_cast<_Link_type>(_M_extract());
488 if (__node)
489 {
490 _M_t._M_destroy_node(__node);
491 _M_t._M_construct_node(__node, _GLIBCXX_FORWARD(_Arg, __arg)std::forward<_Arg>(__arg));
492 return __node;
493 }
494
495 return _M_t._M_create_node(_GLIBCXX_FORWARD(_Arg, __arg)std::forward<_Arg>(__arg));
496 }
497
498 private:
499 _Base_ptr
500 _M_extract()
501 {
502 if (!_M_nodes)
503 return _M_nodes;
504
505 _Base_ptr __node = _M_nodes;
506 _M_nodes = _M_nodes->_M_parent;
507 if (_M_nodes)
508 {
509 if (_M_nodes->_M_right == __node)
510 {
511 _M_nodes->_M_right = 0;
512
513 if (_M_nodes->_M_left)
514 {
515 _M_nodes = _M_nodes->_M_left;
516
517 while (_M_nodes->_M_right)
518 _M_nodes = _M_nodes->_M_right;
519
520 if (_M_nodes->_M_left)
521 _M_nodes = _M_nodes->_M_left;
522 }
523 }
524 else // __node is on the left.
525 _M_nodes->_M_left = 0;
526 }
527 else
528 _M_root = 0;
529
530 return __node;
531 }
532
533 _Base_ptr _M_root;
534 _Base_ptr _M_nodes;
535 _Rb_tree& _M_t;
536 };
537
538 // Functor similar to the previous one but without any pool of nodes to
539 // recycle.
540 struct _Alloc_node
541 {
542 _Alloc_node(_Rb_tree& __t)
543 : _M_t(__t) { }
544
545 template<typename _Arg>
546 _Link_type
547#if __cplusplus201402L < 201103L
548 operator()(const _Arg& __arg) const
549#else
550 operator()(_Arg&& __arg) const
551#endif
552 { return _M_t._M_create_node(_GLIBCXX_FORWARD(_Arg, __arg)std::forward<_Arg>(__arg)); }
553
554 private:
555 _Rb_tree& _M_t;
556 };
557
558 public:
559 typedef _Key key_type;
560 typedef _Val value_type;
561 typedef value_type* pointer;
562 typedef const value_type* const_pointer;
563 typedef value_type& reference;
564 typedef const value_type& const_reference;
565 typedef size_t size_type;
566 typedef ptrdiff_t difference_type;
567 typedef _Alloc allocator_type;
568
569 _Node_allocator&
570 _M_get_Node_allocator() _GLIBCXX_NOEXCEPTnoexcept
571 { return this->_M_impl; }
572
573 const _Node_allocator&
574 _M_get_Node_allocator() const _GLIBCXX_NOEXCEPTnoexcept
575 { return this->_M_impl; }
576
577 allocator_type
578 get_allocator() const _GLIBCXX_NOEXCEPTnoexcept
579 { return allocator_type(_M_get_Node_allocator()); }
580
581 protected:
582 _Link_type
583 _M_get_node()
584 { return _Alloc_traits::allocate(_M_get_Node_allocator(), 1); }
585
586 void
587 _M_put_node(_Link_type __p) _GLIBCXX_NOEXCEPTnoexcept
588 { _Alloc_traits::deallocate(_M_get_Node_allocator(), __p, 1); }
589
590#if __cplusplus201402L < 201103L
591 void
592 _M_construct_node(_Link_type __node, const value_type& __x)
593 {
594 __tryif (true)
595 { get_allocator().construct(__node->_M_valptr(), __x); }
596 __catch(...)if (false)
597 {
598 _M_put_node(__node);
599 __throw_exception_again;
600 }
601 }
602
603 _Link_type
604 _M_create_node(const value_type& __x)
605 {
606 _Link_type __tmp = _M_get_node();
607 _M_construct_node(__tmp, __x);
608 return __tmp;
609 }
610#else
611 template<typename... _Args>
612 void
613 _M_construct_node(_Link_type __node, _Args&&... __args)
614 {
615 __tryif (true)
616 {
617 ::new(__node) _Rb_tree_node<_Val>;
618 _Alloc_traits::construct(_M_get_Node_allocator(),
619 __node->_M_valptr(),
620 std::forward<_Args>(__args)...);
621 }
622 __catch(...)if (false)
623 {
624 __node->~_Rb_tree_node<_Val>();
625 _M_put_node(__node);
626 __throw_exception_again;
627 }
628 }
629
630 template<typename... _Args>
631 _Link_type
632 _M_create_node(_Args&&... __args)
633 {
634 _Link_type __tmp = _M_get_node();
635 _M_construct_node(__tmp, std::forward<_Args>(__args)...);
636 return __tmp;
637 }
638#endif
639
640 void
641 _M_destroy_node(_Link_type __p) _GLIBCXX_NOEXCEPTnoexcept
642 {
643#if __cplusplus201402L < 201103L
644 get_allocator().destroy(__p->_M_valptr());
645#else
646 _Alloc_traits::destroy(_M_get_Node_allocator(), __p->_M_valptr());
647 __p->~_Rb_tree_node<_Val>();
648#endif
649 }
650
651 void
652 _M_drop_node(_Link_type __p) _GLIBCXX_NOEXCEPTnoexcept
653 {
654 _M_destroy_node(__p);
655 _M_put_node(__p);
656 }
657
658 template<typename _NodeGen>
659 _Link_type
660 _M_clone_node(_Const_Link_type __x, _NodeGen& __node_gen)
661 {
662 _Link_type __tmp = __node_gen(*__x->_M_valptr());
663 __tmp->_M_color = __x->_M_color;
664 __tmp->_M_left = 0;
665 __tmp->_M_right = 0;
666 return __tmp;
667 }
668
669 protected:
670#if _GLIBCXX_INLINE_VERSION0
671 template<typename _Key_compare>
672#else
673 // Unused _Is_pod_comparator is kept as it is part of mangled name.
674 template<typename _Key_compare,
675 bool /* _Is_pod_comparator */ = __is_pod(_Key_compare)>
676#endif
677 struct _Rb_tree_impl
678 : public _Node_allocator
679 , public _Rb_tree_key_compare<_Key_compare>
680 , public _Rb_tree_header
681 {
682 typedef _Rb_tree_key_compare<_Key_compare> _Base_key_compare;
683
684 _Rb_tree_impl()
685 _GLIBCXX_NOEXCEPT_IF(noexcept(is_nothrow_default_constructible<_Node_allocator>
::value && is_nothrow_default_constructible<_Base_key_compare
>::value)
686 is_nothrow_default_constructible<_Node_allocator>::valuenoexcept(is_nothrow_default_constructible<_Node_allocator>
::value && is_nothrow_default_constructible<_Base_key_compare
>::value)
687 && is_nothrow_default_constructible<_Base_key_compare>::value )noexcept(is_nothrow_default_constructible<_Node_allocator>
::value && is_nothrow_default_constructible<_Base_key_compare
>::value)
688 : _Node_allocator()
689 { }
690
691 _Rb_tree_impl(const _Rb_tree_impl& __x)
692 : _Node_allocator(_Alloc_traits::_S_select_on_copy(__x))
693 , _Base_key_compare(__x._M_key_compare)
694 { }
695
696#if __cplusplus201402L < 201103L
697 _Rb_tree_impl(const _Key_compare& __comp, const _Node_allocator& __a)
698 : _Node_allocator(__a), _Base_key_compare(__comp)
699 { }
700#else
701 _Rb_tree_impl(_Rb_tree_impl&&) = default;
702
703 explicit
704 _Rb_tree_impl(_Node_allocator&& __a)
705 : _Node_allocator(std::move(__a))
706 { }
707
708 _Rb_tree_impl(_Rb_tree_impl&& __x, _Node_allocator&& __a)
709 : _Node_allocator(std::move(__a)),
710 _Base_key_compare(std::move(__x)),
711 _Rb_tree_header(std::move(__x))
712 { }
713
714 _Rb_tree_impl(const _Key_compare& __comp, _Node_allocator&& __a)
715 : _Node_allocator(std::move(__a)), _Base_key_compare(__comp)
716 { }
717#endif
718 };
719
720 _Rb_tree_impl<_Compare> _M_impl;
721
722 protected:
723 _Base_ptr&
724 _M_root() _GLIBCXX_NOEXCEPTnoexcept
725 { return this->_M_impl._M_header._M_parent; }
726
727 _Const_Base_ptr
728 _M_root() const _GLIBCXX_NOEXCEPTnoexcept
729 { return this->_M_impl._M_header._M_parent; }
730
731 _Base_ptr&
732 _M_leftmost() _GLIBCXX_NOEXCEPTnoexcept
733 { return this->_M_impl._M_header._M_left; }
734
735 _Const_Base_ptr
736 _M_leftmost() const _GLIBCXX_NOEXCEPTnoexcept
737 { return this->_M_impl._M_header._M_left; }
738
739 _Base_ptr&
740 _M_rightmost() _GLIBCXX_NOEXCEPTnoexcept
741 { return this->_M_impl._M_header._M_right; }
742
743 _Const_Base_ptr
744 _M_rightmost() const _GLIBCXX_NOEXCEPTnoexcept
745 { return this->_M_impl._M_header._M_right; }
746
747 _Link_type
748 _M_begin() _GLIBCXX_NOEXCEPTnoexcept
749 { return static_cast<_Link_type>(this->_M_impl._M_header._M_parent); }
750
751 _Const_Link_type
752 _M_begin() const _GLIBCXX_NOEXCEPTnoexcept
753 {
754 return static_cast<_Const_Link_type>
755 (this->_M_impl._M_header._M_parent);
756 }
757
758 _Base_ptr
759 _M_end() _GLIBCXX_NOEXCEPTnoexcept
760 { return &this->_M_impl._M_header; }
761
762 _Const_Base_ptr
763 _M_end() const _GLIBCXX_NOEXCEPTnoexcept
764 { return &this->_M_impl._M_header; }
765
766 static const _Key&
767 _S_key(_Const_Link_type __x)
768 {
769#if __cplusplus201402L >= 201103L
770 // If we're asking for the key we're presumably using the comparison
771 // object, and so this is a good place to sanity check it.
772 static_assert(__is_invocable<_Compare&, const _Key&, const _Key&>{},
773 "comparison object must be invocable "
774 "with two arguments of key type");
775# if __cplusplus201402L >= 201703L
776 // _GLIBCXX_RESOLVE_LIB_DEFECTS
777 // 2542. Missing const requirements for associative containers
778 if constexpr (__is_invocable<_Compare&, const _Key&, const _Key&>{})
779 static_assert(
780 is_invocable_v<const _Compare&, const _Key&, const _Key&>,
781 "comparison object must be invocable as const");
782# endif // C++17
783#endif // C++11
784
785 return _KeyOfValue()(*__x->_M_valptr());
786 }
787
788 static _Link_type
789 _S_left(_Base_ptr __x) _GLIBCXX_NOEXCEPTnoexcept
790 { return static_cast<_Link_type>(__x->_M_left); }
791
792 static _Const_Link_type
793 _S_left(_Const_Base_ptr __x) _GLIBCXX_NOEXCEPTnoexcept
794 { return static_cast<_Const_Link_type>(__x->_M_left); }
795
796 static _Link_type
797 _S_right(_Base_ptr __x) _GLIBCXX_NOEXCEPTnoexcept
798 { return static_cast<_Link_type>(__x->_M_right); }
799
800 static _Const_Link_type
801 _S_right(_Const_Base_ptr __x) _GLIBCXX_NOEXCEPTnoexcept
802 { return static_cast<_Const_Link_type>(__x->_M_right); }
803
804 static const _Key&
805 _S_key(_Const_Base_ptr __x)
806 { return _S_key(static_cast<_Const_Link_type>(__x)); }
807
808 static _Base_ptr
809 _S_minimum(_Base_ptr __x) _GLIBCXX_NOEXCEPTnoexcept
810 { return _Rb_tree_node_base::_S_minimum(__x); }
811
812 static _Const_Base_ptr
813 _S_minimum(_Const_Base_ptr __x) _GLIBCXX_NOEXCEPTnoexcept
814 { return _Rb_tree_node_base::_S_minimum(__x); }
815
816 static _Base_ptr
817 _S_maximum(_Base_ptr __x) _GLIBCXX_NOEXCEPTnoexcept
818 { return _Rb_tree_node_base::_S_maximum(__x); }
819
820 static _Const_Base_ptr
821 _S_maximum(_Const_Base_ptr __x) _GLIBCXX_NOEXCEPTnoexcept
822 { return _Rb_tree_node_base::_S_maximum(__x); }
823
824 public:
825 typedef _Rb_tree_iterator<value_type> iterator;
826 typedef _Rb_tree_const_iterator<value_type> const_iterator;
827
828 typedef std::reverse_iterator<iterator> reverse_iterator;
829 typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
830
831#if __cplusplus201402L > 201402L
832 using node_type = _Node_handle<_Key, _Val, _Node_allocator>;
833 using insert_return_type = _Node_insert_return<
834 conditional_t<is_same_v<_Key, _Val>, const_iterator, iterator>,
835 node_type>;
836#endif
837
838 pair<_Base_ptr, _Base_ptr>
839 _M_get_insert_unique_pos(const key_type& __k);
840
841 pair<_Base_ptr, _Base_ptr>
842 _M_get_insert_equal_pos(const key_type& __k);
843
844 pair<_Base_ptr, _Base_ptr>
845 _M_get_insert_hint_unique_pos(const_iterator __pos,
846 const key_type& __k);
847
848 pair<_Base_ptr, _Base_ptr>
849 _M_get_insert_hint_equal_pos(const_iterator __pos,
850 const key_type& __k);
851
852 private:
853#if __cplusplus201402L >= 201103L
854 template<typename _Arg, typename _NodeGen>
855 iterator
856 _M_insert_(_Base_ptr __x, _Base_ptr __y, _Arg&& __v, _NodeGen&);
857
858 iterator
859 _M_insert_node(_Base_ptr __x, _Base_ptr __y, _Link_type __z);
860
861 template<typename _Arg>
862 iterator
863 _M_insert_lower(_Base_ptr __y, _Arg&& __v);
864
865 template<typename _Arg>
866 iterator
867 _M_insert_equal_lower(_Arg&& __x);
868
869 iterator
870 _M_insert_lower_node(_Base_ptr __p, _Link_type __z);
871
872 iterator
873 _M_insert_equal_lower_node(_Link_type __z);
874#else
875 template<typename _NodeGen>
876 iterator
877 _M_insert_(_Base_ptr __x, _Base_ptr __y,
878 const value_type& __v, _NodeGen&);
879
880 // _GLIBCXX_RESOLVE_LIB_DEFECTS
881 // 233. Insertion hints in associative containers.
882 iterator
883 _M_insert_lower(_Base_ptr __y, const value_type& __v);
884
885 iterator
886 _M_insert_equal_lower(const value_type& __x);
887#endif
888
889 template<typename _NodeGen>
890 _Link_type
891 _M_copy(_Const_Link_type __x, _Base_ptr __p, _NodeGen&);
892
893 template<typename _NodeGen>
894 _Link_type
895 _M_copy(const _Rb_tree& __x, _NodeGen& __gen)
896 {
897 _Link_type __root = _M_copy(__x._M_begin(), _M_end(), __gen);
898 _M_leftmost() = _S_minimum(__root);
899 _M_rightmost() = _S_maximum(__root);
900 _M_impl._M_node_count = __x._M_impl._M_node_count;
901 return __root;
902 }
903
904 _Link_type
905 _M_copy(const _Rb_tree& __x)
906 {
907 _Alloc_node __an(*this);
908 return _M_copy(__x, __an);
909 }
910
911 void
912 _M_erase(_Link_type __x);
913
914 iterator
915 _M_lower_bound(_Link_type __x, _Base_ptr __y,
916 const _Key& __k);
917
918 const_iterator
919 _M_lower_bound(_Const_Link_type __x, _Const_Base_ptr __y,
920 const _Key& __k) const;
921
922 iterator
923 _M_upper_bound(_Link_type __x, _Base_ptr __y,
924 const _Key& __k);
925
926 const_iterator
927 _M_upper_bound(_Const_Link_type __x, _Const_Base_ptr __y,
928 const _Key& __k) const;
929
930 public:
931 // allocation/deallocation
932#if __cplusplus201402L < 201103L
933 _Rb_tree() { }
934#else
935 _Rb_tree() = default;
936#endif
937
938 _Rb_tree(const _Compare& __comp,
939 const allocator_type& __a = allocator_type())
940 : _M_impl(__comp, _Node_allocator(__a)) { }
941
942 _Rb_tree(const _Rb_tree& __x)
943 : _M_impl(__x._M_impl)
944 {
945 if (__x._M_root() != 0)
946 _M_root() = _M_copy(__x);
947 }
948
949#if __cplusplus201402L >= 201103L
950 _Rb_tree(const allocator_type& __a)
951 : _M_impl(_Node_allocator(__a))
952 { }
953
954 _Rb_tree(const _Rb_tree& __x, const allocator_type& __a)
955 : _M_impl(__x._M_impl._M_key_compare, _Node_allocator(__a))
956 {
957 if (__x._M_root() != nullptr)
958 _M_root() = _M_copy(__x);
959 }
960
961 _Rb_tree(_Rb_tree&&) = default;
962
963 _Rb_tree(_Rb_tree&& __x, const allocator_type& __a)
964 : _Rb_tree(std::move(__x), _Node_allocator(__a))
965 { }
966
967 private:
968 _Rb_tree(_Rb_tree&& __x, _Node_allocator&& __a, true_type)
969 noexcept(is_nothrow_default_constructible<_Compare>::value)
970 : _M_impl(std::move(__x._M_impl), std::move(__a))
971 { }
972
973 _Rb_tree(_Rb_tree&& __x, _Node_allocator&& __a, false_type)
974 : _M_impl(__x._M_impl._M_key_compare, std::move(__a))
975 {
976 if (__x._M_root() != nullptr)
977 _M_move_data(__x, false_type{});
978 }
979
980 public:
981 _Rb_tree(_Rb_tree&& __x, _Node_allocator&& __a)
982 noexcept( noexcept(
983 _Rb_tree(std::declval<_Rb_tree&&>(), std::declval<_Node_allocator&&>(),
984 std::declval<typename _Alloc_traits::is_always_equal>())) )
985 : _Rb_tree(std::move(__x), std::move(__a),
986 typename _Alloc_traits::is_always_equal{})
987 { }
988#endif
989
990 ~_Rb_tree() _GLIBCXX_NOEXCEPTnoexcept
991 { _M_erase(_M_begin()); }
992
993 _Rb_tree&
994 operator=(const _Rb_tree& __x);
995
996 // Accessors.
997 _Compare
998 key_comp() const
999 { return _M_impl._M_key_compare; }
1000
1001 iterator
1002 begin() _GLIBCXX_NOEXCEPTnoexcept
1003 { return iterator(this->_M_impl._M_header._M_left); }
1004
1005 const_iterator
1006 begin() const _GLIBCXX_NOEXCEPTnoexcept
1007 { return const_iterator(this->_M_impl._M_header._M_left); }
1008
1009 iterator
1010 end() _GLIBCXX_NOEXCEPTnoexcept
1011 { return iterator(&this->_M_impl._M_header); }
1012
1013 const_iterator
1014 end() const _GLIBCXX_NOEXCEPTnoexcept
1015 { return const_iterator(&this->_M_impl._M_header); }
1016
1017 reverse_iterator
1018 rbegin() _GLIBCXX_NOEXCEPTnoexcept
1019 { return reverse_iterator(end()); }
1020
1021 const_reverse_iterator
1022 rbegin() const _GLIBCXX_NOEXCEPTnoexcept
1023 { return const_reverse_iterator(end()); }
1024
1025 reverse_iterator
1026 rend() _GLIBCXX_NOEXCEPTnoexcept
1027 { return reverse_iterator(begin()); }
1028
1029 const_reverse_iterator
1030 rend() const _GLIBCXX_NOEXCEPTnoexcept
1031 { return const_reverse_iterator(begin()); }
1032
1033 _GLIBCXX_NODISCARD bool
1034 empty() const _GLIBCXX_NOEXCEPTnoexcept
1035 { return _M_impl._M_node_count == 0; }
1036
1037 size_type
1038 size() const _GLIBCXX_NOEXCEPTnoexcept
1039 { return _M_impl._M_node_count; }
1040
1041 size_type
1042 max_size() const _GLIBCXX_NOEXCEPTnoexcept
1043 { return _Alloc_traits::max_size(_M_get_Node_allocator()); }
1044
1045 void
1046 swap(_Rb_tree& __t)
1047 _GLIBCXX_NOEXCEPT_IF(__is_nothrow_swappable<_Compare>::value)noexcept(__is_nothrow_swappable<_Compare>::value);
1048
1049 // Insert/erase.
1050#if __cplusplus201402L >= 201103L
1051 template<typename _Arg>
1052 pair<iterator, bool>
1053 _M_insert_unique(_Arg&& __x);
1054
1055 template<typename _Arg>
1056 iterator
1057 _M_insert_equal(_Arg&& __x);
1058
1059 template<typename _Arg, typename _NodeGen>
1060 iterator
1061 _M_insert_unique_(const_iterator __pos, _Arg&& __x, _NodeGen&);
1062
1063 template<typename _Arg>
1064 iterator
1065 _M_insert_unique_(const_iterator __pos, _Arg&& __x)
1066 {
1067 _Alloc_node __an(*this);
1068 return _M_insert_unique_(__pos, std::forward<_Arg>(__x), __an);
1069 }
1070
1071 template<typename _Arg, typename _NodeGen>
1072 iterator
1073 _M_insert_equal_(const_iterator __pos, _Arg&& __x, _NodeGen&);
1074
1075 template<typename _Arg>
1076 iterator
1077 _M_insert_equal_(const_iterator __pos, _Arg&& __x)
1078 {
1079 _Alloc_node __an(*this);
1080 return _M_insert_equal_(__pos, std::forward<_Arg>(__x), __an);
1081 }
1082
1083 template<typename... _Args>
1084 pair<iterator, bool>
1085 _M_emplace_unique(_Args&&... __args);
1086
1087 template<typename... _Args>
1088 iterator
1089 _M_emplace_equal(_Args&&... __args);
1090
1091 template<typename... _Args>
1092 iterator
1093 _M_emplace_hint_unique(const_iterator __pos, _Args&&... __args);
1094
1095 template<typename... _Args>
1096 iterator
1097 _M_emplace_hint_equal(const_iterator __pos, _Args&&... __args);
1098
1099 template<typename _Iter>
1100 using __same_value_type
1101 = is_same<value_type, typename iterator_traits<_Iter>::value_type>;
1102
1103 template<typename _InputIterator>
1104 __enable_if_t<__same_value_type<_InputIterator>::value>
1105 _M_insert_range_unique(_InputIterator __first, _InputIterator __last)
1106 {
1107 _Alloc_node __an(*this);
1108 for (; __first != __last; ++__first)
1109 _M_insert_unique_(end(), *__first, __an);
1110 }
1111
1112 template<typename _InputIterator>
1113 __enable_if_t<!__same_value_type<_InputIterator>::value>
1114 _M_insert_range_unique(_InputIterator __first, _InputIterator __last)
1115 {
1116 for (; __first != __last; ++__first)
1117 _M_emplace_unique(*__first);
1118 }
1119
1120 template<typename _InputIterator>
1121 __enable_if_t<__same_value_type<_InputIterator>::value>
1122 _M_insert_range_equal(_InputIterator __first, _InputIterator __last)
1123 {
1124 _Alloc_node __an(*this);
1125 for (; __first != __last; ++__first)
1126 _M_insert_equal_(end(), *__first, __an);
1127 }
1128
1129 template<typename _InputIterator>
1130 __enable_if_t<!__same_value_type<_InputIterator>::value>
1131 _M_insert_range_equal(_InputIterator __first, _InputIterator __last)
1132 {
1133 _Alloc_node __an(*this);
1134 for (; __first != __last; ++__first)
1135 _M_emplace_equal(*__first);
1136 }
1137#else
1138 pair<iterator, bool>
1139 _M_insert_unique(const value_type& __x);
1140
1141 iterator
1142 _M_insert_equal(const value_type& __x);
1143
1144 template<typename _NodeGen>
1145 iterator
1146 _M_insert_unique_(const_iterator __pos, const value_type& __x,
1147 _NodeGen&);
1148
1149 iterator
1150 _M_insert_unique_(const_iterator __pos, const value_type& __x)
1151 {
1152 _Alloc_node __an(*this);
1153 return _M_insert_unique_(__pos, __x, __an);
1154 }
1155
1156 template<typename _NodeGen>
1157 iterator
1158 _M_insert_equal_(const_iterator __pos, const value_type& __x,
1159 _NodeGen&);
1160 iterator
1161 _M_insert_equal_(const_iterator __pos, const value_type& __x)
1162 {
1163 _Alloc_node __an(*this);
1164 return _M_insert_equal_(__pos, __x, __an);
1165 }
1166
1167 template<typename _InputIterator>
1168 void
1169 _M_insert_range_unique(_InputIterator __first, _InputIterator __last)
1170 {
1171 _Alloc_node __an(*this);
1172 for (; __first != __last; ++__first)
1173 _M_insert_unique_(end(), *__first, __an);
1174 }
1175
1176 template<typename _InputIterator>
1177 void
1178 _M_insert_range_equal(_InputIterator __first, _InputIterator __last)
1179 {
1180 _Alloc_node __an(*this);
1181 for (; __first != __last; ++__first)
1182 _M_insert_equal_(end(), *__first, __an);
1183 }
1184#endif
1185
1186 private:
1187 void
1188 _M_erase_aux(const_iterator __position);
1189
1190 void
1191 _M_erase_aux(const_iterator __first, const_iterator __last);
1192
1193 public:
1194#if __cplusplus201402L >= 201103L
1195 // _GLIBCXX_RESOLVE_LIB_DEFECTS
1196 // DR 130. Associative erase should return an iterator.
1197 _GLIBCXX_ABI_TAG_CXX11__attribute ((__abi_tag__ ("cxx11")))
1198 iterator
1199 erase(const_iterator __position)
1200 {
1201 __glibcxx_assert(__position != end());
1202 const_iterator __result = __position;
1203 ++__result;
1204 _M_erase_aux(__position);
1205 return __result._M_const_cast();
1206 }
1207
1208 // LWG 2059.
1209 _GLIBCXX_ABI_TAG_CXX11__attribute ((__abi_tag__ ("cxx11")))
1210 iterator
1211 erase(iterator __position)
1212 {
1213 __glibcxx_assert(__position != end());
1214 iterator __result = __position;
1215 ++__result;
1216 _M_erase_aux(__position);
1217 return __result;
1218 }
1219#else
1220 void
1221 erase(iterator __position)
1222 {
1223 __glibcxx_assert(__position != end());
1224 _M_erase_aux(__position);
1225 }
1226
1227 void
1228 erase(const_iterator __position)
1229 {
1230 __glibcxx_assert(__position != end());
1231 _M_erase_aux(__position);
1232 }
1233#endif
1234
1235 size_type
1236 erase(const key_type& __x);
1237
1238#if __cplusplus201402L >= 201103L
1239 // _GLIBCXX_RESOLVE_LIB_DEFECTS
1240 // DR 130. Associative erase should return an iterator.
1241 _GLIBCXX_ABI_TAG_CXX11__attribute ((__abi_tag__ ("cxx11")))
1242 iterator
1243 erase(const_iterator __first, const_iterator __last)
1244 {
1245 _M_erase_aux(__first, __last);
1246 return __last._M_const_cast();
1247 }
1248#else
1249 void
1250 erase(iterator __first, iterator __last)
1251 { _M_erase_aux(__first, __last); }
1252
1253 void
1254 erase(const_iterator __first, const_iterator __last)
1255 { _M_erase_aux(__first, __last); }
1256#endif
1257
1258 void
1259 clear() _GLIBCXX_NOEXCEPTnoexcept
1260 {
1261 _M_erase(_M_begin());
1262 _M_impl._M_reset();
1263 }
1264
1265 // Set operations.
1266 iterator
1267 find(const key_type& __k);
1268
1269 const_iterator
1270 find(const key_type& __k) const;
1271
1272 size_type
1273 count(const key_type& __k) const;
1274
1275 iterator
1276 lower_bound(const key_type& __k)
1277 { return _M_lower_bound(_M_begin(), _M_end(), __k); }
1278
1279 const_iterator
1280 lower_bound(const key_type& __k) const
1281 { return _M_lower_bound(_M_begin(), _M_end(), __k); }
1282
1283 iterator
1284 upper_bound(const key_type& __k)
1285 { return _M_upper_bound(_M_begin(), _M_end(), __k); }
1286
1287 const_iterator
1288 upper_bound(const key_type& __k) const
1289 { return _M_upper_bound(_M_begin(), _M_end(), __k); }
1290
1291 pair<iterator, iterator>
1292 equal_range(const key_type& __k);
1293
1294 pair<const_iterator, const_iterator>
1295 equal_range(const key_type& __k) const;
1296
1297#if __cplusplus201402L >= 201402L
1298 template<typename _Kt,
1299 typename _Req = __has_is_transparent_t<_Compare, _Kt>>
1300 iterator
1301 _M_find_tr(const _Kt& __k)
1302 {
1303 const _Rb_tree* __const_this = this;
1304 return __const_this->_M_find_tr(__k)._M_const_cast();
1305 }
1306
1307 template<typename _Kt,
1308 typename _Req = __has_is_transparent_t<_Compare, _Kt>>
1309 const_iterator
1310 _M_find_tr(const _Kt& __k) const
1311 {
1312 auto __j = _M_lower_bound_tr(__k);
1313 if (__j != end() && _M_impl._M_key_compare(__k, _S_key(__j._M_node)))
1314 __j = end();
1315 return __j;
1316 }
1317
1318 template<typename _Kt,
1319 typename _Req = __has_is_transparent_t<_Compare, _Kt>>
1320 size_type
1321 _M_count_tr(const _Kt& __k) const
1322 {
1323 auto __p = _M_equal_range_tr(__k);
1324 return std::distance(__p.first, __p.second);
1325 }
1326
1327 template<typename _Kt,
1328 typename _Req = __has_is_transparent_t<_Compare, _Kt>>
1329 iterator
1330 _M_lower_bound_tr(const _Kt& __k)
1331 {
1332 const _Rb_tree* __const_this = this;
1333 return __const_this->_M_lower_bound_tr(__k)._M_const_cast();
1334 }
1335
1336 template<typename _Kt,
1337 typename _Req = __has_is_transparent_t<_Compare, _Kt>>
1338 const_iterator
1339 _M_lower_bound_tr(const _Kt& __k) const
1340 {
1341 auto __x = _M_begin();
1342 auto __y = _M_end();
1343 while (__x != 0)
1344 if (!_M_impl._M_key_compare(_S_key(__x), __k))
1345 {
1346 __y = __x;
1347 __x = _S_left(__x);
1348 }
1349 else
1350 __x = _S_right(__x);
1351 return const_iterator(__y);
1352 }
1353
1354 template<typename _Kt,
1355 typename _Req = __has_is_transparent_t<_Compare, _Kt>>
1356 iterator
1357 _M_upper_bound_tr(const _Kt& __k)
1358 {
1359 const _Rb_tree* __const_this = this;
1360 return __const_this->_M_upper_bound_tr(__k)._M_const_cast();
1361 }
1362
1363 template<typename _Kt,
1364 typename _Req = __has_is_transparent_t<_Compare, _Kt>>
1365 const_iterator
1366 _M_upper_bound_tr(const _Kt& __k) const
1367 {
1368 auto __x = _M_begin();
1369 auto __y = _M_end();
1370 while (__x != 0)
1371 if (_M_impl._M_key_compare(__k, _S_key(__x)))
1372 {
1373 __y = __x;
1374 __x = _S_left(__x);
1375 }
1376 else
1377 __x = _S_right(__x);
1378 return const_iterator(__y);
1379 }
1380
1381 template<typename _Kt,
1382 typename _Req = __has_is_transparent_t<_Compare, _Kt>>
1383 pair<iterator, iterator>
1384 _M_equal_range_tr(const _Kt& __k)
1385 {
1386 const _Rb_tree* __const_this = this;
1387 auto __ret = __const_this->_M_equal_range_tr(__k);
1388 return { __ret.first._M_const_cast(), __ret.second._M_const_cast() };
1389 }
1390
1391 template<typename _Kt,
1392 typename _Req = __has_is_transparent_t<_Compare, _Kt>>
1393 pair<const_iterator, const_iterator>
1394 _M_equal_range_tr(const _Kt& __k) const
1395 {
1396 auto __low = _M_lower_bound_tr(__k);
1397 auto __high = __low;
1398 auto& __cmp = _M_impl._M_key_compare;
1399 while (__high != end() && !__cmp(__k, _S_key(__high._M_node)))
1400 ++__high;
1401 return { __low, __high };
1402 }
1403#endif
1404
1405 // Debugging.
1406 bool
1407 __rb_verify() const;
1408
1409#if __cplusplus201402L >= 201103L
1410 _Rb_tree&
1411 operator=(_Rb_tree&&)
1412 noexcept(_Alloc_traits::_S_nothrow_move()
1413 && is_nothrow_move_assignable<_Compare>::value);
1414
1415 template<typename _Iterator>
1416 void
1417 _M_assign_unique(_Iterator, _Iterator);
1418
1419 template<typename _Iterator>
1420 void
1421 _M_assign_equal(_Iterator, _Iterator);
1422
1423 private:
1424 // Move elements from container with equal allocator.
1425 void
1426 _M_move_data(_Rb_tree& __x, true_type)
1427 { _M_impl._M_move_data(__x._M_impl); }
1428
1429 // Move elements from container with possibly non-equal allocator,
1430 // which might result in a copy not a move.
1431 void
1432 _M_move_data(_Rb_tree&, false_type);
1433
1434 // Move assignment from container with equal allocator.
1435 void
1436 _M_move_assign(_Rb_tree&, true_type);
1437
1438 // Move assignment from container with possibly non-equal allocator,
1439 // which might result in a copy not a move.
1440 void
1441 _M_move_assign(_Rb_tree&, false_type);
1442#endif
1443
1444#if __cplusplus201402L > 201402L
1445 public:
1446 /// Re-insert an extracted node.
1447 insert_return_type
1448 _M_reinsert_node_unique(node_type&& __nh)
1449 {
1450 insert_return_type __ret;
1451 if (__nh.empty())
1452 __ret.position = end();
1453 else
1454 {
1455 __glibcxx_assert(_M_get_Node_allocator() == *__nh._M_alloc);
1456
1457 auto __res = _M_get_insert_unique_pos(__nh._M_key());
1458 if (__res.second)
1459 {
1460 __ret.position
1461 = _M_insert_node(__res.first, __res.second, __nh._M_ptr);
1462 __nh._M_ptr = nullptr;
1463 __ret.inserted = true;
1464 }
1465 else
1466 {
1467 __ret.node = std::move(__nh);
1468 __ret.position = iterator(__res.first);
1469 __ret.inserted = false;
1470 }
1471 }
1472 return __ret;
1473 }
1474
1475 /// Re-insert an extracted node.
1476 iterator
1477 _M_reinsert_node_equal(node_type&& __nh)
1478 {
1479 iterator __ret;
1480 if (__nh.empty())
1481 __ret = end();
1482 else
1483 {
1484 __glibcxx_assert(_M_get_Node_allocator() == *__nh._M_alloc);
1485 auto __res = _M_get_insert_equal_pos(__nh._M_key());
1486 if (__res.second)
1487 __ret = _M_insert_node(__res.first, __res.second, __nh._M_ptr);
1488 else
1489 __ret = _M_insert_equal_lower_node(__nh._M_ptr);
1490 __nh._M_ptr = nullptr;
1491 }
1492 return __ret;
1493 }
1494
1495 /// Re-insert an extracted node.
1496 iterator
1497 _M_reinsert_node_hint_unique(const_iterator __hint, node_type&& __nh)
1498 {
1499 iterator __ret;
1500 if (__nh.empty())
1501 __ret = end();
1502 else
1503 {
1504 __glibcxx_assert(_M_get_Node_allocator() == *__nh._M_alloc);
1505 auto __res = _M_get_insert_hint_unique_pos(__hint, __nh._M_key());
1506 if (__res.second)
1507 {
1508 __ret = _M_insert_node(__res.first, __res.second, __nh._M_ptr);
1509 __nh._M_ptr = nullptr;
1510 }
1511 else
1512 __ret = iterator(__res.first);
1513 }
1514 return __ret;
1515 }
1516
1517 /// Re-insert an extracted node.
1518 iterator
1519 _M_reinsert_node_hint_equal(const_iterator __hint, node_type&& __nh)
1520 {
1521 iterator __ret;
1522 if (__nh.empty())
1523 __ret = end();
1524 else
1525 {
1526 __glibcxx_assert(_M_get_Node_allocator() == *__nh._M_alloc);
1527 auto __res = _M_get_insert_hint_equal_pos(__hint, __nh._M_key());
1528 if (__res.second)
1529 __ret = _M_insert_node(__res.first, __res.second, __nh._M_ptr);
1530 else
1531 __ret = _M_insert_equal_lower_node(__nh._M_ptr);
1532 __nh._M_ptr = nullptr;
1533 }
1534 return __ret;
1535 }
1536
1537 /// Extract a node.
1538 node_type
1539 extract(const_iterator __pos)
1540 {
1541 auto __ptr = _Rb_tree_rebalance_for_erase(
1542 __pos._M_const_cast()._M_node, _M_impl._M_header);
1543 --_M_impl._M_node_count;
1544 return { static_cast<_Link_type>(__ptr), _M_get_Node_allocator() };
1545 }
1546
1547 /// Extract a node.
1548 node_type
1549 extract(const key_type& __k)
1550 {
1551 node_type __nh;
1552 auto __pos = find(__k);
1553 if (__pos != end())
1554 __nh = extract(const_iterator(__pos));
1555 return __nh;
1556 }
1557
1558 template<typename _Compare2>
1559 using _Compatible_tree
1560 = _Rb_tree<_Key, _Val, _KeyOfValue, _Compare2, _Alloc>;
1561
1562 template<typename, typename>
1563 friend class _Rb_tree_merge_helper;
1564
1565 /// Merge from a compatible container into one with unique keys.
1566 template<typename _Compare2>
1567 void
1568 _M_merge_unique(_Compatible_tree<_Compare2>& __src) noexcept
1569 {
1570 using _Merge_helper = _Rb_tree_merge_helper<_Rb_tree, _Compare2>;
1571 for (auto __i = __src.begin(), __end = __src.end(); __i != __end;)
1572 {
1573 auto __pos = __i++;
1574 auto __res = _M_get_insert_unique_pos(_KeyOfValue()(*__pos));
1575 if (__res.second)
1576 {
1577 auto& __src_impl = _Merge_helper::_S_get_impl(__src);
1578 auto __ptr = _Rb_tree_rebalance_for_erase(
1579 __pos._M_node, __src_impl._M_header);
1580 --__src_impl._M_node_count;
1581 _M_insert_node(__res.first, __res.second,
1582 static_cast<_Link_type>(__ptr));
1583 }
1584 }
1585 }
1586
1587 /// Merge from a compatible container into one with equivalent keys.
1588 template<typename _Compare2>
1589 void
1590 _M_merge_equal(_Compatible_tree<_Compare2>& __src) noexcept
1591 {
1592 using _Merge_helper = _Rb_tree_merge_helper<_Rb_tree, _Compare2>;
1593 for (auto __i = __src.begin(), __end = __src.end(); __i != __end;)
1594 {
1595 auto __pos = __i++;
1596 auto __res = _M_get_insert_equal_pos(_KeyOfValue()(*__pos));
1597 if (__res.second)
1598 {
1599 auto& __src_impl = _Merge_helper::_S_get_impl(__src);
1600 auto __ptr = _Rb_tree_rebalance_for_erase(
1601 __pos._M_node, __src_impl._M_header);
1602 --__src_impl._M_node_count;
1603 _M_insert_node(__res.first, __res.second,
1604 static_cast<_Link_type>(__ptr));
1605 }
1606 }
1607 }
1608#endif // C++17
1609
1610 friend bool
1611 operator==(const _Rb_tree& __x, const _Rb_tree& __y)
1612 {
1613 return __x.size() == __y.size()
1614 && std::equal(__x.begin(), __x.end(), __y.begin());
1615 }
1616
1617#if __cpp_lib_three_way_comparison
1618 friend auto
1619 operator<=>(const _Rb_tree& __x, const _Rb_tree& __y)
1620 {
1621 if constexpr (requires { typename __detail::__synth3way_t<_Val>; })
1622 return std::lexicographical_compare_three_way(__x.begin(), __x.end(),
1623 __y.begin(), __y.end(),
1624 __detail::__synth3way);
1625 }
1626#else
1627 friend bool
1628 operator<(const _Rb_tree& __x, const _Rb_tree& __y)
1629 {
1630 return std::lexicographical_compare(__x.begin(), __x.end(),
1631 __y.begin(), __y.end());
1632 }
1633
1634 friend bool _GLIBCXX_DEPRECATED__attribute__ ((__deprecated__))
1635 operator!=(const _Rb_tree& __x, const _Rb_tree& __y)
1636 { return !(__x == __y); }
1637
1638 friend bool _GLIBCXX_DEPRECATED__attribute__ ((__deprecated__))
1639 operator>(const _Rb_tree& __x, const _Rb_tree& __y)
1640 { return __y < __x; }
1641
1642 friend bool _GLIBCXX_DEPRECATED__attribute__ ((__deprecated__))
1643 operator<=(const _Rb_tree& __x, const _Rb_tree& __y)
1644 { return !(__y < __x); }
1645
1646 friend bool _GLIBCXX_DEPRECATED__attribute__ ((__deprecated__))
1647 operator>=(const _Rb_tree& __x, const _Rb_tree& __y)
1648 { return !(__x < __y); }
1649#endif
1650 };
1651
1652 template<typename _Key, typename _Val, typename _KeyOfValue,
1653 typename _Compare, typename _Alloc>
1654 inline void
1655 swap(_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& __x,
1656 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& __y)
1657 { __x.swap(__y); }
1658
1659#if __cplusplus201402L >= 201103L
1660 template<typename _Key, typename _Val, typename _KeyOfValue,
1661 typename _Compare, typename _Alloc>
1662 void
1663 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
1664 _M_move_data(_Rb_tree& __x, false_type)
1665 {
1666 if (_M_get_Node_allocator() == __x._M_get_Node_allocator())
1667 _M_move_data(__x, true_type());
1668 else
1669 {
1670 _Alloc_node __an(*this);
1671 auto __lbd =
1672 [&__an](const value_type& __cval)
1673 {
1674 auto& __val = const_cast<value_type&>(__cval);
1675 return __an(std::move_if_noexcept(__val));
1676 };
1677 _M_root() = _M_copy(__x, __lbd);
1678 }
1679 }
1680
1681 template<typename _Key, typename _Val, typename _KeyOfValue,
1682 typename _Compare, typename _Alloc>
1683 inline void
1684 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
1685 _M_move_assign(_Rb_tree& __x, true_type)
1686 {
1687 clear();
1688 if (__x._M_root() != nullptr)
1689 _M_move_data(__x, true_type());
1690 std::__alloc_on_move(_M_get_Node_allocator(),
1691 __x._M_get_Node_allocator());
1692 }
1693
1694 template<typename _Key, typename _Val, typename _KeyOfValue,
1695 typename _Compare, typename _Alloc>
1696 void
1697 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
1698 _M_move_assign(_Rb_tree& __x, false_type)
1699 {
1700 if (_M_get_Node_allocator() == __x._M_get_Node_allocator())
1701 return _M_move_assign(__x, true_type{});
1702
1703 // Try to move each node reusing existing nodes and copying __x nodes
1704 // structure.
1705 _Reuse_or_alloc_node __roan(*this);
1706 _M_impl._M_reset();
1707 if (__x._M_root() != nullptr)
1708 {
1709 auto __lbd =
1710 [&__roan](const value_type& __cval)
1711 {
1712 auto& __val = const_cast<value_type&>(__cval);
1713 return __roan(std::move(__val));
1714 };
1715 _M_root() = _M_copy(__x, __lbd);
1716 __x.clear();
1717 }
1718 }
1719
1720 template<typename _Key, typename _Val, typename _KeyOfValue,
1721 typename _Compare, typename _Alloc>
1722 inline _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>&
1723 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
1724 operator=(_Rb_tree&& __x)
1725 noexcept(_Alloc_traits::_S_nothrow_move()
1726 && is_nothrow_move_assignable<_Compare>::value)
1727 {
1728 _M_impl._M_key_compare = std::move(__x._M_impl._M_key_compare);
1729 _M_move_assign(__x, __bool_constant<_Alloc_traits::_S_nothrow_move()>());
1730 return *this;
1731 }
1732
1733 template<typename _Key, typename _Val, typename _KeyOfValue,
1734 typename _Compare, typename _Alloc>
1735 template<typename _Iterator>
1736 void
1737 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
1738 _M_assign_unique(_Iterator __first, _Iterator __last)
1739 {
1740 _Reuse_or_alloc_node __roan(*this);
1741 _M_impl._M_reset();
1742 for (; __first != __last; ++__first)
1743 _M_insert_unique_(end(), *__first, __roan);
1744 }
1745
1746 template<typename _Key, typename _Val, typename _KeyOfValue,
1747 typename _Compare, typename _Alloc>
1748 template<typename _Iterator>
1749 void
1750 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
1751 _M_assign_equal(_Iterator __first, _Iterator __last)
1752 {
1753 _Reuse_or_alloc_node __roan(*this);
1754 _M_impl._M_reset();
1755 for (; __first != __last; ++__first)
1756 _M_insert_equal_(end(), *__first, __roan);
1757 }
1758#endif
1759
1760 template<typename _Key, typename _Val, typename _KeyOfValue,
1761 typename _Compare, typename _Alloc>
1762 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>&
1763 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
1764 operator=(const _Rb_tree& __x)
1765 {
1766 if (this != &__x)
1767 {
1768 // Note that _Key may be a constant type.
1769#if __cplusplus201402L >= 201103L
1770 if (_Alloc_traits::_S_propagate_on_copy_assign())
1771 {
1772 auto& __this_alloc = this->_M_get_Node_allocator();
1773 auto& __that_alloc = __x._M_get_Node_allocator();
1774 if (!_Alloc_traits::_S_always_equal()
1775 && __this_alloc != __that_alloc)
1776 {
1777 // Replacement allocator cannot free existing storage, we need
1778 // to erase nodes first.
1779 clear();
1780 std::__alloc_on_copy(__this_alloc, __that_alloc);
1781 }
1782 }
1783#endif
1784
1785 _Reuse_or_alloc_node __roan(*this);
1786 _M_impl._M_reset();
1787 _M_impl._M_key_compare = __x._M_impl._M_key_compare;
1788 if (__x._M_root() != 0)
1789 _M_root() = _M_copy(__x, __roan);
1790 }
1791
1792 return *this;
1793 }
1794
1795 template<typename _Key, typename _Val, typename _KeyOfValue,
1796 typename _Compare, typename _Alloc>
1797#if __cplusplus201402L >= 201103L
1798 template<typename _Arg, typename _NodeGen>
1799#else
1800 template<typename _NodeGen>
1801#endif
1802 typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator
1803 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
1804 _M_insert_(_Base_ptr __x, _Base_ptr __p,
1805#if __cplusplus201402L >= 201103L
1806 _Arg&& __v,
1807#else
1808 const _Val& __v,
1809#endif
1810 _NodeGen& __node_gen)
1811 {
1812 bool __insert_left = (__x != 0 || __p == _M_end()
1813 || _M_impl._M_key_compare(_KeyOfValue()(__v),
1814 _S_key(__p)));
1815
1816 _Link_type __z = __node_gen(_GLIBCXX_FORWARD(_Arg, __v)std::forward<_Arg>(__v));
1817
1818 _Rb_tree_insert_and_rebalance(__insert_left, __z, __p,
1819 this->_M_impl._M_header);
1820 ++_M_impl._M_node_count;
1821 return iterator(__z);
1822 }
1823
1824 template<typename _Key, typename _Val, typename _KeyOfValue,
1825 typename _Compare, typename _Alloc>
1826#if __cplusplus201402L >= 201103L
1827 template<typename _Arg>
1828#endif
1829 typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator
1830 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
1831#if __cplusplus201402L >= 201103L
1832 _M_insert_lower(_Base_ptr __p, _Arg&& __v)
1833#else
1834 _M_insert_lower(_Base_ptr __p, const _Val& __v)
1835#endif
1836 {
1837 bool __insert_left = (__p == _M_end()
1838 || !_M_impl._M_key_compare(_S_key(__p),
1839 _KeyOfValue()(__v)));
1840
1841 _Link_type __z = _M_create_node(_GLIBCXX_FORWARD(_Arg, __v)std::forward<_Arg>(__v));
1842
1843 _Rb_tree_insert_and_rebalance(__insert_left, __z, __p,
1844 this->_M_impl._M_header);
1845 ++_M_impl._M_node_count;
1846 return iterator(__z);
1847 }
1848
1849 template<typename _Key, typename _Val, typename _KeyOfValue,
1850 typename _Compare, typename _Alloc>
1851#if __cplusplus201402L >= 201103L
1852 template<typename _Arg>
1853#endif
1854 typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator
1855 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
1856#if __cplusplus201402L >= 201103L
1857 _M_insert_equal_lower(_Arg&& __v)
1858#else
1859 _M_insert_equal_lower(const _Val& __v)
1860#endif
1861 {
1862 _Link_type __x = _M_begin();
1863 _Base_ptr __y = _M_end();
1864 while (__x != 0)
1865 {
1866 __y = __x;
1867 __x = !_M_impl._M_key_compare(_S_key(__x), _KeyOfValue()(__v)) ?
1868 _S_left(__x) : _S_right(__x);
1869 }
1870 return _M_insert_lower(__y, _GLIBCXX_FORWARD(_Arg, __v)std::forward<_Arg>(__v));
1871 }
1872
1873 template<typename _Key, typename _Val, typename _KoV,
1874 typename _Compare, typename _Alloc>
1875 template<typename _NodeGen>
1876 typename _Rb_tree<_Key, _Val, _KoV, _Compare, _Alloc>::_Link_type
1877 _Rb_tree<_Key, _Val, _KoV, _Compare, _Alloc>::
1878 _M_copy(_Const_Link_type __x, _Base_ptr __p, _NodeGen& __node_gen)
1879 {
1880 // Structural copy. __x and __p must be non-null.
1881 _Link_type __top = _M_clone_node(__x, __node_gen);
1882 __top->_M_parent = __p;
1883
1884 __tryif (true)
1885 {
1886 if (__x->_M_right)
1887 __top->_M_right = _M_copy(_S_right(__x), __top, __node_gen);
1888 __p = __top;
1889 __x = _S_left(__x);
1890
1891 while (__x != 0)
1892 {
1893 _Link_type __y = _M_clone_node(__x, __node_gen);
1894 __p->_M_left = __y;
1895 __y->_M_parent = __p;
1896 if (__x->_M_right)
1897 __y->_M_right = _M_copy(_S_right(__x), __y, __node_gen);
1898 __p = __y;
1899 __x = _S_left(__x);
1900 }
1901 }
1902 __catch(...)if (false)
1903 {
1904 _M_erase(__top);
1905 __throw_exception_again;
1906 }
1907 return __top;
1908 }
1909
1910 template<typename _Key, typename _Val, typename _KeyOfValue,
1911 typename _Compare, typename _Alloc>
1912 void
1913 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
1914 _M_erase(_Link_type __x)
1915 {
1916 // Erase without rebalancing.
1917 while (__x != 0)
1918 {
1919 _M_erase(_S_right(__x));
1920 _Link_type __y = _S_left(__x);
1921 _M_drop_node(__x);
1922 __x = __y;
1923 }
1924 }
1925
1926 template<typename _Key, typename _Val, typename _KeyOfValue,
1927 typename _Compare, typename _Alloc>
1928 typename _Rb_tree<_Key, _Val, _KeyOfValue,
1929 _Compare, _Alloc>::iterator
1930 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
1931 _M_lower_bound(_Link_type __x, _Base_ptr __y,
1932 const _Key& __k)
1933 {
1934 while (__x != 0)
1935 if (!_M_impl._M_key_compare(_S_key(__x), __k))
1936 __y = __x, __x = _S_left(__x);
1937 else
1938 __x = _S_right(__x);
1939 return iterator(__y);
1940 }
1941
1942 template<typename _Key, typename _Val, typename _KeyOfValue,
1943 typename _Compare, typename _Alloc>
1944 typename _Rb_tree<_Key, _Val, _KeyOfValue,
1945 _Compare, _Alloc>::const_iterator
1946 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
1947 _M_lower_bound(_Const_Link_type __x, _Const_Base_ptr __y,
1948 const _Key& __k) const
1949 {
1950 while (__x != 0)
1951 if (!_M_impl._M_key_compare(_S_key(__x), __k))
1952 __y = __x, __x = _S_left(__x);
1953 else
1954 __x = _S_right(__x);
1955 return const_iterator(__y);
1956 }
1957
1958 template<typename _Key, typename _Val, typename _KeyOfValue,
1959 typename _Compare, typename _Alloc>
1960 typename _Rb_tree<_Key, _Val, _KeyOfValue,
1961 _Compare, _Alloc>::iterator
1962 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
1963 _M_upper_bound(_Link_type __x, _Base_ptr __y,
1964 const _Key& __k)
1965 {
1966 while (__x != 0)
1967 if (_M_impl._M_key_compare(__k, _S_key(__x)))
1968 __y = __x, __x = _S_left(__x);
1969 else
1970 __x = _S_right(__x);
1971 return iterator(__y);
1972 }
1973
1974 template<typename _Key, typename _Val, typename _KeyOfValue,
1975 typename _Compare, typename _Alloc>
1976 typename _Rb_tree<_Key, _Val, _KeyOfValue,
1977 _Compare, _Alloc>::const_iterator
1978 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
1979 _M_upper_bound(_Const_Link_type __x, _Const_Base_ptr __y,
1980 const _Key& __k) const
1981 {
1982 while (__x != 0)
1983 if (_M_impl._M_key_compare(__k, _S_key(__x)))
1984 __y = __x, __x = _S_left(__x);
1985 else
1986 __x = _S_right(__x);
1987 return const_iterator(__y);
1988 }
1989
1990 template<typename _Key, typename _Val, typename _KeyOfValue,
1991 typename _Compare, typename _Alloc>
1992 pair<typename _Rb_tree<_Key, _Val, _KeyOfValue,
1993 _Compare, _Alloc>::iterator,
1994 typename _Rb_tree<_Key, _Val, _KeyOfValue,
1995 _Compare, _Alloc>::iterator>
1996 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
1997 equal_range(const _Key& __k)
1998 {
1999 _Link_type __x = _M_begin();
2000 _Base_ptr __y = _M_end();
2001 while (__x != 0)
2002 {
2003 if (_M_impl._M_key_compare(_S_key(__x), __k))
2004 __x = _S_right(__x);
2005 else if (_M_impl._M_key_compare(__k, _S_key(__x)))
2006 __y = __x, __x = _S_left(__x);
2007 else
2008 {
2009 _Link_type __xu(__x);
2010 _Base_ptr __yu(__y);
2011 __y = __x, __x = _S_left(__x);
2012 __xu = _S_right(__xu);
2013 return pair<iterator,
2014 iterator>(_M_lower_bound(__x, __y, __k),
2015 _M_upper_bound(__xu, __yu, __k));
2016 }
2017 }
2018 return pair<iterator, iterator>(iterator(__y),
2019 iterator(__y));
2020 }
2021
2022 template<typename _Key, typename _Val, typename _KeyOfValue,
2023 typename _Compare, typename _Alloc>
2024 pair<typename _Rb_tree<_Key, _Val, _KeyOfValue,
2025 _Compare, _Alloc>::const_iterator,
2026 typename _Rb_tree<_Key, _Val, _KeyOfValue,
2027 _Compare, _Alloc>::const_iterator>
2028 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
2029 equal_range(const _Key& __k) const
2030 {
2031 _Const_Link_type __x = _M_begin();
2032 _Const_Base_ptr __y = _M_end();
2033 while (__x != 0)
2034 {
2035 if (_M_impl._M_key_compare(_S_key(__x), __k))
2036 __x = _S_right(__x);
2037 else if (_M_impl._M_key_compare(__k, _S_key(__x)))
2038 __y = __x, __x = _S_left(__x);
2039 else
2040 {
2041 _Const_Link_type __xu(__x);
2042 _Const_Base_ptr __yu(__y);
2043 __y = __x, __x = _S_left(__x);
2044 __xu = _S_right(__xu);
2045 return pair<const_iterator,
2046 const_iterator>(_M_lower_bound(__x, __y, __k),
2047 _M_upper_bound(__xu, __yu, __k));
2048 }
2049 }
2050 return pair<const_iterator, const_iterator>(const_iterator(__y),
2051 const_iterator(__y));
2052 }
2053
2054 template<typename _Key, typename _Val, typename _KeyOfValue,
2055 typename _Compare, typename _Alloc>
2056 void
2057 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
2058 swap(_Rb_tree& __t)
2059 _GLIBCXX_NOEXCEPT_IF(__is_nothrow_swappable<_Compare>::value)noexcept(__is_nothrow_swappable<_Compare>::value)
2060 {
2061 if (_M_root() == 0)
2062 {
2063 if (__t._M_root() != 0)
2064 _M_impl._M_move_data(__t._M_impl);
2065 }
2066 else if (__t._M_root() == 0)
2067 __t._M_impl._M_move_data(_M_impl);
2068 else
2069 {
2070 std::swap(_M_root(),__t._M_root());
2071 std::swap(_M_leftmost(),__t._M_leftmost());
2072 std::swap(_M_rightmost(),__t._M_rightmost());
2073
2074 _M_root()->_M_parent = _M_end();
2075 __t._M_root()->_M_parent = __t._M_end();
2076 std::swap(this->_M_impl._M_node_count, __t._M_impl._M_node_count);
2077 }
2078 // No need to swap header's color as it does not change.
2079 std::swap(this->_M_impl._M_key_compare, __t._M_impl._M_key_compare);
2080
2081 _Alloc_traits::_S_on_swap(_M_get_Node_allocator(),
2082 __t._M_get_Node_allocator());
2083 }
2084
2085 template<typename _Key, typename _Val, typename _KeyOfValue,
2086 typename _Compare, typename _Alloc>
2087 pair<typename _Rb_tree<_Key, _Val, _KeyOfValue,
2088 _Compare, _Alloc>::_Base_ptr,
2089 typename _Rb_tree<_Key, _Val, _KeyOfValue,
2090 _Compare, _Alloc>::_Base_ptr>
2091 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
2092 _M_get_insert_unique_pos(const key_type& __k)
2093 {
2094 typedef pair<_Base_ptr, _Base_ptr> _Res;
2095 _Link_type __x = _M_begin();
2096 _Base_ptr __y = _M_end();
2097 bool __comp = true;
2098 while (__x != 0)
2099 {
2100 __y = __x;
2101 __comp = _M_impl._M_key_compare(__k, _S_key(__x));
2102 __x = __comp ? _S_left(__x) : _S_right(__x);
2103 }
2104 iterator __j = iterator(__y);
2105 if (__comp)
2106 {
2107 if (__j == begin())
2108 return _Res(__x, __y);
2109 else
2110 --__j;
2111 }
2112 if (_M_impl._M_key_compare(_S_key(__j._M_node), __k))
2113 return _Res(__x, __y);
2114 return _Res(__j._M_node, 0);
2115 }
2116
2117 template<typename _Key, typename _Val, typename _KeyOfValue,
2118 typename _Compare, typename _Alloc>
2119 pair<typename _Rb_tree<_Key, _Val, _KeyOfValue,
2120 _Compare, _Alloc>::_Base_ptr,
2121 typename _Rb_tree<_Key, _Val, _KeyOfValue,
2122 _Compare, _Alloc>::_Base_ptr>
2123 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
2124 _M_get_insert_equal_pos(const key_type& __k)
2125 {
2126 typedef pair<_Base_ptr, _Base_ptr> _Res;
2127 _Link_type __x = _M_begin();
2128 _Base_ptr __y = _M_end();
2129 while (__x != 0)
2130 {
2131 __y = __x;
2132 __x = _M_impl._M_key_compare(__k, _S_key(__x)) ?
2133 _S_left(__x) : _S_right(__x);
2134 }
2135 return _Res(__x, __y);
2136 }
2137
2138 template<typename _Key, typename _Val, typename _KeyOfValue,
2139 typename _Compare, typename _Alloc>
2140#if __cplusplus201402L >= 201103L
2141 template<typename _Arg>
2142#endif
2143 pair<typename _Rb_tree<_Key, _Val, _KeyOfValue,
2144 _Compare, _Alloc>::iterator, bool>
2145 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
2146#if __cplusplus201402L >= 201103L
2147 _M_insert_unique(_Arg&& __v)
2148#else
2149 _M_insert_unique(const _Val& __v)
2150#endif
2151 {
2152 typedef pair<iterator, bool> _Res;
2153 pair<_Base_ptr, _Base_ptr> __res
2154 = _M_get_insert_unique_pos(_KeyOfValue()(__v));
2155
2156 if (__res.second)
2157 {
2158 _Alloc_node __an(*this);
2159 return _Res(_M_insert_(__res.first, __res.second,
2160 _GLIBCXX_FORWARD(_Arg, __v)std::forward<_Arg>(__v), __an),
2161 true);
2162 }
2163
2164 return _Res(iterator(__res.first), false);
2165 }
2166
2167 template<typename _Key, typename _Val, typename _KeyOfValue,
2168 typename _Compare, typename _Alloc>
2169#if __cplusplus201402L >= 201103L
2170 template<typename _Arg>
2171#endif
2172 typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator
2173 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
2174#if __cplusplus201402L >= 201103L
2175 _M_insert_equal(_Arg&& __v)
2176#else
2177 _M_insert_equal(const _Val& __v)
2178#endif
2179 {
2180 pair<_Base_ptr, _Base_ptr> __res
2181 = _M_get_insert_equal_pos(_KeyOfValue()(__v));
2182 _Alloc_node __an(*this);
2183 return _M_insert_(__res.first, __res.second,
2184 _GLIBCXX_FORWARD(_Arg, __v)std::forward<_Arg>(__v), __an);
2185 }
2186
2187 template<typename _Key, typename _Val, typename _KeyOfValue,
2188 typename _Compare, typename _Alloc>
2189 pair<typename _Rb_tree<_Key, _Val, _KeyOfValue,
2190 _Compare, _Alloc>::_Base_ptr,
2191 typename _Rb_tree<_Key, _Val, _KeyOfValue,
2192 _Compare, _Alloc>::_Base_ptr>
2193 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
2194 _M_get_insert_hint_unique_pos(const_iterator __position,
2195 const key_type& __k)
2196 {
2197 iterator __pos = __position._M_const_cast();
2198 typedef pair<_Base_ptr, _Base_ptr> _Res;
2199
2200 // end()
2201 if (__pos._M_node == _M_end())
2202 {
2203 if (size() > 0
2204 && _M_impl._M_key_compare(_S_key(_M_rightmost()), __k))
2205 return _Res(0, _M_rightmost());
2206 else
2207 return _M_get_insert_unique_pos(__k);
2208 }
2209 else if (_M_impl._M_key_compare(__k, _S_key(__pos._M_node)))
2210 {
2211 // First, try before...
2212 iterator __before = __pos;
2213 if (__pos._M_node == _M_leftmost()) // begin()
2214 return _Res(_M_leftmost(), _M_leftmost());
2215 else if (_M_impl._M_key_compare(_S_key((--__before)._M_node), __k))
2216 {
2217 if (_S_right(__before._M_node) == 0)
2218 return _Res(0, __before._M_node);
2219 else
2220 return _Res(__pos._M_node, __pos._M_node);
2221 }
2222 else
2223 return _M_get_insert_unique_pos(__k);
2224 }
2225 else if (_M_impl._M_key_compare(_S_key(__pos._M_node), __k))
2226 {
2227 // ... then try after.
2228 iterator __after = __pos;
2229 if (__pos._M_node == _M_rightmost())
2230 return _Res(0, _M_rightmost());
2231 else if (_M_impl._M_key_compare(__k, _S_key((++__after)._M_node)))
2232 {
2233 if (_S_right(__pos._M_node) == 0)
2234 return _Res(0, __pos._M_node);
2235 else
2236 return _Res(__after._M_node, __after._M_node);
2237 }
2238 else
2239 return _M_get_insert_unique_pos(__k);
2240 }
2241 else
2242 // Equivalent keys.
2243 return _Res(__pos._M_node, 0);
2244 }
2245
2246 template<typename _Key, typename _Val, typename _KeyOfValue,
2247 typename _Compare, typename _Alloc>
2248#if __cplusplus201402L >= 201103L
2249 template<typename _Arg, typename _NodeGen>
2250#else
2251 template<typename _NodeGen>
2252#endif
2253 typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator
2254 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
2255 _M_insert_unique_(const_iterator __position,
2256#if __cplusplus201402L >= 201103L
2257 _Arg&& __v,
2258#else
2259 const _Val& __v,
2260#endif
2261 _NodeGen& __node_gen)
2262 {
2263 pair<_Base_ptr, _Base_ptr> __res
2264 = _M_get_insert_hint_unique_pos(__position, _KeyOfValue()(__v));
2265
2266 if (__res.second)
2267 return _M_insert_(__res.first, __res.second,
2268 _GLIBCXX_FORWARD(_Arg, __v)std::forward<_Arg>(__v),
2269 __node_gen);
2270 return iterator(__res.first);
2271 }
2272
2273 template<typename _Key, typename _Val, typename _KeyOfValue,
2274 typename _Compare, typename _Alloc>
2275 pair<typename _Rb_tree<_Key, _Val, _KeyOfValue,
2276 _Compare, _Alloc>::_Base_ptr,
2277 typename _Rb_tree<_Key, _Val, _KeyOfValue,
2278 _Compare, _Alloc>::_Base_ptr>
2279 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
2280 _M_get_insert_hint_equal_pos(const_iterator __position, const key_type& __k)
2281 {
2282 iterator __pos = __position._M_const_cast();
2283 typedef pair<_Base_ptr, _Base_ptr> _Res;
2284
2285 // end()
2286 if (__pos._M_node == _M_end())
2287 {
2288 if (size() > 0
2289 && !_M_impl._M_key_compare(__k, _S_key(_M_rightmost())))
2290 return _Res(0, _M_rightmost());
2291 else
2292 return _M_get_insert_equal_pos(__k);
2293 }
2294 else if (!_M_impl._M_key_compare(_S_key(__pos._M_node), __k))
2295 {
2296 // First, try before...
2297 iterator __before = __pos;
2298 if (__pos._M_node == _M_leftmost()) // begin()
2299 return _Res(_M_leftmost(), _M_leftmost());
2300 else if (!_M_impl._M_key_compare(__k, _S_key((--__before)._M_node)))
2301 {
2302 if (_S_right(__before._M_node) == 0)
2303 return _Res(0, __before._M_node);
2304 else
2305 return _Res(__pos._M_node, __pos._M_node);
2306 }
2307 else
2308 return _M_get_insert_equal_pos(__k);
2309 }
2310 else
2311 {
2312 // ... then try after.
2313 iterator __after = __pos;
2314 if (__pos._M_node == _M_rightmost())
2315 return _Res(0, _M_rightmost());
2316 else if (!_M_impl._M_key_compare(_S_key((++__after)._M_node), __k))
2317 {
2318 if (_S_right(__pos._M_node) == 0)
2319 return _Res(0, __pos._M_node);
2320 else
2321 return _Res(__after._M_node, __after._M_node);
2322 }
2323 else
2324 return _Res(0, 0);
2325 }
2326 }
2327
2328 template<typename _Key, typename _Val, typename _KeyOfValue,
2329 typename _Compare, typename _Alloc>
2330#if __cplusplus201402L >= 201103L
2331 template<typename _Arg, typename _NodeGen>
2332#else
2333 template<typename _NodeGen>
2334#endif
2335 typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator
2336 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
2337 _M_insert_equal_(const_iterator __position,
2338#if __cplusplus201402L >= 201103L
2339 _Arg&& __v,
2340#else
2341 const _Val& __v,
2342#endif
2343 _NodeGen& __node_gen)
2344 {
2345 pair<_Base_ptr, _Base_ptr> __res
2346 = _M_get_insert_hint_equal_pos(__position, _KeyOfValue()(__v));
2347
2348 if (__res.second)
2349 return _M_insert_(__res.first, __res.second,
2350 _GLIBCXX_FORWARD(_Arg, __v)std::forward<_Arg>(__v),
2351 __node_gen);
2352
2353 return _M_insert_equal_lower(_GLIBCXX_FORWARD(_Arg, __v)std::forward<_Arg>(__v));
2354 }
2355
2356#if __cplusplus201402L >= 201103L
2357 template<typename _Key, typename _Val, typename _KeyOfValue,
2358 typename _Compare, typename _Alloc>
2359 typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator
2360 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
2361 _M_insert_node(_Base_ptr __x, _Base_ptr __p, _Link_type __z)
2362 {
2363 bool __insert_left = (__x != 0 || __p == _M_end()
2364 || _M_impl._M_key_compare(_S_key(__z),
2365 _S_key(__p)));
2366
2367 _Rb_tree_insert_and_rebalance(__insert_left, __z, __p,
2368 this->_M_impl._M_header);
2369 ++_M_impl._M_node_count;
2370 return iterator(__z);
2371 }
2372
2373 template<typename _Key, typename _Val, typename _KeyOfValue,
2374 typename _Compare, typename _Alloc>
2375 typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator
2376 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
2377 _M_insert_lower_node(_Base_ptr __p, _Link_type __z)
2378 {
2379 bool __insert_left = (__p == _M_end()
2380 || !_M_impl._M_key_compare(_S_key(__p),
2381 _S_key(__z)));
2382
2383 _Rb_tree_insert_and_rebalance(__insert_left, __z, __p,
2384 this->_M_impl._M_header);
2385 ++_M_impl._M_node_count;
2386 return iterator(__z);
2387 }
2388
2389 template<typename _Key, typename _Val, typename _KeyOfValue,
2390 typename _Compare, typename _Alloc>
2391 typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator
2392 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
2393 _M_insert_equal_lower_node(_Link_type __z)
2394 {
2395 _Link_type __x = _M_begin();
2396 _Base_ptr __y = _M_end();
2397 while (__x != 0)
2398 {
2399 __y = __x;
2400 __x = !_M_impl._M_key_compare(_S_key(__x), _S_key(__z)) ?
2401 _S_left(__x) : _S_right(__x);
2402 }
2403 return _M_insert_lower_node(__y, __z);
2404 }
2405
2406 template<typename _Key, typename _Val, typename _KeyOfValue,
2407 typename _Compare, typename _Alloc>
2408 template<typename... _Args>
2409 pair<typename _Rb_tree<_Key, _Val, _KeyOfValue,
2410 _Compare, _Alloc>::iterator, bool>
2411 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
2412 _M_emplace_unique(_Args&&... __args)
2413 {
2414 _Link_type __z = _M_create_node(std::forward<_Args>(__args)...);
2415
2416 __tryif (true)
2417 {
2418 typedef pair<iterator, bool> _Res;
2419 auto __res = _M_get_insert_unique_pos(_S_key(__z));
2420 if (__res.second)
2421 return _Res(_M_insert_node(__res.first, __res.second, __z), true);
2422
2423 _M_drop_node(__z);
2424 return _Res(iterator(__res.first), false);
2425 }
2426 __catch(...)if (false)
2427 {
2428 _M_drop_node(__z);
2429 __throw_exception_again;
2430 }
2431 }
2432
2433 template<typename _Key, typename _Val, typename _KeyOfValue,
2434 typename _Compare, typename _Alloc>
2435 template<typename... _Args>
2436 typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator
2437 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
2438 _M_emplace_equal(_Args&&... __args)
2439 {
2440 _Link_type __z = _M_create_node(std::forward<_Args>(__args)...);
2441
2442 __tryif (true)
2443 {
2444 auto __res = _M_get_insert_equal_pos(_S_key(__z));
2445 return _M_insert_node(__res.first, __res.second, __z);
2446 }
2447 __catch(...)if (false)
2448 {
2449 _M_drop_node(__z);
2450 __throw_exception_again;
2451 }
2452 }
2453
2454 template<typename _Key, typename _Val, typename _KeyOfValue,
2455 typename _Compare, typename _Alloc>
2456 template<typename... _Args>
2457 typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator
2458 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
2459 _M_emplace_hint_unique(const_iterator __pos, _Args&&... __args)
2460 {
2461 _Link_type __z = _M_create_node(std::forward<_Args>(__args)...);
2462
2463 __tryif (true)
2464 {
2465 auto __res = _M_get_insert_hint_unique_pos(__pos, _S_key(__z));
2466
2467 if (__res.second)
2468 return _M_insert_node(__res.first, __res.second, __z);
2469
2470 _M_drop_node(__z);
2471 return iterator(__res.first);
2472 }
2473 __catch(...)if (false)
2474 {
2475 _M_drop_node(__z);
2476 __throw_exception_again;
2477 }
2478 }
2479
2480 template<typename _Key, typename _Val, typename _KeyOfValue,
2481 typename _Compare, typename _Alloc>
2482 template<typename... _Args>
2483 typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator
2484 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
2485 _M_emplace_hint_equal(const_iterator __pos, _Args&&... __args)
2486 {
2487 _Link_type __z = _M_create_node(std::forward<_Args>(__args)...);
2488
2489 __tryif (true)
2490 {
2491 auto __res = _M_get_insert_hint_equal_pos(__pos, _S_key(__z));
2492
2493 if (__res.second)
2494 return _M_insert_node(__res.first, __res.second, __z);
2495
2496 return _M_insert_equal_lower_node(__z);
2497 }
2498 __catch(...)if (false)
2499 {
2500 _M_drop_node(__z);
2501 __throw_exception_again;
2502 }
2503 }
2504#endif
2505
2506
2507 template<typename _Key, typename _Val, typename _KeyOfValue,
2508 typename _Compare, typename _Alloc>
2509 void
2510 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
2511 _M_erase_aux(const_iterator __position)
2512 {
2513 _Link_type __y =
2514 static_cast<_Link_type>(_Rb_tree_rebalance_for_erase
2515 (const_cast<_Base_ptr>(__position._M_node),
2516 this->_M_impl._M_header));
2517 _M_drop_node(__y);
2518 --_M_impl._M_node_count;
2519 }
2520
2521 template<typename _Key, typename _Val, typename _KeyOfValue,
2522 typename _Compare, typename _Alloc>
2523 void
2524 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
2525 _M_erase_aux(const_iterator __first, const_iterator __last)
2526 {
2527 if (__first == begin() && __last == end())
2528 clear();
2529 else
2530 while (__first != __last)
2531 _M_erase_aux(__first++);
2532 }
2533
2534 template<typename _Key, typename _Val, typename _KeyOfValue,
2535 typename _Compare, typename _Alloc>
2536 typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::size_type
2537 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
2538 erase(const _Key& __x)
2539 {
2540 pair<iterator, iterator> __p = equal_range(__x);
2541 const size_type __old_size = size();
2542 _M_erase_aux(__p.first, __p.second);
2543 return __old_size - size();
2544 }
2545
2546 template<typename _Key, typename _Val, typename _KeyOfValue,
2547 typename _Compare, typename _Alloc>
2548 typename _Rb_tree<_Key, _Val, _KeyOfValue,
2549 _Compare, _Alloc>::iterator
2550 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
2551 find(const _Key& __k)
2552 {
2553 iterator __j = _M_lower_bound(_M_begin(), _M_end(), __k);
2554 return (__j == end()
2555 || _M_impl._M_key_compare(__k,
2556 _S_key(__j._M_node))) ? end() : __j;
2557 }
2558
2559 template<typename _Key, typename _Val, typename _KeyOfValue,
2560 typename _Compare, typename _Alloc>
2561 typename _Rb_tree<_Key, _Val, _KeyOfValue,
2562 _Compare, _Alloc>::const_iterator
2563 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
2564 find(const _Key& __k) const
2565 {
2566 const_iterator __j = _M_lower_bound(_M_begin(), _M_end(), __k);
2567 return (__j == end()
2568 || _M_impl._M_key_compare(__k,
2569 _S_key(__j._M_node))) ? end() : __j;
2570 }
2571
2572 template<typename _Key, typename _Val, typename _KeyOfValue,
2573 typename _Compare, typename _Alloc>
2574 typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::size_type
2575 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
2576 count(const _Key& __k) const
2577 {
2578 pair<const_iterator, const_iterator> __p = equal_range(__k);
2579 const size_type __n = std::distance(__p.first, __p.second);
2580 return __n;
2581 }
2582
2583 _GLIBCXX_PURE__attribute__ ((__pure__)) unsigned int
2584 _Rb_tree_black_count(const _Rb_tree_node_base* __node,
2585 const _Rb_tree_node_base* __root) throw ();
2586
2587 template<typename _Key, typename _Val, typename _KeyOfValue,
2588 typename _Compare, typename _Alloc>
2589 bool
2590 _Rb_tree<_Key,_Val,_KeyOfValue,_Compare,_Alloc>::__rb_verify() const
2591 {
2592 if (_M_impl._M_node_count == 0 || begin() == end())
2593 return _M_impl._M_node_count == 0 && begin() == end()
2594 && this->_M_impl._M_header._M_left == _M_end()
2595 && this->_M_impl._M_header._M_right == _M_end();
2596
2597 unsigned int __len = _Rb_tree_black_count(_M_leftmost(), _M_root());
2598 for (const_iterator __it = begin(); __it != end(); ++__it)
2599 {
2600 _Const_Link_type __x = static_cast<_Const_Link_type>(__it._M_node);
2601 _Const_Link_type __L = _S_left(__x);
2602 _Const_Link_type __R = _S_right(__x);
2603
2604 if (__x->_M_color == _S_red)
2605 if ((__L && __L->_M_color == _S_red)
2606 || (__R && __R->_M_color == _S_red))
2607 return false;
2608
2609 if (__L && _M_impl._M_key_compare(_S_key(__x), _S_key(__L)))
2610 return false;
2611 if (__R && _M_impl._M_key_compare(_S_key(__R), _S_key(__x)))
2612 return false;
2613
2614 if (!__L && !__R && _Rb_tree_black_count(__x, _M_root()) != __len)
2615 return false;
2616 }
2617
2618 if (_M_leftmost() != _Rb_tree_node_base::_S_minimum(_M_root()))
2619 return false;
2620 if (_M_rightmost() != _Rb_tree_node_base::_S_maximum(_M_root()))
2621 return false;
2622 return true;
2623 }
2624
2625#if __cplusplus201402L > 201402L
2626 // Allow access to internals of compatible _Rb_tree specializations.
2627 template<typename _Key, typename _Val, typename _Sel, typename _Cmp1,
2628 typename _Alloc, typename _Cmp2>
2629 struct _Rb_tree_merge_helper<_Rb_tree<_Key, _Val, _Sel, _Cmp1, _Alloc>,
2630 _Cmp2>
2631 {
2632 private:
2633 friend class _Rb_tree<_Key, _Val, _Sel, _Cmp1, _Alloc>;
2634
2635 static auto&
2636 _S_get_impl(_Rb_tree<_Key, _Val, _Sel, _Cmp2, _Alloc>& __tree)
2637 { return __tree._M_impl; }
2638 };
2639#endif // C++17
2640
2641_GLIBCXX_END_NAMESPACE_VERSION
2642} // namespace
2643
2644#endif

/build/llvm-toolchain-snapshot-14~++20220119111520+da61cb019eb2/clang/include/clang/AST/ASTTypeTraits.h

1//===--- ASTTypeTraits.h ----------------------------------------*- 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// Provides a dynamic type identifier and a dynamically typed node container
10// that can be used to store an AST base node at runtime in the same storage in
11// a type safe way.
12//
13//===----------------------------------------------------------------------===//
14
15#ifndef LLVM_CLANG_AST_ASTTYPETRAITS_H
16#define LLVM_CLANG_AST_ASTTYPETRAITS_H
17
18#include "clang/AST/ASTFwd.h"
19#include "clang/AST/DeclCXX.h"
20#include "clang/AST/LambdaCapture.h"
21#include "clang/AST/NestedNameSpecifier.h"
22#include "clang/AST/TemplateBase.h"
23#include "clang/AST/TypeLoc.h"
24#include "clang/Basic/LLVM.h"
25#include "llvm/ADT/DenseMapInfo.h"
26#include "llvm/Support/AlignOf.h"
27
28namespace llvm {
29class raw_ostream;
30} // namespace llvm
31
32namespace clang {
33
34struct PrintingPolicy;
35
36/// Defines how we descend a level in the AST when we pass
37/// through expressions.
38enum TraversalKind {
39 /// Will traverse all child nodes.
40 TK_AsIs,
41
42 /// Ignore AST nodes not written in the source
43 TK_IgnoreUnlessSpelledInSource
44};
45
46/// Kind identifier.
47///
48/// It can be constructed from any node kind and allows for runtime type
49/// hierarchy checks.
50/// Use getFromNodeKind<T>() to construct them.
51class ASTNodeKind {
52public:
53 /// Empty identifier. It matches nothing.
54 ASTNodeKind() : KindId(NKI_None) {}
55
56 /// Construct an identifier for T.
57 template <class T>
58 static ASTNodeKind getFromNodeKind() {
59 return ASTNodeKind(KindToKindId<T>::Id);
60 }
61
62 /// \{
63 /// Construct an identifier for the dynamic type of the node
64 static ASTNodeKind getFromNode(const Decl &D);
65 static ASTNodeKind getFromNode(const Stmt &S);
66 static ASTNodeKind getFromNode(const Type &T);
67 static ASTNodeKind getFromNode(const TypeLoc &T);
68 static ASTNodeKind getFromNode(const LambdaCapture &L);
69 static ASTNodeKind getFromNode(const OMPClause &C);
70 static ASTNodeKind getFromNode(const Attr &A);
71 /// \}
72
73 /// Returns \c true if \c this and \c Other represent the same kind.
74 bool isSame(ASTNodeKind Other) const {
75 return KindId != NKI_None && KindId == Other.KindId;
76 }
77
78 /// Returns \c true only for the default \c ASTNodeKind()
79 bool isNone() const { return KindId == NKI_None; }
80
81 /// Returns \c true if \c this is a base kind of (or same as) \c Other.
82 /// \param Distance If non-null, used to return the distance between \c this
83 /// and \c Other in the class hierarchy.
84 bool isBaseOf(ASTNodeKind Other, unsigned *Distance = nullptr) const;
85
86 /// String representation of the kind.
87 StringRef asStringRef() const;
88
89 /// Strict weak ordering for ASTNodeKind.
90 bool operator<(const ASTNodeKind &Other) const {
91 return KindId < Other.KindId;
92 }
93
94 /// Return the most derived type between \p Kind1 and \p Kind2.
95 ///
96 /// Return ASTNodeKind() if they are not related.
97 static ASTNodeKind getMostDerivedType(ASTNodeKind Kind1, ASTNodeKind Kind2);
98
99 /// Return the most derived common ancestor between Kind1 and Kind2.
100 ///
101 /// Return ASTNodeKind() if they are not related.
102 static ASTNodeKind getMostDerivedCommonAncestor(ASTNodeKind Kind1,
103 ASTNodeKind Kind2);
104
105 ASTNodeKind getCladeKind() const;
106
107 /// Hooks for using ASTNodeKind as a key in a DenseMap.
108 struct DenseMapInfo {
109 // ASTNodeKind() is a good empty key because it is represented as a 0.
110 static inline ASTNodeKind getEmptyKey() { return ASTNodeKind(); }
111 // NKI_NumberOfKinds is not a valid value, so it is good for a
112 // tombstone key.
113 static inline ASTNodeKind getTombstoneKey() {
114 return ASTNodeKind(NKI_NumberOfKinds);
115 }
116 static unsigned getHashValue(const ASTNodeKind &Val) { return Val.KindId; }
117 static bool isEqual(const ASTNodeKind &LHS, const ASTNodeKind &RHS) {
118 return LHS.KindId == RHS.KindId;
119 }
120 };
121
122 /// Check if the given ASTNodeKind identifies a type that offers pointer
123 /// identity. This is useful for the fast path in DynTypedNode.
124 bool hasPointerIdentity() const {
125 return KindId > NKI_LastKindWithoutPointerIdentity;
126 }
127
128private:
129 /// Kind ids.
130 ///
131 /// Includes all possible base and derived kinds.
132 enum NodeKindId {
133 NKI_None,
134 NKI_TemplateArgument,
135 NKI_TemplateArgumentLoc,
136 NKI_LambdaCapture,
137 NKI_TemplateName,
138 NKI_NestedNameSpecifierLoc,
139 NKI_QualType,
140#define TYPELOC(CLASS, PARENT) NKI_##CLASS##TypeLoc,
141#include "clang/AST/TypeLocNodes.def"
142 NKI_TypeLoc,
143 NKI_LastKindWithoutPointerIdentity = NKI_TypeLoc,
144 NKI_CXXBaseSpecifier,
145 NKI_CXXCtorInitializer,
146 NKI_NestedNameSpecifier,
147 NKI_Decl,
148#define DECL(DERIVED, BASE) NKI_##DERIVED##Decl,
149#include "clang/AST/DeclNodes.inc"
150 NKI_Stmt,
151#define STMT(DERIVED, BASE) NKI_##DERIVED,
152#include "clang/AST/StmtNodes.inc"
153 NKI_Type,
154#define TYPE(DERIVED, BASE) NKI_##DERIVED##Type,
155#include "clang/AST/TypeNodes.inc"
156 NKI_OMPClause,
157#define GEN_CLANG_CLAUSE_CLASS
158#define CLAUSE_CLASS(Enum, Str, Class) NKI_##Class,
159#include "llvm/Frontend/OpenMP/OMP.inc"
160 NKI_Attr,
161#define ATTR(A) NKI_##A##Attr,
162#include "clang/Basic/AttrList.inc"
163 NKI_NumberOfKinds
164 };
165
166 /// Use getFromNodeKind<T>() to construct the kind.
167 ASTNodeKind(NodeKindId KindId) : KindId(KindId) {}
168
169 /// Returns \c true if \c Base is a base kind of (or same as) \c
170 /// Derived.
171 /// \param Distance If non-null, used to return the distance between \c Base
172 /// and \c Derived in the class hierarchy.
173 static bool isBaseOf(NodeKindId Base, NodeKindId Derived, unsigned *Distance);
174
175 /// Helper meta-function to convert a kind T to its enum value.
176 ///
177 /// This struct is specialized below for all known kinds.
178 template <class T> struct KindToKindId {
179 static const NodeKindId Id = NKI_None;
180 };
181 template <class T>
182 struct KindToKindId<const T> : KindToKindId<T> {};
183
184 /// Per kind info.
185 struct KindInfo {
186 /// The id of the parent kind, or None if it has no parent.
187 NodeKindId ParentId;
188 /// Name of the kind.
189 const char *Name;
190 };
191 static const KindInfo AllKindInfo[NKI_NumberOfKinds];
192
193 NodeKindId KindId;
194};
195
196#define KIND_TO_KIND_ID(Class) \
197 template <> struct ASTNodeKind::KindToKindId<Class> { \
198 static const NodeKindId Id = NKI_##Class; \
199 };
200KIND_TO_KIND_ID(CXXCtorInitializer)
201KIND_TO_KIND_ID(TemplateArgument)
202KIND_TO_KIND_ID(TemplateArgumentLoc)
203KIND_TO_KIND_ID(LambdaCapture)
204KIND_TO_KIND_ID(TemplateName)
205KIND_TO_KIND_ID(NestedNameSpecifier)
206KIND_TO_KIND_ID(NestedNameSpecifierLoc)
207KIND_TO_KIND_ID(QualType)
208#define TYPELOC(CLASS, PARENT) KIND_TO_KIND_ID(CLASS##TypeLoc)
209#include "clang/AST/TypeLocNodes.def"
210KIND_TO_KIND_ID(TypeLoc)
211KIND_TO_KIND_ID(Decl)
212KIND_TO_KIND_ID(Stmt)
213KIND_TO_KIND_ID(Type)
214KIND_TO_KIND_ID(OMPClause)
215KIND_TO_KIND_ID(Attr)
216KIND_TO_KIND_ID(CXXBaseSpecifier)
217#define DECL(DERIVED, BASE) KIND_TO_KIND_ID(DERIVED##Decl)
218#include "clang/AST/DeclNodes.inc"
219#define STMT(DERIVED, BASE) KIND_TO_KIND_ID(DERIVED)
220#include "clang/AST/StmtNodes.inc"
221#define TYPE(DERIVED, BASE) KIND_TO_KIND_ID(DERIVED##Type)
222#include "clang/AST/TypeNodes.inc"
223#define GEN_CLANG_CLAUSE_CLASS
224#define CLAUSE_CLASS(Enum, Str, Class) KIND_TO_KIND_ID(Class)
225#include "llvm/Frontend/OpenMP/OMP.inc"
226#define ATTR(A) KIND_TO_KIND_ID(A##Attr)
227#include "clang/Basic/AttrList.inc"
228#undef KIND_TO_KIND_ID
229
230inline raw_ostream &operator<<(raw_ostream &OS, ASTNodeKind K) {
231 OS << K.asStringRef();
232 return OS;
233}
234
235/// A dynamically typed AST node container.
236///
237/// Stores an AST node in a type safe way. This allows writing code that
238/// works with different kinds of AST nodes, despite the fact that they don't
239/// have a common base class.
240///
241/// Use \c create(Node) to create a \c DynTypedNode from an AST node,
242/// and \c get<T>() to retrieve the node as type T if the types match.
243///
244/// See \c ASTNodeKind for which node base types are currently supported;
245/// You can create DynTypedNodes for all nodes in the inheritance hierarchy of
246/// the supported base types.
247class DynTypedNode {
248public:
249 /// Creates a \c DynTypedNode from \c Node.
250 template <typename T>
251 static DynTypedNode create(const T &Node) {
252 return BaseConverter<T>::create(Node);
253 }
254
255 /// Retrieve the stored node as type \c T.
256 ///
257 /// Returns NULL if the stored node does not have a type that is
258 /// convertible to \c T.
259 ///
260 /// For types that have identity via their pointer in the AST
261 /// (like \c Stmt, \c Decl, \c Type and \c NestedNameSpecifier) the returned
262 /// pointer points to the referenced AST node.
263 /// For other types (like \c QualType) the value is stored directly
264 /// in the \c DynTypedNode, and the returned pointer points at
265 /// the storage inside DynTypedNode. For those nodes, do not
266 /// use the pointer outside the scope of the DynTypedNode.
267 template <typename T> const T *get() const {
268 return BaseConverter<T>::get(NodeKind, &Storage);
43
Calling 'DynCastPtrConverter::get'
47
Returning from 'DynCastPtrConverter::get'
48
Returning pointer, which participates in a condition later
269 }
270
271 /// Retrieve the stored node as type \c T.
272 ///
273 /// Similar to \c get(), but asserts that the type is what we are expecting.
274 template <typename T>
275 const T &getUnchecked() const {
276 return BaseConverter<T>::getUnchecked(NodeKind, &Storage);
277 }
278
279 ASTNodeKind getNodeKind() const { return NodeKind; }
280
281 /// Returns a pointer that identifies the stored AST node.
282 ///
283 /// Note that this is not supported by all AST nodes. For AST nodes
284 /// that don't have a pointer-defined identity inside the AST, this
285 /// method returns NULL.
286 const void *getMemoizationData() const {
287 return NodeKind.hasPointerIdentity()
288 ? *reinterpret_cast<void *const *>(&Storage)
289 : nullptr;
290 }
291
292 /// Prints the node to the given output stream.
293 void print(llvm::raw_ostream &OS, const PrintingPolicy &PP) const;
294
295 /// Dumps the node to the given output stream.
296 void dump(llvm::raw_ostream &OS, const ASTContext &Context) const;
297
298 /// For nodes which represent textual entities in the source code,
299 /// return their SourceRange. For all other nodes, return SourceRange().
300 SourceRange getSourceRange() const;
301
302 /// @{
303 /// Imposes an order on \c DynTypedNode.
304 ///
305 /// Supports comparison of nodes that support memoization.
306 /// FIXME: Implement comparison for other node types (currently
307 /// only Stmt, Decl, Type and NestedNameSpecifier return memoization data).
308 bool operator<(const DynTypedNode &Other) const {
309 if (!NodeKind.isSame(Other.NodeKind))
310 return NodeKind < Other.NodeKind;
311
312 if (ASTNodeKind::getFromNodeKind<QualType>().isSame(NodeKind))
313 return getUnchecked<QualType>().getAsOpaquePtr() <
314 Other.getUnchecked<QualType>().getAsOpaquePtr();
315
316 if (ASTNodeKind::getFromNodeKind<TypeLoc>().isBaseOf(NodeKind)) {
317 auto TLA = getUnchecked<TypeLoc>();
318 auto TLB = Other.getUnchecked<TypeLoc>();
319 return std::make_pair(TLA.getType().getAsOpaquePtr(),
320 TLA.getOpaqueData()) <
321 std::make_pair(TLB.getType().getAsOpaquePtr(),
322 TLB.getOpaqueData());
323 }
324
325 if (ASTNodeKind::getFromNodeKind<NestedNameSpecifierLoc>().isSame(
326 NodeKind)) {
327 auto NNSLA = getUnchecked<NestedNameSpecifierLoc>();
328 auto NNSLB = Other.getUnchecked<NestedNameSpecifierLoc>();
329 return std::make_pair(NNSLA.getNestedNameSpecifier(),
330 NNSLA.getOpaqueData()) <
331 std::make_pair(NNSLB.getNestedNameSpecifier(),
332 NNSLB.getOpaqueData());
333 }
334
335 assert(getMemoizationData() && Other.getMemoizationData())(static_cast <bool> (getMemoizationData() && Other
.getMemoizationData()) ? void (0) : __assert_fail ("getMemoizationData() && Other.getMemoizationData()"
, "clang/include/clang/AST/ASTTypeTraits.h", 335, __extension__
__PRETTY_FUNCTION__))
;
336 return getMemoizationData() < Other.getMemoizationData();
337 }
338 bool operator==(const DynTypedNode &Other) const {
339 // DynTypedNode::create() stores the exact kind of the node in NodeKind.
340 // If they contain the same node, their NodeKind must be the same.
341 if (!NodeKind.isSame(Other.NodeKind))
342 return false;
343
344 // FIXME: Implement for other types.
345 if (ASTNodeKind::getFromNodeKind<QualType>().isSame(NodeKind))
346 return getUnchecked<QualType>() == Other.getUnchecked<QualType>();
347
348 if (ASTNodeKind::getFromNodeKind<TypeLoc>().isBaseOf(NodeKind))
349 return getUnchecked<TypeLoc>() == Other.getUnchecked<TypeLoc>();
350
351 if (ASTNodeKind::getFromNodeKind<NestedNameSpecifierLoc>().isSame(NodeKind))
352 return getUnchecked<NestedNameSpecifierLoc>() ==
353 Other.getUnchecked<NestedNameSpecifierLoc>();
354
355 assert(getMemoizationData() && Other.getMemoizationData())(static_cast <bool> (getMemoizationData() && Other
.getMemoizationData()) ? void (0) : __assert_fail ("getMemoizationData() && Other.getMemoizationData()"
, "clang/include/clang/AST/ASTTypeTraits.h", 355, __extension__
__PRETTY_FUNCTION__))
;
356 return getMemoizationData() == Other.getMemoizationData();
357 }
358 bool operator!=(const DynTypedNode &Other) const {
359 return !operator==(Other);
360 }
361 /// @}
362
363 /// Hooks for using DynTypedNode as a key in a DenseMap.
364 struct DenseMapInfo {
365 static inline DynTypedNode getEmptyKey() {
366 DynTypedNode Node;
367 Node.NodeKind = ASTNodeKind::DenseMapInfo::getEmptyKey();
368 return Node;
369 }
370 static inline DynTypedNode getTombstoneKey() {
371 DynTypedNode Node;
372 Node.NodeKind = ASTNodeKind::DenseMapInfo::getTombstoneKey();
373 return Node;
374 }
375 static unsigned getHashValue(const DynTypedNode &Val) {
376 // FIXME: Add hashing support for the remaining types.
377 if (ASTNodeKind::getFromNodeKind<TypeLoc>().isBaseOf(Val.NodeKind)) {
378 auto TL = Val.getUnchecked<TypeLoc>();
379 return llvm::hash_combine(TL.getType().getAsOpaquePtr(),
380 TL.getOpaqueData());
381 }
382
383 if (ASTNodeKind::getFromNodeKind<NestedNameSpecifierLoc>().isSame(
384 Val.NodeKind)) {
385 auto NNSL = Val.getUnchecked<NestedNameSpecifierLoc>();
386 return llvm::hash_combine(NNSL.getNestedNameSpecifier(),
387 NNSL.getOpaqueData());
388 }
389
390 assert(Val.getMemoizationData())(static_cast <bool> (Val.getMemoizationData()) ? void (
0) : __assert_fail ("Val.getMemoizationData()", "clang/include/clang/AST/ASTTypeTraits.h"
, 390, __extension__ __PRETTY_FUNCTION__))
;
391 return llvm::hash_value(Val.getMemoizationData());
392 }
393 static bool isEqual(const DynTypedNode &LHS, const DynTypedNode &RHS) {
394 auto Empty = ASTNodeKind::DenseMapInfo::getEmptyKey();
395 auto TombStone = ASTNodeKind::DenseMapInfo::getTombstoneKey();
396 return (ASTNodeKind::DenseMapInfo::isEqual(LHS.NodeKind, Empty) &&
397 ASTNodeKind::DenseMapInfo::isEqual(RHS.NodeKind, Empty)) ||
398 (ASTNodeKind::DenseMapInfo::isEqual(LHS.NodeKind, TombStone) &&
399 ASTNodeKind::DenseMapInfo::isEqual(RHS.NodeKind, TombStone)) ||
400 LHS == RHS;
401 }
402 };
403
404private:
405 /// Takes care of converting from and to \c T.
406 template <typename T, typename EnablerT = void> struct BaseConverter;
407
408 /// Converter that uses dyn_cast<T> from a stored BaseT*.
409 template <typename T, typename BaseT> struct DynCastPtrConverter {
410 static const T *get(ASTNodeKind NodeKind, const void *Storage) {
411 if (ASTNodeKind::getFromNodeKind<T>().isBaseOf(NodeKind))
44
Assuming the condition is true
45
Taking true branch
412 return &getUnchecked(NodeKind, Storage);
46
Returning pointer, which participates in a condition later
413 return nullptr;
414 }
415 static const T &getUnchecked(ASTNodeKind NodeKind, const void *Storage) {
416 assert(ASTNodeKind::getFromNodeKind<T>().isBaseOf(NodeKind))(static_cast <bool> (ASTNodeKind::getFromNodeKind<T>
().isBaseOf(NodeKind)) ? void (0) : __assert_fail ("ASTNodeKind::getFromNodeKind<T>().isBaseOf(NodeKind)"
, "clang/include/clang/AST/ASTTypeTraits.h", 416, __extension__
__PRETTY_FUNCTION__))
;
417 return *cast<T>(static_cast<const BaseT *>(
418 *reinterpret_cast<const void *const *>(Storage)));
419 }
420 static DynTypedNode create(const BaseT &Node) {
421 DynTypedNode Result;
422 Result.NodeKind = ASTNodeKind::getFromNode(Node);
423 new (&Result.Storage) const void *(&Node);
424 return Result;
425 }
426 };
427
428 /// Converter that stores T* (by pointer).
429 template <typename T> struct PtrConverter {
430 static const T *get(ASTNodeKind NodeKind, const void *Storage) {
431 if (ASTNodeKind::getFromNodeKind<T>().isSame(NodeKind))
432 return &getUnchecked(NodeKind, Storage);
433 return nullptr;
434 }
435 static const T &getUnchecked(ASTNodeKind NodeKind, const void *Storage) {
436 assert(ASTNodeKind::getFromNodeKind<T>().isSame(NodeKind))(static_cast <bool> (ASTNodeKind::getFromNodeKind<T>
().isSame(NodeKind)) ? void (0) : __assert_fail ("ASTNodeKind::getFromNodeKind<T>().isSame(NodeKind)"
, "clang/include/clang/AST/ASTTypeTraits.h", 436, __extension__
__PRETTY_FUNCTION__))
;
437 return *static_cast<const T *>(
438 *reinterpret_cast<const void *const *>(Storage));
439 }
440 static DynTypedNode create(const T &Node) {
441 DynTypedNode Result;
442 Result.NodeKind = ASTNodeKind::getFromNodeKind<T>();
443 new (&Result.Storage) const void *(&Node);
444 return Result;
445 }
446 };
447
448 /// Converter that stores T (by value).
449 template <typename T> struct ValueConverter {
450 static const T *get(ASTNodeKind NodeKind, const void *Storage) {
451 if (ASTNodeKind::getFromNodeKind<T>().isSame(NodeKind))
452 return reinterpret_cast<const T *>(Storage);
453 return nullptr;
454 }
455 static const T &getUnchecked(ASTNodeKind NodeKind, const void *Storage) {
456 assert(ASTNodeKind::getFromNodeKind<T>().isSame(NodeKind))(static_cast <bool> (ASTNodeKind::getFromNodeKind<T>
().isSame(NodeKind)) ? void (0) : __assert_fail ("ASTNodeKind::getFromNodeKind<T>().isSame(NodeKind)"
, "clang/include/clang/AST/ASTTypeTraits.h", 456, __extension__
__PRETTY_FUNCTION__))
;
457 return *reinterpret_cast<const T *>(Storage);
458 }
459 static DynTypedNode create(const T &Node) {
460 DynTypedNode Result;
461 Result.NodeKind = ASTNodeKind::getFromNodeKind<T>();
462 new (&Result.Storage) T(Node);
463 return Result;
464 }
465 };
466
467 /// Converter that stores nodes by value. It must be possible to dynamically
468 /// cast the stored node within a type hierarchy without breaking (especially
469 /// through slicing).
470 template <typename T, typename BaseT,
471 typename = std::enable_if_t<(sizeof(T) == sizeof(BaseT))>>
472 struct DynCastValueConverter {
473 static const T *get(ASTNodeKind NodeKind, const void *Storage) {
474 if (ASTNodeKind::getFromNodeKind<T>().isBaseOf(NodeKind))
475 return &getUnchecked(NodeKind, Storage);
476 return nullptr;
477 }
478 static const T &getUnchecked(ASTNodeKind NodeKind, const void *Storage) {
479 assert(ASTNodeKind::getFromNodeKind<T>().isBaseOf(NodeKind))(static_cast <bool> (ASTNodeKind::getFromNodeKind<T>
().isBaseOf(NodeKind)) ? void (0) : __assert_fail ("ASTNodeKind::getFromNodeKind<T>().isBaseOf(NodeKind)"
, "clang/include/clang/AST/ASTTypeTraits.h", 479, __extension__
__PRETTY_FUNCTION__))
;
480 return *static_cast<const T *>(reinterpret_cast<const BaseT *>(Storage));
481 }
482 static DynTypedNode create(const T &Node) {
483 DynTypedNode Result;
484 Result.NodeKind = ASTNodeKind::getFromNode(Node);
485 new (&Result.Storage) T(Node);
486 return Result;
487 }
488 };
489
490 ASTNodeKind NodeKind;
491
492 /// Stores the data of the node.
493 ///
494 /// Note that we can store \c Decls, \c Stmts, \c Types,
495 /// \c NestedNameSpecifiers and \c CXXCtorInitializer by pointer as they are
496 /// guaranteed to be unique pointers pointing to dedicated storage in the AST.
497 /// \c QualTypes, \c NestedNameSpecifierLocs, \c TypeLocs,
498 /// \c TemplateArguments and \c TemplateArgumentLocs on the other hand do not
499 /// have storage or unique pointers and thus need to be stored by value.
500 llvm::AlignedCharArrayUnion<const void *, TemplateArgument,
501 TemplateArgumentLoc, NestedNameSpecifierLoc,
502 QualType, TypeLoc>
503 Storage;
504};
505
506template <typename T>
507struct DynTypedNode::BaseConverter<
508 T, std::enable_if_t<std::is_base_of<Decl, T>::value>>
509 : public DynCastPtrConverter<T, Decl> {};
510
511template <typename T>
512struct DynTypedNode::BaseConverter<
513 T, std::enable_if_t<std::is_base_of<Stmt, T>::value>>
514 : public DynCastPtrConverter<T, Stmt> {};
515
516template <typename T>
517struct DynTypedNode::BaseConverter<
518 T, std::enable_if_t<std::is_base_of<Type, T>::value>>
519 : public DynCastPtrConverter<T, Type> {};
520
521template <typename T>
522struct DynTypedNode::BaseConverter<
523 T, std::enable_if_t<std::is_base_of<OMPClause, T>::value>>
524 : public DynCastPtrConverter<T, OMPClause> {};
525
526template <typename T>
527struct DynTypedNode::BaseConverter<
528 T, std::enable_if_t<std::is_base_of<Attr, T>::value>>
529 : public DynCastPtrConverter<T, Attr> {};
530
531template <>
532struct DynTypedNode::BaseConverter<
533 NestedNameSpecifier, void> : public PtrConverter<NestedNameSpecifier> {};
534
535template <>
536struct DynTypedNode::BaseConverter<
537 CXXCtorInitializer, void> : public PtrConverter<CXXCtorInitializer> {};
538
539template <>
540struct DynTypedNode::BaseConverter<
541 TemplateArgument, void> : public ValueConverter<TemplateArgument> {};
542
543template <>
544struct DynTypedNode::BaseConverter<TemplateArgumentLoc, void>
545 : public ValueConverter<TemplateArgumentLoc> {};
546
547template <>
548struct DynTypedNode::BaseConverter<LambdaCapture, void>
549 : public ValueConverter<LambdaCapture> {};
550
551template <>
552struct DynTypedNode::BaseConverter<
553 TemplateName, void> : public ValueConverter<TemplateName> {};
554
555template <>
556struct DynTypedNode::BaseConverter<
557 NestedNameSpecifierLoc,
558 void> : public ValueConverter<NestedNameSpecifierLoc> {};
559
560template <>
561struct DynTypedNode::BaseConverter<QualType,
562 void> : public ValueConverter<QualType> {};
563
564template <typename T>
565struct DynTypedNode::BaseConverter<
566 T, std::enable_if_t<std::is_base_of<TypeLoc, T>::value>>
567 : public DynCastValueConverter<T, TypeLoc> {};
568
569template <>
570struct DynTypedNode::BaseConverter<CXXBaseSpecifier, void>
571 : public PtrConverter<CXXBaseSpecifier> {};
572
573// The only operation we allow on unsupported types is \c get.
574// This allows to conveniently use \c DynTypedNode when having an arbitrary
575// AST node that is not supported, but prevents misuse - a user cannot create
576// a DynTypedNode from arbitrary types.
577template <typename T, typename EnablerT> struct DynTypedNode::BaseConverter {
578 static const T *get(ASTNodeKind NodeKind, const char Storage[]) {
579 return NULL__null;
580 }
581};
582
583} // end namespace clang
584
585namespace llvm {
586
587template <>
588struct DenseMapInfo<clang::ASTNodeKind> : clang::ASTNodeKind::DenseMapInfo {};
589
590template <>
591struct DenseMapInfo<clang::DynTypedNode> : clang::DynTypedNode::DenseMapInfo {};
592
593} // end namespace llvm
594
595#endif