Home | History | Annotate | Download | only in ASTMatchers

Lines Matching refs:EXPECT_TRUE

26     EXPECT_TRUE(notMatches("class X {};", HasEmptyName));
33 EXPECT_TRUE(notMatches("class X {};", HasEmptyName));
40 EXPECT_TRUE(notMatches("class X {};", IsDerivedFromEmpty));
47 EXPECT_TRUE(Finder.addDynamicMatcher(decl(), nullptr));
48 EXPECT_TRUE(Finder.addDynamicMatcher(callExpr(), nullptr));
49 EXPECT_TRUE(Finder.addDynamicMatcher(constantArrayType(hasSize(42)),
59 EXPECT_TRUE(notMatches("", decl(usingDecl())));
60 EXPECT_TRUE(matches("namespace x { class X {}; } using x::X;",
66 EXPECT_TRUE(matches("typedef int X;", NamedX));
67 EXPECT_TRUE(matches("int X;", NamedX));
68 EXPECT_TRUE(matches("class foo { virtual void X(); };", NamedX));
69 EXPECT_TRUE(matches("void foo() try { } catch(int X) { }", NamedX));
70 EXPECT_TRUE(matches("void foo() { int X; }", NamedX));
71 EXPECT_TRUE(matches("namespace X { }", NamedX));
72 EXPECT_TRUE(matches("enum X { A, B, C };", NamedX));
74 EXPECT_TRUE(notMatches("#define X 1", NamedX));
79 EXPECT_TRUE(matches("typedef int Xa;", NamedX));
80 EXPECT_TRUE(matches("int Xb;", NamedX));
81 EXPECT_TRUE(matches("class foo { virtual void Xc(); };", NamedX));
82 EXPECT_TRUE(matches("void foo() try { } catch(int Xdef) { }", NamedX));
83 EXPECT_TRUE(matches("void foo() { int Xgh; }", NamedX));
84 EXPECT_TRUE(matches("namespace Xij { }", NamedX));
85 EXPECT_TRUE(matches("enum X { A, B, C };", NamedX));
87 EXPECT_TRUE(notMatches("#define Xkl 1", NamedX));
90 EXPECT_TRUE(matches("int no_foo;", StartsWithNo));
91 EXPECT_TRUE(matches("class foo { virtual void nobody(); };", StartsWithNo));
94 EXPECT_TRUE(matches("int abc;", Abc));
95 EXPECT_TRUE(matches("int aFOObBARc;", Abc));
96 EXPECT_TRUE(notMatches("int cab;", Abc));
97 EXPECT_TRUE(matches("int cabc;", Abc));
100 EXPECT_TRUE(matches("int k;", StartsWithK));
101 EXPECT_TRUE(matches("int kAbc;", StartsWithK));
102 EXPECT_TRUE(matches("namespace x { int kTest; }", StartsWithK));
103 EXPECT_TRUE(matches("class C { int k; };", StartsWithK));
104 EXPECT_TRUE(notMatches("class C { int ckc; };", StartsWithK));
115 EXPECT_TRUE(matches("", ClassMatcher));
118 EXPECT_TRUE(matches("class X;", ClassX));
119 EXPECT_TRUE(matches("class X {};", ClassX));
120 EXPECT_TRUE(matches("template<class T> class X {};", ClassX));
121 EXPECT_TRUE(notMatches("", ClassX));
127 EXPECT_TRUE(matches("class X {}; class Y : public X {};", IsDerivedFromX));
128 EXPECT_TRUE(notMatches("class X {};", IsDerivedFromX));
129 EXPECT_TRUE(notMatches("class X;", IsDerivedFromX));
130 EXPECT_TRUE(notMatches("class Y;", IsDerivedFromX));
131 EXPECT_TRUE(notMatches("", IsDerivedFromX));
135 EXPECT_TRUE(matches("class X {}; class Y : public X {};", IsAX));
136 EXPECT_TRUE(matches("class X {};", IsAX));
137 EXPECT_TRUE(matches("class X;", IsAX));
138 EXPECT_TRUE(notMatches("class Y;", IsAX));
139 EXPECT_TRUE(notMatches("", IsAX));
143 EXPECT_TRUE(
146 EXPECT_TRUE(
150 EXPECT_TRUE(matches("class X {}; template<class T> class Z : public X {};",
152 EXPECT_TRUE(
156 EXPECT_TRUE(
160 EXPECT_TRUE(
163 EXPECT_TRUE(
166 EXPECT_TRUE(
170 EXPECT_TRUE(
173 EXPECT_TRUE(
178 EXPECT_TRUE(
181 EXPECT_TRUE(
186 EXPECT_TRUE(
189 EXPECT_TRUE(
192 EXPECT_TRUE(matches("class X {}; class Z : public ::X {};",
194 EXPECT_TRUE(
198 EXPECT_TRUE(
203 EXPECT_TRUE(
206 EXPECT_TRUE(
209 EXPECT_TRUE(
213 EXPECT_TRUE(
217 EXPECT_TRUE(
221 EXPECT_TRUE(
224 EXPECT_TRUE(
227 EXPECT_TRUE(
230 EXPECT_TRUE(
233 EXPECT_TRUE(
236 EXPECT_TRUE(
239 EXPECT_TRUE(
242 EXPECT_TRUE(
247 EXPECT_TRUE(
252 EXPECT_TRUE(matches(
258 EXPECT_TRUE(
262 EXPECT_TRUE(matches(
282 EXPECT_TRUE(matches(
286 EXPECT_TRUE(notMatches(
290 EXPECT_TRUE(matches(
307 EXPECT_TRUE(matches(
311 EXPECT_TRUE(notMatches(
315 EXPECT_TRUE(matches(
320 EXPECT_TRUE(matches(
323 EXPECT_TRUE(notMatches(
327 EXPECT_TRUE(matches(
331 EXPECT_TRUE(matches(
339 EXPECT_TRUE(matches("class A { void func(); };",
341 EXPECT_TRUE(notMatches("class A { void func(); };",
346 EXPECT_TRUE(matches(
356 EXPECT_TRUE(matches(
363 EXPECT_TRUE(notMatches(
371 EXPECT_TRUE(matches("namespace {"
382 EXPECT_TRUE(notMatches("class X;", ClassX));
383 EXPECT_TRUE(notMatches("class X {};", ClassX));
388 EXPECT_TRUE(matches("template<typename T> class X {};", ClassX));
389 EXPECT_TRUE(matches("class Z { template<class T> class X {}; };", ClassX));
393 EXPECT_TRUE(notMatches("template<typename T> class X { };"
400 EXPECT_TRUE
411 EXPECT_TRUE(matches(Program,
414 EXPECT_TRUE(matches(Program,
419 EXPECT_TRUE(matches(Program,
425 EXPECT_TRUE(matches(Program,
437 EXPECT_TRUE(
439 EXPECT_TRUE(matches("class Y {};", YOrZDerivedFromX));
440 EXPECT_TRUE(
442 EXPECT_TRUE(notMatches("class Z {};", YOrZDerivedFromX));
446 EXPECT_TRUE(matches("class X {};", XOrYOrZOrU));
447 EXPECT_TRUE(notMatches("class V {};", XOrYOrZOrU));
452 EXPECT_TRUE(matches("class X {};", XOrYOrZOrUOrV));
453 EXPECT_TRUE(matches("class Y {};", XOrYOrZOrUOrV));
454 EXPECT_TRUE(matches("class Z {};", XOrYOrZOrUOrV));
455 EXPECT_TRUE(matches("class U {};", XOrYOrZOrUOrV));
456 EXPECT_TRUE(matches("class V {};", XOrYOrZOrUOrV));
457 EXPECT_TRUE(notMatches("class A {};", XOrYOrZOrUOrV));
462 EXPECT_TRUE(matches("class Y { class X {}; };", HasClassX));
463 EXPECT_TRUE(matches("class X {};", HasClassX));
467 EXPECT_TRUE(matches("class Y { class X {}; };", YHasClassX));
468 EXPECT_TRUE(notMatches("class X {};", YHasClassX));
469 EXPECT_TRUE(
486 EXPECT_TRUE(matches(
498 EXPECT_TRUE(matches(
512 EXPECT_TRUE(matches(
551 EXPECT_TRUE(matches("class F {};", Recursive));
552 EXPECT_TRUE(matches("class Z {};", Recursive));
553 EXPECT_TRUE(matches("class C {};", Recursive));
554 EXPECT_TRUE(matches("class M { class N { class X {}; }; };", Recursive));
555 EXPECT_TRUE(matches("class M { class N { class B {}; }; };", Recursive));
556 EXPECT_TRUE(
567 EXPECT_TRUE(notMatches("", NotClassX));
568 EXPECT_TRUE(notMatches("class Y {};", NotClassX));
569 EXPECT_TRUE(matches("class Y {}; class Z : public Y {};", NotClassX));
570 EXPECT_TRUE(notMatches("class Y {}; class X : public Y {};", NotClassX));
571 EXPECT_TRUE(
581 EXPECT_TRUE(matches("class X { class Z {}; };", ClassXHasNotClassY));
582 EXPECT_TRUE(notMatches("class X { class Y {}; class Z {}; };",
591 EXPECT_TRUE(matches("class Z { class X {}; };", ZDescendantClassX));
592 EXPECT_TRUE(
594 EXPECT_TRUE(
597 EXPECT_TRUE(
600 EXPECT_TRUE(notMatches("class Z {};", ZDescendantClassX));
607 EXPECT_TRUE(matches("class Z { class X { class Y {}; }; };",
609 EXPECT_TRUE(
612 EXPECT_TRUE(notMatches(
630 EXPECT_TRUE(
633 EXPECT_TRUE(matches(
701 EXPECT_TRUE(M.count(Id) == 0 ||
719 EXPECT_TRUE(matches("void f() { int i = 3; }",
721 EXPECT_TRUE(matches("void f() { int i = 3; }",
724 EXPECT_TRUE(matches("void f() { int i = 3; }",
726 EXPECT_TRUE(matches("void f() { int i = 3; }",
729 EXPECT_TRUE(notMatches("void f() { float f = 2.0f; }",
732 EXPECT_TRUE(matchAndVerifyResultTrue(
740 EXPECT_TRUE(matches("void f() { int*** i; }",
742 EXPECT_TRUE(matches("void f() { int*** i; }",
745 EXPECT_TRUE(matches("void f() { int*** i; }",
748 EXPECT_TRUE(matchAndVerifyResultTrue(
755 EXPECT_TRUE(matches("int i;",
757 EXPECT_TRUE(notMatches("int** i;",
759 EXPECT_TRUE(matchAndVerifyResultTrue(
766 EXPECT_TRUE(matches(
769 EXPECT_TRUE(notMatches(
775 EXPECT_TRUE(notMatches("class X {};", enumDecl(hasName("X"))));
779 EXPECT_TRUE(matches("enum X {};", enumDecl(hasName("X"))));
784 EXPECT_TRUE(matches("enum X{ A };", Matcher));
785 EXPECT_TRUE(notMatches("enum X{ B };", Matcher));
786 EXPECT_TRUE(notMatches("enum X {};", Matcher));
794 EXPECT_TRUE(matches(
796 EXPECT_TRUE(notMatches(
805 EXPECT_TRUE(matches(
808 EXPECT_TRUE(notMatches(
816 EXPECT_TRUE(matches("class A { public: A *a; };", TypeA));
817 EXPECT_TRUE(notMatches("class A {};", TypeA));
821 EXPECT_TRUE(matches("class A {}; class B : public A { public: B *b; };",
823 EXPECT_TRUE(notMatches("class A {};", TypeA));
828 EXPECT_TRUE(
835 EXPECT_TRUE(matchAndVerifyResultTrue("class X {};",
838 EXPECT_TRUE(matchAndVerifyResultFalse("class X {};",
844 EXPECT_TRUE(matchAndVerifyResultTrue("class A { public: A *a; class B {}; };",
851 EXPECT_TRUE(matchAndVerifyResultTrue("class A { void x() { x(); } };",
865 EXPECT_TRUE(matchAndVerifyResultTrue(
877 EXPECT_TRUE(matchAndVerifyResultTrue(
886 EXPECT_TRUE(matches("enum X {}; void y(X *x) { x; }",
892 EXPECT_TRUE(internal::has_getDecl<TypedefType>::value);
893 EXPECT_TRUE(internal::has_getDecl<RecordType>::value);
898 EXPECT_TRUE(matches("typedef int X; X a;",
906 EXPECT_TRUE(matches("template <typename T> class A {}; A<int> a;",
913 EXPECT_TRUE(
915 EXPECT_TRUE(
918 EXPECT_TRUE(
925 EXPECT_TRUE(
927 EXPECT_TRUE(
929 EXPECT_TRUE(
936 EXPECT_TRUE(
938 EXPECT_TRUE(
945 EXPECT_TRUE(
947 EXPECT_TRUE(
952 EXPECT_TRUE(matches("int x;",
956 EXPECT_TRUE(notMatches("class X {}; X x;",
965 EXPECT_TRUE(matches("class Y { void x() { x(); } };", MethodX));
966 EXPECT_TRUE(notMatches("class Y { void x() {} };", MethodX));
971 EXPECT_TRUE(
974 EXPECT_TRUE(
977 EXPECT_TRUE(
980 EXPECT_TRUE(
983 EXPECT_TRUE(
990 EXPECT_TRUE(
993 EXPECT_TRUE(
996 EXPECT_TRUE(
999 EXPECT_TRUE(
1002 EXPECT_TRUE(
1008 EXPECT_TRUE(matches("auto f = [] (int i) { return i; };",
1013 EXPECT_TRUE(matches("int as[] = { 1, 2, 3 };"
1016 EXPECT_TRUE(notMatches("void f() { for (int i; i<5; ++i); }",
1025 EXPECT_TRUE(matches("template<int N>\n"
1032 EXPECT_TRUE(matches("constexpr char operator \"\" _inc (const char i) {"
1040 EXPECT_TRUE(matches("void f() { while(true) { break; } }", breakStmt()));
1041 EXPECT_TRUE(matches("void f() { while(true) { continue; } }",
1043 EXPECT_TRUE(matches("void f() { goto FOO; FOO: ;}", gotoStmt()));
1044 EXPECT_TRUE(matches("void f() { goto FOO; FOO: ;}", labelStmt()));
1045 EXPECT_TRUE(matches("void f() { return; }", returnStmt()));
1049 EXPECT_TRUE(
1052 EXPECT_TRUE(matches("class X { void x(int x) {} };",
1054 EXPECT_TRUE(matches("namespace ns { struct A {}; } struct B { ns::A a; };",
1056 EXPECT_TRUE(matches("namespace { struct A {}; } struct B { A a; };",
1063 EXPECT_TRUE(matches("class Y { }; "
1069 // EXPECT_TRUE(NotMatches("#include <stddef.h>\n"
1073 EXPECT_TRUE(notMatches("class Y { }; "
1077 EXPECT_TRUE(matches("class Y { }; "
1082 EXPECT_TRUE(notMatches("bool x = true, y = true; bool t = x && y;", OpCall));
1083 EXPECT_TRUE(notMatches("int t = 5 << 2;", OpCall));
1089 EXPECT_TRUE(matches("class Y { }; "
1094 EXPECT_TRUE(notMatches("class Y { }; "
1100 EXPECT_TRUE(matches("class Y { int operator*(); };",
1102 EXPECT_TRUE(notMatches("class Y { void myOperator(); };",
1107 EXPECT_TRUE(matchAndVerifyResultTrue(
1113 EXPECT_TRUE(matches(
1118 EXPECT_TRUE(matches(
1129 EXPECT_TRUE(
1132 EXPECT_TRUE(
1135 EXPECT_TRUE(
1138 EXPECT_TRUE(
1141 EXPECT_TRUE(
1145 EXPECT_TRUE(matches(
1161 EXPECT_TRUE(matches(
1171 EXPECT_TRUE(notMatches(
1183 EXPECT_TRUE(matches("void f() { int X; }", M));
1184 EXPECT_TRUE(notMatches("int X;", M));
1185 EXPECT_TRUE(notMatches("void f() { static int X; }", M));
1188 EXPECT_TRUE(notMatches("void f() { int X; }", M));
1189 EXPECT_TRUE(matches("int X;", M));
1190 EXPECT_TRUE(matches("void f() { static int X; }", M));
1194 EXPECT_TRUE(matches(
1203 EXPECT_TRUE(matches(
1205 EXPECT_TRUE(matches(
1207 EXPECT_TRUE(matches(
1210 EXPECT_TRUE(matches(
1213 EXPECT_TRUE(notMatches(
1220 EXPECT_TRUE(matches("void x() { int a = sizeof(a); }",
1222 EXPECT_TRUE(notMatches("void x() { int a = sizeof(a); }",
1225 // EXPECT_TRUE(matches("void x() { int a = alignof(a); }",
1227 // EXPECT_TRUE(notMatches("void x() { int a = alignof(a); }",
1232 EXPECT_TRUE(matches("void x() { int a = sizeof(a); }", sizeOfExpr(
1234 EXPECT_TRUE(notMatches("void x() { int a = sizeof(a); }", sizeOfExpr(
1236 EXPECT_TRUE(matches(
1239 EXPECT_TRUE(notMatches("void x() { int a = sizeof(a); }", sizeOfExpr(
1244 EXPECT_TRUE(notMatches("class Y { void x() {} };", memberExpr()));
1248 EXPECT_TRUE(matches("class Y { void x() { x(); } };", memberExpr()));
1252 EXPECT_TRUE(
1254 EXPECT_TRUE(
1256 EXPECT_TRUE(
1261 EXPECT_TRUE(matches("class Y { void x() { this->y; } static int y; };",
1263 EXPECT_TRUE(notMatches("class Y { void x() { y; } static int y; };",
1265 EXPECT_TRUE(notMatches("class Y { void x() { Y::y; } static int y; };",
1270 EXPECT_TRUE(matches("int i = 0;", varDecl(hasType(isInteger()))));
1271 EXPECT_TRUE(matches(
1278 EXPECT_TRUE(notMatches("int *i;", varDecl(hasType(isInteger()))));
1279 EXPECT_TRUE(notMatches("struct T {}; T t; void f(T *) { }; void g() {f(&t);}",
1285 EXPECT_TRUE(matches("class Y { void x() { this->y; } int y; };",
1287 EXPECT_TRUE(matches("class Y { void x() { y; } int y; };",
1289 EXPECT_TRUE(notMatches("class Y { void x() { (*this).y; } int y; };",
1294 EXPECT_TRUE
1296 EXPECT_TRUE(notMatches("class Y { void x() { y; } static int y; };",
1298 EXPECT_TRUE(notMatches("class Y { void x() { (*this).y; } static int y; };",
1303 EXPECT_TRUE(matches("class Y { void x() { this->x(); } };",
1305 EXPECT_TRUE(matches("class Y { void x() { x(); } };",
1307 EXPECT_TRUE(notMatches("class Y { void x() { Y y; y.x(); } };",
1314 EXPECT_TRUE(matches("class Y { void x() { x(); } };", CallMethodX));
1315 EXPECT_TRUE(notMatches("class Y { void x() {} };", CallMethodX));
1319 EXPECT_TRUE(matches("class Y { void x() { this->x(); } };",
1321 EXPECT_TRUE(
1328 EXPECT_TRUE(matches("void f() { f(); }", CallFunctionF));
1329 EXPECT_TRUE(notMatches("void f() { }", CallFunctionF));
1335 EXPECT_TRUE(matches("void f(); template <int N> void g() { f(); }",
1337 EXPECT_TRUE(
1343 EXPECT_TRUE(
1346 EXPECT_TRUE(
1353 EXPECT_TRUE(
1359 EXPECT_TRUE(
1365 EXPECT_TRUE(
1377 EXPECT_TRUE(matches("void x(int) { int y; x(y); }", CallArgumentY));
1378 EXPECT_TRUE(
1380 EXPECT_TRUE(notMatches("void x(int) { int z; x(z); }", CallArgumentY));
1384 EXPECT_TRUE(notMatches("void x(int) { int y; x(y); }", WrongIndex));
1390 EXPECT_TRUE(matches("void x(int, int) { int y; x(1, y); }", CallArgumentY));
1391 EXPECT_TRUE(matches("void x(int, int) { int y; x(y, 42); }", CallArgumentY));
1392 EXPECT_TRUE(notMatches("void x(int, int) { x(1, 2); }", CallArgumentY));
1398 EXPECT_TRUE(matches("void x(int) { x(0); }", Call1Arg));
1399 EXPECT_TRUE(matches("class X { void x(int) { x(0); } };", Call1Arg));
1400 EXPECT_TRUE(notMatches("void x(int, int) { x(0, 0); }", Call1Arg));
1405 EXPECT_TRUE(matches("void f(int i) {}", Function1Arg));
1406 EXPECT_TRUE(matches("class X { void f(int i) {} };", Function1Arg));
1407 EXPECT_TRUE(notMatches("void f() {}", Function1Arg));
1408 EXPECT_TRUE(notMatches("void f(int i, int j, int k) {}", Function1Arg));
1414 EXPECT_TRUE(matches("class X {}; void y(X y) { X &x = y; }",
1416 EXPECT_TRUE(
1420 EXPECT_TRUE(
1422 EXPECT_TRUE(
1424 EXPECT_TRUE(
1429 EXPECT_TRUE(notMatches("typedef int &int_ref;"
1433 EXPECT_TRUE(
1441 EXPECT_TRUE(notMatches("typedef const int const_int; const_int i = 1;",
1443 EXPECT_TRUE(matches("int *const j = nullptr;",
1445 EXPECT_TRUE(matches("int *volatile k;",
1447 EXPECT_TRUE(notMatches("int m;",
1452 EXPECT_TRUE(matches("class X { void x(int) {} };",
1454 EXPECT_TRUE(notMatches("class X { void x(int) {} };",
1459 EXPECT_TRUE(notMatches("class X { void x(int) {} };",
1464 EXPECT_TRUE(matches("class X { void x(X x) {} };",
1466 EXPECT_TRUE(notMatches("class X { void x(const X &x) {} };",
1468 EXPECT_TRUE(matches("class X { void x(const X *x) {} };",
1471 EXPECT_TRUE(matches("class X { void x(const X &x) {} };",
1477 EXPECT_TRUE(matches("class Y {}; class X { void x(X x, Y y) {} };",
1479 EXPECT_TRUE(matches("class Y {}; class X { void x(Y y, X x) {} };",
1484 EXPECT_TRUE(matches("class Y { int f() { return 1; } };",
1486 EXPECT_TRUE(notMatches("class Y { int f() { return 1; } };",
1488 EXPECT_TRUE(matches("class Y { Y getMe() { return *this; } };",
1494 EXPECT_TRUE(matches("extern \"C\" void f() {}", functionDecl(isExternC())));
1495 EXPECT_TRUE(matches("extern \"C\" { void f() {} }",
1497 EXPECT_TRUE(notMatches("void f() {}", functionDecl(isExternC())));
1501 EXPECT_TRUE(notMatches("class Y {}; class X { void x(int) {} };",
1506 EXPECT_TRUE(notMatches("class Y {}; class X { void x() {} };",
1512 EXPECT_TRUE(matches("class Y {}; class X { void x(int x) {} };",
1514 EXPECT_TRUE(notMatches("class Y {}; class X { void x(int) {} };",
1519 EXPECT_TRUE(matches("template<typename T> struct A {};"
1522 EXPECT_TRUE(matches("template<typename T> struct A {}; A<int> a;",
1524 EXPECT_TRUE(notMatches("template<typename T> struct A {};",
1529 EXPECT_TRUE(matches("int x;", declaratorDecl()));
1530 EXPECT_TRUE(notMatches("class A {};", declaratorDecl()));
1534 EXPECT_TRUE(matches("void f(int x);", parmVarDecl()));
1535 EXPECT_TRUE(notMatches("void f();", parmVarDecl()));
1539 EXPECT_TRUE(matches(
1547 EXPECT_TRUE(matches(
1554 EXPECT_TRUE(notMatches(
1560 EXPECT_TRUE(matches(
1567 EXPECT_TRUE(notMatches(
1575 EXPECT_TRUE(matches(
1580 EXPECT_TRUE(notMatches(
1586 EXPECT_TRUE(matches(
1591 EXPECT_TRUE(notMatches(
1599 EXPECT_TRUE(matches("class C { public: int i; };", accessSpecDecl()));
1600 EXPECT_TRUE(
1602 EXPECT_TRUE(
1604 EXPECT_TRUE(
1607 EXPECT_TRUE(notMatches("class C { int i; };", accessSpecDecl()));
1611 EXPECT_TRUE(matches("class X { virtual int f(); };",
1613 EXPECT_TRUE(notMatches("class X { int f(); };",
1618 EXPECT_TRUE(matches("class X { virtual int f() = 0; };",
1620 EXPECT_TRUE(notMatches("class X { int f(); };",
1625 EXPECT_TRUE(matches("struct A { void foo() const; };",
1627 EXPECT_TRUE(notMatches("struct A { void foo(); };",
1632 EXPECT_TRUE(matches("class X { virtual int f(); }; "
1635 EXPECT_TRUE(notMatches("class X { virtual int f(); }; "
1638 EXPECT_TRUE(notMatches("class X { int f(); }; "
1641 EXPECT_TRUE(notMatches("class X { int f(); int f(int); }; ",
1648 EXPECT_TRUE(
1650 EXPECT_TRUE(
1653 EXPECT_TRUE(
1656 EXPECT_TRUE(matches("class X {}; void x(int) { X x; }", Constructor));
1663 EXPECT_TRUE(
1666 EXPECT_TRUE(
1669 EXPECT_TRUE(
1672 EXPECT_TRUE(
1678 EXPECT_TRUE(
1686 EXPECT_TRUE(
1689 EXPECT_TRUE(
1692 EXPECT_TRUE(
1695 EXPECT_TRUE(
1703 EXPECT_TRUE(
1712 EXPECT_TRUE(
1714 EXPECT_TRUE(
1723 EXPECT_TRUE(
1730 EXPECT_TRUE(
1741 EXPECT_TRUE(
1753 EXPECT_TRUE(
1760 EXPECT_TRUE(
1771 EXPECT_TRUE(
1777 EXPECT_TRUE(
1785 EXPECT_TRUE(matches("class Foo { Foo(int i); };",
1787 EXPECT_TRUE(notMatches("class Foo { Foo(int i); };",
1794 EXPECT_TRUE(notMatches("class Foo { };",
1797 EXPECT_TRUE(matches("class Foo { }; Foo* f = new Foo();",
1799 EXPECT_TRUE(matches("class Foo { Foo(){} };",
1802 EXPECT_TRUE(matches("struct A { int x; } a = {0}, b = a; void f() { a = b; }",
1807 EXPECT_TRUE(matches("class Foo { virtual ~Foo(); };",
1812 EXPECT_TRUE(notMatches("class Foo {};",
1817 EXPECT_TRUE(notMatches(
1820 EXPECT_TRUE(matches(
1836 EXPECT_TRUE(matches(Code, constructorDecl(hasAnyConstructorInitializer(
1838 EXPECT_TRUE(matches(Code, constructorDecl(hasAnyConstructorInitializer(
1840 EXPECT_TRUE(notMatches(Code, constructorDecl(hasAnyConstructorInitializer(
1850 EXPECT_TRUE(matches(Code, constructorDecl(hasAnyConstructorInitializer(
1852 EXPECT_TRUE(notMatches(Code, constructorDecl(hasAnyConstructorInitializer(
1864 EXPECT_TRUE(matches(Code, constructorDecl(hasAnyConstructorInitializer(
1866 EXPECT_TRUE(notMatches(Code, constructorDecl(hasAnyConstructorInitializer(
1868 EXPECT_TRUE(matches(Code, constructorDecl(hasAnyConstructorInitializer(
1875 EXPECT_TRUE(matches("class X { public: X(); }; void x() { new X; }", New));
1876 EXPECT_TRUE(
1878 EXPECT_TRUE(
1880 EXPECT_TRUE(matches("class X {}; void x(int) { new X; }", New));
1887 EXPECT_TRUE(
1890 EXPECT_TRUE(
1893 EXPECT_TRUE(
1899 EXPECT_TRUE(
1907 EXPECT_TRUE(
1909 EXPECT_TRUE(
1915 EXPECT_TRUE(matches("struct A {}; void f(A* a) { delete a; }",
1922 EXPECT_TRUE(matches("void x(int, int = 0) { int y; x(y); }", Arg));
1923 EXPECT_TRUE(
1925 EXPECT_TRUE(notMatches("void x(int, int = 0) { int y; x(y, 0); }", Arg));
1930 EXPECT_TRUE(matches("const char *s = \"string\";", Literal));
1932 EXPECT_TRUE(matches("const wchar_t *s = L\"string\";", Literal));
1934 EXPECT_TRUE(matches("const char *s = \"\x05five\";", Literal));
1936 EXPECT_TRUE(notMatches("const char s[1] = {'a'};", Literal));
1941 EXPECT_TRUE(matches("const char c = 'c';", CharLiteral));
1943 EXPECT_TRUE(matches("const char c = L'c';", CharLiteral));
1945 EXPECT_TRUE(notMatches("const wchar_t c = 0x2126;", CharLiteral));
1946 EXPECT_TRUE(notMatches("const char c = 0x1;", CharLiteral));
1951 EXPECT_TRUE(matches("int i = 10;", HasIntLiteral));
1952 EXPECT_TRUE(matches("int i = 0x1AB;", HasIntLiteral));
1953 EXPECT_TRUE(matches("int i = 10L;", HasIntLiteral));
1954 EXPECT_TRUE(matches("int i = 10U;", HasIntLiteral));
1957 EXPECT_TRUE(notMatches("int i = L'a';",
1960 EXPECT_TRUE(notMatches("int i = 'a';", HasIntLiteral));
1961 EXPECT_TRUE(notMatches("int i = 1e10;", HasIntLiteral));
1962 EXPECT_TRUE(notMatches("int i = 10.0;", HasIntLiteral));
1967 EXPECT_TRUE(matches("float i = 10.0;", HasFloatLiteral));
1968 EXPECT_TRUE(matches("float i = 10.0f;", HasFloatLiteral));
1969 EXPECT_TRUE(matches("double i = 10.0;", HasFloatLiteral));
1970 EXPECT_TRUE(matches("double i = 10.0L;", HasFloatLiteral));
1971 EXPECT_TRUE(matches("double i = 1e10;", HasFloatLiteral));
1973 EXPECT_TRUE(notMatches("float i = 10;", HasFloatLiteral));
1977 EXPECT_TRUE(matches("int* i = nullptr;", nullPtrLiteralExpr()));
1981 EXPECT_TRUE(matches("void foo() { __asm(\"mov al, 2\"); }", asmStmt()));
1987 EXPECT_TRUE(matches("void x() { if (true) {} }", Condition));
1988 EXPECT_TRUE(notMatches("void x() { if (false) {} }", Condition));
1989 EXPECT_TRUE(notMatches("void x() { bool a = true; if (a) {} }", Condition));
1990 EXPECT_TRUE(notMatches("void x() { if (true || false) {} }", Condition));
1991 EXPECT_TRUE(notMatches("void x() { if (1) {} }", Condition));
1995 EXPECT_TRUE(matches("void f() { if (false) true; else false; }",
1997 EXPECT_TRUE(notMatches("void f() { if (false) false; else true; }",
1999 EXPECT_TRUE(matches("void f() { if (false) false; else true; }",
2001 EXPECT_TRUE(notMatches("void f() { if (false) true; else false; }",
2008 EXPECT_TRUE(matches("void x() { true || false; }", OperatorOr));
2009 EXPECT_TRUE(notMatches("void x() { true && false; }", OperatorOr));
2017 EXPECT_TRUE(matches("void x() { true || false; }", OperatorTrueFalse));
2018 EXPECT_TRUE(matches("void x() { true && false; }", OperatorTrueFalse));
2019 EXPECT_TRUE(notMatches("void x() { false || true; }", OperatorTrueFalse));
2026 EXPECT_TRUE(matches("void x() { true || false; }", HasOperand));
2027 EXPECT_TRUE(matches("void x() { false && true; }", HasOperand));
2028 EXPECT_TRUE(notMatches("void x() { true || true; }", HasOperand));
2035 EXPECT_TRUE(
2037 EXPECT_TRUE(
2040 EXPECT_TRUE(
2042 EXPECT_TRUE(
2044 EXPECT_TRUE(matches("bool b = 1 < 2;", binaryOperator(hasOperatorName("<"))));
2045 EXPECT_TRUE(
2047 EXPECT_TRUE(
2049 EXPECT_TRUE(
2052 EXPECT_TRUE(matches("bool b = 1 > 2;", binaryOperator(hasOperatorName(">"))));
2053 EXPECT_TRUE(
2055 EXPECT_TRUE(
2057 EXPECT_TRUE(
2060 EXPECT_TRUE(
2062 EXPECT_TRUE(
2065 EXPECT_TRUE(
2067 EXPECT_TRUE(
2070 EXPECT_TRUE(
2072 EXPECT_TRUE(
2075 EXPECT_TRUE(
2078 EXPECT_TRUE(
2080 EXPECT_TRUE(
2083 EXPECT_TRUE(
2086 EXPECT_TRUE(
2088 EXPECT_TRUE(
2091 EXPECT_TRUE(
2093 EXPECT_TRUE(
2096 EXPECT_TRUE(
2098 EXPECT_TRUE(
2101 EXPECT_TRUE(
2103 EXPECT_TRUE(
2106 EXPECT_TRUE(
2109 EXPECT_TRUE(
2114 EXPECT_TRUE(
2119 EXPECT_TRUE(
2123 EXPECT_TRUE(notMatches("int a[42]; void x() { a[23]; }", unaryOperator()));
2126 EXPECT_TRUE(notMatches(
2135 EXPECT_TRUE(matches("void x() { !true; } ", OperatorNot));
2136 EXPECT_TRUE(notMatches("void x() { true; } ", OperatorNot));
2143 EXPECT_TRUE(matches("void x() { !false; }", OperatorOnFalse));
2144 EXPECT_TRUE
2150 EXPECT_TRUE(matches("bool b = !true;", unaryOperator(hasOperatorName("!"))));
2151 EXPECT_TRUE(
2153 EXPECT_TRUE(matches("int i = ~ 1;", unaryOperator(hasOperatorName("~"))));
2154 EXPECT_TRUE(
2156 EXPECT_TRUE(
2158 EXPECT_TRUE(
2160 EXPECT_TRUE(
2162 EXPECT_TRUE(
2164 EXPECT_TRUE(
2166 EXPECT_TRUE(
2170 EXPECT_TRUE(notMatches("int i; double d = (double)i;", unaryOperator()));
2173 EXPECT_TRUE(notMatches("void f(); void x() { f(); }", unaryOperator()));
2177 EXPECT_TRUE(notMatches(
2187 EXPECT_TRUE(matches("void x() { true ? false : true; }", Conditional));
2188 EXPECT_TRUE(notMatches("void x() { false ? false : true; }", Conditional));
2189 EXPECT_TRUE(notMatches("void x() { true ? true : false; }", Conditional));
2194 EXPECT_TRUE(matches("void x() { true ? true : false; }", ConditionalFalse));
2195 EXPECT_TRUE(
2200 EXPECT_TRUE(matches("int i[2]; void f() { i[1] = 1; }",
2202 EXPECT_TRUE(notMatches("int i; void f() { i = 1; }",
2207 EXPECT_TRUE(matches(
2210 EXPECT_TRUE(matches(
2213 EXPECT_TRUE(notMatches(
2219 EXPECT_TRUE(matches(
2226 EXPECT_TRUE(matches("namespace a { namespace b { class C; } }",
2228 EXPECT_TRUE(matches("namespace a { namespace b { class C; } }",
2230 EXPECT_TRUE(matches("namespace a { namespace b { class C; } }",
2232 EXPECT_TRUE(matches("namespace a { namespace b { class C; } }",
2234 EXPECT_TRUE(notMatches("namespace a { namespace b { class C; } }",
2236 EXPECT_TRUE(notMatches("namespace a { namespace b { class C; } }",
2238 EXPECT_TRUE(notMatches("namespace a { namespace b { class C; } }",
2240 EXPECT_TRUE(notMatches("namespace a { namespace b { class C; } }",
2242 EXPECT_TRUE(notMatches("namespace a { namespace b { class C; } }",
2244 EXPECT_TRUE(notMatches("namespace a { namespace b { class C; } }",
2246 EXPECT_TRUE(notMatches("namespace a { namespace b { class C; } }",
2248 EXPECT_TRUE(notMatches("namespace a { namespace b { class AC; } }",
2253 EXPECT_TRUE(
2256 EXPECT_TRUE(
2259 EXPECT_TRUE(
2262 EXPECT_TRUE(
2265 EXPECT_TRUE(
2268 EXPECT_TRUE(
2271 EXPECT_TRUE(
2274 EXPECT_TRUE(
2277 EXPECT_TRUE(
2280 EXPECT_TRUE(notMatches("class A { class B { class C; }; };",
2282 EXPECT_TRUE(
2290 EXPECT_TRUE(matches("class A {};", DefinitionOfClassA));
2291 EXPECT_TRUE(notMatches("class A;", DefinitionOfClassA));
2295 EXPECT_TRUE(matches("int a;", DefinitionOfVariableA));
2296 EXPECT_TRUE(notMatches("extern int a;", DefinitionOfVariableA));
2300 EXPECT_TRUE(matches("class A { void a() {} };", DefinitionOfMethodA));
2301 EXPECT_TRUE(notMatches("class A { void a(); };", DefinitionOfMethodA));
2308 EXPECT_TRUE(
2310 EXPECT_TRUE(
2313 EXPECT_TRUE(
2319 EXPECT_TRUE(matches(
2325 EXPECT_TRUE(matches(
2345 EXPECT_TRUE(matches(
2373 EXPECT_TRUE(matchAndVerifyResultTrue("class A { class B {}; };",
2376 EXPECT_TRUE(matchAndVerifyResultFalse("class A { class B {}; };",
2379 EXPECT_TRUE(matchAndVerifyResultFalse("class A { class C {}; };",
2397 EXPECT_TRUE(matchAndVerifyResultTrue("class A { class B {}; };",
2400 EXPECT_TRUE(matchAndVerifyResultFalse("class A { class B {}; };",
2403 EXPECT_TRUE(matchAndVerifyResultFalse("class A { class C {}; };",
2409 EXPECT_TRUE(matches("void x() { class B {}; }", StatementHasClassB));
2413 EXPECT_TRUE(matches("void f() { for(;;); }", forStmt()));
2414 EXPECT_TRUE(matches("void f() { if(true) for(;;); }", forStmt()));
2415 EXPECT_TRUE(notMatches("int as[] = { 1, 2, 3 };"
2421 EXPECT_TRUE(matches("void f(){ int i; for (; i < 3 ; ); }",
2423 EXPECT_TRUE(matches("void f() { for (int i = 0; ;); }",
2428 EXPECT_TRUE(matches("void f(){ int a[] {1, 2}; for (int i : a); }",
2430 EXPECT_TRUE(matches(
2436 EXPECT_TRUE(notMatches("void f(){ for (int i = 0; ; ++i); }",
2438 EXPECT_TRUE(notMatches("void f() {int i; for (; i < 4; ++i) {} }",
2443 EXPECT_TRUE(notMatches("void f() { ; }", forStmt()));
2444 EXPECT_TRUE(notMatches("void f() { if(true); }", forStmt()));
2448 EXPECT_TRUE(notMatches("void f();", compoundStmt()));
2449 EXPECT_TRUE(matches("void f() {}", compoundStmt()));
2450 EXPECT_TRUE(matches("void f() {{}}", compoundStmt()));
2456 EXPECT_TRUE(notMatches("namespace n { struct S {}; }",
2458 EXPECT_TRUE(matches("namespace n { struct S { void f() {{}} }; }",
2463 EXPECT_TRUE(matches("void f() { for(;;) {} }",
2465 EXPECT_TRUE(notMatches("void f() { for(;;); }",
2467 EXPECT_TRUE(matches("void f() { while(true) {} }",
2469 EXPECT_TRUE(matches("void f() { do {} while(true); }",
2471 EXPECT_TRUE(matches("void f() { int p[2]; for (auto x : p) {} }",
2479 EXPECT_TRUE(matches("void f() { for (;;); }",
2485 EXPECT_TRUE(notMatches("void f() { if (true) for (;;); }",
2490 EXPECT_TRUE(matches("void f() { if (true) { for (;;); } }",
2495 EXPECT_TRUE(matches("void f() { 1; 2; 3; for (;;); 4; 5; 6; }",
2500 EXPECT_TRUE(matches("void f() { }",
2502 EXPECT_TRUE(notMatches("void f() {}",
2507 EXPECT_TRUE(matches("void f() { 1; }",
2509 EXPECT_TRUE(notMatches("void f() { 1; }",
2511 EXPECT_TRUE(notMatches("void f() { 1; }",
2516 EXPECT_TRUE(matches("void f() { 1; 2; 3; }",
2521 EXPECT_TRUE(matches("void f() { { 1; } { 1; 2; 3; 4; } }",
2523 EXPECT_TRUE(matches("void f() { { 1; } { 1; 2; 3; 4; } }",
2525 EXPECT_TRUE(notMatches("void f() { { 1; } { 1; 2; 3; 4; } }",
2527 EXPECT_TRUE(matches("void f() { { 1; } { 1; 2; 3; 4; } }",
2532 EXPECT_TRUE(matches("struct { int first; } s; int i(s.first);",
2539 EXPECT_TRUE(notMatches("struct { int i; } first; int i(first.i);",
2544 EXPECT_TRUE(matches("void f() {"
2552 EXPECT_TRUE(matches(
2555 EXPECT_TRUE(notMatches(
2561 EXPECT_TRUE(matches(
2563 EXPECT_TRUE(notMatches(
2565 EXPECT_TRUE(notMatches(
2568 EXPECT_TRUE(notMatches(
2570 EXPECT_TRUE(notMatches(
2572 EXPECT_TRUE(matches(
2575 EXPECT_TRUE(notMatches(
2577 EXPECT_TRUE(matches("class A { protected: int i; };",
2579 EXPECT_TRUE(notMatches(
2583 EXPECT_TRUE(notMatches("int i;", varDecl(isPublic(), hasName("i"))));
2584 EXPECT_TRUE(notMatches("int i;", varDecl(isProtected(), hasName("i"))));
2585 EXPECT_TRUE(notMatches("int i;", varDecl(isPrivate(), hasName("i"))));
2590 EXPECT_TRUE(matchesConditionally(
2595 EXPECT_TRUE(matches("class X { void operator delete(void*); };",
2599 EXPECT_TRUE(matchesConditionally(
2606 EXPECT_TRUE(notMatches(
2612 EXPECT_TRUE(matches(
2615 EXPECT_TRUE(matches(
2623 EXPECT_TRUE(matches(
2627 EXPECT_TRUE(matches(
2634 EXPECT_TRUE(notMatches("class X { void m(); };", fieldDecl(hasName("m"))));
2635 EXPECT_TRUE(notMatches("class X { class m {}; };", fieldDecl(hasName("m"))));
2636 EXPECT_TRUE(notMatches("class X { enum { m }; };", fieldDecl(hasName("m"))));
2637 EXPECT_TRUE(notMatches("class X { enum m {}; };", fieldDecl(hasName("m"))));
2641 EXPECT_TRUE(matches("class X { int m; };", fieldDecl(hasName("m"))));
2645 EXPECT_TRUE(matches("const int i = 42;",
2650 EXPECT_TRUE(matches("int i = 42; int* const p(&i);",
2655 EXPECT_TRUE(matches("typedef const int const_int; const_int i = 42;",
2657 EXPECT_TRUE(matches("typedef int* int_ptr; const int_ptr p(0);",
2662 EXPECT_TRUE(notMatches("typedef int nonconst_int; nonconst_int i = 42;",
2664 EXPECT_TRUE(notMatches("int const* p;",
2669 EXPECT_TRUE(matches("char *p = reinterpret_cast<char *>(&p);",castExpr()));
2670 EXPECT_TRUE(matches("void *p = (void *)(&p);", castExpr()));
2671 EXPECT_TRUE(matches("char q, *p = const_cast<char *>(&q);", castExpr()));
2672 EXPECT_TRUE(matches("char c = char(0);", castExpr()));
2676 EXPECT_TRUE(matches("char c = 0;", castExpr()));
2678 EXPECT_TRUE(matches("char c = 0, d = c;", castExpr()));
2682 EXPECT_TRUE(notMatches("char c = '0';", castExpr()));
2683 EXPECT_TRUE(notMatches("char c, &q = c;", castExpr()));
2684 EXPECT_TRUE(notMatches("int i = (0);", castExpr()));
2685 EXPECT_TRUE(notMatches("int i = 0;", castExpr()));
2689 EXPECT_TRUE(matches("char* p = reinterpret_cast<char*>(&p);",
2694 EXPECT_TRUE(notMatches("char* p = (char*)(&p);", reinterpretCastExpr()));
2695 EXPECT_TRUE(notMatches("char q, *p = const_cast<char*>(&q);",
2697 EXPECT_TRUE(notMatches("void* p = static_cast<void*>(&p);",
2699 EXPECT_TRUE(notMatches("struct B { virtual ~B() {} }; struct D : B {};"
2707 EXPECT_TRUE(matches(foo_class + "void r() { Foo f = Foo(\"hello world\"); }",
2713 EXPECT_TRUE(
2716 EXPECT_TRUE(
2722 EXPECT_TRUE(matches("struct B { virtual ~B() {} }; struct D : B {};"
2729 EXPECT_TRUE(matches("void* p(static_cast<void*>(&p));",
2734 EXPECT_TRUE(notMatches("char* p = (char*)(&p);", staticCastExpr()));
2735 EXPECT_TRUE(notMatches("char q, *p = const_cast<char*>(&q);",
2737 EXPECT_TRUE(notMatches("void* p = reinterpret_cast<char*>(&p);",
2739 EXPECT_TRUE(notMatches("struct B { virtual ~B() {} }; struct D : B {};"
2746 EXPECT_TRUE(matches("int i = (int) 2.2f;", cStyleCastExpr()));
2750 EXPECT_TRUE(notMatches("char* p = static_cast<char*>(0);"
2760 EXPECT_TRUE(matches("char* p = static_cast<char*>(0);",
2767 EXPECT_TRUE(matches("int x; const int i = x;",
2771 EXPECT_TRUE(matches("int arr[3]; int *p = arr;",
2778 EXPECT_TRUE(notMatches("char c = 0;",
2782 EXPECT_TRUE(notMatches("int arr[3]; int *p = arr;",
2789 EXPECT_TRUE(matches("int x = 0; const int y = x;",
2792 EXPECT_TRUE(matches("char c = 0;",
2795 EXPECT_TRUE(matches("int arr[6]; int *p = arr;",
2804 EXPECT_TRUE(notMatches("int x = 0;",
2806 EXPECT_TRUE(notMatches("int x = 0, &y = x;",
2809 EXPECT_TRUE(notMatches("int x = 0; double d = (double) x;",
2811 EXPECT_TRUE(notMatches("const int *p; int *q = const_cast<int *>(p);",
2814 EXPECT_TRUE(notMatches("int x = (0);",
2822 EXPECT_TRUE(matches("int x = 0; const int y = x;",
2826 EXPECT_TRUE(matches("char x = 0;",
2835 EXPECT_TRUE(notMatches("int x; const int y = x;",
2838 EXPECT_TRUE(notMatches("int x; int y = x;",
2844 EXPECT_TRUE(notMatches("char* p = static_cast<char*>(0);",
2847 EXPECT_TRUE(notMatches("int i = (0);",
2850 EXPECT_TRUE(notMatches("float i = (float)0;",
2853 EXPECT_TRUE(notMatches("float i = float(0);",
2861 EXPECT_TRUE(matches("int x = 0; int &y = x;",
2869 EXPECT_TRUE(matches("int x = (0);",
2872 EXPECT_TRUE(matches("int x = (((((0)))));",
2878 EXPECT_TRUE(matches("char x = (0);",
2882 EXPECT_TRUE(matches("char x = (char)0;",
2885 EXPECT_TRUE(matches("char* p = static_cast<char*>(0);",
2892 EXPECT_TRUE(matches("int x = 0;",
2900 EXPECT_TRUE(notMatches("int x = ((0));",
2906 EXPECT_TRUE(notMatches("char x = ((0));",
2910 EXPECT_TRUE(notMatches("char *x = static_cast<char *>((0));",
2920 EXPECT_TRUE(matches("int x = 0; const int y = x;",
2924 EXPECT_TRUE(matches("const char x = (0);",
2932 EXPECT_TRUE(matches("int x = 0; int &y = x;",
2935 EXPECT_TRUE(matches("int x = 0;",
2944 EXPECT_TRUE(notMatches("char c = ((3));",
2949 EXPECT_TRUE(notMatches("float y = (float(0));",
2952 EXPECT_TRUE(notMatches("float y = (float)0;",
2955 EXPECT_TRUE(notMatches("char* p = static_cast<char*>(0);",
2961 EXPECT_TRUE(matches("class string {}; class URL { public: URL(string s); };"
2968 EXPECT_TRUE(matches("float x = static_cast<float>(42);",
2975 EXPECT_TRUE(notMatches("class X {};", stmt()));
2979 EXPECT_TRUE(matches("void x() {}", stmt()));
2983 EXPECT_TRUE(notMatches("void x() {}", declStmt()));
2987 EXPECT_TRUE(matches("void x() { int a; }", declStmt()));
2991 EXPECT_TRUE(matches("struct Foo { ~Foo(); };"
3000 EXPECT_TRUE(matches("int a[] = { 1, 2 };",
3002 EXPECT_TRUE(matches("struct B { int x, y; }; B b = { 5, 6 };",
3007 EXPECT_TRUE(matches("namespace X { int x; } using X::x;",
3012 EXPECT_TRUE(matches("namespace f { int a; } using f::a;",
3017 EXPECT_TRUE(matches("namespace f { int a; void b(); } using f::b;",
3020 EXPECT_TRUE(notMatches("namespace f { int a; void b(); } using f::a;",
3026 EXPECT_TRUE(matches(
3029 EXPECT_TRUE(notMatches(
3037 EXPECT_TRUE(matches("void f() {int a = 4;}", SingleDeclStmt));
3038 EXPECT_TRUE(notMatches("void f() {int a;}", SingleDeclStmt));
3039 EXPECT_TRUE(notMatches("void f() {int a = 4, b = 3;}",
3046 EXPECT_TRUE(matches("void f() {int a = 4;}",
3048 EXPECT_TRUE(matches("void f() {int a = 4, b = 3;}",
3052 EXPECT_TRUE(notMatches("void f() {int a = 4, b = 3;}",
3058 EXPECT_TRUE(matches("void f() {int i,j;}",
3060 EXPECT_TRUE(notMatches("void f() {int i,j; int k;}",
3062 EXPECT_TRUE(notMatches("void f() {int i,j, k, l;}",
3067 EXPECT_TRUE(notMatches("void x() {}", whileStmt()));
3068 EXPECT_TRUE(matches("void x() { while(true); }", whileStmt()));
3069 EXPECT_TRUE(notMatches("void x() { do {} while(true); }", whileStmt()));
3073 EXPECT_TRUE(matches("void x() { do {} while(true); }", doStmt()));
3074 EXPECT_TRUE(matches("void x() { do ; while(false); }", doStmt()));
3078 EXPECT_TRUE(notMatches("void x() { while(true) {} }", doStmt()));
3082 EXPECT_TRUE(matches("void x() { switch(42) { case 42:; } }", switchCase()));
3083 EXPECT_TRUE(matches("void x() { switch(42) { default:; } }", switchCase()));
3084 EXPECT_TRUE(matches("void x() { switch(42) default:; }", switchCase()));
3085 EXPECT_TRUE(notMatches("void x() { switch(42) {} }", switchCase()));
3089 EXPECT_TRUE(matches("void x() { switch(42) { case 42:; } }", switchStmt()));
3090 EXPECT_TRUE(matches("void x() { switch(42) { default:; } }", switchStmt()));
3091 EXPECT_TRUE(matches("void x() { switch(42) default:; }", switchStmt()));
3092 EXPECT_TRUE(notMatches("void x() {}", switchStmt()));
3096 EXPECT_TRUE(notMatches("void x() { switch(42); }",
3098 EXPECT_TRUE(matches("void x() { switch(42) case 42:; }",
3100 EXPECT_TRUE(matches("void x() { switch(42) { case 42:; } }",
3102 EXPECT_TRUE(notMatches(
3105 EXPECT_TRUE(matches("void x() { switch(42) { case 1+1: case 4:; } }",
3108 EXPECT_TRUE(notMatches("void x() { switch(42) { case 1+1: case 2+2:; } }",
3111 EXPECT_TRUE(notMatches("void x() { switch(42) { case 1 ... 2:; } }",
3114 EXPECT_TRUE(matchAndVerifyResultTrue(
3121 EXPECT_TRUE(matches(
3127 EXPECT_TRUE(matches("void foo() try { } catch(int X) { }", catchStmt()));
3128 EXPECT_TRUE(matches("void foo() try { } catch(int X) { }", tryStmt()));
3129 EXPECT_TRUE(notMatches("void foo() try { } catch(int X) { }", throwExpr()));
3130 EXPECT_TRUE(matches("void foo() try { throw; } catch(int X) { }",
3132 EXPECT_TRUE(matches("void foo() try { throw 5;} catch(int X) { }",
3137 EXPECT_TRUE(notMatches(
3140 EXPECT_TRUE(notMatches(
3146 EXPECT_TRUE(matches(
3152 EXPECT_TRUE(matchAndVerifyResultTrue("class C { int x; };",
3158 EXPECT_TRUE(matchAndVerifyResultTrue("class C { int x; int y; int z; };",
3164 EXPECT_TRUE(matchAndVerifyResultTrue(
3172 EXPECT_TRUE(matchAndVerifyResultTrue("class C { class D { int x; }; };",
3181 EXPECT_TRUE(matchAndVerifyResultTrue(
3189 EXPECT_TRUE(matchAndVerifyResultTrue(
3196 EXPECT_TRUE(matchAndVerifyResultTrue(
3204 EXPECT_TRUE(matchAndVerifyResultTrue(
3213 EXPECT_TRUE(matchAndVerifyResultTrue(
3222 EXPECT_TRUE(matchAndVerifyResultTrue(
3247 EXPECT_TRUE(matchAndVerifyResultTrue(
3253 EXPECT_TRUE(matchAndVerifyResultTrue(
3257 EXPECT_TRUE(matchAndVerifyResultTrue(
3263 EXPECT_TRUE(matchAndVerifyResultTrue(
3267 EXPECT_TRUE(matchAndVerifyResultTrue(
3273 EXPECT_TRUE(matchAndVerifyResultTrue(
3277 EXPECT_TRUE(matchAndVerifyResultTrue(
3281 EXPECT_TRUE(matchAndVerifyResultTrue(
3286 EXPECT_TRUE(matchAndVerifyResultTrue(
3292 EXPECT_TRUE(matchAndVerifyResultTrue(
3296 EXPECT_TRUE(matchAndVerifyResultTrue(
3301 EXPECT_TRUE(matchAndVerifyResultTrue(
3305 EXPECT_TRUE(matchAndVerifyResultTrue(
3312 EXPECT_TRUE(matchAndVerifyResultTrue(
3316 EXPECT_TRUE(matchAndVerifyResultTrue(
3324 EXPECT_TRUE(matchAndVerifyResultTrue(
3328 EXPECT_TRUE(matchAndVerifyResultTrue(
3335 EXPECT_TRUE(matchAndVerifyResultTrue(
3342 EXPECT_TRUE(matchAndVerifyResultTrue(
3349 EXPECT_TRUE(matchAndVerifyResultTrue(
3356 EXPECT_TRUE(matchAndVerifyResultTrue(
3363 EXPECT_TRUE(matchAndVerifyResultTrue(
3371 EXPECT_TRUE(matchAndVerifyResultTrue(
3376 EXPECT_TRUE(matchAndVerifyResultTrue(
3381 EXPECT_TRUE(notMatches(
3391 EXPECT_TRUE(matches(
3395 EXPECT_TRUE(matches(
3402 EXPECT_TRUE(matches(
3409 EXPECT_TRUE(matches(
3418 EXPECT_TRUE(matches(
3426 EXPECT_TRUE(matches(
3439 EXPECT_TRUE(matches(
3449 EXPECT_TRUE(notMatches(
3456 EXPECT_TRUE(notMatches(
3463 EXPECT_TRUE(notMatches(
3466 EXPECT_TRUE(notMatches(
3473 EXPECT_TRUE(notMatches(
3477 EXPECT_TRUE(notMatches(
3485 EXPECT_TRUE(notMatches(
3488 EXPECT_TRUE(notMatches(
3495 EXPECT_TRUE(matches(
3499 EXPECT_TRUE(matches(
3506 EXPECT_TRUE(matches(
3512 EXPECT_TRUE(notMatches(
3518 EXPECT_TRUE(matches(
3525 EXPECT_TRUE(matches(
3531 EXPECT_TRUE(matches(
3537 EXPECT_TRUE(matchAndVerifyResultTrue(
3544 EXPECT_TRUE(matchAndVerifyResultTrue(
3556 EXPECT_TRUE(matchAndVerifyResultTrue(
3570 EXPECT_TRUE(matches(
3578 EXPECT_TRUE(matches(
3586 EXPECT_TRUE(matches(
3589 EXPECT_TRUE(notMatches(
3592 EXPECT_TRUE(notMatches(
3598 EXPECT_TRUE(matches(
3608 EXPECT_TRUE(matches(
3615 EXPECT_TRUE(matches(
3622 EXPECT_TRUE(matches(
3631 EXPECT_TRUE(
3659 EXPECT_TRUE(matches("struct S {};", qualType().bind("loc")));
3663 EXPECT_TRUE(matches("int a[] = {2,3};", arrayType()));
3664 EXPECT_TRUE(matches("int a[42];", arrayType()));
3665 EXPECT_TRUE(matches("void f(int b) { int a[b]; }", arrayType()));
3667 EXPECT_TRUE(notMatches("struct A {}; A a[7];",
3670 EXPECT_TRUE(matches(
3673 EXPECT_TRUE(matches(
3676 EXPECT_TRUE(matches(
3680 EXPECT_TRUE(notMatches(
3683 EXPECT_TRUE(notMatches(
3686 EXPECT_TRUE(notMatches(
3691 EXPECT_TRUE(matches("int a[2];",
3693 EXPECT_TRUE(matches("const int a = 0;", qualType(isInteger())));
3697 EXPECT_TRUE(matches("_Complex float f;", complexType()));
3698 EXPECT_TRUE(matches(
3701 EXPECT_TRUE(notMatches(
3707 EXPECT_TRUE(matches("int a[2];", constantArrayType()));
3708 EXPECT_TRUE(notMatches(
3712 EXPECT_TRUE(matches("int a[42];", constantArrayType(hasSize(42))));
3713 EXPECT_TRUE(matches("int b[2*21];", constantArrayType(hasSize(42))));
3714 EXPECT_TRUE(notMatches("int c[41], d[43];", constantArrayType(hasSize(42))));
3718 EXPECT_TRUE(matches(
3721 EXPECT_TRUE(notMatches(
3727 EXPECT_TRUE(matches("int a[] = { 2, 3 };", incompleteArrayType()));
3728 EXPECT_TRUE(matches("void f(int a[]) {}", incompleteArrayType()));
3730 EXPECT_TRUE(notMatches("int a[42]; void f() { int b[a[0]]; }",
3735 EXPECT_TRUE(matches("void f(int b) { int a[b]; }", variableArrayType()));
3736 EXPECT_TRUE(notMatches("int a[] = {2, 3}; int b[42];", variableArrayType()));
3738 EXPECT_TRUE(matches(
3748 EXPECT_TRUE(matches("_Atomic(int) i;", atomicType()));
3750 EXPECT_TRUE(matches("_Atomic(int) i;",
3752 EXPECT_TRUE(notMatches("_Atomic(float) f;",
3758 EXPECT_TRUE(matches("auto i = 2;", autoType()));
3759 EXPECT_TRUE(matches("int v[] = { 2, 3 }; void f() { for (int i : v) {} }",
3764 //EXPECT_TRUE(matches("auto a = 1;",
3766 //EXPECT_TRUE(notMatches("auto b = 2.0;",
3771 EXPECT_TRUE(matches("int (*f)(int);", functionType()));
3772 EXPECT_TRUE(matches("void f(int i) {}", functionType()));
3776 EXPECT_TRUE(
3778 EXPECT_TRUE(notMatches("int *array[4];", varDecl(hasType(parenType()))));
3780 EXPECT_TRUE(matches(
3783 EXPECT_TRUE(notMatches(
3792 //EXPECT_TRUE(matchAndVerifyResultTrue(
3796 //EXPECT_TRUE(matchAndVerifyResultTrue(
3800 EXPECT_TRUE(matches(
3803 EXPECT_TRUE(matches(
3806 EXPECT_TRUE(matches(
3811 EXPECT_TRUE(notMatches(Fragment, varDecl(hasName("ptr"),
3813 EXPECT_TRUE(matches(Fragment, varDecl(hasName("ptr"),
3815 EXPECT_TRUE(notMatches(Fragment, varDecl(hasName("ptr"),
3817 EXPECT_TRUE(notMatches(Fragment, varDecl(hasName("ptr"),
3819 EXPECT_TRUE(notMatches(Fragment, varDecl(hasName("ptr"),
3821 EXPECT_TRUE(notMatches(Fragment, varDecl(hasName("ptr"),
3825 EXPECT_TRUE(notMatches(Fragment, varDecl(hasName("ptr"),
3827 EXPECT_TRUE(notMatches(Fragment, varDecl(hasName("ptr"),
3829 EXPECT_TRUE(matches(Fragment, varDecl(hasName("ptr"),
3831 EXPECT_TRUE(notMatches(Fragment, varDecl(hasName("ptr"),
3835 EXPECT_TRUE(notMatches(Fragment, varDecl(hasName("ref"),
3837 EXPECT_TRUE(notMatches(Fragment, varDecl(hasName("ref"),
3839 EXPECT_TRUE(notMatches(Fragment, varDecl(hasName("ref"),
3841 EXPECT_TRUE(matches(Fragment, varDecl(hasName("ref"),
3843 EXPECT_TRUE(matches(Fragment, varDecl(hasName("ref"),
3845 EXPECT_TRUE(notMatches(Fragment, varDecl(hasName("ref"),
3849 EXPECT_TRUE(notMatches(Fragment, varDecl(hasName("ref"),
3851 EXPECT_TRUE(notMatches(Fragment, varDecl(hasName("ref"),
3853 EXPECT_TRUE(notMatches(Fragment, varDecl(hasName("ref"),
3855 EXPECT_TRUE(matches(Fragment, varDecl(hasName("ref"),
3857 EXPECT_TRUE(notMatches(Fragment, varDecl(hasName("ref"),
3859 EXPECT_TRUE(matches(Fragment, varDecl(hasName("ref"),
3869 EXPECT_TRUE(notMatches(Fragment, varDecl(hasName("a"),
3871 EXPECT_TRUE(notMatches(Fragment, varDecl(hasName("b"),
3873 EXPECT_TRUE(matches(Fragment, varDecl(hasName("c"),
3875 EXPECT_TRUE(matches(Fragment, varDecl(hasName("c"),
3877 EXPECT_TRUE(notMatches(Fragment, varDecl(hasName("c"),
3879 EXPECT_TRUE(matches(Fragment, varDecl(hasName("d"),
3881 EXPECT_TRUE(matches(Fragment, varDecl(hasName("d"),
3883 EXPECT_TRUE(notMatches(Fragment, varDecl(hasName("d"),
3885 EXPECT_TRUE(matches(Fragment, varDecl(hasName("e"),
3887 EXPECT_TRUE(notMatches(Fragment, varDecl(hasName("e"),
3889 EXPECT_TRUE(matches(Fragment, varDecl(hasName("e"),
3894 EXPECT_TRUE(matches("int b; int &a = b;",
3896 EXPECT_TRUE(matches("int *a;", pointerType(pointee(builtinType()))));
3898 EXPECT_TRUE(matches("int *a;",
3901 EXPECT_TRUE(matches(
3904 EXPECT_TRUE(notMatches(
3910 EXPECT_TRUE(matches("int b; int * const a = &b;",
3912 EXPECT_TRUE(matches("int b; int * const a = &b;",
3914 EXPECT_TRUE(matches(
3917 EXPECT_TRUE(matches(
3923 EXPECT_TRUE(matches("typedef int X; X a;", varDecl(hasName("a"),
3928 EXPECT_TRUE(matches("template <typename T> class A{}; A<int> a;",
3933 EXPECT_TRUE(matches("class C{}; C c;", recordType()));
3934 EXPECT_TRUE(matches("struct S{}; S s;",
3936 EXPECT_TRUE(notMatches("int i;",
3941 EXPECT_TRUE(matches(
3948 EXPECT_TRUE(matches("class C {} c;", elaboratedType()));
3949 EXPECT_TRUE(notMatches("class C {}; C c;", elaboratedType()));
3953 EXPECT_TRUE(matches(
3961 EXPECT_TRUE(notMatches(
3967 EXPECT_TRUE(notMatches(
3974 EXPECT_TRUE(matches(
3983 EXPECT_TRUE(notMatches(
3992 EXPECT_TRUE(matches("namespace ns { struct A {}; } ns::A a;",
3994 EXPECT_TRUE(matches("template <typename T> class A { typename T::B b; };",
3996 EXPECT_TRUE(matches("struct A { void f(); }; void A::f() {}",
3999 EXPECT_TRUE(matches(
4002 EXPECT_TRUE(notMatches(
4008 EXPECT_TRUE(matches("void f() {int i;;}", nullStmt()));
4009 EXPECT_TRUE(notMatches("void f() {int i;}", nullStmt()));
4015 EXPECT_TRUE(matches("struct A { struct B {}; }; A::B b;", Matcher));
4016 EXPECT_TRUE(matches("struct A { struct B { struct C {}; }; }; A::B::C c;",
4018 EXPECT_TRUE(notMatches("namespace A { struct B {}; } A::B b;", Matcher));
4024 EXPECT_TRUE(matches("namespace ns { struct A {}; } ns::A a;", Matcher));
4025 EXPECT_TRUE(notMatches("namespace xx { struct A {}; } xx::A a;", Matcher));
4026 EXPECT_TRUE(notMatches("struct ns { struct A {}; }; ns::A a;", Matcher));
4030 EXPECT_TRUE(matchAndVerifyResultTrue(
4037 EXPECT_TRUE(matchAndVerifyResultTrue(
4044 EXPECT_TRUE(matches(
4047 EXPECT_TRUE(matches(
4057 EXPECT_TRUE(matches(
4062 EXPECT_TRUE(notMatches(
4067 EXPECT_TRUE(matches(
4075 EXPECT_TRUE(matchAndVerifyResultTrue(
4086 EXPECT_TRUE(matches(
4090 EXPECT_TRUE(matchAndVerifyResultTrue(
4102 EXPECT_TRUE(matches(
4107 EXPECT_TRUE(notMatches(
4112 EXPECT_TRUE(matches(
4118 EXPECT_TRUE(matchAndVerifyResultTrue(
4129 EXPECT_TRUE(matches(
4133 EXPECT_TRUE(matchAndVerifyResultTrue(
4162 EXPECT_TRUE(matchAndVerifyResultTrue(
4167 EXPECT_TRUE(matchAndVerifyResultFalse(
4175 EXPECT_TRUE(matchAndVerifyResultTrue(
4179 EXPECT_TRUE(matchAndVerifyResultFalse(
4186 EXPECT_TRUE(matchAndVerifyResultTrue(
4190 EXPECT_TRUE(matchAndVerifyResultFalse(
4227 EXPECT_TRUE(matchAndVerifyResultTrue(
4230 EXPECT_TRUE(matchAndVerifyResultTrue(
4239 EXPECT_TRUE(Called);
4254 EXPECT_TRUE(VerifyCallback.Called);
4260 EXPECT_TRUE(VerifyCallback.Called);
4282 EXPECT_TRUE(VerifyCallback.Called);
4288 EXPECT_TRUE(VerifyCallback.Called);
4292 EXPECT_TRUE(matches(
4296 EXPECT_TRUE(notMatches("int i = 1.f;",
4303 EXPECT_TRUE(notMatches(
4310 EXPECT_TRUE(
4315 EXPECT_TRUE(notMatches(
4321 EXPECT_TRUE(matches(
4326 EXPECT_TRUE(notMatches("class X { class Y {}; };",
4332 EXPECT_TRUE(matches(
4338 EXPECT_TRUE(notMatches(
4346 EXPECT_TRUE(matchAndVerifyResultTrue(
4367 EXPECT_TRUE(matchAndVerifyResultTrue(
4380 EXPECT_TRUE(matchAndVerifyResultTrue(