clang  3.8.0
Registry.cpp
Go to the documentation of this file.
1 //===--- Registry.cpp - Matcher registry -------------------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===------------------------------------------------------------===//
9 ///
10 /// \file
11 /// \brief Registry map populated at static initialization time.
12 ///
13 //===------------------------------------------------------------===//
14 
16 #include "Marshallers.h"
18 #include "llvm/ADT/STLExtras.h"
19 #include "llvm/ADT/StringMap.h"
20 #include "llvm/ADT/StringRef.h"
21 #include "llvm/Support/ManagedStatic.h"
22 #include <set>
23 #include <utility>
24 
25 using namespace clang::ast_type_traits;
26 
27 namespace clang {
28 namespace ast_matchers {
29 namespace dynamic {
30 namespace {
31 
32 using internal::MatcherDescriptor;
33 
34 typedef llvm::StringMap<const MatcherDescriptor *> ConstructorMap;
35 class RegistryMaps {
36 public:
37  RegistryMaps();
38  ~RegistryMaps();
39 
40  const ConstructorMap &constructors() const { return Constructors; }
41 
42 private:
43  void registerMatcher(StringRef MatcherName, MatcherDescriptor *Callback);
44  ConstructorMap Constructors;
45 };
46 
47 void RegistryMaps::registerMatcher(StringRef MatcherName,
48  MatcherDescriptor *Callback) {
49  assert(Constructors.find(MatcherName) == Constructors.end());
50  Constructors[MatcherName] = Callback;
51 }
52 
53 #define REGISTER_MATCHER(name) \
54  registerMatcher(#name, internal::makeMatcherAutoMarshall( \
55  ::clang::ast_matchers::name, #name));
56 
57 #define SPECIFIC_MATCHER_OVERLOAD(name, Id) \
58  static_cast< ::clang::ast_matchers::name##_Type##Id>( \
59  ::clang::ast_matchers::name)
60 
61 #define REGISTER_OVERLOADED_2(name) \
62  do { \
63  MatcherDescriptor *Callbacks[] = { \
64  internal::makeMatcherAutoMarshall(SPECIFIC_MATCHER_OVERLOAD(name, 0), \
65  #name), \
66  internal::makeMatcherAutoMarshall(SPECIFIC_MATCHER_OVERLOAD(name, 1), \
67  #name) \
68  }; \
69  registerMatcher(#name, \
70  new internal::OverloadedMatcherDescriptor(Callbacks)); \
71  } while (0)
72 
73 /// \brief Generate a registry map with all the known matchers.
74 RegistryMaps::RegistryMaps() {
75  // TODO: Here is the list of the missing matchers, grouped by reason.
76  //
77  // Need Variant/Parser fixes:
78  // ofKind
79  //
80  // Polymorphic + argument overload:
81  // findAll
82  //
83  // Other:
84  // equals
85  // equalsNode
86 
87  REGISTER_OVERLOADED_2(callee);
88  REGISTER_OVERLOADED_2(hasPrefix);
89  REGISTER_OVERLOADED_2(hasType);
90  REGISTER_OVERLOADED_2(isDerivedFrom);
91  REGISTER_OVERLOADED_2(isSameOrDerivedFrom);
93  REGISTER_OVERLOADED_2(pointsTo);
94  REGISTER_OVERLOADED_2(references);
95  REGISTER_OVERLOADED_2(thisPointerType);
96 
102  REGISTER_MATCHER(argumentCountIs);
104  REGISTER_MATCHER(arrayType);
106  REGISTER_MATCHER(asString);
107  REGISTER_MATCHER(atomicType);
108  REGISTER_MATCHER(autoType);
110  REGISTER_MATCHER(blockPointerType);
111  REGISTER_MATCHER(booleanType);
113  REGISTER_MATCHER(builtinType);
120  REGISTER_MATCHER(complexType);
124  REGISTER_MATCHER(constantArrayType);
125  REGISTER_MATCHER(containsDeclaration);
156  REGISTER_MATCHER(decayedType);
159  REGISTER_MATCHER(declCountIs);
163  REGISTER_MATCHER(dependentSizedArrayType);
166  REGISTER_MATCHER(elaboratedType);
169  REGISTER_MATCHER(equalsBoundNode);
170  REGISTER_MATCHER(equalsIntegralValue);
177  REGISTER_MATCHER(forEachConstructorInitializer);
179  REGISTER_MATCHER(forEachSwitchCase);
180  REGISTER_MATCHER(forField);
185  REGISTER_MATCHER(functionType);
189  REGISTER_MATCHER(hasAnyArgument);
190  REGISTER_MATCHER(hasAnyConstructorInitializer);
191  REGISTER_MATCHER(hasAnyParameter);
192  REGISTER_MATCHER(hasAnySubstatement);
193  REGISTER_MATCHER(hasAnyTemplateArgument);
194  REGISTER_MATCHER(hasAnyUsingShadowDecl);
195  REGISTER_MATCHER(hasArgument);
196  REGISTER_MATCHER(hasArgumentOfType);
197  REGISTER_MATCHER(hasAttr);
198  REGISTER_MATCHER(hasAutomaticStorageDuration);
199  REGISTER_MATCHER(hasBase);
200  REGISTER_MATCHER(hasBody);
201  REGISTER_MATCHER(hasCanonicalType);
202  REGISTER_MATCHER(hasCaseConstant);
203  REGISTER_MATCHER(hasCondition);
204  REGISTER_MATCHER(hasConditionVariableStatement);
205  REGISTER_MATCHER(hasDecayedType);
207  REGISTER_MATCHER(hasDeclContext);
208  REGISTER_MATCHER(hasDeducedType);
210  REGISTER_MATCHER(hasDestinationType);
212  REGISTER_MATCHER(hasElementType);
213  REGISTER_MATCHER(hasElse);
214  REGISTER_MATCHER(hasFalseExpression);
215  REGISTER_MATCHER(hasGlobalStorage);
216  REGISTER_MATCHER(hasImplicitDestinationType);
217  REGISTER_MATCHER(hasIncrement);
218  REGISTER_MATCHER(hasIndex);
219  REGISTER_MATCHER(hasInitializer);
220  REGISTER_MATCHER(hasKeywordSelector);
221  REGISTER_MATCHER(hasLHS);
222  REGISTER_MATCHER(hasLocalQualifiers);
223  REGISTER_MATCHER(hasLocalStorage);
224  REGISTER_MATCHER(hasLoopInit);
225  REGISTER_MATCHER(hasLoopVariable);
226  REGISTER_MATCHER(hasMethod);
228  REGISTER_MATCHER(hasNullSelector);
229  REGISTER_MATCHER(hasObjectExpression);
230  REGISTER_MATCHER(hasOperatorName);
232  REGISTER_MATCHER(hasParameter);
234  REGISTER_MATCHER(hasQualifier);
235  REGISTER_MATCHER(hasRangeInit);
236  REGISTER_MATCHER(hasReceiverType);
237  REGISTER_MATCHER(hasRHS);
238  REGISTER_MATCHER(hasSelector);
239  REGISTER_MATCHER(hasSingleDecl);
240  REGISTER_MATCHER(hasSize);
241  REGISTER_MATCHER(hasSizeExpr);
242  REGISTER_MATCHER(hasSourceExpression);
243  REGISTER_MATCHER(hasStaticStorageDuration);
244  REGISTER_MATCHER(hasTargetDecl);
245  REGISTER_MATCHER(hasTemplateArgument);
246  REGISTER_MATCHER(hasThen);
247  REGISTER_MATCHER(hasThreadStorageDuration);
248  REGISTER_MATCHER(hasTrueExpression);
249  REGISTER_MATCHER(hasTypeLoc);
250  REGISTER_MATCHER(hasUnaryOperand);
251  REGISTER_MATCHER(hasUnarySelector);
252  REGISTER_MATCHER(hasValueType);
254  REGISTER_MATCHER(ignoringImpCasts);
255  REGISTER_MATCHER(ignoringParenCasts);
256  REGISTER_MATCHER(ignoringParenImpCasts);
258  REGISTER_MATCHER(incompleteArrayType);
260  REGISTER_MATCHER(injectedClassNameType);
261  REGISTER_MATCHER(innerType);
263  REGISTER_MATCHER(isAnonymous);
264  REGISTER_MATCHER(isArrow);
265  REGISTER_MATCHER(isBaseInitializer);
266  REGISTER_MATCHER(isCatchAll);
267  REGISTER_MATCHER(isClass);
268  REGISTER_MATCHER(isConst);
269  REGISTER_MATCHER(isConstQualified);
270  REGISTER_MATCHER(isCopyConstructor);
271  REGISTER_MATCHER(isDefaultConstructor);
272  REGISTER_MATCHER(isDefinition);
273  REGISTER_MATCHER(isDeleted);
274  REGISTER_MATCHER(isExceptionVariable);
275  REGISTER_MATCHER(isExplicit);
276  REGISTER_MATCHER(isExplicitTemplateSpecialization);
277  REGISTER_MATCHER(isExpr);
279  REGISTER_MATCHER(isFinal);
280  REGISTER_MATCHER(isInline);
281  REGISTER_MATCHER(isImplicit);
282  REGISTER_MATCHER(isExpansionInFileMatching);
283  REGISTER_MATCHER(isExpansionInMainFile);
284  REGISTER_MATCHER(isInstantiated);
285  REGISTER_MATCHER(isExpansionInSystemHeader);
286  REGISTER_MATCHER(isInteger);
287  REGISTER_MATCHER(isIntegral);
288  REGISTER_MATCHER(isInTemplateInstantiation);
289  REGISTER_MATCHER(isListInitialization);
290  REGISTER_MATCHER(isMemberInitializer);
291  REGISTER_MATCHER(isMoveConstructor);
292  REGISTER_MATCHER(isNoThrow);
293  REGISTER_MATCHER(isOverride);
294  REGISTER_MATCHER(isPrivate);
295  REGISTER_MATCHER(isProtected);
296  REGISTER_MATCHER(isPublic);
297  REGISTER_MATCHER(isPure);
298  REGISTER_MATCHER(isStruct);
300  REGISTER_MATCHER(isUnion);
301  REGISTER_MATCHER(isVariadic);
302  REGISTER_MATCHER(isVirtual);
303  REGISTER_MATCHER(isVolatileQualified);
304  REGISTER_MATCHER(isWritten);
307  REGISTER_MATCHER(lValueReferenceType);
308  REGISTER_MATCHER(matchesName);
309  REGISTER_MATCHER(matchesSelector);
311  REGISTER_MATCHER(member);
313  REGISTER_MATCHER(memberPointerType);
317  REGISTER_MATCHER(namesType);
321  REGISTER_MATCHER(numSelectorArgs);
322  REGISTER_MATCHER(ofClass);
325  REGISTER_MATCHER(objcObjectPointerType);
326  REGISTER_MATCHER(on);
327  REGISTER_MATCHER(onImplicitObjectArgument);
328  REGISTER_MATCHER(parameterCountIs);
329  REGISTER_MATCHER(parenType);
331  REGISTER_MATCHER(pointee);
332  REGISTER_MATCHER(pointerType);
335  REGISTER_MATCHER(recordType);
336  REGISTER_MATCHER(referenceType);
337  REGISTER_MATCHER(refersToDeclaration);
338  REGISTER_MATCHER(refersToIntegralType);
339  REGISTER_MATCHER(refersToType);
340  REGISTER_MATCHER(returns);
342  REGISTER_MATCHER(rValueReferenceType);
344  REGISTER_MATCHER(specifiesNamespace);
345  REGISTER_MATCHER(specifiesType);
346  REGISTER_MATCHER(specifiesTypeLoc);
347  REGISTER_MATCHER(statementCountIs);
352  REGISTER_MATCHER(substTemplateTypeParmType);
356  REGISTER_MATCHER(templateArgumentCountIs);
357  REGISTER_MATCHER(templateSpecializationType);
358  REGISTER_MATCHER(templateTypeParmType);
359  REGISTER_MATCHER(throughUsingDecl);
360  REGISTER_MATCHER(to);
364  REGISTER_MATCHER(typedefType);
368  REGISTER_MATCHER(unaryTransformType);
377  REGISTER_MATCHER(variableArrayType);
378  REGISTER_MATCHER(voidType);
380  REGISTER_MATCHER(withInitializer);
381 }
382 
383 RegistryMaps::~RegistryMaps() {
384  llvm::DeleteContainerSeconds(Constructors);
385 }
386 
387 static llvm::ManagedStatic<RegistryMaps> RegistryData;
388 
389 } // anonymous namespace
390 
391 // static
392 llvm::Optional<MatcherCtor> Registry::lookupMatcherCtor(StringRef MatcherName) {
393  ConstructorMap::const_iterator it =
394  RegistryData->constructors().find(MatcherName);
395  return it == RegistryData->constructors().end()
397  : it->second;
398 }
399 
400 namespace {
401 
402 llvm::raw_ostream &operator<<(llvm::raw_ostream &OS,
403  const std::set<ASTNodeKind> &KS) {
404  unsigned Count = 0;
405  for (std::set<ASTNodeKind>::const_iterator I = KS.begin(), E = KS.end();
406  I != E; ++I) {
407  if (I != KS.begin())
408  OS << "|";
409  if (Count++ == 3) {
410  OS << "...";
411  break;
412  }
413  OS << *I;
414  }
415  return OS;
416 }
417 
418 } // namespace
419 
420 std::vector<ArgKind> Registry::getAcceptedCompletionTypes(
421  ArrayRef<std::pair<MatcherCtor, unsigned>> Context) {
422  ASTNodeKind InitialTypes[] = {
423  ASTNodeKind::getFromNodeKind<Decl>(),
424  ASTNodeKind::getFromNodeKind<QualType>(),
425  ASTNodeKind::getFromNodeKind<Type>(),
426  ASTNodeKind::getFromNodeKind<Stmt>(),
427  ASTNodeKind::getFromNodeKind<NestedNameSpecifier>(),
428  ASTNodeKind::getFromNodeKind<NestedNameSpecifierLoc>(),
429  ASTNodeKind::getFromNodeKind<TypeLoc>()};
430 
431  // Starting with the above seed of acceptable top-level matcher types, compute
432  // the acceptable type set for the argument indicated by each context element.
433  std::set<ArgKind> TypeSet(std::begin(InitialTypes), std::end(InitialTypes));
434  for (const auto &CtxEntry : Context) {
435  MatcherCtor Ctor = CtxEntry.first;
436  unsigned ArgNumber = CtxEntry.second;
437  std::vector<ArgKind> NextTypeSet;
438  for (const ArgKind &Kind : TypeSet) {
439  if (Kind.getArgKind() == Kind.AK_Matcher &&
440  Ctor->isConvertibleTo(Kind.getMatcherKind()) &&
441  (Ctor->isVariadic() || ArgNumber < Ctor->getNumArgs()))
442  Ctor->getArgKinds(Kind.getMatcherKind(), ArgNumber, NextTypeSet);
443  }
444  TypeSet.clear();
445  TypeSet.insert(NextTypeSet.begin(), NextTypeSet.end());
446  }
447  return std::vector<ArgKind>(TypeSet.begin(), TypeSet.end());
448 }
449 
450 std::vector<MatcherCompletion>
451 Registry::getMatcherCompletions(ArrayRef<ArgKind> AcceptedTypes) {
452  std::vector<MatcherCompletion> Completions;
453 
454  // Search the registry for acceptable matchers.
455  for (const auto &M : RegistryData->constructors()) {
456  const auto *Matcher = M.getValue();
457  StringRef Name = M.getKey();
458 
459  std::set<ASTNodeKind> RetKinds;
460  unsigned NumArgs = Matcher->isVariadic() ? 1 : Matcher->getNumArgs();
461  bool IsPolymorphic = Matcher->isPolymorphic();
462  std::vector<std::vector<ArgKind>> ArgsKinds(NumArgs);
463  unsigned MaxSpecificity = 0;
464  for (const ArgKind& Kind : AcceptedTypes) {
465  if (Kind.getArgKind() != Kind.AK_Matcher)
466  continue;
467  unsigned Specificity;
468  ASTNodeKind LeastDerivedKind;
469  if (Matcher->isConvertibleTo(Kind.getMatcherKind(), &Specificity,
470  &LeastDerivedKind)) {
471  if (MaxSpecificity < Specificity)
472  MaxSpecificity = Specificity;
473  RetKinds.insert(LeastDerivedKind);
474  for (unsigned Arg = 0; Arg != NumArgs; ++Arg)
475  Matcher->getArgKinds(Kind.getMatcherKind(), Arg, ArgsKinds[Arg]);
476  if (IsPolymorphic)
477  break;
478  }
479  }
480 
481  if (!RetKinds.empty() && MaxSpecificity > 0) {
482  std::string Decl;
483  llvm::raw_string_ostream OS(Decl);
484 
485  if (IsPolymorphic) {
486  OS << "Matcher<T> " << Name << "(Matcher<T>";
487  } else {
488  OS << "Matcher<" << RetKinds << "> " << Name << "(";
489  for (const std::vector<ArgKind> &Arg : ArgsKinds) {
490  if (&Arg != &ArgsKinds[0])
491  OS << ", ";
492 
493  bool FirstArgKind = true;
494  std::set<ASTNodeKind> MatcherKinds;
495  // Two steps. First all non-matchers, then matchers only.
496  for (const ArgKind &AK : Arg) {
497  if (AK.getArgKind() == ArgKind::AK_Matcher) {
498  MatcherKinds.insert(AK.getMatcherKind());
499  } else {
500  if (!FirstArgKind) OS << "|";
501  FirstArgKind = false;
502  OS << AK.asString();
503  }
504  }
505  if (!MatcherKinds.empty()) {
506  if (!FirstArgKind) OS << "|";
507  OS << "Matcher<" << MatcherKinds << ">";
508  }
509  }
510  }
511  if (Matcher->isVariadic())
512  OS << "...";
513  OS << ")";
514 
515  std::string TypedText = Name;
516  TypedText += "(";
517  if (ArgsKinds.empty())
518  TypedText += ")";
519  else if (ArgsKinds[0][0].getArgKind() == ArgKind::AK_String)
520  TypedText += "\"";
521 
522  Completions.emplace_back(TypedText, OS.str(), MaxSpecificity);
523  }
524  }
525 
526  return Completions;
527 }
528 
529 // static
530 VariantMatcher Registry::constructMatcher(MatcherCtor Ctor,
531  SourceRange NameRange,
533  Diagnostics *Error) {
534  return Ctor->create(NameRange, Args, Error);
535 }
536 
537 // static
538 VariantMatcher Registry::constructBoundMatcher(MatcherCtor Ctor,
539  SourceRange NameRange,
540  StringRef BindID,
542  Diagnostics *Error) {
543  VariantMatcher Out = constructMatcher(Ctor, NameRange, Args, Error);
544  if (Out.isNull()) return Out;
545 
547  if (Result.hasValue()) {
548  llvm::Optional<DynTypedMatcher> Bound = Result->tryBind(BindID);
549  if (Bound.hasValue()) {
550  return VariantMatcher::SingleMatcher(*Bound);
551  }
552  }
553  Error->addError(NameRange, Error->ET_RegistryNotBindable);
554  return VariantMatcher();
555 }
556 
557 } // namespace dynamic
558 } // namespace ast_matchers
559 } // namespace clang
internal::TrueMatcher anything()
Matches any node.
Definition: ASTMatchers.h:145
const internal::ArgumentAdaptingMatcherFunc< internal::HasParentMatcher, internal::TypeList< Decl, NestedNameSpecifierLoc, Stmt, TypeLoc >, internal::TypeList< Decl, NestedNameSpecifierLoc, Stmt, TypeLoc > > LLVM_ATTRIBUTE_UNUSED hasParent
Matches AST nodes that have a parent that matches the provided matcher.
Definition: ASTMatchers.h:2074
const internal::VariadicDynCastAllOfMatcher< Stmt, Expr > expr
Matches expressions.
Definition: ASTMatchers.h:1192
const internal::ArgumentAdaptingMatcherFunc< internal::HasAncestorMatcher, internal::TypeList< Decl, NestedNameSpecifierLoc, Stmt, TypeLoc >, internal::TypeList< Decl, NestedNameSpecifierLoc, Stmt, TypeLoc > > LLVM_ATTRIBUTE_UNUSED hasAncestor
Matches AST nodes that have an ancestor that matches the provided matcher.
Definition: ASTMatchers.h:2091
const internal::VariadicDynCastAllOfMatcher< Stmt, BreakStmt > breakStmt
Matches break statements.
Definition: ASTMatchers.h:1316
const internal::VariadicDynCastAllOfMatcher< Stmt, DoStmt > doStmt
Matches do statements.
Definition: ASTMatchers.h:1306
const internal::ArgumentAdaptingMatcherFunc< internal::HasDescendantMatcher > LLVM_ATTRIBUTE_UNUSED hasDescendant
Matches AST nodes that have descendant AST nodes that match the provided matcher. ...
Definition: ASTMatchers.h:1988
const internal::VariadicAllOfMatcher< Stmt > stmt
Matches statements.
Definition: ASTMatchers.h:876
Registry of all known matchers.
internal::PolymorphicMatcherWithParam1< internal::HasDeclarationMatcher, internal::Matcher< Decl >, void(internal::HasDeclarationSupportedTypes)> hasDeclaration(const internal::Matcher< Decl > &InnerMatcher)
Matches a node if the declaration associated with that node matches the given matcher.
Definition: ASTMatchers.h:2127
const internal::VariadicDynCastAllOfMatcher< Decl, CXXMethodDecl > cxxMethodDecl
Matches method declarations.
Definition: ASTMatchers.h:808
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXNullPtrLiteralExpr > cxxNullPtrLiteralExpr
Matches nullptr literal.
Definition: ASTMatchers.h:1526
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXDynamicCastExpr > cxxDynamicCastExpr
Matches a dynamic_cast expression.
Definition: ASTMatchers.h:1625
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:77
const internal::ArgumentAdaptingMatcherFunc< internal::ForEachMatcher > LLVM_ATTRIBUTE_UNUSED forEach
Matches AST nodes that have child AST nodes that match the provided matcher.
Definition: ASTMatchers.h:2008
const internal::VariadicDynCastAllOfMatcher< Stmt, LabelStmt > labelStmt
Matches label statements.
Definition: ASTMatchers.h:1358
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXThisExpr > cxxThisExpr
Matches implicit and explicit this expressions.
Definition: ASTMatchers.h:1087
const internal::VariadicDynCastAllOfMatcher< Decl, UsingDecl > usingDecl
Matches using declarations.
Definition: ASTMatchers.h:1002
const internal::VariadicDynCastAllOfMatcher< Decl, ValueDecl > valueDecl
Matches any value declaration.
Definition: ASTMatchers.h:750
const internal::VariadicDynCastAllOfMatcher< Decl, ClassTemplateDecl > classTemplateDecl
Matches C++ class template declarations.
Definition: ASTMatchers.h:340
const internal::VariadicDynCastAllOfMatcher< Decl, EnumConstantDecl > enumConstantDecl
Matches enum constants.
Definition: ASTMatchers.h:800
const DynTypedMatcher *const Matcher
const internal::VariadicDynCastAllOfMatcher< Decl, VarDecl > varDecl
Matches variable declarations.
Definition: ASTMatchers.h:828
iterator begin() const
Definition: Type.h:4072
const internal::VariadicDynCastAllOfMatcher< Stmt, AsmStmt > asmStmt
Matches asm statements.
Definition: ASTMatchers.h:1452
const internal::VariadicDynCastAllOfMatcher< Stmt, ConditionalOperator > conditionalOperator
Matches conditional operator expressions.
Definition: ASTMatchers.h:1561
const internal::VariadicDynCastAllOfMatcher< Stmt, UnaryExprOrTypeTraitExpr > unaryExprOrTypeTraitExpr
Matches sizeof (C99), alignof (C++11) and vec_step (OpenCL)
Definition: ASTMatchers.h:1776
const internal::VariadicAllOfMatcher< QualType > qualType
Matches QualTypes in the clang AST.
Definition: ASTMatchers.h:1720
const internal::VariadicDynCastAllOfMatcher< Stmt, CaseStmt > caseStmt
Matches case statements inside switch statements.
Definition: ASTMatchers.h:1388
#define REGISTER_OVERLOADED_2(name)
Definition: Registry.cpp:61
class LLVM_ALIGNAS(8) DependentTemplateSpecializationType const IdentifierInfo * Name
Represents a template specialization type whose template cannot be resolved, e.g. ...
Definition: Type.h:4381
const internal::VariadicAllOfMatcher< Decl > decl
Matches declarations.
Definition: ASTMatchers.h:259
const internal::VariadicDynCastAllOfMatcher< Stmt, ObjCMessageExpr > objcMessageExpr
Matches ObjectiveC Message invocation expressions.
Definition: ASTMatchers.h:943
const internal::VariadicDynCastAllOfMatcher< Decl, CXXDestructorDecl > cxxDestructorDecl
Matches explicit C++ destructor declarations.
Definition: ASTMatchers.h:778
const internal::VariadicDynCastAllOfMatcher< Stmt, WhileStmt > whileStmt
Matches while statements.
Definition: ASTMatchers.h:1296
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXTryStmt > cxxTryStmt
Matches try statements.
Definition: ASTMatchers.h:1424
const internal::VariadicDynCastAllOfMatcher< Stmt, CompoundLiteralExpr > compoundLiteralExpr
Matches compound (i.e.
Definition: ASTMatchers.h:1521
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXReinterpretCastExpr > cxxReinterpretCastExpr
Matches a reinterpret_cast expression.
Definition: ASTMatchers.h:1592
const internal::VariadicDynCastAllOfMatcher< Stmt, NullStmt > nullStmt
Matches null statements.
Definition: ASTMatchers.h:1442
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXNewExpr > cxxNewExpr
Matches new expressions.
Definition: ASTMatchers.h:1131
const internal::VariadicDynCastAllOfMatcher< Decl, NamedDecl > namedDecl
Matches a declaration of anything that could have a name.
Definition: ASTMatchers.h:283
const internal::VariadicDynCastAllOfMatcher< Decl, TypedefDecl > typedefDecl
Matches typedef declarations.
Definition: ASTMatchers.h:169
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXMemberCallExpr > cxxMemberCallExpr
Matches member call expressions.
Definition: ASTMatchers.h:930
const internal::VariadicOperatorMatcherFunc< 2, UINT_MAX > eachOf
Matches if any of the given matchers matches.
Definition: ASTMatchers.h:1747
const internal::VariadicDynCastAllOfMatcher< Stmt, DefaultStmt > defaultStmt
Matches default statements inside switch statements.
Definition: ASTMatchers.h:1398
const internal::VariadicDynCastAllOfMatcher< Stmt, ExprWithCleanups > exprWithCleanups
Matches expressions that introduce cleanups to be run at the end of the sub-expression's evaluation...
Definition: ASTMatchers.h:965
const internal::VariadicDynCastAllOfMatcher< Stmt, CompoundStmt > compoundStmt
Matches compound statements.
Definition: ASTMatchers.h:1406
const internal::VariadicDynCastAllOfMatcher< Decl, ParmVarDecl > parmVarDecl
Matches parameter variable declarations.
Definition: ASTMatchers.h:376
const internal::VariadicDynCastAllOfMatcher< Stmt, ReturnStmt > returnStmt
Matches return statements.
Definition: ASTMatchers.h:1336
const internal::VariadicDynCastAllOfMatcher< Decl, TranslationUnitDecl > translationUnitDecl
Matches the top declaration context.
Definition: ASTMatchers.h:159
const internal::VariadicDynCastAllOfMatcher< Decl, FriendDecl > friendDecl
Matches friend declarations.
Definition: ASTMatchers.h:866
internal::Matcher< Stmt > sizeOfExpr(const internal::Matcher< UnaryExprOrTypeTraitExpr > &InnerMatcher)
Same as unaryExprOrTypeTraitExpr, but only matching sizeof.
Definition: ASTMatchers.h:1815
Functions templates and classes to wrap matcher construct functions.
const internal::VariadicDynCastAllOfMatcher< Decl, StaticAssertDecl > staticAssertDecl
Matches a C++ static_assert declaration.
Definition: ASTMatchers.h:1578
iterator end() const
const internal::VariadicDynCastAllOfMatcher< Stmt, DeclStmt > declStmt
Matches declaration statements.
Definition: ASTMatchers.h:888
internal::PolymorphicMatcherWithParam1< internal::HasOverloadedOperatorNameMatcher, StringRef, AST_POLYMORPHIC_SUPPORTED_TYPES(CXXOperatorCallExpr, FunctionDecl)> hasOverloadedOperatorName(StringRef Name)
Matches overloaded operator names.
Definition: ASTMatchers.h:1885
detail::InMemoryDirectory::const_iterator I
const internal::VariadicDynCastAllOfMatcher< Stmt, UnaryOperator > unaryOperator
Matches unary operator expressions.
Definition: ASTMatchers.h:1551
const internal::VariadicDynCastAllOfMatcher< Stmt, MemberExpr > memberExpr
Matches member expressions.
Definition: ASTMatchers.h:901
bool isNull() const
Whether the matcher is null.
Definition: VariantValue.h:158
const internal::VariadicDynCastAllOfMatcher< Stmt, InitListExpr > initListExpr
Matches init list expressions.
Definition: ASTMatchers.h:977
const internal::VariadicOperatorMatcherFunc< 2, UINT_MAX > allOf
Matches if all given matchers match.
Definition: ASTMatchers.h:1761
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXFunctionalCastExpr > cxxFunctionalCastExpr
Matches functional cast expressions.
Definition: ASTMatchers.h:1707
const internal::VariadicDynCastAllOfMatcher< Stmt, ArraySubscriptExpr > arraySubscriptExpr
Matches array subscript expressions.
Definition: ASTMatchers.h:1153
ASTContext * Context
const internal::VariadicDynCastAllOfMatcher< Stmt, LambdaExpr > lambdaExpr
Matches lambda expressions.
Definition: ASTMatchers.h:919
const internal::VariadicDynCastAllOfMatcher< Stmt, BinaryOperator > binaryOperator
Matches binary operator expressions.
Definition: ASTMatchers.h:1541
const internal::VariadicAllOfMatcher< NestedNameSpecifier > nestedNameSpecifier
Matches nested name specifiers.
Definition: ASTMatchers.h:4335
const internal::ArgumentAdaptingMatcherFunc< internal::ForEachDescendantMatcher > LLVM_ATTRIBUTE_UNUSED forEachDescendant
Matches AST nodes that have descendant AST nodes that match the provided matcher. ...
Definition: ASTMatchers.h:2037
const internal::VariadicDynCastAllOfMatcher< Stmt, IntegerLiteral > integerLiteral
Matches integer literals of all sizes / encodings, e.g.
Definition: ASTMatchers.h:1493
const internal::VariadicDynCastAllOfMatcher< Stmt, ForStmt > forStmt
Matches for statements.
Definition: ASTMatchers.h:1218
MatchFinder::MatchCallback * Callback
const internal::VariadicOperatorMatcherFunc< 1, 1 > unless
Matches if the provided matcher does not match.
Definition: ASTMatchers.h:2102
const internal::VariadicAllOfMatcher< NestedNameSpecifierLoc > nestedNameSpecifierLoc
Same as nestedNameSpecifier but matches NestedNameSpecifierLoc.
Definition: ASTMatchers.h:4339
const internal::VariadicDynCastAllOfMatcher< Stmt, GotoStmt > gotoStmt
Matches goto statements.
Definition: ASTMatchers.h:1347
#define REGISTER_MATCHER(name)
Definition: Registry.cpp:53
const internal::VariadicDynCastAllOfMatcher< Decl, RecordDecl > recordDecl
Matches class, struct, and union declarations.
Definition: ASTMatchers.h:319
virtual VariantMatcher create(SourceRange NameRange, ArrayRef< ParserValue > Args, Diagnostics *Error) const =0
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXTemporaryObjectExpr > cxxTemporaryObjectExpr
Matches functional cast expressions having N != 1 arguments.
Definition: ASTMatchers.h:1717
const internal::VariadicDynCastAllOfMatcher< Stmt, MaterializeTemporaryExpr > materializeTemporaryExpr
Matches nodes where temporaries are materialized.
Definition: ASTMatchers.h:1121
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXForRangeStmt > cxxForRangeStmt
Matches range-based for statements.
Definition: ASTMatchers.h:1258
class LLVM_ALIGNAS(8) TemplateSpecializationType unsigned NumArgs
Represents a type template specialization; the template must be a class template, a type alias templa...
Definition: Type.h:3988
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXStaticCastExpr > cxxStaticCastExpr
Matches a C++ static_cast expression.
Definition: ASTMatchers.h:1609
The result type of a method or function.
bool isTemplateInstantiation(TemplateSpecializationKind Kind)
Determine whether this template specialization kind refers to an instantiation of an entity (as oppos...
Definition: Specifiers.h:162
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXDeleteExpr > cxxDeleteExpr
Matches delete expressions.
Definition: ASTMatchers.h:1141
const internal::VariadicDynCastAllOfMatcher< Stmt, SwitchCase > switchCase
Matches case and default statements inside switch statements.
Definition: ASTMatchers.h:1378
Helper class to manage error messages.
Definition: Diagnostics.h:51
const internal::VariadicDynCastAllOfMatcher< Decl, ObjCInterfaceDecl > objcInterfaceDecl
Matches Objective-C interface declarations.
Definition: ASTMatchers.h:954
const internal::VariadicAllOfMatcher< TypeLoc > typeLoc
Matches TypeLocs in the clang AST.
Definition: ASTMatchers.h:1726
ArgStream addError(SourceRange Range, ErrorType Error)
Add an error to the diagnostics.
Definition: Diagnostics.cpp:66
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXBindTemporaryExpr > cxxBindTemporaryExpr
Matches nodes where temporaries are created.
Definition: ASTMatchers.h:1099
const internal::VariadicDynCastAllOfMatcher< Decl, UnresolvedUsingValueDecl > unresolvedUsingValueDecl
Matches unresolved using value declarations.
Definition: ASTMatchers.h:1030
Kind
const internal::VariadicDynCastAllOfMatcher< Stmt, CharacterLiteral > characterLiteral
Matches character literals (also matches wchar_t).
Definition: ASTMatchers.h:1485
const internal::VariadicDynCastAllOfMatcher< Stmt, DeclRefExpr > declRefExpr
Matches expressions that refer to declarations.
Definition: ASTMatchers.h:1201
const internal::VariadicAllOfMatcher< CXXCtorInitializer > cxxCtorInitializer
Matches constructor initializers.
Definition: ASTMatchers.h:402
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXThrowExpr > cxxThrowExpr
Matches throw expressions.
Definition: ASTMatchers.h:1433
const internal::VariadicDynCastAllOfMatcher< Stmt, ImplicitCastExpr > implicitCastExpr
Matches the implicit cast nodes of Clang's AST.
Definition: ASTMatchers.h:1680
const internal::ArgumentAdaptingMatcherFunc< internal::HasMatcher > LLVM_ATTRIBUTE_UNUSED has
Matches AST nodes that have child AST nodes that match the provided matcher.
Definition: ASTMatchers.h:1971
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXOperatorCallExpr > cxxOperatorCallExpr
Matches overloaded operator calls.
Definition: ASTMatchers.h:1184
const internal::VariadicDynCastAllOfMatcher< Decl, ClassTemplateSpecializationDecl > classTemplateSpecializationDecl
Matches C++ class template specializations.
Definition: ASTMatchers.h:354
internal::Matcher< Stmt > alignOfExpr(const internal::Matcher< UnaryExprOrTypeTraitExpr > &InnerMatcher)
Same as unaryExprOrTypeTraitExpr, but only matching alignof.
Definition: ASTMatchers.h:1807
const internal::VariadicDynCastAllOfMatcher< Decl, FunctionDecl > functionDecl
Matches function declarations.
Definition: ASTMatchers.h:846
const internal::VariadicDynCastAllOfMatcher< Decl, CXXConstructorDecl > cxxConstructorDecl
Matches C++ constructor declarations.
Definition: ASTMatchers.h:765
const internal::VariadicDynCastAllOfMatcher< Decl, AccessSpecDecl > accessSpecDecl
Matches C++ access specifier declarations.
Definition: ASTMatchers.h:391
virtual bool isVariadic() const =0
Returns whether the matcher is variadic.
const internal::VariadicDynCastAllOfMatcher< Stmt, ExplicitCastExpr > explicitCastExpr
Matches explicit cast expressions.
Definition: ASTMatchers.h:1672
const internal::VariadicDynCastAllOfMatcher< Stmt, SubstNonTypeTemplateParmExpr > substNonTypeTemplateParmExpr
Matches substitutions of non-type template parameters.
Definition: ASTMatchers.h:991
virtual unsigned getNumArgs() const =0
Returns the number of arguments accepted by the matcher if not variadic.
const internal::VariadicDynCastAllOfMatcher< Stmt, StringLiteral > stringLiteral
Matches string literals (also matches wide string literals).
Definition: ASTMatchers.h:1472
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXDefaultArgExpr > cxxDefaultArgExpr
Matches the value of a default argument at the call site.
Definition: ASTMatchers.h:1166
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXConstCastExpr > cxxConstCastExpr
Matches a const_cast expression.
Definition: ASTMatchers.h:1637
const internal::VariadicDynCastAllOfMatcher< Decl, FunctionTemplateDecl > functionTemplateDecl
Matches C++ function template declarations.
Definition: ASTMatchers.h:856
const internal::VariadicDynCastAllOfMatcher< Decl, EnumDecl > enumDecl
Matches enum declarations.
Definition: ASTMatchers.h:788
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
Definition: ASTMatchers.h:1723
detail::InMemoryDirectory::const_iterator E
const internal::VariadicDynCastAllOfMatcher< Stmt, CUDAKernelCallExpr > cudaKernelCallExpr
Matches CUDA kernel call expression.
Definition: ASTMatchers.h:4666
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXUnresolvedConstructExpr > cxxUnresolvedConstructExpr
Matches unresolved constructor call expressions.
Definition: ASTMatchers.h:1075
const internal::VariadicDynCastAllOfMatcher< Decl, UsingDirectiveDecl > usingDirectiveDecl
Matches using namespace declarations.
Definition: ASTMatchers.h:1015
const internal::VariadicDynCastAllOfMatcher< Stmt, CStyleCastExpr > cStyleCastExpr
Matches a C-style cast expression.
Definition: ASTMatchers.h:1647
const internal::VariadicDynCastAllOfMatcher< Decl, UnresolvedUsingTypenameDecl > unresolvedUsingTypenameDecl
Matches unresolved using value declarations that involve the typename.
Definition: ASTMatchers.h:1049
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXConstructExpr > cxxConstructExpr
Matches constructor call expressions (including implicit ones).
Definition: ASTMatchers.h:1063
const internal::VariadicDynCastAllOfMatcher< Stmt, FloatingLiteral > floatLiteral
Matches float literals of all sizes / encodings, e.g.
Definition: ASTMatchers.h:1504
const internal::VariadicDynCastAllOfMatcher< Stmt, IfStmt > ifStmt
Matches if statements.
Definition: ASTMatchers.h:1209
const internal::VariadicDynCastAllOfMatcher< Stmt, CallExpr > callExpr
Matches call expressions.
Definition: ASTMatchers.h:911
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXCatchStmt > cxxCatchStmt
Matches catch statements.
Definition: ASTMatchers.h:1415
internal::Matcher< BinaryOperator > hasEitherOperand(const internal::Matcher< Expr > &InnerMatcher)
Matches if either the left hand side or the right hand side of a binary operator matches.
Definition: ASTMatchers.h:3232
const internal::VariadicOperatorMatcherFunc< 2, UINT_MAX > anyOf
Matches if any of the given matchers matches.
Definition: ASTMatchers.h:1754
const internal::VariadicDynCastAllOfMatcher< Stmt, ContinueStmt > continueStmt
Matches continue statements.
Definition: ASTMatchers.h:1326
const internal::VariadicAllOfMatcher< TemplateArgument > templateArgument
Matches template arguments.
Definition: ASTMatchers.h:413
const internal::VariadicDynCastAllOfMatcher< Stmt, CastExpr > castExpr
Matches any cast nodes of Clang's AST.
Definition: ASTMatchers.h:1695
internal::Matcher< NamedDecl > hasName(const std::string &Name)
Matches NamedDecl nodes that have the specified name.
Definition: ASTMatchers.h:1836
raw_ostream & operator<<(raw_ostream &OS, ASTNodeKind K)
const internal::VariadicDynCastAllOfMatcher< Decl, CXXConversionDecl > cxxConversionDecl
Matches conversion operator declarations.
Definition: ASTMatchers.h:817
const internal::VariadicDynCastAllOfMatcher< Decl, NamespaceDecl > namespaceDecl
Matches a declaration of a namespace.
Definition: ASTMatchers.h:294
const internal::VariadicDynCastAllOfMatcher< Stmt, UserDefinedLiteral > userDefinedLiteral
Matches user defined literal operator call.
Definition: ASTMatchers.h:1511
const internal::VariadicDynCastAllOfMatcher< Stmt, SwitchStmt > switchStmt
Matches switch statements.
Definition: ASTMatchers.h:1368
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXBoolLiteralExpr > cxxBoolLiteral
Matches bool literals.
Definition: ASTMatchers.h:1462
const internal::VariadicDynCastAllOfMatcher< Decl, FieldDecl > fieldDecl
Matches field declarations.
Definition: ASTMatchers.h:838
ConstructorMap Constructors
Definition: Registry.cpp:44
virtual void getArgKinds(ast_type_traits::ASTNodeKind ThisKind, unsigned ArgNo, std::vector< ArgKind > &ArgKinds) const =0
Given that the matcher is being converted to type ThisKind, append the set of argument types accepted...
const internal::VariadicDynCastAllOfMatcher< Decl, NamespaceAliasDecl > namespaceAliasDecl
Matches a declaration of a namespace alias.
Definition: ASTMatchers.h:306
virtual bool isConvertibleTo(ast_type_traits::ASTNodeKind Kind, unsigned *Specificity=nullptr, ast_type_traits::ASTNodeKind *LeastDerivedKind=nullptr) const =0
Returns whether this matcher is convertible to the given type.
const internal::VariadicDynCastAllOfMatcher< Decl, CXXRecordDecl > cxxRecordDecl
Matches C++ class declarations.
Definition: ASTMatchers.h:330
const internal::VariadicDynCastAllOfMatcher< Decl, DeclaratorDecl > declaratorDecl
Matches declarator declarations (field, variable, function and non-type template parameter declaratio...
Definition: ASTMatchers.h:366
llvm::Optional< DynTypedMatcher > getSingleMatcher() const
Return a single matcher, if there is no ambiguity.
static bool isExternC(const NamedDecl *ND)
Definition: Mangle.cpp:59