clang 20.0.0git
Registry.cpp
Go to the documentation of this file.
1//===- Registry.cpp - Matcher registry ------------------------------------===//
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/// Registry map populated at static initialization time.
11//
12//===----------------------------------------------------------------------===//
13
15#include "Marshallers.h"
20#include "llvm/ADT/STLExtras.h"
21#include "llvm/ADT/StringMap.h"
22#include "llvm/ADT/StringRef.h"
23#include "llvm/Support/ManagedStatic.h"
24#include "llvm/Support/raw_ostream.h"
25#include <cassert>
26#include <iterator>
27#include <memory>
28#include <optional>
29#include <set>
30#include <string>
31#include <utility>
32#include <vector>
33
34namespace clang {
35namespace ast_matchers {
36namespace dynamic {
37
38namespace {
39
40using internal::MatcherDescriptor;
41
42using ConstructorMap =
43 llvm::StringMap<std::unique_ptr<const MatcherDescriptor>>;
44
45class RegistryMaps {
46public:
47 RegistryMaps();
48 ~RegistryMaps();
49
50 const ConstructorMap &constructors() const { return Constructors; }
51
52private:
53 void registerMatcher(StringRef MatcherName,
54 std::unique_ptr<MatcherDescriptor> Callback);
55
56 ConstructorMap Constructors;
57};
58
59} // namespace
60
61void RegistryMaps::registerMatcher(
62 StringRef MatcherName, std::unique_ptr<MatcherDescriptor> Callback) {
63 assert(!Constructors.contains(MatcherName));
64 Constructors[MatcherName] = std::move(Callback);
65}
66
67#define REGISTER_MATCHER(name) \
68 registerMatcher(#name, internal::makeMatcherAutoMarshall( \
69 ::clang::ast_matchers::name, #name));
70
71#define REGISTER_MATCHER_OVERLOAD(name) \
72 registerMatcher(#name, \
73 std::make_unique<internal::OverloadedMatcherDescriptor>(name##Callbacks))
74
75#define SPECIFIC_MATCHER_OVERLOAD(name, Id) \
76 static_cast<::clang::ast_matchers::name##_Type##Id>( \
77 ::clang::ast_matchers::name)
78
79#define MATCHER_OVERLOAD_ENTRY(name, Id) \
80 internal::makeMatcherAutoMarshall(SPECIFIC_MATCHER_OVERLOAD(name, Id), \
81 #name)
82
83#define REGISTER_OVERLOADED_2(name) \
84 do { \
85 std::unique_ptr<MatcherDescriptor> name##Callbacks[] = { \
86 MATCHER_OVERLOAD_ENTRY(name, 0), \
87 MATCHER_OVERLOAD_ENTRY(name, 1)}; \
88 REGISTER_MATCHER_OVERLOAD(name); \
89 } while (false)
90
91#define REGISTER_REGEX_MATCHER(name) \
92 registerMatcher(#name, internal::makeMatcherRegexMarshall(name, name))
93
94/// Generate a registry map with all the known matchers.
95/// Please keep sorted alphabetically!
96RegistryMaps::RegistryMaps() {
97 // TODO: Here is the list of the missing matchers, grouped by reason.
98 //
99 // Polymorphic + argument overload:
100 // findAll
101 //
102 // Other:
103 // equalsNode
104
105 registerMatcher("mapAnyOf",
106 std::make_unique<internal::MapAnyOfBuilderDescriptor>());
107
108 REGISTER_OVERLOADED_2(callee);
109 REGISTER_OVERLOADED_2(hasPrefix);
110 REGISTER_OVERLOADED_2(hasType);
111 REGISTER_OVERLOADED_2(ignoringParens);
112 REGISTER_OVERLOADED_2(isDerivedFrom);
113 REGISTER_OVERLOADED_2(isDirectlyDerivedFrom);
114 REGISTER_OVERLOADED_2(isSameOrDerivedFrom);
116 REGISTER_OVERLOADED_2(pointsTo);
117 REGISTER_OVERLOADED_2(references);
118 REGISTER_OVERLOADED_2(thisPointerType);
119
120 std::unique_ptr<MatcherDescriptor> equalsCallbacks[] = {
124 };
126
127 REGISTER_REGEX_MATCHER(isExpansionInFileMatching);
128 REGISTER_REGEX_MATCHER(matchesName);
129 REGISTER_REGEX_MATCHER(matchesSelector);
130
139 REGISTER_MATCHER(argumentCountIs);
140 REGISTER_MATCHER(argumentCountAtLeast);
143 REGISTER_MATCHER(asString);
157 REGISTER_MATCHER(booleanType);
162 REGISTER_MATCHER(capturesThis);
163 REGISTER_MATCHER(capturesVar);
179 REGISTER_MATCHER(containsDeclaration);
223 REGISTER_MATCHER(declCountIs);
234 REGISTER_MATCHER(designatorCountIs);
243 REGISTER_MATCHER(equalsBoundNode);
244 REGISTER_MATCHER(equalsIntegralValue);
252 REGISTER_MATCHER(forCallable);
253 REGISTER_MATCHER(forDecomposition);
255 REGISTER_MATCHER(forEachArgumentWithParam);
256 REGISTER_MATCHER(forEachArgumentWithParamType);
257 REGISTER_MATCHER(forEachConstructorInitializer);
259 REGISTER_MATCHER(forEachLambdaCapture);
260 REGISTER_MATCHER(forEachOverridden);
261 REGISTER_MATCHER(forEachSwitchCase);
262 REGISTER_MATCHER(forEachTemplateArgument);
263 REGISTER_MATCHER(forField);
264 REGISTER_MATCHER(forFunction);
276 REGISTER_MATCHER(hasAnyArgument);
277 REGISTER_MATCHER(hasAnyBase);
278 REGISTER_MATCHER(hasAnyBinding);
279 REGISTER_MATCHER(hasAnyBody);
280 REGISTER_MATCHER(hasAnyCapture);
281 REGISTER_MATCHER(hasAnyClause);
282 REGISTER_MATCHER(hasAnyConstructorInitializer);
283 REGISTER_MATCHER(hasAnyDeclaration);
287 REGISTER_MATCHER(hasAnyParameter);
288 REGISTER_MATCHER(hasAnyPlacementArg);
290 REGISTER_MATCHER(hasAnySubstatement);
291 REGISTER_MATCHER(hasAnyTemplateArgument);
292 REGISTER_MATCHER(hasAnyTemplateArgumentLoc);
293 REGISTER_MATCHER(hasAnyUsingShadowDecl);
294 REGISTER_MATCHER(hasArgument);
295 REGISTER_MATCHER(hasArgumentOfType);
296 REGISTER_MATCHER(hasArraySize);
298 REGISTER_MATCHER(hasAutomaticStorageDuration);
299 REGISTER_MATCHER(hasBase);
300 REGISTER_MATCHER(hasBinding);
301 REGISTER_MATCHER(hasBitWidth);
302 REGISTER_MATCHER(hasBody);
303 REGISTER_MATCHER(hasCanonicalType);
304 REGISTER_MATCHER(hasCaseConstant);
305 REGISTER_MATCHER(hasCastKind);
306 REGISTER_MATCHER(hasCondition);
307 REGISTER_MATCHER(hasConditionVariableStatement);
308 REGISTER_MATCHER(hasDecayedType);
309 REGISTER_MATCHER(hasDeclContext);
311 REGISTER_MATCHER(hasDeducedType);
312 REGISTER_MATCHER(hasDefaultArgument);
315 REGISTER_MATCHER(hasDestinationType);
316 REGISTER_MATCHER(hasDirectBase);
317 REGISTER_MATCHER(hasDynamicExceptionSpec);
318 REGISTER_MATCHER(hasEitherOperand);
319 REGISTER_MATCHER(hasElementType);
320 REGISTER_MATCHER(hasElse);
321 REGISTER_MATCHER(hasExplicitSpecifier);
322 REGISTER_MATCHER(hasExternalFormalLinkage);
323 REGISTER_MATCHER(hasFalseExpression);
324 REGISTER_MATCHER(hasFoldInit);
325 REGISTER_MATCHER(hasGlobalStorage);
326 REGISTER_MATCHER(hasImplicitDestinationType);
327 REGISTER_MATCHER(hasInClassInitializer);
328 REGISTER_MATCHER(hasIncrement);
329 REGISTER_MATCHER(hasIndex);
330 REGISTER_MATCHER(hasInit);
331 REGISTER_MATCHER(hasInitializer);
332 REGISTER_MATCHER(hasInitStatement);
333 REGISTER_MATCHER(hasKeywordSelector);
334 REGISTER_MATCHER(hasLHS);
335 REGISTER_MATCHER(hasLocalQualifiers);
336 REGISTER_MATCHER(hasLocalStorage);
337 REGISTER_MATCHER(hasLoopInit);
338 REGISTER_MATCHER(hasLoopVariable);
339 REGISTER_MATCHER(hasMemberName);
340 REGISTER_MATCHER(hasMethod);
342 REGISTER_MATCHER(hasNamedTypeLoc);
343 REGISTER_MATCHER(hasNullSelector);
344 REGISTER_MATCHER(hasObjectExpression);
345 REGISTER_MATCHER(hasOperands);
346 REGISTER_MATCHER(hasOperatorName);
348 REGISTER_MATCHER(hasParameter);
350 REGISTER_MATCHER(hasPattern);
351 REGISTER_MATCHER(hasPointeeLoc);
352 REGISTER_MATCHER(hasQualifier);
353 REGISTER_MATCHER(hasRHS);
354 REGISTER_MATCHER(hasRangeInit);
355 REGISTER_MATCHER(hasReceiver);
356 REGISTER_MATCHER(hasReceiverType);
357 REGISTER_MATCHER(hasReferentLoc);
358 REGISTER_MATCHER(hasReplacementType);
359 REGISTER_MATCHER(hasReturnTypeLoc);
360 REGISTER_MATCHER(hasReturnValue);
361 REGISTER_MATCHER(hasPlacementArg);
362 REGISTER_MATCHER(hasSelector);
363 REGISTER_MATCHER(hasSingleDecl);
364 REGISTER_MATCHER(hasSize);
365 REGISTER_MATCHER(hasSizeExpr);
366 REGISTER_MATCHER(hasSourceExpression);
367 REGISTER_MATCHER(hasSpecializedTemplate);
368 REGISTER_MATCHER(hasStaticStorageDuration);
369 REGISTER_MATCHER(hasStructuredBlock);
370 REGISTER_MATCHER(hasSyntacticForm);
371 REGISTER_MATCHER(hasTargetDecl);
372 REGISTER_MATCHER(hasTemplateArgument);
373 REGISTER_MATCHER(hasTemplateArgumentLoc);
374 REGISTER_MATCHER(hasThen);
375 REGISTER_MATCHER(hasThreadStorageDuration);
376 REGISTER_MATCHER(hasTrailingReturn);
377 REGISTER_MATCHER(hasTrueExpression);
378 REGISTER_MATCHER(hasTypeLoc);
379 REGISTER_MATCHER(hasUnaryOperand);
380 REGISTER_MATCHER(hasUnarySelector);
381 REGISTER_MATCHER(hasUnderlyingDecl);
382 REGISTER_MATCHER(hasUnderlyingType);
383 REGISTER_MATCHER(hasUnqualifiedDesugaredType);
384 REGISTER_MATCHER(hasUnqualifiedLoc);
385 REGISTER_MATCHER(hasValueType);
387 REGISTER_MATCHER(ignoringElidableConstructorCall);
388 REGISTER_MATCHER(ignoringImpCasts);
389 REGISTER_MATCHER(ignoringImplicit);
390 REGISTER_MATCHER(ignoringParenCasts);
391 REGISTER_MATCHER(ignoringParenImpCasts);
399 REGISTER_MATCHER(innerType);
402 REGISTER_MATCHER(isAllowedToContainClauseKind);
403 REGISTER_MATCHER(isAnonymous);
404 REGISTER_MATCHER(isAnyCharacter);
405 REGISTER_MATCHER(isAnyPointer);
406 REGISTER_MATCHER(isArray);
407 REGISTER_MATCHER(isArrow);
408 REGISTER_MATCHER(isAssignmentOperator);
409 REGISTER_MATCHER(isAtPosition);
410 REGISTER_MATCHER(isBaseInitializer);
411 REGISTER_MATCHER(isBinaryFold);
412 REGISTER_MATCHER(isBitField);
413 REGISTER_MATCHER(isCatchAll);
414 REGISTER_MATCHER(isClass);
415 REGISTER_MATCHER(isClassMessage);
416 REGISTER_MATCHER(isClassMethod);
417 REGISTER_MATCHER(isComparisonOperator);
418 REGISTER_MATCHER(isConst);
419 REGISTER_MATCHER(isConstQualified);
420 REGISTER_MATCHER(isConsteval);
421 REGISTER_MATCHER(isConstexpr);
422 REGISTER_MATCHER(isConstinit);
423 REGISTER_MATCHER(isCopyAssignmentOperator);
424 REGISTER_MATCHER(isCopyConstructor);
425 REGISTER_MATCHER(isDefaultConstructor);
426 REGISTER_MATCHER(isDefaulted);
427 REGISTER_MATCHER(isDefinition);
428 REGISTER_MATCHER(isDelegatingConstructor);
429 REGISTER_MATCHER(isDeleted);
430 REGISTER_MATCHER(isEnum);
431 REGISTER_MATCHER(isExceptionVariable);
432 REGISTER_MATCHER(isExpandedFromMacro);
433 REGISTER_MATCHER(isExpansionInMainFile);
434 REGISTER_MATCHER(isExpansionInSystemHeader);
435 REGISTER_MATCHER(isExplicit);
436 REGISTER_MATCHER(isExplicitObjectMemberFunction);
437 REGISTER_MATCHER(isExplicitTemplateSpecialization);
438 REGISTER_MATCHER(isExpr);
440 REGISTER_MATCHER(isFinal);
441 REGISTER_MATCHER(isPrivateKind);
442 REGISTER_MATCHER(isFirstPrivateKind);
443 REGISTER_MATCHER(isImplicit);
444 REGISTER_MATCHER(isInAnonymousNamespace);
445 REGISTER_MATCHER(isInStdNamespace);
446 REGISTER_MATCHER(isInTemplateInstantiation);
447 REGISTER_MATCHER(isInitCapture);
448 REGISTER_MATCHER(isInline);
449 REGISTER_MATCHER(isInstanceMessage);
451 REGISTER_MATCHER(isInstantiated);
452 REGISTER_MATCHER(isInstantiationDependent);
453 REGISTER_MATCHER(isInteger);
454 REGISTER_MATCHER(isIntegral);
455 REGISTER_MATCHER(isLambda);
456 REGISTER_MATCHER(isLeftFold);
457 REGISTER_MATCHER(isListInitialization);
458 REGISTER_MATCHER(isMain);
459 REGISTER_MATCHER(isMemberInitializer);
460 REGISTER_MATCHER(isMoveAssignmentOperator);
461 REGISTER_MATCHER(isMoveConstructor);
462 REGISTER_MATCHER(isNoReturn);
463 REGISTER_MATCHER(isNoThrow);
464 REGISTER_MATCHER(isNoneKind);
465 REGISTER_MATCHER(isOverride);
466 REGISTER_MATCHER(isPrivate);
467 REGISTER_MATCHER(isProtected);
468 REGISTER_MATCHER(isPublic);
469 REGISTER_MATCHER(isPure);
470 REGISTER_MATCHER(isRightFold);
471 REGISTER_MATCHER(isScoped);
472 REGISTER_MATCHER(isSharedKind);
473 REGISTER_MATCHER(isSignedInteger);
474 REGISTER_MATCHER(isStandaloneDirective);
475 REGISTER_MATCHER(isStaticLocal);
476 REGISTER_MATCHER(isStaticStorageClass);
477 REGISTER_MATCHER(isStruct);
479 REGISTER_MATCHER(isTypeDependent);
480 REGISTER_MATCHER(isUnaryFold);
481 REGISTER_MATCHER(isUnion);
482 REGISTER_MATCHER(isUnsignedInteger);
483 REGISTER_MATCHER(isUserProvided);
484 REGISTER_MATCHER(isValueDependent);
485 REGISTER_MATCHER(isVariadic);
486 REGISTER_MATCHER(isVirtual);
487 REGISTER_MATCHER(isVirtualAsWritten);
488 REGISTER_MATCHER(isVolatileQualified);
489 REGISTER_MATCHER(isWeak);
490 REGISTER_MATCHER(isWritten);
499 REGISTER_MATCHER(member);
501 REGISTER_MATCHER(memberHasSameNameAsBoundNode);
504 REGISTER_MATCHER(namesType);
510 REGISTER_MATCHER(nullPointerConstant);
512 REGISTER_MATCHER(numSelectorArgs);
529 REGISTER_MATCHER(ofClass);
530 REGISTER_MATCHER(ofKind);
534 REGISTER_MATCHER(onImplicitObjectArgument);
537 REGISTER_MATCHER(parameterCountIs);
542 REGISTER_MATCHER(pointee);
549 REGISTER_MATCHER(realFloatingPointType);
554 REGISTER_MATCHER(refersToDeclaration);
555 REGISTER_MATCHER(refersToIntegralType);
556 REGISTER_MATCHER(refersToTemplate);
557 REGISTER_MATCHER(refersToType);
558 REGISTER_MATCHER(requiresZeroInitialization);
560 REGISTER_MATCHER(returns);
562 REGISTER_MATCHER(specifiesNamespace);
563 REGISTER_MATCHER(specifiesType);
564 REGISTER_MATCHER(specifiesTypeLoc);
565 REGISTER_MATCHER(statementCountIs);
577 REGISTER_MATCHER(templateArgumentCountIs);
585 REGISTER_MATCHER(throughUsingDecl);
604 REGISTER_MATCHER(usesADL);
611 REGISTER_MATCHER(voidType);
613 REGISTER_MATCHER(withInitializer);
614}
615
616RegistryMaps::~RegistryMaps() = default;
617
618static llvm::ManagedStatic<RegistryMaps> RegistryData;
619
621 return Ctor->nodeMatcherType();
622}
623
625 : Ptr(Ptr) {}
626
628
630 return Ctor->isBuilderMatcher();
631}
632
635 ArrayRef<ParserValue> Args, Diagnostics *Error) {
637 Ctor->buildMatcherCtor(NameRange, Args, Error).release());
638}
639
640// static
641std::optional<MatcherCtor> Registry::lookupMatcherCtor(StringRef MatcherName) {
642 auto it = RegistryData->constructors().find(MatcherName);
643 return it == RegistryData->constructors().end() ? std::optional<MatcherCtor>()
644 : it->second.get();
645}
646
647static llvm::raw_ostream &operator<<(llvm::raw_ostream &OS,
648 const std::set<ASTNodeKind> &KS) {
649 unsigned Count = 0;
650 for (std::set<ASTNodeKind>::const_iterator I = KS.begin(), E = KS.end();
651 I != E; ++I) {
652 if (I != KS.begin())
653 OS << "|";
654 if (Count++ == 3) {
655 OS << "...";
656 break;
657 }
658 OS << *I;
659 }
660 return OS;
661}
662
664 ArrayRef<std::pair<MatcherCtor, unsigned>> Context) {
665 ASTNodeKind InitialTypes[] = {
666 ASTNodeKind::getFromNodeKind<Decl>(),
667 ASTNodeKind::getFromNodeKind<QualType>(),
668 ASTNodeKind::getFromNodeKind<Type>(),
669 ASTNodeKind::getFromNodeKind<Stmt>(),
670 ASTNodeKind::getFromNodeKind<NestedNameSpecifier>(),
671 ASTNodeKind::getFromNodeKind<NestedNameSpecifierLoc>(),
672 ASTNodeKind::getFromNodeKind<TypeLoc>()};
673
674 // Starting with the above seed of acceptable top-level matcher types, compute
675 // the acceptable type set for the argument indicated by each context element.
676 std::set<ArgKind> TypeSet;
677 for (auto IT : InitialTypes) {
678 TypeSet.insert(ArgKind::MakeMatcherArg(IT));
679 }
680 for (const auto &CtxEntry : Context) {
681 MatcherCtor Ctor = CtxEntry.first;
682 unsigned ArgNumber = CtxEntry.second;
683 std::vector<ArgKind> NextTypeSet;
684 for (const ArgKind &Kind : TypeSet) {
685 if (Kind.getArgKind() == Kind.AK_Matcher &&
686 Ctor->isConvertibleTo(Kind.getMatcherKind()) &&
687 (Ctor->isVariadic() || ArgNumber < Ctor->getNumArgs()))
688 Ctor->getArgKinds(Kind.getMatcherKind(), ArgNumber, NextTypeSet);
689 }
690 TypeSet.clear();
691 TypeSet.insert(NextTypeSet.begin(), NextTypeSet.end());
692 }
693 return std::vector<ArgKind>(TypeSet.begin(), TypeSet.end());
694}
695
696std::vector<MatcherCompletion>
698 std::vector<MatcherCompletion> Completions;
699
700 // Search the registry for acceptable matchers.
701 for (const auto &M : RegistryData->constructors()) {
702 const MatcherDescriptor& Matcher = *M.getValue();
703 StringRef Name = M.getKey();
704
705 std::set<ASTNodeKind> RetKinds;
706 unsigned NumArgs = Matcher.isVariadic() ? 1 : Matcher.getNumArgs();
707 bool IsPolymorphic = Matcher.isPolymorphic();
708 std::vector<std::vector<ArgKind>> ArgsKinds(NumArgs);
709 unsigned MaxSpecificity = 0;
710 bool NodeArgs = false;
711 for (const ArgKind& Kind : AcceptedTypes) {
712 if (Kind.getArgKind() != Kind.AK_Matcher &&
713 Kind.getArgKind() != Kind.AK_Node) {
714 continue;
715 }
716
717 if (Kind.getArgKind() == Kind.AK_Node) {
718 NodeArgs = true;
719 unsigned Specificity;
720 ASTNodeKind LeastDerivedKind;
721 if (Matcher.isConvertibleTo(Kind.getNodeKind(), &Specificity,
722 &LeastDerivedKind)) {
723 if (MaxSpecificity < Specificity)
724 MaxSpecificity = Specificity;
725 RetKinds.insert(LeastDerivedKind);
726 for (unsigned Arg = 0; Arg != NumArgs; ++Arg)
727 Matcher.getArgKinds(Kind.getNodeKind(), Arg, ArgsKinds[Arg]);
728 if (IsPolymorphic)
729 break;
730 }
731 } else {
732 unsigned Specificity;
733 ASTNodeKind LeastDerivedKind;
734 if (Matcher.isConvertibleTo(Kind.getMatcherKind(), &Specificity,
735 &LeastDerivedKind)) {
736 if (MaxSpecificity < Specificity)
737 MaxSpecificity = Specificity;
738 RetKinds.insert(LeastDerivedKind);
739 for (unsigned Arg = 0; Arg != NumArgs; ++Arg)
740 Matcher.getArgKinds(Kind.getMatcherKind(), Arg, ArgsKinds[Arg]);
741 if (IsPolymorphic)
742 break;
743 }
744 }
745 }
746
747 if (!RetKinds.empty() && MaxSpecificity > 0) {
748 std::string Decl;
749 llvm::raw_string_ostream OS(Decl);
750
751 std::string TypedText = std::string(Name);
752
753 if (NodeArgs) {
754 OS << Name;
755 } else {
756
757 if (IsPolymorphic) {
758 OS << "Matcher<T> " << Name << "(Matcher<T>";
759 } else {
760 OS << "Matcher<" << RetKinds << "> " << Name << "(";
761 for (const std::vector<ArgKind> &Arg : ArgsKinds) {
762 if (&Arg != &ArgsKinds[0])
763 OS << ", ";
764
765 bool FirstArgKind = true;
766 std::set<ASTNodeKind> MatcherKinds;
767 // Two steps. First all non-matchers, then matchers only.
768 for (const ArgKind &AK : Arg) {
769 if (AK.getArgKind() == ArgKind::AK_Matcher) {
770 MatcherKinds.insert(AK.getMatcherKind());
771 } else {
772 if (!FirstArgKind)
773 OS << "|";
774 FirstArgKind = false;
775 OS << AK.asString();
776 }
777 }
778 if (!MatcherKinds.empty()) {
779 if (!FirstArgKind) OS << "|";
780 OS << "Matcher<" << MatcherKinds << ">";
781 }
782 }
783 }
784 if (Matcher.isVariadic())
785 OS << "...";
786 OS << ")";
787
788 TypedText += "(";
789 if (ArgsKinds.empty())
790 TypedText += ")";
791 else if (ArgsKinds[0][0].getArgKind() == ArgKind::AK_String)
792 TypedText += "\"";
793 }
794
795 Completions.emplace_back(TypedText, Decl, MaxSpecificity);
796 }
797 }
798
799 return Completions;
800}
801
803 SourceRange NameRange,
805 Diagnostics *Error) {
806 return Ctor->create(NameRange, Args, Error);
807}
808
810 SourceRange NameRange,
811 StringRef BindID,
813 Diagnostics *Error) {
814 VariantMatcher Out = constructMatcher(Ctor, NameRange, Args, Error);
815 if (Out.isNull()) return Out;
816
817 std::optional<DynTypedMatcher> Result = Out.getSingleMatcher();
818 if (Result) {
819 std::optional<DynTypedMatcher> Bound = Result->tryBind(BindID);
820 if (Bound) {
821 return VariantMatcher::SingleMatcher(*Bound);
822 }
823 }
824 Error->addError(NameRange, Error->ET_RegistryNotBindable);
825 return VariantMatcher();
826}
827
828} // namespace dynamic
829} // namespace ast_matchers
830} // namespace clang
Expr * E
enum clang::sema::@1712::IndirectLocalPathEntry::EntryKind Kind
Diagnostics class to manage error messages.
static bool hasDefinition(const ObjCObjectPointerType *ObjPtr)
static bool isExternC(const NamedDecl *ND)
Definition: Mangle.cpp:57
Functions templates and classes to wrap matcher construct functions.
#define MATCHER_OVERLOAD_ENTRY(name, Id)
Definition: Registry.cpp:79
#define REGISTER_MATCHER_OVERLOAD(name)
Definition: Registry.cpp:71
#define REGISTER_MATCHER(name)
Definition: Registry.cpp:67
#define REGISTER_REGEX_MATCHER(name)
Definition: Registry.cpp:91
#define REGISTER_OVERLOADED_2(name)
Definition: Registry.cpp:83
Registry of all known matchers.
static bool hasAttr(const Decl *D, bool IgnoreImplicitAttr)
Definition: SemaCUDA.cpp:109
Polymorphic value type.
Kind identifier.
Definition: ASTTypeTraits.h:51
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:86
static ArgKind MakeMatcherArg(ASTNodeKind MatcherKind)
Constructor for matcher types.
Definition: VariantValue.h:48
Helper class to manage error messages.
Definition: Diagnostics.h:50
static std::vector< ArgKind > getAcceptedCompletionTypes(llvm::ArrayRef< std::pair< MatcherCtor, unsigned > > Context)
Compute the list of completion types for Context.
Definition: Registry.cpp:663
static bool isBuilderMatcher(MatcherCtor Ctor)
Definition: Registry.cpp:629
static ASTNodeKind nodeMatcherType(MatcherCtor)
Definition: Registry.cpp:620
static std::optional< MatcherCtor > lookupMatcherCtor(StringRef MatcherName)
Look up a matcher in the registry by name,.
Definition: Registry.cpp:641
static internal::MatcherDescriptorPtr buildMatcherCtor(MatcherCtor, SourceRange NameRange, ArrayRef< ParserValue > Args, Diagnostics *Error)
Definition: Registry.cpp:634
static std::vector< MatcherCompletion > getMatcherCompletions(ArrayRef< ArgKind > AcceptedTypes)
Compute the list of completions that match any of AcceptedTypes.
Definition: Registry.cpp:697
static VariantMatcher constructBoundMatcher(MatcherCtor Ctor, SourceRange NameRange, StringRef BindID, ArrayRef< ParserValue > Args, Diagnostics *Error)
Construct a matcher from the registry and bind it.
Definition: Registry.cpp:809
static VariantMatcher constructMatcher(MatcherCtor Ctor, SourceRange NameRange, ArrayRef< ParserValue > Args, Diagnostics *Error)
Construct a matcher from the registry.
Definition: Registry.cpp:802
static VariantMatcher SingleMatcher(const DynTypedMatcher &Matcher)
Clones the provided matcher.
A smart (owning) pointer for MatcherDescriptor.
Definition: Registry.h:38
virtual bool isConvertibleTo(ASTNodeKind Kind, unsigned *Specificity=nullptr, ASTNodeKind *LeastDerivedKind=nullptr) const =0
Returns whether this matcher is convertible to the given type.
virtual void getArgKinds(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...
virtual std::unique_ptr< MatcherDescriptor > buildMatcherCtor(SourceRange NameRange, ArrayRef< ParserValue > Args, Diagnostics *Error) const
Definition: Marshallers.h:317
virtual bool isVariadic() const =0
Returns whether the matcher is variadic.
virtual VariantMatcher create(SourceRange NameRange, ArrayRef< ParserValue > Args, Diagnostics *Error) const =0
static llvm::ManagedStatic< RegistryMaps > RegistryData
Definition: Registry.cpp:618
static llvm::raw_ostream & operator<<(llvm::raw_ostream &OS, const std::set< ASTNodeKind > &KS)
Definition: Registry.cpp:647
const internal::VariadicDynCastAllOfMatcher< Stmt, FixedPointLiteral > fixedPointLiteral
Matches fixed point literals.
const internal::VariadicDynCastAllOfMatcher< Stmt, CStyleCastExpr > cStyleCastExpr
Matches a C-style cast expression.
const internal::VariadicDynCastAllOfMatcher< Decl, TagDecl > tagDecl
Matches tag declarations.
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXReinterpretCastExpr > cxxReinterpretCastExpr
Matches a reinterpret_cast expression.
const internal::VariadicDynCastAllOfMatcher< Decl, VarDecl > varDecl
Matches variable declarations.
const internal::VariadicDynCastAllOfMatcher< TypeLoc, ElaboratedTypeLoc > elaboratedTypeLoc
Matches C or C++ elaborated TypeLocs.
const internal::VariadicDynCastAllOfMatcher< Stmt, StmtExpr > stmtExpr
Matches statement expression (GNU extension).
const internal::VariadicDynCastAllOfMatcher< Stmt, ExprWithCleanups > exprWithCleanups
Matches expressions that introduce cleanups to be run at the end of the sub-expression's evaluation.
const internal::VariadicDynCastAllOfMatcher< Stmt, DeclRefExpr > declRefExpr
Matches expressions that refer to declarations.
const internal::VariadicDynCastAllOfMatcher< Decl, TypedefNameDecl > typedefNameDecl
Matches typedef name declarations.
const internal::VariadicDynCastAllOfMatcher< Decl, ObjCIvarDecl > objcIvarDecl
Matches Objective-C instance variable declarations.
const AstTypeMatcher< EnumType > enumType
Matches enum types.
const AstTypeMatcher< FunctionProtoType > functionProtoType
Matches FunctionProtoType nodes.
const AstTypeMatcher< ElaboratedType > elaboratedType
Matches types specified with an elaborated type keyword or with a qualified name.
const internal::VariadicDynCastAllOfMatcher< Decl, TypeAliasDecl > typeAliasDecl
Matches type alias declarations.
const internal::VariadicDynCastAllOfMatcher< Decl, UsingEnumDecl > usingEnumDecl
Matches using-enum declarations.
const AstTypeMatcher< ObjCObjectPointerType > objcObjectPointerType
Matches an Objective-C object pointer type, which is different from a pointer type,...
const internal::VariadicDynCastAllOfMatcher< Stmt, ConstantExpr > constantExpr
Matches a constant expression wrapper.
const internal::VariadicDynCastAllOfMatcher< Stmt, ArrayInitLoopExpr > arrayInitLoopExpr
Matches a loop initializing the elements of an array in a number of contexts:
const internal::VariadicDynCastAllOfMatcher< Stmt, ObjCIvarRefExpr > objcIvarRefExpr
Matches a reference to an ObjCIvar.
const AstTypeMatcher< BuiltinType > builtinType
Matches builtin Types.
const internal::VariadicOperatorMatcherFunc< 1, 1 > unless
Matches if the provided matcher does not match.
const internal::VariadicDynCastAllOfMatcher< Decl, ConceptDecl > conceptDecl
Matches concept declarations.
const internal::VariadicDynCastAllOfMatcher< Stmt, CoyieldExpr > coyieldExpr
Matches co_yield expressions.
const AstTypeMatcher< DependentSizedExtVectorType > dependentSizedExtVectorType
Matches C++ extended vector type where either the type or size is dependent.
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXDeleteExpr > cxxDeleteExpr
Matches delete expressions.
const internal::VariadicAllOfMatcher< TemplateName > templateName
Matches template name.
const internal::VariadicDynCastAllOfMatcher< Decl, ObjCProtocolDecl > objcProtocolDecl
Matches Objective-C protocol declarations.
const internal::VariadicDynCastAllOfMatcher< Stmt, ImplicitCastExpr > implicitCastExpr
Matches the implicit cast nodes of Clang's AST.
const internal::VariadicOperatorMatcherFunc< 1, 1 > optionally
Matches any node regardless of the submatcher.
const internal::VariadicDynCastAllOfMatcher< Decl, UsingDecl > usingDecl
Matches using declarations.
const internal::ArgumentAdaptingMatcherFunc< internal::HasDescendantMatcher > hasDescendant
Matches AST nodes that have descendant AST nodes that match the provided matcher.
const internal::VariadicDynCastAllOfMatcher< Decl, ObjCPropertyDecl > objcPropertyDecl
Matches Objective-C property declarations.
const internal::VariadicDynCastAllOfMatcher< Stmt, StringLiteral > stringLiteral
Matches string literals (also matches wide string literals).
const internal::VariadicAllOfMatcher< CXXCtorInitializer > cxxCtorInitializer
Matches constructor initializers.
const internal::VariadicDynCastAllOfMatcher< Stmt, ObjCAtFinallyStmt > objcFinallyStmt
Matches Objective-C @finally statements.
const AstTypeMatcher< DependentSizedArrayType > dependentSizedArrayType
Matches C++ arrays whose size is a value-dependent expression.
const AstTypeMatcher< TemplateSpecializationType > templateSpecializationType
Matches template specialization types.
const internal::VariadicDynCastAllOfMatcher< Stmt, AtomicExpr > atomicExpr
Matches atomic builtins.
const AstTypeMatcher< DeducedTemplateSpecializationType > deducedTemplateSpecializationType
Matches C++17 deduced template specialization types, e.g.
const internal::VariadicDynCastAllOfMatcher< Stmt, CoawaitExpr > coawaitExpr
Matches co_await expressions.
const internal::VariadicDynCastAllOfMatcher< Decl, EnumDecl > enumDecl
Matches enum declarations.
const internal::VariadicDynCastAllOfMatcher< Stmt, ConvertVectorExpr > convertVectorExpr
Matches builtin function __builtin_convertvector.
const internal::VariadicDynCastAllOfMatcher< Stmt, AddrLabelExpr > addrLabelExpr
Matches address of label statements (GNU extension).
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXDependentScopeMemberExpr > cxxDependentScopeMemberExpr
Matches member expressions where the actual member referenced could not be resolved because the base ...
const internal::VariadicDynCastAllOfMatcher< Stmt, PredefinedExpr > predefinedExpr
Matches predefined identifier expressions [C99 6.4.2.2].
const internal::VariadicAllOfMatcher< NestedNameSpecifier > nestedNameSpecifier
Matches nested name specifiers.
const AstTypeMatcher< PointerType > pointerType
Matches pointer types, but does not match Objective-C object pointer types.
const internal::VariadicDynCastAllOfMatcher< Stmt, DependentCoawaitExpr > dependentCoawaitExpr
Matches co_await expressions where the type of the promise is dependent.
const internal::VariadicDynCastAllOfMatcher< Stmt, BreakStmt > breakStmt
Matches break statements.
const internal::VariadicDynCastAllOfMatcher< Decl, BindingDecl > bindingDecl
Matches binding declarations Example matches foo and bar (matcher = bindingDecl()
const internal::VariadicDynCastAllOfMatcher< Stmt, UnresolvedLookupExpr > unresolvedLookupExpr
Matches reference to a name that can be looked up during parsing but could not be resolved to a speci...
const internal::VariadicDynCastAllOfMatcher< Stmt, OMPExecutableDirective > ompExecutableDirective
Matches any #pragma omp executable directive.
const internal::VariadicDynCastAllOfMatcher< Stmt, ObjCStringLiteral > objcStringLiteral
Matches ObjectiveC String literal expressions.
const internal::VariadicDynCastAllOfMatcher< Decl, ObjCMethodDecl > objcMethodDecl
Matches Objective-C method declarations.
const internal::VariadicDynCastAllOfMatcher< Decl, ParmVarDecl > parmVarDecl
Matches parameter variable declarations.
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXRewrittenBinaryOperator > cxxRewrittenBinaryOperator
Matches rewritten binary operators.
const internal::VariadicDynCastAllOfMatcher< Decl, TypedefDecl > typedefDecl
Matches typedef declarations.
const internal::VariadicDynCastAllOfMatcher< Stmt, GenericSelectionExpr > genericSelectionExpr
Matches C11 _Generic expression.
const internal::VariadicDynCastAllOfMatcher< Decl, CXXDeductionGuideDecl > cxxDeductionGuideDecl
Matches user-defined and implicitly generated deduction guide.
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXBoolLiteralExpr > cxxBoolLiteral
Matches bool literals.
const internal::VariadicDynCastAllOfMatcher< Stmt, ReturnStmt > returnStmt
Matches return statements.
const internal::VariadicDynCastAllOfMatcher< Stmt, AsmStmt > asmStmt
Matches asm statements.
internal::Matcher< NamedDecl > hasName(StringRef Name)
Matches NamedDecl nodes that have the specified name.
Definition: ASTMatchers.h:3090
const internal::VariadicAllOfMatcher< Attr > attr
Matches attributes.
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXDynamicCastExpr > cxxDynamicCastExpr
Matches a dynamic_cast expression.
const internal::VariadicDynCastAllOfMatcher< Stmt, CoreturnStmt > coreturnStmt
Matches co_return statements.
const internal::VariadicDynCastAllOfMatcher< Stmt, CallExpr > callExpr
Matches call expressions.
const internal::VariadicDynCastAllOfMatcher< Stmt, LambdaExpr > lambdaExpr
Matches lambda expressions.
const internal::VariadicDynCastAllOfMatcher< Stmt, CompoundStmt > compoundStmt
Matches compound statements.
const internal::VariadicDynCastAllOfMatcher< Stmt, FloatingLiteral > floatLiteral
Matches float literals of all sizes / encodings, e.g.
const internal::VariadicDynCastAllOfMatcher< Stmt, ObjCAutoreleasePoolStmt > autoreleasePoolStmt
Matches an Objective-C autorelease pool statement.
const internal::VariadicFunction< internal::PolymorphicMatcher< internal::HasOverloadedOperatorNameMatcher, AST_POLYMORPHIC_SUPPORTED_TYPES(CXXOperatorCallExpr, FunctionDecl), std::vector< std::string > >, StringRef, internal::hasAnyOverloadedOperatorNameFunc > hasAnyOverloadedOperatorName
Matches overloaded operator names.
const internal::VariadicDynCastAllOfMatcher< Decl, NonTypeTemplateParmDecl > nonTypeTemplateParmDecl
Matches non-type template parameter declarations.
const AstTypeMatcher< VariableArrayType > variableArrayType
Matches C arrays with a specified size that is not an integer-constant-expression.
const internal::VariadicDynCastAllOfMatcher< Stmt, UnaryExprOrTypeTraitExpr > unaryExprOrTypeTraitExpr
Matches sizeof (C99), alignof (C++11) and vec_step (OpenCL)
const internal::VariadicDynCastAllOfMatcher< Stmt, NullStmt > nullStmt
Matches null statements.
const internal::VariadicDynCastAllOfMatcher< TypeLoc, TemplateSpecializationTypeLoc > templateSpecializationTypeLoc
Matches template specialization TypeLocs.
const internal::ArgumentAdaptingMatcherFunc< internal::ForEachDescendantMatcher > forEachDescendant
Matches AST nodes that have descendant AST nodes that match the provided matcher.
const internal::VariadicAllOfMatcher< CXXBaseSpecifier > cxxBaseSpecifier
Matches class bases.
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXDefaultArgExpr > cxxDefaultArgExpr
Matches the value of a default argument at the call site.
const internal::VariadicAllOfMatcher< TemplateArgument > templateArgument
Matches template arguments.
const internal::ArgumentAdaptingMatcherFunc< internal::ForEachMatcher > forEach
Matches AST nodes that have child AST nodes that match the provided matcher.
const internal::VariadicDynCastAllOfMatcher< Stmt, CaseStmt > caseStmt
Matches case statements inside switch statements.
const internal::VariadicAllOfMatcher< NestedNameSpecifierLoc > nestedNameSpecifierLoc
Same as nestedNameSpecifier but matches NestedNameSpecifierLoc.
const internal::VariadicDynCastAllOfMatcher< Decl, NamedDecl > namedDecl
Matches a declaration of anything that could have a name.
const internal::VariadicDynCastAllOfMatcher< Decl, UnresolvedUsingTypenameDecl > unresolvedUsingTypenameDecl
Matches unresolved using value declarations that involve the typename.
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
const AstTypeMatcher< DecltypeType > decltypeType
Matches types nodes representing C++11 decltype(<expr>) types.
const internal::VariadicAllOfMatcher< TypeLoc > typeLoc
Matches TypeLocs in the clang AST.
const internal::VariadicDynCastAllOfMatcher< Stmt, ParenListExpr > parenListExpr
Matches paren list expressions.
const internal::VariadicDynCastAllOfMatcher< Decl, ClassTemplatePartialSpecializationDecl > classTemplatePartialSpecializationDecl
Matches C++ class template partial specializations.
const internal::VariadicDynCastAllOfMatcher< Stmt, WhileStmt > whileStmt
Matches while statements.
const internal::VariadicDynCastAllOfMatcher< Decl, ObjCCategoryDecl > objcCategoryDecl
Matches Objective-C category declarations.
internal::TrueMatcher anything()
Matches any node.
Definition: ASTMatchers.h:171
const internal::VariadicFunction< internal::Matcher< ObjCMessageExpr >, StringRef, internal::hasAnySelectorFunc > hasAnySelector
Matches when at least one of the supplied string equals to the Selector.getAsString()
const AstTypeMatcher< AutoType > autoType
Matches types nodes representing C++11 auto types.
const AstTypeMatcher< ArrayType > arrayType
Matches all kinds of arrays.
const internal::VariadicDynCastAllOfMatcher< Decl, CXXConversionDecl > cxxConversionDecl
Matches conversion operator declarations.
const AstTypeMatcher< ParenType > parenType
Matches ParenType nodes.
const internal::VariadicDynCastAllOfMatcher< Decl, LabelDecl > labelDecl
Matches a declaration of label.
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXFunctionalCastExpr > cxxFunctionalCastExpr
Matches functional cast expressions.
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXConstCastExpr > cxxConstCastExpr
Matches a const_cast expression.
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXTemporaryObjectExpr > cxxTemporaryObjectExpr
Matches functional cast expressions having N != 1 arguments.
const internal::VariadicDynCastAllOfMatcher< Stmt, UnaryOperator > unaryOperator
Matches unary operator expressions.
const internal::VariadicDynCastAllOfMatcher< TypeLoc, ReferenceTypeLoc > referenceTypeLoc
Matches reference TypeLocs.
const internal::VariadicFunction< internal::Matcher< NamedDecl >, StringRef, internal::hasAnyNameFunc > hasAnyName
Matches NamedDecl nodes that have any of the specified names.
const internal::VariadicDynCastAllOfMatcher< Stmt, ObjCMessageExpr > objcMessageExpr
Matches ObjectiveC Message invocation expressions.
const internal::MapAnyOfMatcher< BinaryOperator, CXXOperatorCallExpr, CXXRewrittenBinaryOperator > binaryOperation
Matches nodes which can be used with binary operators.
const internal::VariadicDynCastAllOfMatcher< Stmt, ArraySubscriptExpr > arraySubscriptExpr
Matches array subscript expressions.
const internal::VariadicDynCastAllOfMatcher< OMPClause, OMPDefaultClause > ompDefaultClause
Matches OpenMP default clause.
const internal::VariadicDynCastAllOfMatcher< Decl, AccessSpecDecl > accessSpecDecl
Matches C++ access specifier declarations.
const internal::VariadicDynCastAllOfMatcher< Decl, LinkageSpecDecl > linkageSpecDecl
Matches a declaration of a linkage specification.
const AstTypeMatcher< InjectedClassNameType > injectedClassNameType
Matches injected class name types.
const internal::VariadicDynCastAllOfMatcher< Stmt, GNUNullExpr > gnuNullExpr
Matches GNU __null expression.
const internal::VariadicDynCastAllOfMatcher< TypeLoc, PointerTypeLoc > pointerTypeLoc
Matches pointer TypeLocs.
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXForRangeStmt > cxxForRangeStmt
Matches range-based for statements.
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXMemberCallExpr > cxxMemberCallExpr
Matches member call expressions.
const internal::VariadicDynCastAllOfMatcher< Decl, CXXConstructorDecl > cxxConstructorDecl
Matches C++ constructor declarations.
const AstTypeMatcher< BlockPointerType > blockPointerType
Matches block pointer types, i.e.
internal::BindableMatcher< Stmt > sizeOfExpr(const internal::Matcher< UnaryExprOrTypeTraitExpr > &InnerMatcher)
Same as unaryExprOrTypeTraitExpr, but only matching sizeof.
Definition: ASTMatchers.h:3069
const internal::VariadicDynCastAllOfMatcher< Stmt, InitListExpr > initListExpr
Matches init list expressions.
const AstTypeMatcher< AtomicType > atomicType
Matches atomic types.
const internal::VariadicDynCastAllOfMatcher< Decl, TypeAliasTemplateDecl > typeAliasTemplateDecl
Matches type alias template declarations.
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXNoexceptExpr > cxxNoexceptExpr
Matches noexcept expressions.
const internal::VariadicDynCastAllOfMatcher< Stmt, ArrayInitIndexExpr > arrayInitIndexExpr
The arrayInitIndexExpr consists of two subexpressions: a common expression (the source array) that is...
const AstTypeMatcher< UsingType > usingType
Matches types specified through a using declaration.
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXNewExpr > cxxNewExpr
Matches new expressions.
const internal::VariadicDynCastAllOfMatcher< Decl, EnumConstantDecl > enumConstantDecl
Matches enum constants.
const internal::VariadicDynCastAllOfMatcher< Stmt, ForStmt > forStmt
Matches for statements.
const internal::VariadicDynCastAllOfMatcher< Stmt, GotoStmt > gotoStmt
Matches goto statements.
const internal::VariadicDynCastAllOfMatcher< Decl, DeclaratorDecl > declaratorDecl
Matches declarator declarations (field, variable, function and non-type template parameter declaratio...
const internal::VariadicDynCastAllOfMatcher< Stmt, ObjCAtCatchStmt > objcCatchStmt
Matches Objective-C @catch statements.
const internal::VariadicDynCastAllOfMatcher< Stmt, BinaryOperator > binaryOperator
Matches binary operator expressions.
const internal::VariadicDynCastAllOfMatcher< TypeLoc, QualifiedTypeLoc > qualifiedTypeLoc
Matches QualifiedTypeLocs in the clang AST.
const internal::VariadicDynCastAllOfMatcher< Decl, TemplateTypeParmDecl > templateTypeParmDecl
Matches template type parameter declarations.
const internal::VariadicDynCastAllOfMatcher< Stmt, BlockExpr > blockExpr
Matches a reference to a block.
const internal::VariadicDynCastAllOfMatcher< Decl, FunctionTemplateDecl > functionTemplateDecl
Matches C++ function template declarations.
const internal::VariadicDynCastAllOfMatcher< Stmt, ParenExpr > parenExpr
Matches parentheses used in expressions.
const internal::VariadicDynCastAllOfMatcher< Decl, StaticAssertDecl > staticAssertDecl
Matches a C++ static_assert declaration.
const internal::ArgumentAdaptingMatcherFunc< internal::HasMatcher > has
Matches AST nodes that have child AST nodes that match the provided matcher.
const internal::VariadicDynCastAllOfMatcher< Stmt, CoroutineBodyStmt > coroutineBodyStmt
Matches coroutine body statements.
const AstTypeMatcher< MacroQualifiedType > macroQualifiedType
Matches qualified types when the qualifier is applied via a macro.
const internal::VariadicDynCastAllOfMatcher< Decl, ObjCCategoryImplDecl > objcCategoryImplDecl
Matches Objective-C category definitions.
const AstTypeMatcher< TypedefType > typedefType
Matches typedef types.
const internal::VariadicDynCastAllOfMatcher< Stmt, MaterializeTemporaryExpr > materializeTemporaryExpr
Matches nodes where temporaries are materialized.
const AstTypeMatcher< TagType > tagType
Matches tag types (record and enum types).
const internal::VariadicDynCastAllOfMatcher< Stmt, BinaryConditionalOperator > binaryConditionalOperator
Matches binary conditional operator expressions (GNU extension).
const internal::VariadicDynCastAllOfMatcher< Stmt, ObjCAtTryStmt > objcTryStmt
Matches Objective-C @try statements.
const internal::VariadicDynCastAllOfMatcher< Stmt, ExplicitCastExpr > explicitCastExpr
Matches explicit cast expressions.
internal::PolymorphicMatcher< internal::ValueEqualsMatcher, void(internal::AllNodeBaseTypes), ValueT > equals(const ValueT &Value)
Matches literals that are equal to the given value of type ValueT.
Definition: ASTMatchers.h:5859
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXStaticCastExpr > cxxStaticCastExpr
Matches a C++ static_cast expression.
const internal::VariadicDynCastAllOfMatcher< Decl, ValueDecl > valueDecl
Matches any value declaration.
const internal::VariadicDynCastAllOfMatcher< Decl, TranslationUnitDecl > translationUnitDecl
Matches the top declaration context.
const AstTypeMatcher< TemplateTypeParmType > templateTypeParmType
Matches template type parameter types.
const AstTypeMatcher< ConstantArrayType > constantArrayType
Matches C arrays with a specified constant size.
const internal::VariadicAllOfMatcher< LambdaCapture > lambdaCapture
Matches lambda captures.
const internal::VariadicOperatorMatcherFunc< 2, std::numeric_limits< unsigned >::max()> eachOf
Matches if any of the given matchers matches.
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXConstructExpr > cxxConstructExpr
Matches constructor call expressions (including implicit ones).
const internal::VariadicDynCastAllOfMatcher< Decl, ObjCInterfaceDecl > objcInterfaceDecl
Matches Objective-C interface declarations.
const internal::VariadicDynCastAllOfMatcher< Decl, TemplateTemplateParmDecl > templateTemplateParmDecl
Matches template template parameter declarations.
const internal::VariadicDynCastAllOfMatcher< Decl, FieldDecl > fieldDecl
Matches field declarations.
const internal::VariadicDynCastAllOfMatcher< Stmt, UserDefinedLiteral > userDefinedLiteral
Matches user defined literal operator call.
const internal::VariadicDynCastAllOfMatcher< Stmt, ChooseExpr > chooseExpr
Matches GNU __builtin_choose_expr.
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXOperatorCallExpr > cxxOperatorCallExpr
Matches overloaded operator calls.
internal::PolymorphicMatcher< internal::HasOverloadedOperatorNameMatcher, AST_POLYMORPHIC_SUPPORTED_TYPES(CXXOperatorCallExpr, FunctionDecl), std::vector< std::string > > hasOverloadedOperatorName(StringRef Name)
Matches overloaded operator names.
Definition: ASTMatchers.h:3153
const internal::VariadicDynCastAllOfMatcher< Decl, NamespaceAliasDecl > namespaceAliasDecl
Matches a declaration of a namespace alias.
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXBindTemporaryExpr > cxxBindTemporaryExpr
Matches nodes where temporaries are created.
const internal::VariadicDynCastAllOfMatcher< Stmt, SwitchCase > switchCase
Matches case and default statements inside switch statements.
const internal::VariadicDynCastAllOfMatcher< Stmt, DefaultStmt > defaultStmt
Matches default statements inside switch statements.
const internal::VariadicOperatorMatcherFunc< 2, std::numeric_limits< unsigned >::max()> allOf
Matches if all given matchers match.
const internal::VariadicDynCastAllOfMatcher< Decl, ClassTemplateSpecializationDecl > classTemplateSpecializationDecl
Matches C++ class template specializations.
const internal::VariadicDynCastAllOfMatcher< Decl, DecompositionDecl > decompositionDecl
Matches decomposition-declarations.
const AstTypeMatcher< SubstTemplateTypeParmType > substTemplateTypeParmType
Matches types that represent the result of substituting a type for a template type parameter.
const internal::VariadicDynCastAllOfMatcher< Decl, FunctionDecl > functionDecl
Matches function declarations.
const AstTypeMatcher< UnaryTransformType > unaryTransformType
Matches types nodes representing unary type transformations.
const internal::VariadicDynCastAllOfMatcher< Stmt, UnresolvedMemberExpr > unresolvedMemberExpr
Matches unresolved member expressions.
const internal::VariadicDynCastAllOfMatcher< Stmt, ObjCAtThrowStmt > objcThrowStmt
Matches Objective-C @throw statements.
const internal::MapAnyOfMatcher< CallExpr, CXXConstructExpr > invocation
Matches function calls and constructor calls.
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXThrowExpr > cxxThrowExpr
Matches throw expressions.
const internal::VariadicDynCastAllOfMatcher< Stmt, SwitchStmt > switchStmt
Matches switch statements.
const AstTypeMatcher< RecordType > recordType
Matches record types (e.g.
const internal::VariadicDynCastAllOfMatcher< Stmt, MemberExpr > memberExpr
Matches member expressions.
const internal::VariadicDynCastAllOfMatcher< Decl, CXXRecordDecl > cxxRecordDecl
Matches C++ class declarations.
const internal::VariadicAllOfMatcher< TemplateArgumentLoc > templateArgumentLoc
Matches template arguments (with location info).
const AstTypeMatcher< ReferenceType > referenceType
Matches both lvalue and rvalue reference types.
const internal::VariadicDynCastAllOfMatcher< Stmt, DesignatedInitExpr > designatedInitExpr
Matches C99 designated initializer expressions [C99 6.7.8].
const internal::VariadicAllOfMatcher< Decl > decl
Matches declarations.
const internal::VariadicDynCastAllOfMatcher< Decl, CXXDestructorDecl > cxxDestructorDecl
Matches explicit C++ destructor declarations.
internal::BindableMatcher< Stmt > alignOfExpr(const internal::Matcher< UnaryExprOrTypeTraitExpr > &InnerMatcher)
Same as unaryExprOrTypeTraitExpr, but only matching alignof.
Definition: ASTMatchers.h:3060
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXUnresolvedConstructExpr > cxxUnresolvedConstructExpr
Matches unresolved constructor call expressions.
const internal::VariadicDynCastAllOfMatcher< Decl, ObjCImplementationDecl > objcImplementationDecl
Matches Objective-C implementation declarations.
const internal::VariadicDynCastAllOfMatcher< Decl, RecordDecl > recordDecl
Matches class, struct, and union declarations.
const internal::VariadicDynCastAllOfMatcher< Stmt, IntegerLiteral > integerLiteral
Matches integer literals of all sizes / encodings, e.g.
const internal::VariadicDynCastAllOfMatcher< Decl, ExportDecl > exportDecl
Matches any export declaration.
const internal::VariadicDynCastAllOfMatcher< Stmt, ImplicitValueInitExpr > implicitValueInitExpr
Matches implicit initializers of init list expressions.
const internal::VariadicDynCastAllOfMatcher< Stmt, DoStmt > doStmt
Matches do statements.
const internal::VariadicDynCastAllOfMatcher< Decl, NamespaceDecl > namespaceDecl
Matches a declaration of a namespace.
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXNullPtrLiteralExpr > cxxNullPtrLiteralExpr
Matches nullptr literal.
internal::PolymorphicMatcher< internal::HasDeclarationMatcher, void(internal::HasDeclarationSupportedTypes), internal::Matcher< Decl > > hasDeclaration(const internal::Matcher< Decl > &InnerMatcher)
Matches a node if the declaration associated with that node matches the given matcher.
Definition: ASTMatchers.h:3664
const AstTypeMatcher< DecayedType > decayedType
Matches decayed type Example matches i[] in declaration of f.
const internal::VariadicDynCastAllOfMatcher< Stmt, DeclStmt > declStmt
Matches declaration statements.
const internal::VariadicDynCastAllOfMatcher< Stmt, CompoundLiteralExpr > compoundLiteralExpr
Matches compound (i.e.
const AstTypeMatcher< MemberPointerType > memberPointerType
Matches member pointer types.
const internal::VariadicDynCastAllOfMatcher< Stmt, LabelStmt > labelStmt
Matches label statements.
const internal::VariadicAllOfMatcher< Stmt > stmt
Matches statements.
const internal::VariadicDynCastAllOfMatcher< Decl, FriendDecl > friendDecl
Matches friend declarations.
const internal::VariadicDynCastAllOfMatcher< Stmt, Expr > expr
Matches expressions.
const AstTypeMatcher< IncompleteArrayType > incompleteArrayType
Matches C arrays with unspecified size.
const internal::VariadicDynCastAllOfMatcher< Stmt, CharacterLiteral > characterLiteral
Matches character literals (also matches wchar_t).
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXFoldExpr > cxxFoldExpr
Matches C++17 fold expressions.
const internal::VariadicDynCastAllOfMatcher< Stmt, ConditionalOperator > conditionalOperator
Matches conditional operator expressions.
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXStdInitializerListExpr > cxxStdInitializerListExpr
Matches C++ initializer list expressions.
const internal::VariadicOperatorMatcherFunc< 2, std::numeric_limits< unsigned >::max()> anyOf
Matches if any of the given matchers matches.
const internal::VariadicFunction< internal::PolymorphicMatcher< internal::HasAnyOperatorNameMatcher, AST_POLYMORPHIC_SUPPORTED_TYPES(BinaryOperator, CXXOperatorCallExpr, CXXRewrittenBinaryOperator, UnaryOperator), std::vector< std::string > >, StringRef, internal::hasAnyOperatorNameFunc > hasAnyOperatorName
Matches operator expressions (binary or unary) that have any of the specified names.
const internal::VariadicDynCastAllOfMatcher< Stmt, OpaqueValueExpr > opaqueValueExpr
Matches opaque value expressions.
const AstTypeMatcher< ComplexType > complexType
Matches C99 complex types.
const internal::VariadicDynCastAllOfMatcher< Stmt, CUDAKernelCallExpr > cudaKernelCallExpr
Matches CUDA kernel call expression.
const internal::VariadicDynCastAllOfMatcher< Decl, IndirectFieldDecl > indirectFieldDecl
Matches indirect field declarations.
const AstTypeMatcher< FunctionType > functionType
Matches FunctionType nodes.
const internal::VariadicDynCastAllOfMatcher< Decl, BlockDecl > blockDecl
Matches block declarations.
const internal::VariadicDynCastAllOfMatcher< Decl, CXXMethodDecl > cxxMethodDecl
Matches method declarations.
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXCatchStmt > cxxCatchStmt
Matches catch statements.
const internal::VariadicDynCastAllOfMatcher< Stmt, CastExpr > castExpr
Matches any cast nodes of Clang's AST.
const internal::VariadicAllOfMatcher< QualType > qualType
Matches QualTypes in the clang AST.
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXTryStmt > cxxTryStmt
Matches try statements.
const internal::VariadicDynCastAllOfMatcher< Stmt, SubstNonTypeTemplateParmExpr > substNonTypeTemplateParmExpr
Matches substitutions of non-type template parameters.
const internal::VariadicDynCastAllOfMatcher< Decl, UsingDirectiveDecl > usingDirectiveDecl
Matches using namespace declarations.
const internal::VariadicDynCastAllOfMatcher< Decl, UnresolvedUsingValueDecl > unresolvedUsingValueDecl
Matches unresolved using value declarations.
const internal::ArgumentAdaptingMatcherFunc< internal::HasAncestorMatcher, internal::TypeList< Decl, NestedNameSpecifierLoc, Stmt, TypeLoc, Attr >, internal::TypeList< Decl, NestedNameSpecifierLoc, Stmt, TypeLoc, Attr > > hasAncestor
Matches AST nodes that have an ancestor that matches the provided matcher.
const internal::ArgumentAdaptingMatcherFunc< internal::HasParentMatcher, internal::TypeList< Decl, NestedNameSpecifierLoc, Stmt, TypeLoc, Attr >, internal::TypeList< Decl, NestedNameSpecifierLoc, Stmt, TypeLoc, Attr > > hasParent
Matches AST nodes that have a parent that matches the provided matcher.
const internal::VariadicDynCastAllOfMatcher< Stmt, IfStmt > ifStmt
Matches if statements.
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXThisExpr > cxxThisExpr
Matches implicit and explicit this expressions.
const internal::VariadicDynCastAllOfMatcher< Stmt, ImaginaryLiteral > imaginaryLiteral
Matches imaginary literals, which are based on integer and floating point literals e....
const AstTypeMatcher< RValueReferenceType > rValueReferenceType
Matches rvalue reference types.
const internal::VariadicDynCastAllOfMatcher< Stmt, ContinueStmt > continueStmt
Matches continue statements.
const internal::VariadicDynCastAllOfMatcher< Decl, ClassTemplateDecl > classTemplateDecl
Matches C++ class template declarations.
const AstTypeMatcher< LValueReferenceType > lValueReferenceType
Matches lvalue reference types.
The JSON file list parser is used to communicate input to InstallAPI.
bool isTemplateInstantiation(TemplateSpecializationKind Kind)
Determine whether this template specialization kind refers to an instantiation of an entity (as oppos...
Definition: Specifiers.h:212
bool isInstanceMethod(const Decl *D)
Definition: Attr.h:120
@ Result
The result type of a method or function.