#include "ASTMatchersTest.h"
#include "clang/AST/Attrs.inc"
#include "clang/AST/DeclCXX.h"
#include "clang/AST/PrettyPrinter.h"
#include "clang/ASTMatchers/ASTMatchFinder.h"
#include "clang/ASTMatchers/ASTMatchers.h"
#include "clang/Tooling/Tooling.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/TargetParser/Host.h"
#include "llvm/TargetParser/Triple.h"
#include "gtest/gtest.h"
namespace clang {
namespace ast_matchers {
TEST(DeclarationMatcher, hasMethod) { … }
TEST(DeclarationMatcher, ClassDerivedFromDependentTemplateSpecialization) { … }
TEST(DeclarationMatcher, hasDeclContext) { … }
TEST(HasDescendant, MatchesDescendantTypes) { … }
TEST(HasDescendant, MatchesDescendantsOfTypes) { … }
TEST(Has, MatchesChildrenOfTypes) { … }
TEST(Has, MatchesChildTypes) { … }
TEST(StatementMatcher, Has) { … }
TEST(StatementMatcher, HasDescendant) { … }
TEST(TypeMatcher, MatchesClassType) { … }
TEST(TypeMatcher, MatchesDeclTypes) { … }
TEST(HasDeclaration, HasDeclarationOfEnumType) { … }
TEST(HasDeclaration, HasGetDeclTraitTest) { … }
TEST(HasDeclaration, ElaboratedType) { … }
TEST(HasDeclaration, HasDeclarationOfTypeWithDecl) { … }
TEST(HasDeclaration, HasDeclarationOfTemplateSpecializationType) { … }
TEST(HasDeclaration, HasDeclarationOfCXXNewExpr) { … }
TEST(HasDeclaration, HasDeclarationOfTypeAlias) { … }
TEST(HasUnqualifiedDesugaredType, DesugarsUsing) { … }
TEST(HasUnderlyingDecl, Matches) { … }
TEST(HasType, TakesQualTypeMatcherAndMatchesExpr) { … }
TEST(HasType, TakesQualTypeMatcherAndMatchesValueDecl) { … }
TEST(HasType, TakesQualTypeMatcherAndMatchesCXXBaseSpecifier) { … }
TEST(HasType, TakesDeclMatcherAndMatchesExpr) { … }
TEST(HasType, TakesDeclMatcherAndMatchesValueDecl) { … }
TEST(HasType, TakesDeclMatcherAndMatchesCXXBaseSpecifier) { … }
TEST(HasType, MatchesTypedefDecl) { … }
TEST(HasType, MatchesTypedefNameDecl) { … }
TEST(HasTypeLoc, MatchesBlockDecl) { … }
TEST(HasTypeLoc, MatchesCXXBaseSpecifierAndCtorInitializer) { … }
TEST(HasTypeLoc, MatchesCXXFunctionalCastExpr) { … }
TEST(HasTypeLoc, MatchesCXXNewExpr) { … }
TEST(HasTypeLoc, MatchesCXXTemporaryObjectExpr) { … }
TEST(HasTypeLoc, MatchesCXXUnresolvedConstructExpr) { … }
TEST(HasTypeLoc, MatchesCompoundLiteralExpr) { … }
TEST(HasTypeLoc, MatchesDeclaratorDecl) { … }
TEST(HasTypeLoc, MatchesExplicitCastExpr) { … }
TEST(HasTypeLoc, MatchesObjCPropertyDecl) { … }
TEST(HasTypeLoc, MatchesTemplateArgumentLoc) { … }
TEST(HasTypeLoc, MatchesTypedefNameDecl) { … }
TEST(Callee, MatchesDeclarations) { … }
TEST(Callee, MatchesMemberExpressions) { … }
TEST(Matcher, Argument) { … }
TEST(Matcher, AnyArgument) { … }
TEST(Matcher, HasReceiver) { … }
TEST(Matcher, MatchesMethodsOnLambda) { … }
TEST(Matcher, MatchesCoroutine) { … }
TEST(Matcher, isClassMessage) { … }
TEST(Matcher, isInstanceMessage) { … }
TEST(Matcher, isClassMethod) { … }
TEST(Matcher, isInstanceMethod) { … }
TEST(MatcherCXXMemberCallExpr, On) { … }
TEST(MatcherCXXMemberCallExpr, OnImplicitObjectArgument) { … }
TEST(Matcher, HasObjectExpr) { … }
TEST(ForEachArgumentWithParam, ReportsNoFalsePositives) { … }
TEST(ForEachArgumentWithParam, MatchesCXXMemberCallExpr) { … }
TEST(ForEachArgumentWithParam, MatchesCallExpr) { … }
TEST(ForEachArgumentWithParam, MatchesConstructExpr) { … }
TEST(ForEachArgumentWithParam, HandlesBoundNodesForNonMatches) { … }
TEST_P(ASTMatchersTest,
ForEachArgumentWithParamMatchesExplicitObjectParamOnOperatorCalls) { … }
TEST(ForEachArgumentWithParamType, ReportsNoFalsePositives) { … }
TEST(ForEachArgumentWithParamType, MatchesCXXMemberCallExpr) { … }
TEST(ForEachArgumentWithParamType, MatchesCallExpr) { … }
TEST(ForEachArgumentWithParamType, MatchesConstructExpr) { … }
TEST(ForEachArgumentWithParamType, HandlesKandRFunctions) { … }
TEST(ForEachArgumentWithParamType, HandlesBoundNodesForNonMatches) { … }
TEST(ForEachArgumentWithParamType, MatchesFunctionPtrCalls) { … }
TEST(ForEachArgumentWithParamType, MatchesMemberFunctionPtrCalls) { … }
TEST(ForEachArgumentWithParamType, MatchesVariadicFunctionPtrCalls) { … }
TEST_P(ASTMatchersTest,
ForEachArgumentWithParamTypeMatchesExplicitObjectParamOnOperatorCalls) { … }
TEST(QualType, hasCanonicalType) { … }
TEST(HasParameter, CallsInnerMatcher) { … }
TEST(HasParameter, DoesNotMatchIfIndexOutOfBounds) { … }
TEST(HasType, MatchesParameterVariableTypesStrictly) { … }
TEST(HasAnyParameter, MatchesIndependentlyOfPosition) { … }
TEST(Returns, MatchesReturnTypes) { … }
TEST(HasAnyParameter, DoesntMatchIfInnerMatcherDoesntMatch) { … }
TEST(HasAnyParameter, DoesNotMatchThisPointer) { … }
TEST(HasName, MatchesParameterVariableDeclarations) { … }
TEST(Matcher, MatchesTypeTemplateArgument) { … }
TEST(Matcher, MatchesTemplateTemplateArgument) { … }
TEST(Matcher, MatchesDeclarationReferenceTemplateArgument) { … }
TEST(Matcher, MatchesSpecificArgument) { … }
TEST(TemplateArgument, Matches) { … }
TEST(TemplateTypeParmDecl, CXXMethodDecl) { … }
TEST(TemplateTypeParmDecl, VarDecl) { … }
TEST(TemplateTypeParmDecl, VarTemplatePartialSpecializationDecl) { … }
TEST(TemplateTypeParmDecl, ClassTemplatePartialSpecializationDecl) { … }
TEST(TemplateTypeParmDecl, EnumDecl) { … }
TEST(TemplateTypeParmDecl, RecordDecl) { … }
TEST(RefersToIntegralType, Matches) { … }
TEST(ConstructorDeclaration, SimpleCase) { … }
TEST(DestructorDeclaration, MatchesVirtualDestructor) { … }
TEST(DestructorDeclaration, DoesNotMatchImplicitDestructor) { … }
TEST(HasAnyConstructorInitializer, SimpleCase) { … }
TEST(HasAnyConstructorInitializer, ForField) { … }
TEST(HasAnyConstructorInitializer, WithInitializer) { … }
TEST(HasAnyConstructorInitializer, IsWritten) { … }
TEST(HasAnyConstructorInitializer, IsBaseInitializer) { … }
TEST(IfStmt, ChildTraversalMatchers) { … }
TEST(MatchBinaryOperator, HasOperatorName) { … }
TEST(MatchBinaryOperator, HasAnyOperatorName) { … }
TEST(MatchBinaryOperator, HasLHSAndHasRHS) { … }
TEST(MatchBinaryOperator, HasEitherOperand) { … }
TEST(MatchBinaryOperator, HasOperands) { … }
TEST(MatchBinaryOperator, HasOperandsEnsureOrdering) { … }
TEST(Matcher, BinaryOperatorTypes) { … }
TEST(MatchUnaryOperator, HasOperatorName) { … }
TEST(MatchUnaryOperator, HasAnyOperatorName) { … }
TEST(MatchUnaryOperator, HasUnaryOperand) { … }
TEST(Matcher, UnaryOperatorTypes) { … }
TEST_P(ASTMatchersTest, HasInit) { … }
TEST_P(ASTMatchersTest, HasFoldInit) { … }
TEST_P(ASTMatchersTest, HasPattern) { … }
TEST_P(ASTMatchersTest, HasLHSAndHasRHS) { … }
TEST_P(ASTMatchersTest, HasEitherOperandAndHasOperands) { … }
TEST_P(ASTMatchersTest, Callee) { … }
TEST(ArraySubscriptMatchers, ArrayIndex) { … }
TEST(ArraySubscriptMatchers, MatchesArrayBase) { … }
TEST(Matcher, OfClass) { … }
TEST(Matcher, VisitsTemplateInstantiations) { … }
TEST(Matcher, HasCondition) { … }
TEST(For, ForLoopInternals) { … }
TEST(For, ForRangeLoopInternals) { … }
TEST(For, NegativeForLoopInternals) { … }
TEST(HasBody, FindsBodyOfForWhileDoLoops) { … }
TEST(HasBody, FindsBodyOfFunctions) { … }
TEST(HasAnyBody, FindsAnyBodyOfFunctions) { … }
TEST(HasAnySubstatement, MatchesForTopLevelCompoundStatement) { … }
TEST(HasAnySubstatement, IsNotRecursive) { … }
TEST(HasAnySubstatement, MatchesInNestedCompoundStatements) { … }
TEST(HasAnySubstatement, FindsSubstatementBetweenOthers) { … }
TEST(Member, MatchesMemberAllocationFunction) { … }
TEST(HasDestinationType, MatchesSimpleCase) { … }
TEST(HasImplicitDestinationType, MatchesSimpleCase) { … }
TEST(HasImplicitDestinationType, DoesNotMatchIncorrectly) { … }
TEST(Matcher, IgnoresElidableConstructors) { … }
TEST(Matcher, IgnoresElidableInReturn) { … }
TEST(Matcher, IgnoreElidableConstructorDoesNotMatchConstructors) { … }
TEST(Matcher, IgnoresElidableDoesNotPreventMatches) { … }
TEST(Matcher, IgnoresElidableInVarInit) { … }
TEST(IgnoringImplicit, MatchesImplicit) { … }
TEST(IgnoringImplicit, MatchesNestedImplicit) { … }
TEST(IgnoringImplicit, DoesNotMatchIncorrectly) { … }
TEST(Traversal, traverseMatcher) { … }
TEST(Traversal, traverseNoImplicit) { … }
template <typename MatcherT>
bool matcherTemplateWithBinding(StringRef Code, const MatcherT &M) { … }
TEST(Traversal, traverseWithBinding) { … }
TEST(Traversal, traverseMatcherNesting) { … }
TEST(Traversal, traverseMatcherThroughImplicit) { … }
TEST(Traversal, traverseMatcherThroughMemoization) { … }
TEST(Traversal, traverseUnlessSpelledInSource) { … }
TEST(IgnoringImpCasts, PathologicalLambda) { … }
TEST(IgnoringImpCasts, MatchesImpCasts) { … }
TEST(IgnoringImpCasts, DoesNotMatchIncorrectly) { … }
TEST(IgnoringImpCasts, MatchesWithoutImpCasts) { … }
TEST(IgnoringParenCasts, MatchesParenCasts) { … }
TEST(IgnoringParenCasts, MatchesWithoutParenCasts) { … }
TEST(IgnoringParenCasts, DoesNotMatchIncorrectly) { … }
TEST(IgnoringParenAndImpCasts, MatchesParenImpCasts) { … }
TEST(IgnoringParenAndImpCasts, MatchesWithoutParenImpCasts) { … }
TEST(IgnoringParenAndImpCasts, DoesNotMatchIncorrectly) { … }
TEST(HasSourceExpression, MatchesImplicitCasts) { … }
TEST(HasSourceExpression, MatchesExplicitCasts) { … }
TEST(UsingDeclaration, MatchesSpecificTarget) { … }
TEST(UsingDeclaration, ThroughUsingDeclaration) { … }
TEST(SingleDecl, IsSingleDecl) { … }
TEST(DeclStmt, ContainsDeclaration) { … }
TEST(SwitchCase, MatchesEachCase) { … }
TEST(Declaration, HasExplicitSpecifier) { … }
TEST(ForEachConstructorInitializer, MatchesInitializers) { … }
TEST(LambdaCapture, InvalidLambdaCapture) { … }
TEST(ForEachLambdaCapture, MatchesCaptures) { … }
TEST(ForEachLambdaCapture, IgnoreUnlessSpelledInSource) { … }
TEST(ForEachLambdaCapture, MatchImplicitCapturesOnly) { … }
TEST(ForEachLambdaCapture, MatchExplicitCapturesOnly) { … }
TEST(HasConditionVariableStatement, DoesNotMatchCondition) { … }
TEST(HasConditionVariableStatement, MatchesConditionVariables) { … }
TEST(ForEach, BindsOneNode) { … }
TEST(ForEach, BindsMultipleNodes) { … }
TEST(ForEach, BindsRecursiveCombinations) { … }
TEST(ForEach, DoesNotIgnoreImplicit) { … }
TEST(ForEachDescendant, BindsOneNode) { … }
TEST(ForEachDescendant, NestedForEachDescendant) { … }
TEST(ForEachDescendant, BindsMultipleNodes) { … }
TEST(ForEachDescendant, BindsRecursiveCombinations) { … }
TEST(ForEachDescendant, BindsCombinations) { … }
TEST(ForEachTemplateArgument, OnFunctionDecl) { … }
TEST(ForEachTemplateArgument, OnClassTemplateSpecialization) { … }
TEST(Has, DoesNotDeleteBindings) { … }
TEST(TemplateArgumentLoc, Matches) { … }
TEST(LoopingMatchers, DoNotOverwritePreviousMatchResultOnFailure) { … }
TEST(ForEachDescendant, BindsCorrectNodes) { … }
TEST(FindAll, BindsNodeOnMatch) { … }
TEST(FindAll, BindsDescendantNodeOnMatch) { … }
TEST(FindAll, BindsNodeAndDescendantNodesOnOneMatch) { … }
TEST(HasAncenstor, MatchesDeclarationAncestors) { … }
TEST(HasAncenstor, FailsIfNoAncestorMatches) { … }
TEST(HasAncestor, MatchesDeclarationsThatGetVisitedLater) { … }
TEST(HasAncenstor, MatchesStatementAncestors) { … }
TEST(HasAncestor, DrillsThroughDifferentHierarchies) { … }
TEST(HasAncestor, BindsRecursiveCombinations) { … }
TEST(HasAncestor, BindsCombinationsWithHasDescendant) { … }
TEST(HasAncestor, MatchesClosestAncestor) { … }
TEST(HasAncestor, MatchesInTemplateInstantiations) { … }
TEST(HasAncestor, MatchesInImplicitCode) { … }
TEST(HasParent, MatchesOnlyParent) { … }
TEST(MatcherMemoize, HasParentDiffersFromHas) { … }
TEST(MatcherMemoize, HasDiffersFromHasDescendant) { … }
TEST(HasAncestor, MatchesAllAncestors) { … }
TEST(HasAncestor, ImplicitArrayCopyCtorDeclRefExpr) { … }
TEST(HasAncestor, AnonymousUnionMemberExpr) { … }
TEST(HasAncestor, NonParmDependentTemplateParmVarDeclRefExpr) { … }
TEST(HasAncestor, AddressOfExplicitSpecializationFunction) { … }
TEST(HasParent, MatchesAllParents) { … }
TEST(HasParent, NoDuplicateParents) { … }
TEST(HasAnyBase, BindsInnerBoundNodes) { … }
TEST(TypeMatching, PointeeTypes) { … }
TEST(ElaboratedTypeNarrowing, hasQualifier) { … }
TEST(ElaboratedTypeNarrowing, namesType) { … }
TEST(NNS, BindsNestedNameSpecifiers) { … }
TEST(NNS, BindsNestedNameSpecifierLocs) { … }
TEST(NNS, DescendantsOfNestedNameSpecifiers) { … }
TEST(NNS, NestedNameSpecifiersAsDescendants) { … }
TEST(NNSLoc, DescendantsOfNestedNameSpecifierLocs) { … }
TEST(NNSLoc, NestedNameSpecifierLocsAsDescendants) { … }
TEST(Attr, AttrsAsDescendants) { … }
TEST(Attr, ParentsOfAttrs) { … }
template <typename T> class VerifyMatchOnNode : public BoundNodesCallback { … };
TEST(MatchFinder, CanMatchDeclarationsRecursively) { … }
TEST(MatchFinder, CanMatchStatementsRecursively) { … }
TEST(MatchFinder, CanMatchSingleNodesRecursively) { … }
TEST(StatementMatcher, HasReturnValue) { … }
TEST(StatementMatcher, ForFunction) { … }
TEST(StatementMatcher, ForCallable) { … }
namespace {
class ForCallablePreservesBindingWithMultipleParentsTestCallback
: public BoundNodesCallback { … };
}
TEST(StatementMatcher, ForCallablePreservesBindingWithMultipleParents) { … }
TEST(Matcher, ForEachOverriden) { … }
TEST(Matcher, HasAnyDeclaration) { … }
TEST(SubstTemplateTypeParmType, HasReplacementType) { … }
TEST(ClassTemplateSpecializationDecl, HasSpecializedTemplate) { … }
TEST(CXXNewExpr, Array) { … }
TEST(CXXNewExpr, PlacementArgs) { … }
TEST(HasUnqualifiedLoc, BindsToConstIntVarDecl) { … }
TEST(HasUnqualifiedLoc, BindsToVolatileIntVarDecl) { … }
TEST(HasUnqualifiedLoc, BindsToConstVolatileIntVarDecl) { … }
TEST(HasUnqualifiedLoc, BindsToConstPointerVarDecl) { … }
TEST(HasUnqualifiedLoc, BindsToPointerToConstVolatileIntVarDecl) { … }
TEST(HasUnqualifiedLoc, BindsToConstIntFunctionDecl) { … }
TEST(HasUnqualifiedLoc, FloatBindsToConstFloatVarDecl) { … }
TEST(HasUnqualifiedLoc, FloatDoesNotBindToIntVarDecl) { … }
TEST(HasUnqualifiedLoc, FloatDoesNotBindToConstIntVarDecl) { … }
TEST(HasReturnTypeLoc, BindsToIntReturnTypeLoc) { … }
TEST(HasReturnTypeLoc, BindsToFloatReturnTypeLoc) { … }
TEST(HasReturnTypeLoc, BindsToVoidReturnTypeLoc) { … }
TEST(HasReturnTypeLoc, FloatDoesNotBindToIntReturnTypeLoc) { … }
TEST(HasReturnTypeLoc, IntDoesNotBindToFloatReturnTypeLoc) { … }
TEST(HasPointeeLoc, BindsToAnyPointeeTypeLoc) { … }
TEST(HasPointeeLoc, DoesNotBindToTypeLocWithoutPointee) { … }
TEST(HasPointeeLoc, BindsToTypeLocPointingToInt) { … }
TEST(HasPointeeLoc, BindsToTypeLocPointingToIntPointer) { … }
TEST(HasPointeeLoc, BindsToTypeLocPointingToTypeLocPointingToInt) { … }
TEST(HasPointeeLoc, BindsToTypeLocPointingToFloat) { … }
TEST(HasPointeeLoc, IntPointeeDoesNotBindToTypeLocPointingToFloat) { … }
TEST(HasPointeeLoc, FloatPointeeDoesNotBindToTypeLocPointingToInt) { … }
TEST(HasReferentLoc, BindsToAnyReferentTypeLoc) { … }
TEST(HasReferentLoc, DoesNotBindToTypeLocWithoutReferent) { … }
TEST(HasReferentLoc, BindsToAnyRvalueReference) { … }
TEST(HasReferentLoc, BindsToIntReferenceTypeLoc) { … }
TEST(HasReferentLoc, BindsToIntRvalueReferenceTypeLoc) { … }
TEST(HasReferentLoc, BindsToFloatReferenceTypeLoc) { … }
TEST(HasReferentLoc, BindsToParameterWithIntReferenceTypeLoc) { … }
TEST(HasReferentLoc, IntReferenceDoesNotBindToFloatReferenceTypeLoc) { … }
TEST(HasReferentLoc, FloatReferenceDoesNotBindToIntReferenceTypeLoc) { … }
TEST(HasReferentLoc, DoesNotBindToParameterWithoutIntReferenceTypeLoc) { … }
TEST(HasAnyTemplateArgumentLoc, BindsToSpecializationWithIntArgument) { … }
TEST(HasAnyTemplateArgumentLoc, BindsToSpecializationWithDoubleArgument) { … }
TEST(HasAnyTemplateArgumentLoc, BindsToExplicitSpecializationWithIntArgument) { … }
TEST(HasAnyTemplateArgumentLoc,
BindsToExplicitSpecializationWithDoubleArgument) { … }
TEST(HasAnyTemplateArgumentLoc, BindsToSpecializationWithMultipleArguments) { … }
TEST(HasAnyTemplateArgumentLoc, DoesNotBindToSpecializationWithIntArgument) { … }
TEST(HasAnyTemplateArgumentLoc,
DoesNotBindToExplicitSpecializationWithIntArgument) { … }
TEST(HasTemplateArgumentLoc, BindsToSpecializationWithIntArgument) { … }
TEST(HasTemplateArgumentLoc, BindsToSpecializationWithDoubleArgument) { … }
TEST(HasTemplateArgumentLoc, DoesNotBindToSpecializationWithIntArgument) { … }
TEST(HasTemplateArgumentLoc, BindsToExplicitSpecializationWithIntArgument) { … }
TEST(HasTemplateArgumentLoc, BindsToExplicitSpecializationWithDoubleArgument) { … }
TEST(HasTemplateArgumentLoc, BindsToSpecializationWithMultipleArguments) { … }
TEST(HasTemplateArgumentLoc,
DoesNotBindToExplicitSpecializationWithIntArgument) { … }
TEST(HasTemplateArgumentLoc,
DoesNotBindToSpecializationWithMisplacedArguments) { … }
TEST(HasTemplateArgumentLoc, DoesNotBindWithBadIndex) { … }
TEST(HasTemplateArgumentLoc, BindsToDeclRefExprWithIntArgument) { … }
TEST(HasTemplateArgumentLoc, BindsToDeclRefExprWithDoubleArgument) { … }
TEST(HasTemplateArgumentLoc, DoesNotBindToDeclRefExprWithDoubleArgument) { … }
TEST(HasNamedTypeLoc, BindsToElaboratedObjectDeclaration) { … }
TEST(HasNamedTypeLoc, DoesNotBindToNonElaboratedObjectDeclaration) { … }
}
}