Home | History | Annotate | Download | only in ASTMatchers

Lines Matching refs:matches

28   EXPECT_TRUE(matches(Program,
31 EXPECT_TRUE(matches(Program,
36 EXPECT_TRUE(matches(Program,
42 EXPECT_TRUE(matches(Program,
53 EXPECT_TRUE(matches("class Y { class X {}; };", HasClassX));
54 EXPECT_TRUE(matches("class X {};", HasClassX));
58 EXPECT_TRUE(matches("class Y { class X {}; };", YHasClassX));
77 EXPECT_TRUE(matches(
89 EXPECT_TRUE(matches(
103 EXPECT_TRUE(matches(
142 EXPECT_TRUE(matches("class F {};", Recursive));
143 EXPECT_TRUE(matches("class Z {};", Recursive));
144 EXPECT_TRUE(matches("class C {};", Recursive));
145 EXPECT_TRUE(matches("class M { class N { class X {}; }; };", Recursive));
146 EXPECT_TRUE(matches("class M { class N { class B {}; }; };", Recursive));
148 matches("class O1 { class O2 {"
160 EXPECT_TRUE(matches("class Y {}; class Z : public Y {};", NotClassX));
172 EXPECT_TRUE(matches("class X { class Z {}; };", ClassXHasNotClassY));
178 EXPECT_TRUE(matches("void Foo(){}", NamedNotRecord));
183 EXPECT_TRUE(matches("char *p = 0;",
187 EXPECT_TRUE(matches("char *p = 0;",
196 EXPECT_TRUE(matches("class Z { class X {}; };", ZDescendantClassX));
198 matches("class Z { class Y { class X {}; }; };", ZDescendantClassX));
200 matches("class Z { class A { class Y { class X {}; }; }; };",
203 matches("class Z { class A { class B { class Y { class X {}; }; }; }; };",
212 EXPECT_TRUE(matches("class Z { class X { class Y {}; }; };",
215 matches("class Z { class A { class B { class X { class Y {}; }; }; }; };",
236 matches("class Z { class A { class X { class B { class Y {}; }; }; }; };",
238 EXPECT_TRUE(matches(
254 EXPECT_TRUE(matches("void f() { int i; }", CannotMemoize));
267 EXPECT_TRUE(matches("void f() { int i; }",
285 EXPECT_TRUE(matches("struct __attribute__((warn_unused)) X {};",
287 EXPECT_FALSE(matches("struct X {};",
295 EXPECT_TRUE(matches("class X {}; class Z : public X {};", YOrZDerivedFromX));
296 EXPECT_TRUE(matches("class Y {};", YOrZDerivedFromX));
303 EXPECT_TRUE(matches("class X {};", XOrYOrZOrU));
309 EXPECT_TRUE(matches("class X {};", XOrYOrZOrUOrV));
310 EXPECT_TRUE(matches("class Y {};", XOrYOrZOrUOrV));
311 EXPECT_TRUE(matches("class Z {};", XOrYOrZOrUOrV));
312 EXPECT_TRUE(matches("class U {};", XOrYOrZOrUOrV));
313 EXPECT_TRUE(matches("class V {};", XOrYOrZOrUOrV));
317 EXPECT_TRUE(matches("int F() { return 1 + 2; }", MixedTypes));
318 EXPECT_TRUE(matches("int F() { if (true) return 1; }", MixedTypes));
322 matches("void f() try { } catch (int) { } catch (...) { }",
329 EXPECT_TRUE(matches("class X {}; class Y : public X {};", IsDerivedFromX));
337 EXPECT_TRUE(matches("class X {}; class Y : public X {};", IsAX));
338 EXPECT_TRUE(matches("class X {};", IsAX));
339 EXPECT_TRUE(matches("class X;", IsAX));
346 matches("class X {}; class Y : public X {}; class Z : public Y {};",
349 matches("class X {};"
352 EXPECT_TRUE(matches("class X {}; template<class T> class Z : public X {};",
355 matches("template<class T> class X {}; "
359 matches("template<class T, class U=T> class X {}; "
366 matches("template<class X> class A { public: class Z : public X {}; }; "
369 matches("template <class T> class X {}; "
376 matches("template<template<class T> class X> class A { "
384 matches("template<class X> class A { public: "
389 matches("class X {}; typedef X Y; class Z : public Y {};",
392 matches("template<class T> class Y { typedef typename T::U X; "
394 EXPECT_TRUE(matches("class X {}; class Z : public ::X {};",
401 matches("template<class T> class X { public: typedef X<T> D; }; "
409 matches("class X {}; typedef X V; typedef V W; class Z : public W {};",
412 matches("class X {}; class Y : public X {}; "
416 matches("template<class T, class U> class X {}; "
424 matches("class X {}; typedef X A; typedef A B; "
427 matches("class X {}; typedef X A; typedef A B; typedef B C; "
430 matches("class U {}; typedef U X; typedef X V; "
433 matches("class Base {}; typedef Base X; "
436 matches("class Base {}; typedef Base Base2; typedef Base2 X; "
442 matches("class A {}; typedef A X; typedef A Y; "
450 matches("template <typename T> class X;"
454 EXPECT_TRUE(matches(
464 EXPECT_TRUE(matches(
484 EXPECT_TRUE(matches(
492 EXPECT_TRUE(matches(
509 EXPECT_TRUE(matches(
517 EXPECT_TRUE(matches(
522 EXPECT_TRUE(matches(
529 EXPECT_TRUE(matches(
533 EXPECT_TRUE(matches(
542 EXPECT_TRUE(matches("auto x = []{};", IsLambda));
601 matches("class Y { public: void x(); }; void z() {Y* y; y->x(); }",
604 matches("class X { void x(int x) {} };",
606 EXPECT_TRUE(matches("namespace ns { struct A {}; } struct B { ns::A a; };",
608 EXPECT_TRUE(matches("namespace { struct A {}; } struct B { A a; };",
615 EXPECT_TRUE(matches("class Y { }; "
626 EXPECT_TRUE(matches("class Y; int operator*(Y &); void f(Y &y) { *y; }",
630 EXPECT_TRUE(matches("class Y { int operator*(); };",
635 EXPECT_TRUE(matches("class Y; int operator*(Y &);", AnyOpStar));
636 EXPECT_TRUE(matches("class Y { int operator*(); };", AnyOpStar));
647 EXPECT_TRUE(matches("class Y { }; "
652 matches("class Y { }; "
660 EXPECT_TRUE(matches("void f() { int X; }", M));
666 EXPECT_TRUE(matches("int X;", M));
667 EXPECT_TRUE(matches("void f() { static int X; }", M));
674 EXPECT_TRUE(matches(T, varDecl(hasName("x"), hasAutomaticStorageDuration())));
680 EXPECT_TRUE(matches(T, varDecl(hasName("y"), hasStaticStorageDuration())));
681 EXPECT_TRUE(matches(T, varDecl(hasName("a"), hasStaticStorageDuration())));
694 EXPECT_TRUE(matches(
700 EXPECT_TRUE(matches("void x() { int a = sizeof(a); }", sizeOfExpr(
704 EXPECT_TRUE(matches(
712 EXPECT_TRUE(matches("int i = 0;", varDecl(hasType(isInteger()))));
713 EXPECT_TRUE(matches(
727 EXPECT_TRUE(matches("int i = 0;", varDecl(hasType(isSignedInteger()))));
734 EXPECT_TRUE(matches("unsigned i = 0;",
739 EXPECT_TRUE(matches("int* i = nullptr;", varDecl(hasType(isAnyPointer()))));
752 EXPECT_TRUE(matches("char i = 0;", varDecl(hasType(isAnyCharacter()))));
760 EXPECT_TRUE(matches("class Y { void x() { this->y; } int y; };",
762 EXPECT_TRUE(matches("class Y { void x() { y; } int y; };",
769 EXPECT_TRUE(matches("class Y { void x() { this->y; } static int y; };",
778 EXPECT_TRUE(matches("class Y { void x() { this->x(); } };",
780 EXPECT_TRUE(matches("class Y { void x() { x(); } };",
787 EXPECT_TRUE(matches("struct S { explicit operator int(); };",
796 EXPECT_TRUE(matches("void x(int) { x(0); }", Call1Arg));
797 EXPECT_TRUE(matches("class X { void x(int) { x(0); } };", Call1Arg));
803 EXPECT_TRUE(matches("void f(int i) {}", Function1Arg));
804 EXPECT_TRUE(matches("class X { void f(int i) {} };", Function1Arg));
807 EXPECT_TRUE(matches("void f(int i, ...) {};", Function1Arg));
813 EXPECT_TRUE(matches("class X {}; void y(X y) { X &x = y; }",
816 matches("class X {}; void y(X y) { const X &x = y; }", ReferenceClassX));
820 matches("class X {}; void y(X y) { X x = y; }", ReferenceClassX));
830 EXPECT_TRUE(matches("int *const j = nullptr;",
832 EXPECT_TRUE(matches("int *volatile k;",
839 EXPECT_TRUE(matches("extern \"C\" void f() {}", functionDecl(isExternC())));
840 EXPECT_TRUE(matches("extern \"C\" { void f() {} }",
848 EXPECT_TRUE(matches("class B { ~B() = default; };",
855 EXPECT_TRUE(matches("void Func() = delete;",
864 EXPECT_TRUE(matches("void f() throw();", functionDecl(isNoThrow())));
865 EXPECT_TRUE(matches("void f() noexcept;", functionDecl(isNoThrow())));
871 EXPECT_TRUE(matches("void f() throw();", functionProtoType(isNoThrow())));
872 EXPECT_TRUE(matches("void f() noexcept;", functionProtoType(isNoThrow())));
876 EXPECT_TRUE(matches("constexpr int foo = 42;",
878 EXPECT_TRUE(matches("constexpr int bar();",
882 TEST(TemplateArgumentCountIs, Matches) {
884 matches("template<typename T> struct C {}; C<int> c;",
890 EXPECT_TRUE(matches("template<typename T> struct C {}; C<int> c;",
897 TEST(IsIntegral, Matches) {
898 EXPECT_TRUE(matches("template<int T> struct C {}; C<42> c;",
906 TEST(EqualsIntegralValue, Matches) {
907 EXPECT_TRUE(matches("template<int T> struct C {}; C<42> c;",
910 EXPECT_TRUE(matches("template<int T> struct C {}; C<-42> c;",
913 EXPECT_TRUE(matches("template<int T> struct C {}; C<-0042> c;",
922 EXPECT_TRUE(matches("class C { public: int i; };", accessSpecDecl()));
924 matches("class C { public: int i; };", accessSpecDecl(isPublic())));
934 EXPECT_TRUE(matches("class X final {};", cxxRecordDecl(isFinal())));
935 EXPECT_TRUE(matches("class X { virtual void f() final; };",
943 EXPECT_TRUE(matches("class X { virtual int f(); };",
949 EXPECT_TRUE(matches("class A { virtual int f(); };"
959 EXPECT_TRUE(matches("class X { virtual int f() = 0; };",
965 EXPECT_TRUE(matches("class X { X &operator=(X); };",
967 EXPECT_TRUE(matches("class X { X &operator=(X &); };",
969 EXPECT_TRUE(matches("class X { X &operator=(const X &); };",
971 EXPECT_TRUE(matches("class X { X &operator=(volatile X &); };",
973 EXPECT_TRUE(matches("class X { X &operator=(const volatile X &); };",
982 EXPECT_TRUE(matches("class X { X &operator=(X &&); };",
984 EXPECT_TRUE(matches("class X { X &operator=(const X &&); };",
986 EXPECT_TRUE(matches("class X { X &operator=(volatile X &&); };",
988 EXPECT_TRUE(matches("class X { X &operator=(const volatile X &&); };",
996 matches("struct A { void foo() const; };", cxxMethodDecl(isConst())));
1002 EXPECT_TRUE(matches("class X { virtual int f(); }; "
1014 matches("template <typename Base> struct Y : Base { void f() override;};",
1023 matches("class X { public: X(int); }; void x() { int y; X x(y); }",
1026 matches("class X { public: X(int); }; void x() { int y; X x = X(y); }",
1029 matches("class X { public: X(int); }; void x() { int y; X x = y; }",
1046 matches("class X { public: X(int); }; void x() { X x(0); }",
1049 matches("class X { public: X(int); }; void x() { X x = X(0); }",
1052 matches("class X { public: X(int); }; void x() { X x = 0; }",
1064 matches("class X { public: X(int); }; void x() { X x{0}; }",
1067 matches("class X { public: X(int); }; void x() { X x(0); }",
1077 EXPECT_TRUE(matches("class Foo { }; Foo* f = new Foo();",
1079 EXPECT_TRUE(matches("class Foo { Foo(){} };",
1082 EXPECT_TRUE(matches("struct A { int x; } a = {0}, b = a; void f() { a = b; }",
1087 EXPECT_TRUE(matches("struct S { explicit S(int); };",
1094 EXPECT_TRUE(matches("struct S { S(); };",
1103 EXPECT_TRUE(matches("struct S { S(const S&); };",
1112 EXPECT_TRUE(matches("struct S { S(S&&); };",
1124 matches("struct S { S(); };", cxxConstructorDecl(isUserProvided())));
1125 EXPECT_TRUE(matches("struct S { S(); }; S::S(){}",
1134 EXPECT_TRUE(matches(
1137 EXPECT_TRUE(matches(
1144 EXPECT_TRUE(matches("const char *s = \"abcd\";", Literal));
1146 EXPECT_TRUE(matches("const wchar_t *s = L\"abcd\";", Literal));
1148 EXPECT_TRUE(matches("const char *s = \"\x05\x06\x07\x08\";", Literal));
1154 EXPECT_TRUE(matches("namespace a { namespace b { class C; } }",
1156 EXPECT_TRUE(matches("namespace a { namespace b { class C; } }",
1158 EXPECT_TRUE(matches("namespace a { namespace b { class C; } }",
1160 EXPECT_TRUE(matches("namespace a { namespace b { class C; } }",
1182 matches("class A { class B { class C; }; };",
1185 matches("class A { class B { class C; }; };",
1188 matches("class A { class B { class C; }; };",
1191 matches("class A { class B { class C; }; };",
1217 EXPECT_TRUE(matches(code, recordDecl(hasName("a::b::C"))));
1218 EXPECT_TRUE(matches(code, recordDecl(hasName("a::C"))));
1219 EXPECT_TRUE(matches(code, recordDecl(hasName("::a::b::C"))));
1220 EXPECT_TRUE(matches(code, recordDecl(hasName("::a::C"))));
1226 matches(code, recordDecl(hasName("a::(anonymous namespace)::C"))));
1227 EXPECT_TRUE(matches(code, recordDecl(hasName("a::C"))));
1229 matches(code, recordDecl(hasName("::a::(anonymous namespace)::C"))));
1230 EXPECT_TRUE(matches(code, recordDecl(hasName("::a::C"))));
1234 EXPECT_TRUE(matches("class A { class { class C; } x; };",
1236 EXPECT_TRUE(matches("class A { class { class C; } x; };",
1238 EXPECT_FALSE(matches("class A { class { class C; } x; };",
1240 EXPECT_TRUE(matches("class A { struct { class C; } x; };",
1242 EXPECT_TRUE(matches("class A { struct { class C; } x; };",
1244 EXPECT_FALSE(matches("class A { struct { class C; } x; };",
1251 EXPECT_TRUE(matches(code, varDecl(hasName("i"))));
1252 EXPECT_FALSE(matches(code, varDecl(hasName("F()::i"))));
1254 EXPECT_TRUE(matches(code, fieldDecl(hasName("m"))));
1255 EXPECT_TRUE(matches(code, fieldDecl(hasName("S::m"))));
1256 EXPECT_TRUE(matches(code, fieldDecl(hasName("F(int)::S::m"))));
1257 EXPECT_TRUE(matches(code, fieldDecl(hasName("a::F(int)::S::m"))));
1258 EXPECT_TRUE(matches(code, fieldDecl(hasName("::a::F(int)::S::m"))));
1264 EXPECT_TRUE(matches(Code, recordDecl(hasAnyName("XX", "a::b::C"))));
1265 EXPECT_TRUE(matches(Code, recordDecl(hasAnyName("a::b::C", "XX"))));
1266 EXPECT_TRUE(matches(Code, recordDecl(hasAnyName("XX::C", "a::b::C"))));
1267 EXPECT_TRUE(matches(Code, recordDecl(hasAnyName("XX", "C"))));
1271 matches(Code, recordDecl(hasAnyName("::C", "::b::C", "::a::b::C"))));
1274 EXPECT_TRUE(matches(Code, recordDecl(hasAnyName(Names))));
1280 EXPECT_TRUE(matches("class A {};", DefinitionOfClassA));
1285 EXPECT_TRUE(matches("int a;", DefinitionOfVariableA));
1290 EXPECT_TRUE(matches("class A { void a() {} };", DefinitionOfMethodA));
1301 EXPECT_TRUE(matches(
1321 EXPECT_TRUE(matches("void f() { }",
1328 EXPECT_TRUE(matches("void f() { 1; }",
1337 EXPECT_TRUE(matches("void f() { 1; 2; 3; }",
1342 EXPECT_TRUE(matches("void f() { { 1; } { 1; 2; 3; 4; } }",
1344 EXPECT_TRUE(matches("void f() { { 1; } { 1; 2; 3; 4; } }",
1348 EXPECT_TRUE(matches("void f() { { 1; } { 1; 2; 3; 4; } }",
1353 EXPECT_TRUE(matches("struct { int first; } s; int i(s.first);",
1365 EXPECT_TRUE(matches("void f() {"
1373 EXPECT_TRUE(matches(
1382 EXPECT_TRUE(matches("class C { int a : 2; int b; };",
1386 EXPECT_TRUE(matches("class C { int a : 2; int b : 4; };",
1391 EXPECT_TRUE(matches(
1402 EXPECT_TRUE(matches(
1407 EXPECT_TRUE(matches("class A { protected: int i; };",
1427 matches("void j() throw();", functionDecl(hasDynamicExceptionSpec())));
1429 matches("void k() throw(int);", functionDecl(hasDynamicExceptionSpec())));
1431 matches("void l() throw(...);", functionDecl(hasDynamicExceptionSpec())));
1441 matches("void j() throw();", functionProtoType(hasDynamicExceptionSpec())));
1443 matches("void k() throw(int);", functionProtoType(hasDynamicExceptionSpec())));
1445 matches("void l() throw(...);", functionProtoType(hasDynamicExceptionSpec())));
1455 EXPECT_TRUE(matches(
1458 EXPECT_TRUE(matches(
1466 EXPECT_TRUE(matches(
1470 EXPECT_TRUE(matches(
1484 EXPECT_TRUE(matches("class X { int m; };", fieldDecl(hasName("m"))));
1488 EXPECT_TRUE(matches("volatile int i = 42;",
1492 EXPECT_TRUE(matches("typedef volatile int v_int; v_int i = 42;",
1497 EXPECT_TRUE(matches("const int i = 42;",
1502 EXPECT_TRUE(matches("int i = 42; int* const p(&i);",
1507 EXPECT_TRUE(matches("typedef const int const_int; const_int i = 42;",
1509 EXPECT_TRUE(matches("typedef int* int_ptr; const int_ptr p(0);",
1521 EXPECT_TRUE(matches("void f() {int i,j;}",
1559 EXPECT_TRUE(matches(
1563 EXPECT_TRUE(matches(
1570 EXPECT_TRUE(matches(
1577 EXPECT_TRUE(matches(
1586 EXPECT_TRUE(matches(
1594 EXPECT_TRUE(matches(
1607 EXPECT_TRUE(matches(
1631 matches("template<typename T> class A { T i; }; class Y { A<int> a; };",
1641 EXPECT_TRUE(matches("template<typename T> struct A { A() { T i; } };"
1653 matches("template<typename T> void A(T t) { T i; } void x() { A(0); }",
1664 matches("template<typename T> void A(T t) { T i; } void x() { A(0); }",
1680 EXPECT_TRUE(matches(
1719 EXPECT_TRUE(matches(
1723 EXPECT_TRUE(matches(
1730 EXPECT_TRUE(matches("struct S { bool func(); };",
1737 EXPECT_TRUE(matches("struct S { void func(); };",
1742 EXPECT_TRUE(matches("struct S { float func(); };",
1746 EXPECT_TRUE(matches("struct S { long double func(); };",
1751 EXPECT_TRUE(matches("int a[] = {2,3};", arrayType()));
1752 EXPECT_TRUE(matches("int a[42];", arrayType()));
1753 EXPECT_TRUE(matches("void f(int b) { int a[b]; }", arrayType()));
1758 EXPECT_TRUE(matches(
1761 EXPECT_TRUE(matches(
1764 EXPECT_TRUE(matches(
1779 EXPECT_TRUE(matches("int a[2];",
1781 EXPECT_TRUE(matches("const int a = 0;", qualType(isInteger())));
1785 EXPECT_TRUE(matches("void f(int i[]);", valueDecl(hasType(decayedType(hasDecayedType(pointerType()))))));
1790 EXPECT_TRUE(matches("_Complex float f;", complexType()));
1791 EXPECT_TRUE(matches(
1801 EXPECT_TRUE(matches("namespace {}", namespaceDecl(isAnonymous())));
1805 EXPECT_TRUE(matches(
1824 matches("void f() { if(true) {} }",
1834 EXPECT_TRUE(matches(
1845 EXPECT_TRUE(matches(
1908 EXPECT_FALSE(matches(
1925 EXPECT_TRUE(matches("#define NULL ((void *)0)\n"
1927 EXPECT_TRUE(matches("void *v2 = nullptr;", expr(nullPointerConstant())));
1928 EXPECT_TRUE(matches("void *v3 = __null;", expr(nullPointerConstant())));
1929 EXPECT_TRUE(matches("char *cp = (char *)0;", expr(nullPointerConstant())));
1930 EXPECT_TRUE(matches("int *ip = 0;", expr(nullPointerConstant())));