Coverage Report

Created: 2019-07-24 05:18

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/tools/clang/lib/ASTMatchers/ASTMatchersInternal.cpp
Line
Count
Source (jump to first uncovered line)
1
//===- ASTMatchersInternal.cpp - Structural query framework ---------------===//
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
//===----------------------------------------------------------------------===//
12
13
#include "clang/ASTMatchers/ASTMatchersInternal.h"
14
#include "clang/AST/ASTContext.h"
15
#include "clang/AST/ASTTypeTraits.h"
16
#include "clang/AST/Decl.h"
17
#include "clang/AST/DeclTemplate.h"
18
#include "clang/AST/PrettyPrinter.h"
19
#include "clang/ASTMatchers/ASTMatchers.h"
20
#include "clang/Basic/LLVM.h"
21
#include "llvm/ADT/ArrayRef.h"
22
#include "llvm/ADT/IntrusiveRefCntPtr.h"
23
#include "llvm/ADT/None.h"
24
#include "llvm/ADT/SmallString.h"
25
#include "llvm/ADT/SmallVector.h"
26
#include "llvm/ADT/StringRef.h"
27
#include "llvm/Support/Casting.h"
28
#include "llvm/Support/ErrorHandling.h"
29
#include "llvm/Support/ManagedStatic.h"
30
#include "llvm/Support/raw_ostream.h"
31
#include <algorithm>
32
#include <cassert>
33
#include <cstddef>
34
#include <string>
35
#include <utility>
36
#include <vector>
37
38
namespace clang {
39
namespace ast_matchers {
40
41
AST_MATCHER_P(ObjCMessageExpr, hasAnySelectorMatcher, std::vector<std::string>,
42
50
              Matches) {
43
50
  std::string SelString = Node.getSelector().getAsString();
44
50
  for (const std::string &S : Matches)
45
793
    if (S == SelString)
46
20
      return true;
47
50
  
return false30
;
48
50
}
49
50
namespace internal {
51
52
bool NotUnaryOperator(const ast_type_traits::DynTypedNode &DynNode,
53
                      ASTMatchFinder *Finder, BoundNodesTreeBuilder *Builder,
54
                      ArrayRef<DynTypedMatcher> InnerMatchers);
55
56
bool AllOfVariadicOperator(const ast_type_traits::DynTypedNode &DynNode,
57
                           ASTMatchFinder *Finder,
58
                           BoundNodesTreeBuilder *Builder,
59
                           ArrayRef<DynTypedMatcher> InnerMatchers);
60
61
bool EachOfVariadicOperator(const ast_type_traits::DynTypedNode &DynNode,
62
                            ASTMatchFinder *Finder,
63
                            BoundNodesTreeBuilder *Builder,
64
                            ArrayRef<DynTypedMatcher> InnerMatchers);
65
66
bool AnyOfVariadicOperator(const ast_type_traits::DynTypedNode &DynNode,
67
                           ASTMatchFinder *Finder,
68
                           BoundNodesTreeBuilder *Builder,
69
                           ArrayRef<DynTypedMatcher> InnerMatchers);
70
71
9.84k
void BoundNodesTreeBuilder::visitMatches(Visitor *ResultVisitor) {
72
9.84k
  if (Bindings.empty())
73
2.64k
    Bindings.push_back(BoundNodesMap());
74
10.0k
  for (BoundNodesMap &Binding : Bindings) {
75
10.0k
    ResultVisitor->visitMatch(BoundNodes(Binding));
76
10.0k
  }
77
9.84k
}
78
79
namespace {
80
81
using VariadicOperatorFunction = bool (*)(
82
    const ast_type_traits::DynTypedNode &DynNode, ASTMatchFinder *Finder,
83
    BoundNodesTreeBuilder *Builder, ArrayRef<DynTypedMatcher> InnerMatchers);
84
85
template <VariadicOperatorFunction Func>
86
class VariadicMatcher : public DynMatcherInterface {
87
public:
88
  VariadicMatcher(std::vector<DynTypedMatcher> InnerMatchers)
89
120k
      : InnerMatchers(std::move(InnerMatchers)) {}
ASTMatchersInternal.cpp:clang::ast_matchers::internal::(anonymous namespace)::VariadicMatcher<&(clang::ast_matchers::internal::AllOfVariadicOperator(clang::ast_type_traits::DynTypedNode const&, clang::ast_matchers::internal::ASTMatchFinder*, clang::ast_matchers::internal::BoundNodesTreeBuilder*, llvm::ArrayRef<clang::ast_matchers::internal::DynTypedMatcher>))>::VariadicMatcher(std::__1::vector<clang::ast_matchers::internal::DynTypedMatcher, std::__1::allocator<clang::ast_matchers::internal::DynTypedMatcher> >)
Line
Count
Source
89
49.1k
      : InnerMatchers(std::move(InnerMatchers)) {}
ASTMatchersInternal.cpp:clang::ast_matchers::internal::(anonymous namespace)::VariadicMatcher<&(clang::ast_matchers::internal::AnyOfVariadicOperator(clang::ast_type_traits::DynTypedNode const&, clang::ast_matchers::internal::ASTMatchFinder*, clang::ast_matchers::internal::BoundNodesTreeBuilder*, llvm::ArrayRef<clang::ast_matchers::internal::DynTypedMatcher>))>::VariadicMatcher(std::__1::vector<clang::ast_matchers::internal::DynTypedMatcher, std::__1::allocator<clang::ast_matchers::internal::DynTypedMatcher> >)
Line
Count
Source
89
44.9k
      : InnerMatchers(std::move(InnerMatchers)) {}
ASTMatchersInternal.cpp:clang::ast_matchers::internal::(anonymous namespace)::VariadicMatcher<&(clang::ast_matchers::internal::EachOfVariadicOperator(clang::ast_type_traits::DynTypedNode const&, clang::ast_matchers::internal::ASTMatchFinder*, clang::ast_matchers::internal::BoundNodesTreeBuilder*, llvm::ArrayRef<clang::ast_matchers::internal::DynTypedMatcher>))>::VariadicMatcher(std::__1::vector<clang::ast_matchers::internal::DynTypedMatcher, std::__1::allocator<clang::ast_matchers::internal::DynTypedMatcher> >)
Line
Count
Source
89
1.73k
      : InnerMatchers(std::move(InnerMatchers)) {}
ASTMatchersInternal.cpp:clang::ast_matchers::internal::(anonymous namespace)::VariadicMatcher<&(clang::ast_matchers::internal::NotUnaryOperator(clang::ast_type_traits::DynTypedNode const&, clang::ast_matchers::internal::ASTMatchFinder*, clang::ast_matchers::internal::BoundNodesTreeBuilder*, llvm::ArrayRef<clang::ast_matchers::internal::DynTypedMatcher>))>::VariadicMatcher(std::__1::vector<clang::ast_matchers::internal::DynTypedMatcher, std::__1::allocator<clang::ast_matchers::internal::DynTypedMatcher> >)
Line
Count
Source
89
24.9k
      : InnerMatchers(std::move(InnerMatchers)) {}
90
91
  bool dynMatches(const ast_type_traits::DynTypedNode &DynNode,
92
                  ASTMatchFinder *Finder,
93
66.0k
                  BoundNodesTreeBuilder *Builder) const override {
94
66.0k
    return Func(DynNode, Finder, Builder, InnerMatchers);
95
66.0k
  }
ASTMatchersInternal.cpp:clang::ast_matchers::internal::(anonymous namespace)::VariadicMatcher<&(clang::ast_matchers::internal::AllOfVariadicOperator(clang::ast_type_traits::DynTypedNode const&, clang::ast_matchers::internal::ASTMatchFinder*, clang::ast_matchers::internal::BoundNodesTreeBuilder*, llvm::ArrayRef<clang::ast_matchers::internal::DynTypedMatcher>))>::dynMatches(clang::ast_type_traits::DynTypedNode const&, clang::ast_matchers::internal::ASTMatchFinder*, clang::ast_matchers::internal::BoundNodesTreeBuilder*) const
Line
Count
Source
93
21.8k
                  BoundNodesTreeBuilder *Builder) const override {
94
21.8k
    return Func(DynNode, Finder, Builder, InnerMatchers);
95
21.8k
  }
ASTMatchersInternal.cpp:clang::ast_matchers::internal::(anonymous namespace)::VariadicMatcher<&(clang::ast_matchers::internal::AnyOfVariadicOperator(clang::ast_type_traits::DynTypedNode const&, clang::ast_matchers::internal::ASTMatchFinder*, clang::ast_matchers::internal::BoundNodesTreeBuilder*, llvm::ArrayRef<clang::ast_matchers::internal::DynTypedMatcher>))>::dynMatches(clang::ast_type_traits::DynTypedNode const&, clang::ast_matchers::internal::ASTMatchFinder*, clang::ast_matchers::internal::BoundNodesTreeBuilder*) const
Line
Count
Source
93
39.3k
                  BoundNodesTreeBuilder *Builder) const override {
94
39.3k
    return Func(DynNode, Finder, Builder, InnerMatchers);
95
39.3k
  }
ASTMatchersInternal.cpp:clang::ast_matchers::internal::(anonymous namespace)::VariadicMatcher<&(clang::ast_matchers::internal::EachOfVariadicOperator(clang::ast_type_traits::DynTypedNode const&, clang::ast_matchers::internal::ASTMatchFinder*, clang::ast_matchers::internal::BoundNodesTreeBuilder*, llvm::ArrayRef<clang::ast_matchers::internal::DynTypedMatcher>))>::dynMatches(clang::ast_type_traits::DynTypedNode const&, clang::ast_matchers::internal::ASTMatchFinder*, clang::ast_matchers::internal::BoundNodesTreeBuilder*) const
Line
Count
Source
93
1.74k
                  BoundNodesTreeBuilder *Builder) const override {
94
1.74k
    return Func(DynNode, Finder, Builder, InnerMatchers);
95
1.74k
  }
ASTMatchersInternal.cpp:clang::ast_matchers::internal::(anonymous namespace)::VariadicMatcher<&(clang::ast_matchers::internal::NotUnaryOperator(clang::ast_type_traits::DynTypedNode const&, clang::ast_matchers::internal::ASTMatchFinder*, clang::ast_matchers::internal::BoundNodesTreeBuilder*, llvm::ArrayRef<clang::ast_matchers::internal::DynTypedMatcher>))>::dynMatches(clang::ast_type_traits::DynTypedNode const&, clang::ast_matchers::internal::ASTMatchFinder*, clang::ast_matchers::internal::BoundNodesTreeBuilder*) const
Line
Count
Source
93
3.16k
                  BoundNodesTreeBuilder *Builder) const override {
94
3.16k
    return Func(DynNode, Finder, Builder, InnerMatchers);
95
3.16k
  }
96
97
private:
98
  std::vector<DynTypedMatcher> InnerMatchers;
99
};
100
101
class IdDynMatcher : public DynMatcherInterface {
102
public:
103
  IdDynMatcher(StringRef ID,
104
               IntrusiveRefCntPtr<DynMatcherInterface> InnerMatcher)
105
15.1k
      : ID(ID), InnerMatcher(std::move(InnerMatcher)) {}
106
107
  bool dynMatches(const ast_type_traits::DynTypedNode &DynNode,
108
                  ASTMatchFinder *Finder,
109
34.1k
                  BoundNodesTreeBuilder *Builder) const override {
110
34.1k
    bool Result = InnerMatcher->dynMatches(DynNode, Finder, Builder);
111
34.1k
    if (Result) 
Builder->setBinding(ID, DynNode)9.26k
;
112
34.1k
    return Result;
113
34.1k
  }
114
115
private:
116
  const std::string ID;
117
  const IntrusiveRefCntPtr<DynMatcherInterface> InnerMatcher;
118
};
119
120
/// A matcher that always returns true.
121
///
122
/// We only ever need one instance of this matcher, so we create a global one
123
/// and reuse it to reduce the overhead of the matcher and increase the chance
124
/// of cache hits.
125
class TrueMatcherImpl : public DynMatcherInterface {
126
public:
127
878
  TrueMatcherImpl() {
128
878
    Retain(); // Reference count will never become zero.
129
878
  }
130
131
  bool dynMatches(const ast_type_traits::DynTypedNode &, ASTMatchFinder *,
132
2.93k
                  BoundNodesTreeBuilder *) const override {
133
2.93k
    return true;
134
2.93k
  }
135
};
136
137
} // namespace
138
139
static llvm::ManagedStatic<TrueMatcherImpl> TrueMatcherInstance;
140
141
DynTypedMatcher DynTypedMatcher::constructVariadic(
142
    DynTypedMatcher::VariadicOperator Op,
143
    ast_type_traits::ASTNodeKind SupportedKind,
144
120k
    std::vector<DynTypedMatcher> InnerMatchers) {
145
120k
  assert(!InnerMatchers.empty() && "Array must not be empty.");
146
120k
  assert(llvm::all_of(InnerMatchers,
147
120k
                      [SupportedKind](const DynTypedMatcher &M) {
148
120k
                        return M.canConvertTo(SupportedKind);
149
120k
                      }) &&
150
120k
         "InnerMatchers must be convertible to SupportedKind!");
151
120k
152
120k
  // We must relax the restrict kind here.
153
120k
  // The different operators might deal differently with a mismatch.
154
120k
  // Make it the same as SupportedKind, since that is the broadest type we are
155
120k
  // allowed to accept.
156
120k
  auto RestrictKind = SupportedKind;
157
120k
158
120k
  switch (Op) {
159
120k
  case VO_AllOf:
160
49.1k
    // In the case of allOf() we must pass all the checks, so making
161
49.1k
    // RestrictKind the most restrictive can save us time. This way we reject
162
49.1k
    // invalid types earlier and we can elide the kind checks inside the
163
49.1k
    // matcher.
164
103k
    for (auto &IM : InnerMatchers) {
165
103k
      RestrictKind = ast_type_traits::ASTNodeKind::getMostDerivedType(
166
103k
          RestrictKind, IM.RestrictKind);
167
103k
    }
168
49.1k
    return DynTypedMatcher(
169
49.1k
        SupportedKind, RestrictKind,
170
49.1k
        new VariadicMatcher<AllOfVariadicOperator>(std::move(InnerMatchers)));
171
120k
172
120k
  case VO_AnyOf:
173
44.9k
    return DynTypedMatcher(
174
44.9k
        SupportedKind, RestrictKind,
175
44.9k
        new VariadicMatcher<AnyOfVariadicOperator>(std::move(InnerMatchers)));
176
120k
177
120k
  case VO_EachOf:
178
1.73k
    return DynTypedMatcher(
179
1.73k
        SupportedKind, RestrictKind,
180
1.73k
        new VariadicMatcher<EachOfVariadicOperator>(std::move(InnerMatchers)));
181
120k
182
120k
  case VO_UnaryNot:
183
24.9k
    // FIXME: Implement the Not operator to take a single matcher instead of a
184
24.9k
    // vector.
185
24.9k
    return DynTypedMatcher(
186
24.9k
        SupportedKind, RestrictKind,
187
24.9k
        new VariadicMatcher<NotUnaryOperator>(std::move(InnerMatchers)));
188
0
  }
189
0
  llvm_unreachable("Invalid Op value.");
190
0
}
191
192
DynTypedMatcher DynTypedMatcher::trueMatcher(
193
24.1k
    ast_type_traits::ASTNodeKind NodeKind) {
194
24.1k
  return DynTypedMatcher(NodeKind, NodeKind, &*TrueMatcherInstance);
195
24.1k
}
196
197
bool DynTypedMatcher::canMatchNodesOfKind(
198
76.8k
    ast_type_traits::ASTNodeKind Kind) const {
199
76.8k
  return RestrictKind.isBaseOf(Kind);
200
76.8k
}
201
202
DynTypedMatcher DynTypedMatcher::dynCastTo(
203
610k
    const ast_type_traits::ASTNodeKind Kind) const {
204
610k
  auto Copy = *this;
205
610k
  Copy.SupportedKind = Kind;
206
610k
  Copy.RestrictKind =
207
610k
      ast_type_traits::ASTNodeKind::getMostDerivedType(Kind, RestrictKind);
208
610k
  return Copy;
209
610k
}
210
211
bool DynTypedMatcher::matches(const ast_type_traits::DynTypedNode &DynNode,
212
                              ASTMatchFinder *Finder,
213
287k
                              BoundNodesTreeBuilder *Builder) const {
214
287k
  if (RestrictKind.isBaseOf(DynNode.getNodeKind()) &&
215
287k
      
Implementation->dynMatches(DynNode, Finder, Builder)78.8k
) {
216
19.6k
    return true;
217
19.6k
  }
218
268k
  // Delete all bindings when a matcher does not match.
219
268k
  // This prevents unexpected exposure of bound nodes in unmatches
220
268k
  // branches of the match tree.
221
268k
  Builder->removeBindings([](const BoundNodesMap &) 
{ return true; }24.1k
);
222
268k
  return false;
223
268k
}
224
225
bool DynTypedMatcher::matchesNoKindCheck(
226
    const ast_type_traits::DynTypedNode &DynNode, ASTMatchFinder *Finder,
227
71.6k
    BoundNodesTreeBuilder *Builder) const {
228
71.6k
  assert(RestrictKind.isBaseOf(DynNode.getNodeKind()));
229
71.6k
  if (Implementation->dynMatches(DynNode, Finder, Builder)) {
230
22.5k
    return true;
231
22.5k
  }
232
49.0k
  // Delete all bindings when a matcher does not match.
233
49.0k
  // This prevents unexpected exposure of bound nodes in unmatches
234
49.0k
  // branches of the match tree.
235
49.0k
  Builder->removeBindings([](const BoundNodesMap &) 
{ return true; }312
);
236
49.0k
  return false;
237
49.0k
}
238
239
15.1k
llvm::Optional<DynTypedMatcher> DynTypedMatcher::tryBind(StringRef ID) const {
240
15.1k
  if (!AllowBind) 
return llvm::None0
;
241
15.1k
  auto Result = *this;
242
15.1k
  Result.Implementation =
243
15.1k
      new IdDynMatcher(ID, std::move(Result.Implementation));
244
15.1k
  return std::move(Result);
245
15.1k
}
246
247
3.75k
bool DynTypedMatcher::canConvertTo(ast_type_traits::ASTNodeKind To) const {
248
3.75k
  const auto From = getSupportedKind();
249
3.75k
  auto QualKind = ast_type_traits::ASTNodeKind::getFromNodeKind<QualType>();
250
3.75k
  auto TypeKind = ast_type_traits::ASTNodeKind::getFromNodeKind<Type>();
251
3.75k
  /// Mimic the implicit conversions of Matcher<>.
252
3.75k
  /// - From Matcher<Type> to Matcher<QualType>
253
3.75k
  if (From.isSame(TypeKind) && 
To.isSame(QualKind)169
)
return true84
;
254
3.66k
  /// - From Matcher<Base> to Matcher<Derived>
255
3.66k
  return From.isBaseOf(To);
256
3.66k
}
257
258
2.87k
void BoundNodesTreeBuilder::addMatch(const BoundNodesTreeBuilder &Other) {
259
2.87k
  Bindings.append(Other.Bindings.begin(), Other.Bindings.end());
260
2.87k
}
261
262
bool NotUnaryOperator(const ast_type_traits::DynTypedNode &DynNode,
263
                      ASTMatchFinder *Finder, BoundNodesTreeBuilder *Builder,
264
3.16k
                      ArrayRef<DynTypedMatcher> InnerMatchers) {
265
3.16k
  if (InnerMatchers.size() != 1)
266
0
    return false;
267
3.16k
268
3.16k
  // The 'unless' matcher will always discard the result:
269
3.16k
  // If the inner matcher doesn't match, unless returns true,
270
3.16k
  // but the inner matcher cannot have bound anything.
271
3.16k
  // If the inner matcher matches, the result is false, and
272
3.16k
  // any possible binding will be discarded.
273
3.16k
  // We still need to hand in all the bound nodes up to this
274
3.16k
  // point so the inner matcher can depend on bound nodes,
275
3.16k
  // and we need to actively discard the bound nodes, otherwise
276
3.16k
  // the inner matcher will reset the bound nodes if it doesn't
277
3.16k
  // match, but this would be inversed by 'unless'.
278
3.16k
  BoundNodesTreeBuilder Discard(*Builder);
279
3.16k
  return !InnerMatchers[0].matches(DynNode, Finder, &Discard);
280
3.16k
}
281
282
bool AllOfVariadicOperator(const ast_type_traits::DynTypedNode &DynNode,
283
                           ASTMatchFinder *Finder,
284
                           BoundNodesTreeBuilder *Builder,
285
21.8k
                           ArrayRef<DynTypedMatcher> InnerMatchers) {
286
21.8k
  // allOf leads to one matcher for each alternative in the first
287
21.8k
  // matcher combined with each alternative in the second matcher.
288
21.8k
  // Thus, we can reuse the same Builder.
289
30.0k
  for (const DynTypedMatcher &InnerMatcher : InnerMatchers) {
290
30.0k
    if (!InnerMatcher.matchesNoKindCheck(DynNode, Finder, Builder))
291
16.9k
      return false;
292
30.0k
  }
293
21.8k
  
return true4.83k
;
294
21.8k
}
295
296
bool EachOfVariadicOperator(const ast_type_traits::DynTypedNode &DynNode,
297
                            ASTMatchFinder *Finder,
298
                            BoundNodesTreeBuilder *Builder,
299
1.74k
                            ArrayRef<DynTypedMatcher> InnerMatchers) {
300
1.74k
  BoundNodesTreeBuilder Result;
301
1.74k
  bool Matched = false;
302
3.49k
  for (const DynTypedMatcher &InnerMatcher : InnerMatchers) {
303
3.49k
    BoundNodesTreeBuilder BuilderInner(*Builder);
304
3.49k
    if (InnerMatcher.matches(DynNode, Finder, &BuilderInner)) {
305
239
      Matched = true;
306
239
      Result.addMatch(BuilderInner);
307
239
    }
308
3.49k
  }
309
1.74k
  *Builder = std::move(Result);
310
1.74k
  return Matched;
311
1.74k
}
312
313
bool AnyOfVariadicOperator(const ast_type_traits::DynTypedNode &DynNode,
314
                           ASTMatchFinder *Finder,
315
                           BoundNodesTreeBuilder *Builder,
316
39.3k
                           ArrayRef<DynTypedMatcher> InnerMatchers) {
317
152k
  for (const DynTypedMatcher &InnerMatcher : InnerMatchers) {
318
152k
    BoundNodesTreeBuilder Result = *Builder;
319
152k
    if (InnerMatcher.matches(DynNode, Finder, &Result)) {
320
2.95k
      *Builder = std::move(Result);
321
2.95k
      return true;
322
2.95k
    }
323
152k
  }
324
39.3k
  
return false36.4k
;
325
39.3k
}
326
327
inline static
328
751
std::vector<std::string> vectorFromRefs(ArrayRef<const StringRef *> NameRefs) {
329
751
  std::vector<std::string> Names;
330
751
  for (auto *Name : NameRefs)
331
7.33k
    Names.emplace_back(*Name);
332
751
  return Names;
333
751
}
334
335
531
Matcher<NamedDecl> hasAnyNameFunc(ArrayRef<const StringRef *> NameRefs) {
336
531
  std::vector<std::string> Names = vectorFromRefs(NameRefs);
337
531
  return internal::Matcher<NamedDecl>(new internal::HasNameMatcher(Names));
338
531
}
339
340
Matcher<ObjCMessageExpr> hasAnySelectorFunc(
341
220
    ArrayRef<const StringRef *> NameRefs) {
342
220
  return hasAnySelectorMatcher(vectorFromRefs(NameRefs));
343
220
}
344
345
HasNameMatcher::HasNameMatcher(std::vector<std::string> N)
346
    : UseUnqualifiedMatch(std::all_of(
347
          N.begin(), N.end(),
348
8.59k
          [](StringRef Name) { return Name.find("::") == Name.npos; })),
349
8.15k
      Names(std::move(N)) {
350
#ifndef NDEBUG
351
  for (StringRef Name : Names)
352
    assert(!Name.empty());
353
#endif
354
}
355
356
17.6k
static bool consumeNameSuffix(StringRef &FullName, StringRef Suffix) {
357
17.6k
  StringRef Name = FullName;
358
17.6k
  if (!Name.endswith(Suffix))
359
9.16k
    return false;
360
8.44k
  Name = Name.drop_back(Suffix.size());
361
8.44k
  if (!Name.empty()) {
362
495
    if (!Name.endswith("::"))
363
32
      return false;
364
463
    Name = Name.drop_back(2);
365
463
  }
366
8.44k
  FullName = Name;
367
8.41k
  return true;
368
8.44k
}
369
370
static StringRef getNodeName(const NamedDecl &Node,
371
17.0k
                             llvm::SmallString<128> &Scratch) {
372
17.0k
  // Simple name.
373
17.0k
  if (Node.getIdentifier())
374
15.6k
    return Node.getName();
375
1.45k
376
1.45k
  if (Node.getDeclName()) {
377
1.04k
    // Name needs to be constructed.
378
1.04k
    Scratch.clear();
379
1.04k
    llvm::raw_svector_ostream OS(Scratch);
380
1.04k
    Node.printName(OS);
381
1.04k
    return OS.str();
382
1.04k
  }
383
414
384
414
  return "(anonymous)";
385
414
}
386
387
static StringRef getNodeName(const RecordDecl &Node,
388
136
                             llvm::SmallString<128> &Scratch) {
389
136
  if (Node.getIdentifier()) {
390
124
    return Node.getName();
391
124
  }
392
12
  Scratch.clear();
393
12
  return ("(anonymous " + Node.getKindName() + ")").toStringRef(Scratch);
394
12
}
395
396
static StringRef getNodeName(const NamespaceDecl &Node,
397
144
                             llvm::SmallString<128> &Scratch) {
398
144
  return Node.isAnonymousNamespace() ? 
"(anonymous namespace)"8
:
Node.getName()136
;
399
144
}
400
401
namespace {
402
403
class PatternSet {
404
public:
405
940
  PatternSet(ArrayRef<std::string> Names) {
406
940
    for (StringRef Name : Names)
407
1.10k
      Patterns.push_back({Name, Name.startswith("::")});
408
940
  }
409
410
  /// Consumes the name suffix from each pattern in the set and removes the ones
411
  /// that didn't match.
412
  /// Return true if there are still any patterns left.
413
1.22k
  bool consumeNameSuffix(StringRef NodeName, bool CanSkip) {
414
2.61k
    for (size_t I = 0; I < Patterns.size();) {
415
1.39k
      if (::clang::ast_matchers::internal::consumeNameSuffix(Patterns[I].P,
416
1.39k
                                                             NodeName) ||
417
1.39k
          
CanSkip882
) {
418
523
        ++I;
419
874
      } else {
420
874
        Patterns.erase(Patterns.begin() + I);
421
874
      }
422
1.39k
    }
423
1.22k
    return !Patterns.empty();
424
1.22k
  }
425
426
  /// Check if any of the patterns are a match.
427
  /// A match will be a pattern that was fully consumed, that also matches the
428
  /// 'fully qualified' requirement.
429
507
  bool foundMatch(bool AllowFullyQualified) const {
430
507
    for (auto& P: Patterns)
431
523
      if (P.P.empty() && 
(259
AllowFullyQualified259
||
!P.IsFullyQualified72
))
432
193
        return true;
433
507
    
return false314
;
434
507
  }
435
436
private:
437
  struct Pattern {
438
    StringRef P;
439
    bool IsFullyQualified;
440
  };
441
442
  llvm::SmallVector<Pattern, 8> Patterns;
443
};
444
445
} // namespace
446
447
16.1k
bool HasNameMatcher::matchesNodeUnqualified(const NamedDecl &Node) const {
448
16.1k
  assert(UseUnqualifiedMatch);
449
16.1k
  llvm::SmallString<128> Scratch;
450
16.1k
  StringRef NodeName = getNodeName(Node, Scratch);
451
16.2k
  return llvm::any_of(Names, [&](StringRef Name) {
452
16.2k
    return consumeNameSuffix(Name, NodeName) && 
Name.empty()7.90k
;
453
16.2k
  });
454
16.1k
}
455
456
940
bool HasNameMatcher::matchesNodeFullFast(const NamedDecl &Node) const {
457
940
  PatternSet Patterns(Names);
458
940
  llvm::SmallString<128> Scratch;
459
940
460
940
  // This function is copied and adapted from NamedDecl::printQualifiedName()
461
940
  // By matching each part individually we optimize in a couple of ways:
462
940
  //  - We can exit early on the first failure.
463
940
  //  - We can skip inline/anonymous namespaces without another pass.
464
940
  //  - We print one name at a time, reducing the chance of overflowing the
465
940
  //    inlined space of the SmallString.
466
940
467
940
  // First, match the name.
468
940
  if (!Patterns.consumeNameSuffix(getNodeName(Node, Scratch),
469
940
                                  /*CanSkip=*/false))
470
632
    return false;
471
308
472
308
  // Try to match each declaration context.
473
308
  // We are allowed to skip anonymous and inline namespaces if they don't match.
474
308
  const DeclContext *Ctx = Node.getDeclContext();
475
308
476
308
  if (Ctx->isFunctionOrMethod())
477
4
    return Patterns.foundMatch(/*AllowFullyQualified=*/false);
478
304
479
503
  
for (; 304
Ctx && isa<NamedDecl>(Ctx);
Ctx = Ctx->getParent()199
) {
480
308
    if (Patterns.foundMatch(/*AllowFullyQualified=*/false))
481
6
      return true;
482
302
483
302
    if (const auto *ND = dyn_cast<NamespaceDecl>(Ctx)) {
484
144
      // If it matches (or we can skip it), continue.
485
144
      if (Patterns.consumeNameSuffix(getNodeName(*ND, Scratch),
486
144
                                     /*CanSkip=*/ND->isAnonymousNamespace() ||
487
144
                                         
ND->isInline()136
))
488
132
        continue;
489
12
      return false;
490
12
    }
491
158
    if (const auto *RD = dyn_cast<RecordDecl>(Ctx)) {
492
152
      if (!isa<ClassTemplateSpecializationDecl>(Ctx)) {
493
136
        if (Patterns.consumeNameSuffix(getNodeName(*RD, Scratch),
494
136
                                       /*CanSkip=*/false))
495
67
          continue;
496
69
497
69
        return false;
498
69
      }
499
152
    }
500
22
501
22
    // We don't know how to deal with this DeclContext.
502
22
    // Fallback to the slow version of the code.
503
22
    return matchesNodeFullSlow(Node);
504
22
  }
505
304
506
304
  
return Patterns.foundMatch(/*AllowFullyQualified=*/true)195
;
507
304
}
508
509
22
bool HasNameMatcher::matchesNodeFullSlow(const NamedDecl &Node) const {
510
22
  const bool SkipUnwrittenCases[] = {false, true};
511
34
  for (bool SkipUnwritten : SkipUnwrittenCases) {
512
34
    llvm::SmallString<128> NodeName = StringRef("::");
513
34
    llvm::raw_svector_ostream OS(NodeName);
514
34
515
34
    if (SkipUnwritten) {
516
12
      PrintingPolicy Policy = Node.getASTContext().getPrintingPolicy();
517
12
      Policy.SuppressUnwrittenScope = true;
518
12
      Node.printQualifiedName(OS, Policy);
519
22
    } else {
520
22
      Node.printQualifiedName(OS);
521
22
    }
522
34
523
34
    const StringRef FullName = OS.str();
524
34
525
34
    for (const StringRef Pattern : Names) {
526
34
      if (Pattern.startswith("::")) {
527
30
        if (FullName == Pattern)
528
6
          return true;
529
4
      } else if (FullName.endswith(Pattern) &&
530
4
                 FullName.drop_back(Pattern.size()).endswith("::")) {
531
4
        return true;
532
4
      }
533
34
    }
534
34
  }
535
22
536
22
  
return false12
;
537
22
}
538
539
17.0k
bool HasNameMatcher::matchesNode(const NamedDecl &Node) const {
540
17.0k
  assert(matchesNodeFullFast(Node) == matchesNodeFullSlow(Node));
541
17.0k
  if (UseUnqualifiedMatch) {
542
16.1k
    assert(matchesNodeUnqualified(Node) == matchesNodeFullFast(Node));
543
16.1k
    return matchesNodeUnqualified(Node);
544
16.1k
  }
545
940
  return matchesNodeFullFast(Node);
546
940
}
547
548
} // end namespace internal
549
550
const internal::VariadicDynCastAllOfMatcher<Stmt, ObjCAutoreleasePoolStmt>
551
    autoreleasePoolStmt;
552
const internal::VariadicDynCastAllOfMatcher<Decl, TranslationUnitDecl>
553
    translationUnitDecl;
554
const internal::VariadicDynCastAllOfMatcher<Decl, TypedefDecl> typedefDecl;
555
const internal::VariadicDynCastAllOfMatcher<Decl, TypedefNameDecl>
556
    typedefNameDecl;
557
const internal::VariadicDynCastAllOfMatcher<Decl, TypeAliasDecl> typeAliasDecl;
558
const internal::VariadicDynCastAllOfMatcher<Decl, TypeAliasTemplateDecl>
559
    typeAliasTemplateDecl;
560
const internal::VariadicAllOfMatcher<Decl> decl;
561
const internal::VariadicDynCastAllOfMatcher<Decl, LinkageSpecDecl>
562
    linkageSpecDecl;
563
const internal::VariadicDynCastAllOfMatcher<Decl, NamedDecl> namedDecl;
564
const internal::VariadicDynCastAllOfMatcher<Decl, LabelDecl> labelDecl;
565
const internal::VariadicDynCastAllOfMatcher<Decl, NamespaceDecl> namespaceDecl;
566
const internal::VariadicDynCastAllOfMatcher<Decl, NamespaceAliasDecl>
567
    namespaceAliasDecl;
568
const internal::VariadicDynCastAllOfMatcher<Decl, RecordDecl> recordDecl;
569
const internal::VariadicDynCastAllOfMatcher<Decl, CXXRecordDecl> cxxRecordDecl;
570
const internal::VariadicDynCastAllOfMatcher<Decl, ClassTemplateDecl>
571
    classTemplateDecl;
572
const internal::VariadicDynCastAllOfMatcher<Decl,
573
                                            ClassTemplateSpecializationDecl>
574
    classTemplateSpecializationDecl;
575
const internal::VariadicDynCastAllOfMatcher<
576
    Decl, ClassTemplatePartialSpecializationDecl>
577
    classTemplatePartialSpecializationDecl;
578
const internal::VariadicDynCastAllOfMatcher<Decl, DeclaratorDecl>
579
    declaratorDecl;
580
const internal::VariadicDynCastAllOfMatcher<Decl, ParmVarDecl> parmVarDecl;
581
const internal::VariadicDynCastAllOfMatcher<Decl, AccessSpecDecl>
582
    accessSpecDecl;
583
const internal::VariadicAllOfMatcher<CXXCtorInitializer> cxxCtorInitializer;
584
const internal::VariadicAllOfMatcher<TemplateArgument> templateArgument;
585
const internal::VariadicAllOfMatcher<TemplateName> templateName;
586
const internal::VariadicDynCastAllOfMatcher<Decl, NonTypeTemplateParmDecl>
587
    nonTypeTemplateParmDecl;
588
const internal::VariadicDynCastAllOfMatcher<Decl, TemplateTypeParmDecl>
589
    templateTypeParmDecl;
590
const internal::VariadicAllOfMatcher<QualType> qualType;
591
const internal::VariadicAllOfMatcher<Type> type;
592
const internal::VariadicAllOfMatcher<TypeLoc> typeLoc;
593
const internal::VariadicDynCastAllOfMatcher<Stmt, UnaryExprOrTypeTraitExpr>
594
    unaryExprOrTypeTraitExpr;
595
const internal::VariadicDynCastAllOfMatcher<Decl, ValueDecl> valueDecl;
596
const internal::VariadicDynCastAllOfMatcher<Decl, CXXConstructorDecl>
597
    cxxConstructorDecl;
598
const internal::VariadicDynCastAllOfMatcher<Decl, CXXDestructorDecl>
599
    cxxDestructorDecl;
600
const internal::VariadicDynCastAllOfMatcher<Decl, EnumDecl> enumDecl;
601
const internal::VariadicDynCastAllOfMatcher<Decl, EnumConstantDecl>
602
    enumConstantDecl;
603
const internal::VariadicDynCastAllOfMatcher<Decl, CXXMethodDecl> cxxMethodDecl;
604
const internal::VariadicDynCastAllOfMatcher<Decl, CXXConversionDecl>
605
    cxxConversionDecl;
606
const internal::VariadicDynCastAllOfMatcher<Decl, VarDecl> varDecl;
607
const internal::VariadicDynCastAllOfMatcher<Decl, FieldDecl> fieldDecl;
608
const internal::VariadicDynCastAllOfMatcher<Decl, IndirectFieldDecl>
609
    indirectFieldDecl;
610
const internal::VariadicDynCastAllOfMatcher<Decl, FunctionDecl> functionDecl;
611
const internal::VariadicDynCastAllOfMatcher<Decl, FunctionTemplateDecl>
612
    functionTemplateDecl;
613
const internal::VariadicDynCastAllOfMatcher<Decl, FriendDecl> friendDecl;
614
const internal::VariadicAllOfMatcher<Stmt> stmt;
615
const internal::VariadicDynCastAllOfMatcher<Stmt, DeclStmt> declStmt;
616
const internal::VariadicDynCastAllOfMatcher<Stmt, MemberExpr> memberExpr;
617
const internal::VariadicDynCastAllOfMatcher<Stmt, UnresolvedMemberExpr>
618
    unresolvedMemberExpr;
619
const internal::VariadicDynCastAllOfMatcher<Stmt, CXXDependentScopeMemberExpr>
620
    cxxDependentScopeMemberExpr;
621
const internal::VariadicDynCastAllOfMatcher<Stmt, CallExpr> callExpr;
622
const internal::VariadicDynCastAllOfMatcher<Stmt, LambdaExpr> lambdaExpr;
623
const internal::VariadicDynCastAllOfMatcher<Stmt, CXXMemberCallExpr>
624
    cxxMemberCallExpr;
625
const internal::VariadicDynCastAllOfMatcher<Stmt, ObjCMessageExpr>
626
    objcMessageExpr;
627
const internal::VariadicDynCastAllOfMatcher<Decl, ObjCInterfaceDecl>
628
    objcInterfaceDecl;
629
const internal::VariadicDynCastAllOfMatcher<Decl, ObjCImplementationDecl>
630
    objcImplementationDecl;
631
const internal::VariadicDynCastAllOfMatcher<Decl, ObjCProtocolDecl>
632
    objcProtocolDecl;
633
const internal::VariadicDynCastAllOfMatcher<Decl, ObjCCategoryDecl>
634
    objcCategoryDecl;
635
const internal::VariadicDynCastAllOfMatcher<Decl, ObjCCategoryImplDecl>
636
    objcCategoryImplDecl;
637
const internal::VariadicDynCastAllOfMatcher<Decl, ObjCMethodDecl>
638
    objcMethodDecl;
639
const internal::VariadicDynCastAllOfMatcher<Decl, BlockDecl>
640
    blockDecl;
641
const internal::VariadicDynCastAllOfMatcher<Decl, ObjCIvarDecl> objcIvarDecl;
642
const internal::VariadicDynCastAllOfMatcher<Decl, ObjCPropertyDecl>
643
    objcPropertyDecl;
644
const internal::VariadicDynCastAllOfMatcher<Stmt, ObjCAtThrowStmt>
645
    objcThrowStmt;
646
const internal::VariadicDynCastAllOfMatcher<Stmt, ObjCAtTryStmt> objcTryStmt;
647
const internal::VariadicDynCastAllOfMatcher<Stmt, ObjCAtCatchStmt>
648
    objcCatchStmt;
649
const internal::VariadicDynCastAllOfMatcher<Stmt, ObjCAtFinallyStmt>
650
    objcFinallyStmt;
651
const internal::VariadicDynCastAllOfMatcher<Stmt, ExprWithCleanups>
652
    exprWithCleanups;
653
const internal::VariadicDynCastAllOfMatcher<Stmt, InitListExpr> initListExpr;
654
const internal::VariadicDynCastAllOfMatcher<Stmt, CXXStdInitializerListExpr>
655
    cxxStdInitializerListExpr;
656
const internal::VariadicDynCastAllOfMatcher<Stmt, ImplicitValueInitExpr>
657
    implicitValueInitExpr;
658
const internal::VariadicDynCastAllOfMatcher<Stmt, ParenListExpr> parenListExpr;
659
const internal::VariadicDynCastAllOfMatcher<Stmt, SubstNonTypeTemplateParmExpr>
660
    substNonTypeTemplateParmExpr;
661
const internal::VariadicDynCastAllOfMatcher<Decl, UsingDecl> usingDecl;
662
const internal::VariadicDynCastAllOfMatcher<Decl, UsingDirectiveDecl>
663
    usingDirectiveDecl;
664
const internal::VariadicDynCastAllOfMatcher<Stmt, UnresolvedLookupExpr>
665
    unresolvedLookupExpr;
666
const internal::VariadicDynCastAllOfMatcher<Decl, UnresolvedUsingValueDecl>
667
    unresolvedUsingValueDecl;
668
const internal::VariadicDynCastAllOfMatcher<Decl, UnresolvedUsingTypenameDecl>
669
    unresolvedUsingTypenameDecl;
670
const internal::VariadicDynCastAllOfMatcher<Stmt, ConstantExpr> constantExpr;
671
const internal::VariadicDynCastAllOfMatcher<Stmt, ParenExpr> parenExpr;
672
const internal::VariadicDynCastAllOfMatcher<Stmt, CXXConstructExpr>
673
    cxxConstructExpr;
674
const internal::VariadicDynCastAllOfMatcher<Stmt, CXXUnresolvedConstructExpr>
675
    cxxUnresolvedConstructExpr;
676
const internal::VariadicDynCastAllOfMatcher<Stmt, CXXThisExpr> cxxThisExpr;
677
const internal::VariadicDynCastAllOfMatcher<Stmt, CXXBindTemporaryExpr>
678
    cxxBindTemporaryExpr;
679
const internal::VariadicDynCastAllOfMatcher<Stmt, MaterializeTemporaryExpr>
680
    materializeTemporaryExpr;
681
const internal::VariadicDynCastAllOfMatcher<Stmt, CXXNewExpr> cxxNewExpr;
682
const internal::VariadicDynCastAllOfMatcher<Stmt, CXXDeleteExpr> cxxDeleteExpr;
683
const internal::VariadicDynCastAllOfMatcher<Stmt, ArraySubscriptExpr>
684
    arraySubscriptExpr;
685
const internal::VariadicDynCastAllOfMatcher<Stmt, CXXDefaultArgExpr>
686
    cxxDefaultArgExpr;
687
const internal::VariadicDynCastAllOfMatcher<Stmt, CXXOperatorCallExpr>
688
    cxxOperatorCallExpr;
689
const internal::VariadicDynCastAllOfMatcher<Stmt, Expr> expr;
690
const internal::VariadicDynCastAllOfMatcher<Stmt, DeclRefExpr> declRefExpr;
691
const internal::VariadicDynCastAllOfMatcher<Stmt, ObjCIvarRefExpr> objcIvarRefExpr;
692
const internal::VariadicDynCastAllOfMatcher<Stmt, BlockExpr> blockExpr;
693
const internal::VariadicDynCastAllOfMatcher<Stmt, IfStmt> ifStmt;
694
const internal::VariadicDynCastAllOfMatcher<Stmt, ForStmt> forStmt;
695
const internal::VariadicDynCastAllOfMatcher<Stmt, CXXForRangeStmt>
696
    cxxForRangeStmt;
697
const internal::VariadicDynCastAllOfMatcher<Stmt, WhileStmt> whileStmt;
698
const internal::VariadicDynCastAllOfMatcher<Stmt, DoStmt> doStmt;
699
const internal::VariadicDynCastAllOfMatcher<Stmt, BreakStmt> breakStmt;
700
const internal::VariadicDynCastAllOfMatcher<Stmt, ContinueStmt> continueStmt;
701
const internal::VariadicDynCastAllOfMatcher<Stmt, ReturnStmt> returnStmt;
702
const internal::VariadicDynCastAllOfMatcher<Stmt, GotoStmt> gotoStmt;
703
const internal::VariadicDynCastAllOfMatcher<Stmt, LabelStmt> labelStmt;
704
const internal::VariadicDynCastAllOfMatcher<Stmt, AddrLabelExpr> addrLabelExpr;
705
const internal::VariadicDynCastAllOfMatcher<Stmt, SwitchStmt> switchStmt;
706
const internal::VariadicDynCastAllOfMatcher<Stmt, SwitchCase> switchCase;
707
const internal::VariadicDynCastAllOfMatcher<Stmt, CaseStmt> caseStmt;
708
const internal::VariadicDynCastAllOfMatcher<Stmt, DefaultStmt> defaultStmt;
709
const internal::VariadicDynCastAllOfMatcher<Stmt, CompoundStmt> compoundStmt;
710
const internal::VariadicDynCastAllOfMatcher<Stmt, CXXCatchStmt> cxxCatchStmt;
711
const internal::VariadicDynCastAllOfMatcher<Stmt, CXXTryStmt> cxxTryStmt;
712
const internal::VariadicDynCastAllOfMatcher<Stmt, CXXThrowExpr> cxxThrowExpr;
713
const internal::VariadicDynCastAllOfMatcher<Stmt, NullStmt> nullStmt;
714
const internal::VariadicDynCastAllOfMatcher<Stmt, AsmStmt> asmStmt;
715
const internal::VariadicDynCastAllOfMatcher<Stmt, CXXBoolLiteralExpr>
716
    cxxBoolLiteral;
717
const internal::VariadicDynCastAllOfMatcher<Stmt, StringLiteral> stringLiteral;
718
const internal::VariadicDynCastAllOfMatcher<Stmt, CharacterLiteral>
719
    characterLiteral;
720
const internal::VariadicDynCastAllOfMatcher<Stmt, IntegerLiteral>
721
    integerLiteral;
722
const internal::VariadicDynCastAllOfMatcher<Stmt, FloatingLiteral> floatLiteral;
723
const internal::VariadicDynCastAllOfMatcher<Stmt, ImaginaryLiteral> imaginaryLiteral;
724
const internal::VariadicDynCastAllOfMatcher<Stmt, UserDefinedLiteral>
725
    userDefinedLiteral;
726
const internal::VariadicDynCastAllOfMatcher<Stmt, CompoundLiteralExpr>
727
    compoundLiteralExpr;
728
const internal::VariadicDynCastAllOfMatcher<Stmt, CXXNullPtrLiteralExpr>
729
    cxxNullPtrLiteralExpr;
730
const internal::VariadicDynCastAllOfMatcher<Stmt, ChooseExpr> chooseExpr;
731
const internal::VariadicDynCastAllOfMatcher<Stmt, GNUNullExpr> gnuNullExpr;
732
const internal::VariadicDynCastAllOfMatcher<Stmt, AtomicExpr> atomicExpr;
733
const internal::VariadicDynCastAllOfMatcher<Stmt, StmtExpr> stmtExpr;
734
const internal::VariadicDynCastAllOfMatcher<Stmt, BinaryOperator>
735
    binaryOperator;
736
const internal::VariadicDynCastAllOfMatcher<Stmt, UnaryOperator> unaryOperator;
737
const internal::VariadicDynCastAllOfMatcher<Stmt, ConditionalOperator>
738
    conditionalOperator;
739
const internal::VariadicDynCastAllOfMatcher<Stmt, BinaryConditionalOperator>
740
    binaryConditionalOperator;
741
const internal::VariadicDynCastAllOfMatcher<Stmt, OpaqueValueExpr>
742
    opaqueValueExpr;
743
const internal::VariadicDynCastAllOfMatcher<Decl, StaticAssertDecl>
744
    staticAssertDecl;
745
const internal::VariadicDynCastAllOfMatcher<Stmt, CXXReinterpretCastExpr>
746
    cxxReinterpretCastExpr;
747
const internal::VariadicDynCastAllOfMatcher<Stmt, CXXStaticCastExpr>
748
    cxxStaticCastExpr;
749
const internal::VariadicDynCastAllOfMatcher<Stmt, CXXDynamicCastExpr>
750
    cxxDynamicCastExpr;
751
const internal::VariadicDynCastAllOfMatcher<Stmt, CXXConstCastExpr>
752
    cxxConstCastExpr;
753
const internal::VariadicDynCastAllOfMatcher<Stmt, CStyleCastExpr>
754
    cStyleCastExpr;
755
const internal::VariadicDynCastAllOfMatcher<Stmt, ExplicitCastExpr>
756
    explicitCastExpr;
757
const internal::VariadicDynCastAllOfMatcher<Stmt, ImplicitCastExpr>
758
    implicitCastExpr;
759
const internal::VariadicDynCastAllOfMatcher<Stmt, CastExpr> castExpr;
760
const internal::VariadicDynCastAllOfMatcher<Stmt, CXXFunctionalCastExpr>
761
    cxxFunctionalCastExpr;
762
const internal::VariadicDynCastAllOfMatcher<Stmt, CXXTemporaryObjectExpr>
763
    cxxTemporaryObjectExpr;
764
const internal::VariadicDynCastAllOfMatcher<Stmt, PredefinedExpr>
765
    predefinedExpr;
766
const internal::VariadicDynCastAllOfMatcher<Stmt, DesignatedInitExpr>
767
    designatedInitExpr;
768
const internal::VariadicOperatorMatcherFunc<
769
    2, std::numeric_limits<unsigned>::max()>
770
    eachOf = {internal::DynTypedMatcher::VO_EachOf};
771
const internal::VariadicOperatorMatcherFunc<
772
    2, std::numeric_limits<unsigned>::max()>
773
    anyOf = {internal::DynTypedMatcher::VO_AnyOf};
774
const internal::VariadicOperatorMatcherFunc<
775
    2, std::numeric_limits<unsigned>::max()>
776
    allOf = {internal::DynTypedMatcher::VO_AllOf};
777
const internal::VariadicFunction<internal::Matcher<NamedDecl>, StringRef,
778
                                 internal::hasAnyNameFunc>
779
    hasAnyName = {};
780
const internal::VariadicFunction<internal::Matcher<ObjCMessageExpr>, StringRef,
781
                                 internal::hasAnySelectorFunc>
782
    hasAnySelector = {};
783
const internal::ArgumentAdaptingMatcherFunc<internal::HasMatcher> has = {};
784
const internal::ArgumentAdaptingMatcherFunc<internal::HasDescendantMatcher>
785
    hasDescendant = {};
786
const internal::ArgumentAdaptingMatcherFunc<internal::ForEachMatcher> forEach =
787
    {};
788
const internal::ArgumentAdaptingMatcherFunc<internal::ForEachDescendantMatcher>
789
    forEachDescendant = {};
790
const internal::ArgumentAdaptingMatcherFunc<
791
    internal::HasParentMatcher,
792
    internal::TypeList<Decl, NestedNameSpecifierLoc, Stmt, TypeLoc>,
793
    internal::TypeList<Decl, NestedNameSpecifierLoc, Stmt, TypeLoc>>
794
    hasParent = {};
795
const internal::ArgumentAdaptingMatcherFunc<
796
    internal::HasAncestorMatcher,
797
    internal::TypeList<Decl, NestedNameSpecifierLoc, Stmt, TypeLoc>,
798
    internal::TypeList<Decl, NestedNameSpecifierLoc, Stmt, TypeLoc>>
799
    hasAncestor = {};
800
const internal::VariadicOperatorMatcherFunc<1, 1> unless = {
801
    internal::DynTypedMatcher::VO_UnaryNot};
802
const internal::VariadicAllOfMatcher<NestedNameSpecifier> nestedNameSpecifier;
803
const internal::VariadicAllOfMatcher<NestedNameSpecifierLoc>
804
    nestedNameSpecifierLoc;
805
const internal::VariadicDynCastAllOfMatcher<Stmt, CUDAKernelCallExpr>
806
    cudaKernelCallExpr;
807
const AstTypeMatcher<BuiltinType> builtinType;
808
const AstTypeMatcher<ArrayType> arrayType;
809
const AstTypeMatcher<ComplexType> complexType;
810
const AstTypeMatcher<ConstantArrayType> constantArrayType;
811
const AstTypeMatcher<DependentSizedArrayType> dependentSizedArrayType;
812
const AstTypeMatcher<IncompleteArrayType> incompleteArrayType;
813
const AstTypeMatcher<VariableArrayType> variableArrayType;
814
const AstTypeMatcher<AtomicType> atomicType;
815
const AstTypeMatcher<AutoType> autoType;
816
const AstTypeMatcher<DecltypeType> decltypeType;
817
const AstTypeMatcher<FunctionType> functionType;
818
const AstTypeMatcher<FunctionProtoType> functionProtoType;
819
const AstTypeMatcher<ParenType> parenType;
820
const AstTypeMatcher<BlockPointerType> blockPointerType;
821
const AstTypeMatcher<MemberPointerType> memberPointerType;
822
const AstTypeMatcher<PointerType> pointerType;
823
const AstTypeMatcher<ObjCObjectPointerType> objcObjectPointerType;
824
const AstTypeMatcher<ReferenceType> referenceType;
825
const AstTypeMatcher<LValueReferenceType> lValueReferenceType;
826
const AstTypeMatcher<RValueReferenceType> rValueReferenceType;
827
const AstTypeMatcher<TypedefType> typedefType;
828
const AstTypeMatcher<EnumType> enumType;
829
const AstTypeMatcher<TemplateSpecializationType> templateSpecializationType;
830
const AstTypeMatcher<UnaryTransformType> unaryTransformType;
831
const AstTypeMatcher<RecordType> recordType;
832
const AstTypeMatcher<TagType> tagType;
833
const AstTypeMatcher<ElaboratedType> elaboratedType;
834
const AstTypeMatcher<SubstTemplateTypeParmType> substTemplateTypeParmType;
835
const AstTypeMatcher<TemplateTypeParmType> templateTypeParmType;
836
const AstTypeMatcher<InjectedClassNameType> injectedClassNameType;
837
const AstTypeMatcher<DecayedType> decayedType;
838
AST_TYPELOC_TRAVERSE_MATCHER_DEF(hasElementType,
839
                                 AST_POLYMORPHIC_SUPPORTED_TYPES(ArrayType,
840
                                                                 ComplexType));
841
AST_TYPELOC_TRAVERSE_MATCHER_DEF(hasValueType,
842
                                 AST_POLYMORPHIC_SUPPORTED_TYPES(AtomicType));
843
AST_TYPELOC_TRAVERSE_MATCHER_DEF(
844
    pointee,
845
    AST_POLYMORPHIC_SUPPORTED_TYPES(BlockPointerType, MemberPointerType,
846
                                    PointerType, ReferenceType));
847
848
const internal::VariadicDynCastAllOfMatcher<Stmt, OMPExecutableDirective>
849
    ompExecutableDirective;
850
const internal::VariadicDynCastAllOfMatcher<OMPClause, OMPDefaultClause>
851
    ompDefaultClause;
852
const internal::VariadicDynCastAllOfMatcher<Decl, CXXDeductionGuideDecl>
853
    cxxDeductionGuideDecl;
854
855
} // end namespace ast_matchers
856
} // end namespace clang