Lines Matching refs:matches

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));
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));
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));
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));
112 EXPECT_FALSE(matches("", ClassMatcher));
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));
127 EXPECT_TRUE(matches("class X {}; class Y : public X {};", 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));
144 matches("class X {}; class Y : public X {}; class Z : public Y {};",
147 matches("class X {};"
150 EXPECT_TRUE(matches("class X {}; template<class T> class Z : public X {};",
153 matches("template<class T> class X {}; "
157 matches("template<class T, class U=T> class X {}; "
164 matches("template<class X> class A { public: class Z : public X {}; }; "
167 matches("template <class T> class X {}; "
174 matches("template<template<class T> class X> class A { "
182 matches("template<class X> class A { public: "
187 matches("class X {}; typedef X Y; class Z : public Y {};",
190 matches("template<class T> class Y { typedef typename T::U X; "
192 EXPECT_TRUE(matches("class X {}; class Z : public ::X {};",
199 matches("template<class T> class X { public: typedef X<T> D; }; "
207 matches("class X {}; typedef X V; typedef V W; class Z : public W {};",
210 matches("class X {}; class Y : public X {}; "
214 matches("template<class T, class U> class X {}; "
222 matches("class X {}; typedef X A; typedef A B; "
225 matches("class X {}; typedef X A; typedef A B; typedef B C; "
228 matches("class U {}; typedef U X; typedef X V; "
231 matches("class Base {}; typedef Base X; "
234 matches("class Base {}; typedef Base Base2; typedef Base2 X; "
240 matches("class A {}; typedef A X; typedef A Y; "
248 matches("template <typename T> class X;"
252 EXPECT_TRUE(matches(
262 EXPECT_TRUE(matches(
282 EXPECT_TRUE(matches(
290 EXPECT_TRUE(matches(
307 EXPECT_TRUE(matches(
315 EXPECT_TRUE(matches(
320 EXPECT_TRUE(matches(
327 EXPECT_TRUE(matches(
331 EXPECT_TRUE(matches(
339 EXPECT_TRUE(matches("class A { void func(); };",
346 EXPECT_TRUE(matches(
356 EXPECT_TRUE(matches(
371 EXPECT_TRUE(matches("namespace {"
388 EXPECT_TRUE(matches("template<typename T> class X {};", ClassX));
389 EXPECT_TRUE(matches("class Z { template<class T> class X {}; };", ClassX));
411 EXPECT_TRUE(matches(Program,
414 EXPECT_TRUE(matches(Program,
419 EXPECT_TRUE(matches(Program,
425 EXPECT_TRUE(matches(Program,
438 matches("class X {}; class Z : public X {};", YOrZDerivedFromX));
439 EXPECT_TRUE(matches("class Y {};", YOrZDerivedFromX));
446 EXPECT_TRUE(matches("class X {};", 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));
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));
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));
557 matches("class O1 { class O2 {"
569 EXPECT_TRUE(matches("class Y {}; class Z : public Y {};", NotClassX));
581 EXPECT_TRUE(matches("class X { class Z {}; };", ClassXHasNotClassY));
591 EXPECT_TRUE(matches("class Z { class X {}; };", ZDescendantClassX));
593 matches("class Z { class Y { class X {}; }; };", ZDescendantClassX));
595 matches("class Z { class A { class Y { class X {}; }; }; };",
598 matches("class Z { class A { class B { class Y { class X {}; }; }; }; };",
607 EXPECT_TRUE(matches("class Z { class X { class Y {}; }; };",
610 matches("class Z { class A { class B { class X { class Y {}; }; }; }; };",
631 matches("class Z { class A { class X { class B { class Y {}; }; }; }; };",
633 EXPECT_TRUE(matches(
653 // Does not check for a certain number of matches.
658 // Checks that there were exactly \c ExpectedCount matches.
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; }",
740 EXPECT_TRUE(matches("void f() { int*** i; }",
742 EXPECT_TRUE(matches("void f() { int*** i; }",
745 EXPECT_TRUE(matches("void f() { int*** i; }",
755 EXPECT_TRUE(matches("int i;",
766 EXPECT_TRUE(matches(
779 EXPECT_TRUE(matches("enum X {};", enumDecl(hasName("X"))));
784 EXPECT_TRUE(matches("enum X{ A };", Matcher));
794 EXPECT_TRUE(matches(
805 EXPECT_TRUE(matches(
816 EXPECT_TRUE(matches("class A { public: A *a; };", TypeA));
821 EXPECT_TRUE(matches("class A {}; class B : public A { public: B *b; };",
829 matches("class A { public: A *a; class B {}; };", TypeAHasClassB));
886 EXPECT_TRUE(matches("enum X {}; void y(X *x) { x; }",
898 EXPECT_TRUE(matches("typedef int X; X a;",
906 EXPECT_TRUE(matches("template <typename T> class A {}; A<int> a;",
914 matches("class X {}; void y(X &x) { x; }", expr(hasType(ClassX))));
919 matches("class X {}; void y(X *x) { x; }",
926 matches("class X {}; void y() { X x; }", varDecl(hasType(ClassX))));
930 matches("class X {}; void y() { X *x; }",
937 matches("class X {}; void y(X &x) { x; }", expr(hasType(ClassX))));
946 matches("class X {}; void y() { X x; }", varDecl(hasType(ClassX))));
952 EXPECT_TRUE(matches("int x;",
965 EXPECT_TRUE(matches("class Y { void x() { x(); } };", MethodX));
972 matches("class Y { public: void x(); }; void z() { Y y; y.x(); }",
975 matches("class Y { public: void x(); }; void z(Y &y) { y.x(); }",
991 matches("class Y { public: void x(); }; void z() { Y *y; y->x(); }",
994 matches("class Y { public: void x(); }; void z(Y *&y) { y->x(); }",
997 matches("class Y { public: void x(); }; void z(Y y[]) { y->x(); }",
1008 EXPECT_TRUE(matches("auto f = [] (int i) { return i; };",
1013 EXPECT_TRUE(matches("int as[] = { 1, 2, 3 };"
1021 EXPECT_FALSE(matches("template<int N>\n"
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()));
1050 matches("class Y { public: void x(); }; void z() {Y* y; y->x(); }",
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 { }; "
1077 EXPECT_TRUE(matches("class Y { }; "
1089 EXPECT_TRUE(matches("class Y { }; "
1100 EXPECT_TRUE(matches("class Y { int operator*(); };",
1113 EXPECT_TRUE(matches(
1118 EXPECT_TRUE(matches(
1130 matches("class Y { public: void x(); }; void z() { Y y; y.x(); }",
1133 matches("class Y { public: void x(); }; void z(Y &y) { y.x(); }",
1136 matches("class Y { public: void x(); }; void z(Y *&y) { y->x(); }",
1139 matches("class Y { public: void x(); }; void z(Y y[]) { y->x(); }",
1142 matches("class Y { public: void x(); }; void z() { Y *y; y->x(); }",
1145 EXPECT_TRUE(matches(
1161 EXPECT_TRUE(matches(
1183 EXPECT_TRUE(matches("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(
1220 EXPECT_TRUE(matches("void x() { int a = sizeof(a); }",
1225 // EXPECT_TRUE(matches("void x() { int a = alignof(a); }",
1232 EXPECT_TRUE(matches("void x() { int a = sizeof(a); }", sizeOfExpr(
1236 EXPECT_TRUE(matches(
1248 EXPECT_TRUE(matches("class Y { void x() { x(); } };", memberExpr()));
1253 matches("class Y { void x() { this->y; } int y; };", memberExpr()));
1255 matches("class Y { void x() { y; } int y; };", memberExpr()));
1257 matches("class Y { void x() { Y y; y.y; } int y; };", memberExpr()));
1261 EXPECT_TRUE(matches("class Y { void x() { this->y; } static int y; };",
1270 EXPECT_TRUE(matches("int i = 0;", varDecl(hasType(isInteger()))));
1271 EXPECT_TRUE(matches(
1285 EXPECT_TRUE(matches("class Y { void x() { this->y; } int y; };",
1287 EXPECT_TRUE(matches("class Y { void x() { y; } int y; };",
1294 EXPECT_TRUE(matches("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(); } };",
1314 EXPECT_TRUE(matches("class Y { void x() { x(); } };", CallMethodX));
1319 EXPECT_TRUE(matches("class Y { void x() { this->x(); } };",
1328 EXPECT_TRUE(matches("void f() { f(); }", CallFunctionF));
1335 EXPECT_TRUE(matches("void f(); template <int N> void g() { f(); }",
1338 matches("void f(); template <int N> struct S { void g() { f(); } };",
1354 matches("template <typename T> void f(T t) {}",
1377 EXPECT_TRUE(matches("void x(int) { int y; x(y); }", CallArgumentY));
1379 matches("class X { void x(int) { int y; x(y); } };", CallArgumentY));
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));
1398 EXPECT_TRUE(matches("void x(int) { x(0); }", Call1Arg));
1399 EXPECT_TRUE(matches("class X { void x(int) { x(0); } };", Call1Arg));
1405 EXPECT_TRUE(matches("void f(int i) {}", Function1Arg));
1406 EXPECT_TRUE(matches("class X { void f(int i) {} };", Function1Arg));
1414 EXPECT_TRUE(matches("class X {}; void y(X y) { X &x = y; }",
1417 matches("class X {}; void y(X y) { const X &x = y; }", ReferenceClassX));
1421 matches("class X {}; void y(X y) { X x = y; }", ReferenceClassX));
1434 matches("typedef int &int_ref;"
1443 EXPECT_TRUE(matches("int *const j = nullptr;",
1445 EXPECT_TRUE(matches("int *volatile k;",
1452 EXPECT_TRUE(matches("class X { void x(int) {} };",
1464 EXPECT_TRUE(matches("class X { void x(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; } };",
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() {} }",
1512 EXPECT_TRUE(matches("class Y {}; class X { void x(int x) {} };",
1519 EXPECT_TRUE(matches("template<typename T> struct A {};"
1522 EXPECT_TRUE(matches("template<typename T> struct A {}; A<int> a;",
1529 EXPECT_TRUE(matches("int x;", declaratorDecl()));
1534 EXPECT_TRUE(matches("void f(int x);", parmVarDecl()));
1539 EXPECT_TRUE(matches(
1547 EXPECT_TRUE(matches(
1560 EXPECT_TRUE(matches(
1575 EXPECT_TRUE(matches(
1586 EXPECT_TRUE(matches(
1599 EXPECT_TRUE(matches("class C { public: int i; };", accessSpecDecl()));
1601 matches("class C { public: int i; };", accessSpecDecl(isPublic())));
1611 EXPECT_TRUE(matches("class X { virtual int f(); };",
1618 EXPECT_TRUE(matches("class X { virtual int f() = 0; };",
1625 EXPECT_TRUE(matches("struct A { void foo() const; };",
1632 EXPECT_TRUE(matches("class X { virtual int f(); }; "
1649 matches("class X { public: X(); }; void x() { X x; }", Constructor));
1651 matches("class X { public: X(); }; void x() { X x = X(); }",
1654 matches("class X { public: X(int); }; void x() { X x = 0; }",
1656 EXPECT_TRUE(matches("class X {}; void x(int) { X x; }", Constructor));
1664 matches("class X { public: X(int); }; void x() { int y; X x(y); }",
1667 matches("class X { public: X(int); }; void x() { int y; X x = X(y); }",
1670 matches("class X { public: X(int); }; void x() { int y; X x = y; }",
1687 matches("class X { public: X(int); }; void x() { X x(0); }",
1690 matches("class X { public: X(int); }; void x() { X x = X(0); }",
1693 matches("class X { public: X(int); }; void x() { X x = 0; }",
1704 matches("class X { public: X(int); }; void x() { X x{0}; }",
1707 matches("class X { public: X(int); }; void x() { X x(0); }",
1713 matches("struct X { int a; int f () { return a; } };", thisExpr()));
1724 matches(ClassString +
1754 matches(ClassString +
1785 EXPECT_TRUE(matches("class Foo { Foo(int i); };",
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(); };",
1820 EXPECT_TRUE(matches(
1836 EXPECT_TRUE(matches(Code, constructorDecl(hasAnyConstructorInitializer(
1838 EXPECT_TRUE(matches(Code, constructorDecl(hasAnyConstructorInitializer(
1850 EXPECT_TRUE(matches(Code, constructorDecl(hasAnyConstructorInitializer(
1864 EXPECT_TRUE(matches(Code, constructorDecl(hasAnyConstructorInitializer(
1868 EXPECT_TRUE(matches(Code, constructorDecl(hasAnyConstructorInitializer(
1875 EXPECT_TRUE(matches("class X { public: X(); }; void x() { new X; }", New));
1877 matches("class X { public: X(); }; void x() { new X(); }", New));
1879 matches("class X { public: X(int); }; void x() { new X(0); }", New));
1880 EXPECT_TRUE(matches("class X {}; void x(int) { new X; }", New));
1888 matches("class X { public: X(int); }; void x() { int y; new X(y); }",
1891 matches("class X { public: X(int); }; void x() { int y; new X(y); }",
1908 matches("class X { public: X(int); }; void x() { new X(0); }", New));
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));
1924 matches("class X { void x(int, int = 0) { int y; x(y); } };", 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));
1941 EXPECT_TRUE(matches("const char c = 'c';", CharLiteral));
1943 EXPECT_TRUE(matches("const char c = L'c';", 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));
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));
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));
1995 EXPECT_TRUE(matches("void f() { if (false) true; else false; }",
1999 EXPECT_TRUE(matches("void f() { if (false) false; else true; }",
2008 EXPECT_TRUE(matches("void x() { true || false; }", OperatorOr));
2017 EXPECT_TRUE(matches("void x() { true || false; }", OperatorTrueFalse));
2018 EXPECT_TRUE(matches("void x() { true && false; }", OperatorTrueFalse));
2026 EXPECT_TRUE(matches("void x() { true || false; }", HasOperand));
2027 EXPECT_TRUE(matches("void x() { false && true; }", HasOperand));
2036 matches("void x() { 3, 4; }", binaryOperator(hasOperatorName(","))));
2038 matches("bool b; bool c = (b = true);",
2041 matches("bool b = 1 != 2;", binaryOperator(hasOperatorName("!="))));
2043 matches("bool b = 1 == 2;", binaryOperator(hasOperatorName("=="))));
2044 EXPECT_TRUE(matches("bool b = 1 < 2;", binaryOperator(hasOperatorName("<"))));
2046 matches("bool b = 1 <= 2;", binaryOperator(hasOperatorName("<="))));
2048 matches("int i = 1 << 2;", binaryOperator(hasOperatorName("<<"))));
2050 matches("int i = 1; int j = (i <<= 2);",
2052 EXPECT_TRUE(matches("bool b = 1 > 2;", binaryOperator(hasOperatorName(">"))));
2054 matches("bool b = 1 >= 2;", binaryOperator(hasOperatorName(">="))));
2056 matches("int i = 1 >> 2;", binaryOperator(hasOperatorName(">>"))));
2058 matches("int i = 1; int j = (i >>= 2);",
2061 matches("int i = 42 ^ 23;", binaryOperator(hasOperatorName("^"))));
2063 matches("int i = 42; int j = (i ^= 42);",
2066 matches("int i = 42 % 23;", binaryOperator(hasOperatorName("%"))));
2068 matches("int i = 42; int j = (i %= 42);",
2071 matches("bool b = 42 &23;", binaryOperator(hasOperatorName("&"))));
2073 matches("bool b = true && false;",
2076 matches("bool b = true; bool c = (b &= false);",
2079 matches("bool b = 42 | 23;", binaryOperator(hasOperatorName("|"))));
2081 matches("bool b = true || false;",
2084 matches("bool b = true; bool c = (b |= false);",
2087 matches("int i = 42 *23;", binaryOperator(hasOperatorName("*"))));
2089 matches("int i = 42; int j = (i *= 23);",
2092 matches("int i = 42 / 23;", binaryOperator(hasOperatorName("/"))));
2094 matches("int i = 42; int j = (i /= 23);",
2097 matches("int i = 42 + 23;", binaryOperator(hasOperatorName("+"))));
2099 matches("int i = 42; int j = (i += 23);",
2102 matches("int i = 42 - 23;", binaryOperator(hasOperatorName("-"))));
2104 matches("int i = 42; int j = (i -= 23);",
2107 matches("struct A { void x() { void (A::*a)(); (this->*a)(); } };",
2110 matches("struct A { void x() { void (A::*a)(); ((*this).*a)(); } };",
2113 // Member expressions as operators are not supported in matches.
2135 EXPECT_TRUE(matches("void x() { !true; } ", OperatorNot));
2143 EXPECT_TRUE(matches("void x() { !false; }", OperatorOnFalse));
2150 EXPECT_TRUE(matches("bool b = !true;", unaryOperator(hasOperatorName("!"))));
2152 matches("bool b; bool *p = &b;", unaryOperator(hasOperatorName("&"))));
2153 EXPECT_TRUE(matches("int i = ~ 1;", unaryOperator(hasOperatorName("~"))));
2155 matches("bool *p; bool b = *p;", unaryOperator(hasOperatorName("*"))));
2157 matches("int i; int j = +i;", unaryOperator(hasOperatorName("+"))));
2159 matches("int i; int j = -i;", unaryOperator(hasOperatorName("-"))));
2161 matches("int i; int j = ++i;", unaryOperator(hasOperatorName("++"))));
2163 matches("int i; int j = i++;", unaryOperator(hasOperatorName("++"))));
2165 matches("int i; int j = --i;", unaryOperator(hasOperatorName("--"))));
2167 matches("int i; int j = i--;", unaryOperator(hasOperatorName("--"))));
2187 EXPECT_TRUE(matches("void x() { true ? false : true; }", Conditional));
2194 EXPECT_TRUE(matches("void x() { true ? true : false; }", ConditionalFalse));
2200 EXPECT_TRUE(matches("int i[2]; void f() { i[1] = 1; }",
2207 EXPECT_TRUE(matches(
2210 EXPECT_TRUE(matches(
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; } }",
2254 matches("class A { class B { class C; }; };",
2257 matches("class A { class B { class C; }; };",
2260 matches("class A { class B { class C; }; };",
2263 matches("class A { class B { class C; }; };",
2290 EXPECT_TRUE(matches("class A {};", DefinitionOfClassA));
2295 EXPECT_TRUE(matches("int a;", DefinitionOfVariableA));
2300 EXPECT_TRUE(matches("class A { void a() {} };", DefinitionOfMethodA));
2309 matches("class X { public: X(); }; void x(int) { X x; }", Constructor));
2311 matches("class X { public: X(); }; void x(int) { X x = X(); }",
2319 EXPECT_TRUE(matches(
2325 EXPECT_TRUE(matches(
2345 EXPECT_TRUE(matches(
2367 return AMatcher.matches(Node, Finder, Builder);
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()));
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(
2449 EXPECT_TRUE(matches("void f() {}", compoundStmt()));
2450 EXPECT_TRUE(matches("void f() {{}}", compoundStmt()));
2458 EXPECT_TRUE(matches("namespace n { struct S { void f() {{}} }; }",
2463 EXPECT_TRUE(matches("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 (;;); }",
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() { }",
2507 EXPECT_TRUE(matches("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; } }",
2527 EXPECT_TRUE(matches("void f() { { 1; } { 1; 2; 3; 4; } }",
2532 EXPECT_TRUE(matches("struct { int first; } s; int i(s.first);",
2544 EXPECT_TRUE(matches("void f() {"
2552 EXPECT_TRUE(matches(
2561 EXPECT_TRUE(matches(
2572 EXPECT_TRUE(matches(
2577 EXPECT_TRUE(matches("class A { protected: int i; };",
2595 EXPECT_TRUE(matches("class X { void operator delete(void*); };",
2612 EXPECT_TRUE(matches(
2615 EXPECT_TRUE(matches(
2623 EXPECT_TRUE(matches(
2627 EXPECT_TRUE(matches(
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);",
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()));
2689 EXPECT_TRUE(matches("char* p = reinterpret_cast<char*>(&p);",
2707 EXPECT_TRUE(matches(foo_class + "void r() { Foo f = Foo(\"hello world\"); }",
2722 EXPECT_TRUE(matches("struct B { virtual ~B() {} }; struct D : B {};"
2729 EXPECT_TRUE(matches("void* p(static_cast<void*>(&p));",
2746 EXPECT_TRUE(matches("int i = (int) 2.2f;", cStyleCastExpr()));
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;",
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;",
2800 // This test verifies that implicitCastExpr() matches exactly when implicit casts
2819 // This test checks that ignoringImpCasts matches when implicit casts are
2822 EXPECT_TRUE(matches("int x = 0; const int y = x;",
2826 EXPECT_TRUE(matches("char x = 0;",
2861 EXPECT_TRUE(matches("int x = 0; int &y = x;",
2867 // This test checks that ignoringParenCasts matches when parentheses and/or
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;",
2916 // This test checks that ignoringParenAndImpCasts matches when
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;",
2961 EXPECT_TRUE(matches("class string {}; class URL { public: URL(string s); };"
2968 EXPECT_TRUE(matches("float x = static_cast<float>(42);",
2979 EXPECT_TRUE(matches("void x() {}", stmt()));
2987 EXPECT_TRUE(matches("void x() { int a; }", declStmt()));
2991 EXPECT_TRUE(matches("struct Foo { ~Foo(); };"
2994 EXPECT_FALSE(matches("struct 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;",
3026 EXPECT_TRUE(matches(
3037 EXPECT_TRUE(matches("void f() {int a = 4;}", SingleDeclStmt));
3046 EXPECT_TRUE(matches("void f() {int a = 4;}",
3048 EXPECT_TRUE(matches("void f() {int a = 4, b = 3;}",
3058 EXPECT_TRUE(matches("void f() {int i,j;}",
3068 EXPECT_TRUE(matches("void x() { while(true); }", whileStmt()));
3073 EXPECT_TRUE(matches("void x() { do {} while(true); }", doStmt()));
3074 EXPECT_TRUE(matches("void x() { do ; while(false); }", 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()));
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()));
3098 EXPECT_TRUE(matches("void x() { switch(42) case 42:; }",
3100 EXPECT_TRUE(matches("void x() { switch(42) { case 42:; } }",
3105 EXPECT_TRUE(matches("void x() { switch(42) { case 1+1: case 4:; } }",
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()));
3130 EXPECT_TRUE(matches("void foo() try { throw; } catch(int X) { }",
3132 EXPECT_TRUE(matches("void foo() try { throw 5;} catch(int X) { }",
3146 EXPECT_TRUE(matches(
3232 // ... return InnerMatcher.matches(...); ...
3235 // On the other hand, if there are multiple alternative matches
3236 // (for example forEach*) or matches might be discarded (for example has*)
3237 // the implementation must make sure that the discarded matches do not
3240 // - matches a simple node, and binds it as the first thing in the matcher:
3245 // the direct parent matches the inner matcher.
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(
3495 EXPECT_TRUE(matches(
3499 EXPECT_TRUE(matches(
3506 EXPECT_TRUE(matches(
3518 EXPECT_TRUE(matches(
3525 EXPECT_TRUE(matches(
3531 EXPECT_TRUE(matches(
3570 EXPECT_TRUE(matches(
3578 EXPECT_TRUE(matches(
3586 EXPECT_TRUE(matches(
3598 EXPECT_TRUE(matches(
3608 EXPECT_TRUE(matches(
3615 EXPECT_TRUE(matches(
3622 EXPECT_TRUE(matches(
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()));
3670 EXPECT_TRUE(matches(
3673 EXPECT_TRUE(matches(
3676 EXPECT_TRUE(matches(
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(
3707 EXPECT_TRUE(matches("int a[2];", constantArrayType()));
3712 EXPECT_TRUE(matches("int a[42];", constantArrayType(hasSize(42))));
3713 EXPECT_TRUE(matches("int b[2*21];", constantArrayType(hasSize(42))));
3718 EXPECT_TRUE(matches(
3727 EXPECT_TRUE(matches("int a[] = { 2, 3 };", incompleteArrayType()));
3728 EXPECT_TRUE(matches("void f(int a[]) {}", incompleteArrayType()));
3735 EXPECT_TRUE(matches("void f(int b) { int a[b]; }", variableArrayType()));
3738 EXPECT_TRUE(matches(
3748 EXPECT_TRUE(matches("_Atomic(int) i;", atomicType()));
3750 EXPECT_TRUE(matches("_Atomic(int) i;",
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;",
3771 EXPECT_TRUE(matches("int (*f)(int);", functionType()));
3772 EXPECT_TRUE(matches("void f(int i) {}", functionType()));
3777 matches("int (*array)[4];", varDecl(hasType(pointsTo(parenType())))));
3780 EXPECT_TRUE(matches(
3800 EXPECT_TRUE(matches(
3803 EXPECT_TRUE(matches(
3806 EXPECT_TRUE(matches(
3813 EXPECT_TRUE(matches(Fragment, varDecl(hasName("ptr"),
3829 EXPECT_TRUE(matches(Fragment, varDecl(hasName("ptr"),
3841 EXPECT_TRUE(matches(Fragment, varDecl(hasName("ref"),
3843 EXPECT_TRUE(matches(Fragment, varDecl(hasName("ref"),
3855 EXPECT_TRUE(matches(Fragment, varDecl(hasName("ref"),
3859 EXPECT_TRUE(matches(Fragment, varDecl(hasName("ref"),
3873 EXPECT_TRUE(matches(Fragment, varDecl(hasName("c"),
3875 EXPECT_TRUE(matches(Fragment, varDecl(hasName("c"),
3879 EXPECT_TRUE(matches(Fragment, varDecl(hasName("d"),
3881 EXPECT_TRUE(matches(Fragment, varDecl(hasName("d"),
3885 EXPECT_TRUE(matches(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(
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;",
3941 EXPECT_TRUE(matches(
3948 EXPECT_TRUE(matches("class C {} c;", elaboratedType()));
3953 EXPECT_TRUE(matches(
3974 EXPECT_TRUE(matches(
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(
4008 EXPECT_TRUE(matches("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;",
4024 EXPECT_TRUE(matches("namespace ns { struct A {}; } ns::A a;", Matcher));
4044 EXPECT_TRUE(matches(
4047 EXPECT_TRUE(matches(
4057 EXPECT_TRUE(matches(
4067 EXPECT_TRUE(matches(
4086 EXPECT_TRUE(matches(
4102 EXPECT_TRUE(matches(
4112 EXPECT_TRUE(matches(
4129 EXPECT_TRUE(matches(
4292 EXPECT_TRUE(matches(
4311 matches("void f() { if(true) {} }",
4321 EXPECT_TRUE(matches(
4332 EXPECT_TRUE(matches(
4395 EXPECT_FALSE(matches(