Lines Matching refs:AST
35 auto AST = in buildASTFromCodeWithArgs() local
37 EXPECT_FALSE(AST->getDiagnostics().hasErrorOccurred()); in buildASTFromCodeWithArgs()
38 return AST; in buildASTFromCodeWithArgs()
53 bool isMutated(const SmallVectorImpl<BoundNodes> &Results, ASTUnit *AST) { in isMutated() argument
56 TraversalKindScope RAII(AST->getASTContext(), TK_AsIs); in isMutated()
57 return ExprMutationAnalyzer(*S, AST->getASTContext()).isMutated(E); in isMutated()
61 mutatedBy(const SmallVectorImpl<BoundNodes> &Results, ASTUnit *AST) { in mutatedBy() argument
64 ExprMutationAnalyzer Analyzer(*S, AST->getASTContext()); in mutatedBy()
73 By->printPretty(Stream, nullptr, AST->getASTContext().getPrintingPolicy()); in mutatedBy()
109 const auto AST = buildASTFromCode("void f() { int x; x; }"); in TEST() local
111 match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
112 EXPECT_FALSE(isMutated(Results, AST.get())); in TEST()
126 const auto AST = buildASTFromCode("void f() { int x; " + ModExpr + "; }"); in TEST_P() local
128 match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST_P()
129 EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre(ModExpr)); in TEST_P()
135 const auto AST = buildASTFromCode("void f() { int x; " + ModExpr + "; }"); in TEST_P() local
137 match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST_P()
138 EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre(ModExpr)); in TEST_P()
144 const auto AST = buildASTFromCodeWithArgs( in TEST_P() local
147 match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST_P()
148 EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre(ModExpr)); in TEST_P()
155 const auto AST = buildASTFromCodeWithArgs( in TEST_P() local
158 match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST_P()
159 EXPECT_FALSE(isMutated(Results, AST.get())); in TEST_P()
165 const auto AST = in TEST_P() local
168 match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST_P()
169 EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre(ModExpr)); in TEST_P()
177 const auto AST = in TEST_P() local
180 match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST_P()
181 EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre(ModExpr)); in TEST_P()
188 const auto AST = in TEST_P() local
191 match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST_P()
192 EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre(ModExpr)); in TEST_P()
198 const auto AST = in TEST_P() local
201 match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST_P()
202 EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre(ModExpr)); in TEST_P()
211 const auto AST = buildASTFromCode("struct Base {void nonconst(); };" in TEST() local
219 match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
220 EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("b", "b.nonconst()")); in TEST()
227 const auto AST = buildASTFromCode("void f() { int x; " + ModExpr + "; }"); in TEST_P() local
229 match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST_P()
230 EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre(ModExpr)); in TEST_P()
240 const auto AST = buildASTFromCode( in TEST() local
243 match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
244 EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("x.mf()")); in TEST()
248 auto AST = buildASTFromCodeWithArgs( in TEST() local
253 match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
254 EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("x.mf<T>()")); in TEST()
256 AST = buildASTFromCodeWithArgs("template <class T> void f() { T x; x.mf(); }", in TEST()
258 Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
259 EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("x.mf()")); in TEST()
261 AST = buildASTFromCodeWithArgs( in TEST()
265 Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
266 EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("x.mf()")); in TEST()
270 const auto AST = buildASTFromCode( in TEST() local
273 match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
274 EXPECT_FALSE(isMutated(Results, AST.get())); in TEST()
278 const auto AST = buildASTFromCodeWithArgs( in TEST() local
283 match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
284 EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("x.push_back(T())")); in TEST()
290 const auto AST = buildASTFromCode( in TEST() local
293 match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
294 EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("x = 10")); in TEST()
298 const auto AST = buildASTFromCode( in TEST() local
301 match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
302 EXPECT_FALSE(isMutated(Results, AST.get())); in TEST()
306 const auto AST = buildASTFromCodeWithArgs( in TEST() local
312 match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
313 EXPECT_TRUE(isMutated(Results, AST.get())); in TEST()
319 auto AST = buildASTFromCode("void g(int); void f() { int x; g(x); }"); in TEST() local
321 match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
322 EXPECT_FALSE(isMutated(Results, AST.get())); in TEST()
324 AST = buildASTFromCode("void g(int*); void f() { int* x; g(x); }"); in TEST()
325 Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
326 EXPECT_FALSE(isMutated(Results, AST.get())); in TEST()
328 AST = buildASTFromCode("typedef int* IntPtr;" in TEST()
330 Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
331 EXPECT_FALSE(isMutated(Results, AST.get())); in TEST()
333 AST = buildASTFromCode( in TEST()
335 Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
336 EXPECT_FALSE(isMutated(Results, AST.get())); in TEST()
338 AST = buildASTFromCode("void f() { struct A { A(int); }; int x; A y(x); }"); in TEST()
339 Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
340 EXPECT_FALSE(isMutated(Results, AST.get())); in TEST()
342 AST = buildASTFromCode("struct A { A(); A& operator=(A); };" in TEST()
344 Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
345 EXPECT_FALSE(isMutated(Results, AST.get())); in TEST()
347 AST = buildASTFromCode( in TEST()
350 Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
351 EXPECT_FALSE(isMutated(Results, AST.get())); in TEST()
355 auto AST = buildASTFromCode("void g(const int); void f() { int x; g(x); }"); in TEST() local
357 match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
358 EXPECT_FALSE(isMutated(Results, AST.get())); in TEST()
360 AST = buildASTFromCode("void g(int* const); void f() { int* x; g(x); }"); in TEST()
361 Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
362 EXPECT_FALSE(isMutated(Results, AST.get())); in TEST()
364 AST = buildASTFromCode("typedef int* const CIntPtr;" in TEST()
366 Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
367 EXPECT_FALSE(isMutated(Results, AST.get())); in TEST()
369 AST = buildASTFromCode( in TEST()
371 Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
372 EXPECT_FALSE(isMutated(Results, AST.get())); in TEST()
374 AST = buildASTFromCode( in TEST()
376 Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
377 EXPECT_FALSE(isMutated(Results, AST.get())); in TEST()
379 AST = buildASTFromCode("template <int> struct A { A(); A(const A&);" in TEST()
382 Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
383 EXPECT_FALSE(isMutated(Results, AST.get())); in TEST()
387 auto AST = buildASTFromCode("void g(int&); void f() { int x; g(x); }"); in TEST() local
389 match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
390 EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("g(x)")); in TEST()
392 AST = buildASTFromCode("typedef int& IntRef;" in TEST()
394 Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
395 EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("g(x)")); in TEST()
397 AST = buildASTFromCode("template <class T> using TRef = T&;" in TEST()
399 Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
400 EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("g(x)")); in TEST()
402 AST = buildASTFromCode( in TEST()
406 Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
407 EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("g<int>(x)")); in TEST()
409 AST = buildASTFromCode("typedef int* IntPtr;" in TEST()
411 Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
412 EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("g(x)")); in TEST()
414 AST = buildASTFromCode("typedef int* IntPtr; typedef IntPtr& IntPtrRef;" in TEST()
416 Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
417 EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("g(x)")); in TEST()
419 AST = buildASTFromCode( in TEST()
421 Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
422 EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("x + 1")); in TEST()
424 AST = buildASTFromCode("void f() { struct A { A(int&); }; int x; A y(x); }"); in TEST()
425 Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
426 EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("x")); in TEST()
428 AST = buildASTFromCode("void f() { struct A { A(); A(A&); }; A x; A y(x); }"); in TEST()
429 Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
430 EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("x")); in TEST()
432 AST = buildASTFromCode( in TEST()
435 Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
436 EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("A<0>::mf(x)")); in TEST()
440 auto AST = buildASTFromCodeWithArgs( in TEST() local
451 match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
452 EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("parser(x)")); in TEST()
456 auto AST = buildASTFromCode("void g(const int&); void f() { int x; g(x); }"); in TEST() local
458 match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
459 EXPECT_FALSE(isMutated(Results, AST.get())); in TEST()
461 AST = buildASTFromCode("typedef const int& CIntRef;" in TEST()
463 Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
464 EXPECT_FALSE(isMutated(Results, AST.get())); in TEST()
466 AST = buildASTFromCode("template <class T> using CTRef = const T&;" in TEST()
468 Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
469 EXPECT_FALSE(isMutated(Results, AST.get())); in TEST()
471 AST = in TEST()
476 Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
477 EXPECT_FALSE(isMutated(Results, AST.get())); in TEST()
479 AST = buildASTFromCode( in TEST()
481 Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
482 EXPECT_FALSE(isMutated(Results, AST.get())); in TEST()
484 AST = buildASTFromCode( in TEST()
486 Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
487 EXPECT_FALSE(isMutated(Results, AST.get())); in TEST()
489 AST = buildASTFromCode( in TEST()
491 Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
492 EXPECT_FALSE(isMutated(Results, AST.get())); in TEST()
496 auto AST = buildASTFromCode( in TEST() local
499 match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
500 EXPECT_THAT(mutatedBy(Results, AST.get()), in TEST()
503 AST = buildASTFromCode("struct A {}; A operator+(A&&, int);" in TEST()
505 Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
506 EXPECT_THAT(mutatedBy(Results, AST.get()), in TEST()
509 AST = buildASTFromCode("void f() { struct A { A(int&&); }; " in TEST()
511 Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
512 EXPECT_THAT(mutatedBy(Results, AST.get()), in TEST()
515 AST = buildASTFromCode("void f() { struct A { A(); A(A&&); }; " in TEST()
517 Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
518 EXPECT_THAT(mutatedBy(Results, AST.get()), in TEST()
523 auto AST = buildASTFromCode( in TEST() local
526 match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
527 EXPECT_THAT(mutatedBy(Results, AST.get()), in TEST()
530 AST = buildASTFromCode("struct A {}; A operator+(const A&&, int);" in TEST()
532 Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
533 EXPECT_THAT(mutatedBy(Results, AST.get()), in TEST()
536 AST = buildASTFromCode("void f() { struct A { A(const int&&); }; " in TEST()
538 Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
539 EXPECT_THAT(mutatedBy(Results, AST.get()), in TEST()
542 AST = buildASTFromCode("void f() { struct A { A(); A(const A&&); }; " in TEST()
544 Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
545 EXPECT_THAT(mutatedBy(Results, AST.get()), in TEST()
552 auto AST = buildASTFromCode(StdRemoveReference + StdMove + in TEST() local
555 match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
556 EXPECT_FALSE(isMutated(Results, AST.get())); in TEST()
558 AST = buildASTFromCode(StdRemoveReference + StdMove + in TEST()
560 Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
561 EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("std::move(x) = y")); in TEST()
563 AST = buildASTFromCode(StdRemoveReference + StdMove + in TEST()
565 Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
566 EXPECT_FALSE(isMutated(Results, AST.get())); in TEST()
568 AST = in TEST()
572 Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
573 EXPECT_FALSE(isMutated(Results, AST.get())); in TEST()
575 AST = buildASTFromCode(StdRemoveReference + StdMove + in TEST()
578 Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
579 EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("y = std::move(x)")); in TEST()
581 AST = buildASTFromCode(StdRemoveReference + StdMove + in TEST()
585 Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
586 EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("y = std::move(x)")); in TEST()
588 AST = buildASTFromCode(StdRemoveReference + StdMove + in TEST()
592 Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
593 EXPECT_FALSE(isMutated(Results, AST.get())); in TEST()
595 AST = buildASTFromCode(StdRemoveReference + StdMove + in TEST()
598 Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
599 EXPECT_FALSE(isMutated(Results, AST.get())); in TEST()
601 AST = buildASTFromCode(StdRemoveReference + StdMove + in TEST()
603 Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
604 EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("y = std::move(x)")); in TEST()
606 AST = buildASTFromCode( in TEST()
609 Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
610 EXPECT_FALSE(isMutated(Results, AST.get())); in TEST()
614 auto AST = in TEST() local
618 match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
619 EXPECT_FALSE(isMutated(Results, AST.get())); in TEST()
621 AST = buildASTFromCode( in TEST()
624 Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
625 EXPECT_THAT(mutatedBy(Results, AST.get()), in TEST()
633 auto AST = in TEST() local
637 match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
638 EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("g(x)")); in TEST()
640 AST = in TEST()
643 Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
644 EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("g(x)")); in TEST()
646 AST = buildASTFromCodeWithArgs( in TEST()
649 Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
650 EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("g(t, x)")); in TEST()
652 AST = buildASTFromCodeWithArgs( in TEST()
655 Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
656 EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("t.mf(x)")); in TEST()
658 AST = buildASTFromCodeWithArgs( in TEST()
662 Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
663 EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("s.mf(x)")); in TEST()
665 AST = buildASTFromCodeWithArgs( in TEST()
669 Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
670 EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("s.mf<T>(x)")); in TEST()
672 AST = buildASTFromCodeWithArgs("template <class F>" in TEST()
675 Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
676 EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("f(x)")); in TEST()
678 AST = buildASTFromCodeWithArgs( in TEST()
681 Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
682 EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("T(x)")); in TEST()
688 auto AST = buildASTFromCode("int f() { int x; return x; }"); in TEST() local
690 match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
691 EXPECT_FALSE(isMutated(Results, AST.get())); in TEST()
693 AST = buildASTFromCode("int* f() { int* x; return x; }"); in TEST()
694 Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
695 EXPECT_FALSE(isMutated(Results, AST.get())); in TEST()
697 AST = buildASTFromCode("typedef int* IntPtr;" in TEST()
699 Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
700 EXPECT_FALSE(isMutated(Results, AST.get())); in TEST()
704 const auto AST = buildASTFromCode("int& f() { int x; return x; }"); in TEST() local
706 match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
707 EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("return x;")); in TEST()
711 const auto AST = buildASTFromCode("const int& f() { int x; return x; }"); in TEST() local
713 match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
714 EXPECT_FALSE(isMutated(Results, AST.get())); in TEST()
718 const auto AST = in TEST() local
721 match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
722 EXPECT_THAT(mutatedBy(Results, AST.get()), in TEST()
727 const auto AST = buildASTFromCode( in TEST() local
730 match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
731 EXPECT_THAT(mutatedBy(Results, AST.get()), in TEST()
738 const auto AST = buildASTFromCode("void g(int*); void f() { int x; g(&x); }"); in TEST() local
740 match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
741 EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("&x")); in TEST()
745 const auto AST = in TEST() local
748 match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
749 EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("x")); in TEST()
753 const auto AST = buildASTFromCodeWithArgs( in TEST() local
761 match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
762 EXPECT_THAT(mutatedBy(ResultsX, AST.get()), ElementsAre("g(x)")); in TEST()
764 match(withEnclosingCompound(declRefTo("y")), AST->getASTContext()); in TEST()
765 EXPECT_THAT(mutatedBy(ResultsY, AST.get()), ElementsAre("y")); in TEST()
772 auto AST = buildASTFromCode( in TEST() local
776 match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
777 EXPECT_THAT(mutatedBy(Results, AST.get()), in TEST()
780 AST = buildASTFromCode("typedef int& IntRefX;" in TEST()
784 Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
785 EXPECT_THAT(mutatedBy(Results, AST.get()), in TEST()
790 auto AST = buildASTFromCode( in TEST() local
794 match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
795 EXPECT_FALSE(isMutated(Results, AST.get())); in TEST()
797 AST = buildASTFromCode("void f() { int x; int& r0 = x; const int& r1 = r0;}"); in TEST()
798 Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
799 EXPECT_FALSE(isMutated(Results, AST.get())); in TEST()
801 AST = buildASTFromCode("typedef const int& CIntRefX;" in TEST()
805 Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
806 EXPECT_FALSE(isMutated(Results, AST.get())); in TEST()
810 const auto AST = buildASTFromCode( in TEST() local
813 match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
814 EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("r", "r = 10")); in TEST()
818 const auto AST = in TEST() local
821 match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
822 EXPECT_FALSE(isMutated(Results, AST.get())); in TEST()
826 auto AST = buildASTFromCode("template <class T> void g(T&& t) { t = 10; }" in TEST() local
829 match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
830 EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("g(x)")); in TEST()
832 AST = buildASTFromCode( in TEST()
836 Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
837 EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("g(x)")); in TEST()
839 AST = buildASTFromCode( in TEST()
843 Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
844 EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("g(x, y)")); in TEST()
845 Results = match(withEnclosingCompound(declRefTo("y")), AST->getASTContext()); in TEST()
846 EXPECT_FALSE(isMutated(Results, AST.get())); in TEST()
848 AST = buildASTFromCode( in TEST()
852 Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
853 EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("g(y, x)")); in TEST()
854 Results = match(withEnclosingCompound(declRefTo("y")), AST->getASTContext()); in TEST()
855 EXPECT_FALSE(isMutated(Results, AST.get())); in TEST()
857 AST = buildASTFromCode("struct S { template <class T> S(T&& t) { t = 10; } };" in TEST()
859 Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
860 EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("x")); in TEST()
862 AST = buildASTFromCode( in TEST()
865 Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
866 EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("x")); in TEST()
868 AST = buildASTFromCode("template <class U> struct S {" in TEST()
871 Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
872 EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("x")); in TEST()
874 AST = buildASTFromCode(StdRemoveReference + StdForward + in TEST()
881 Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
882 EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("g(x)")); in TEST()
886 auto AST = buildASTFromCode("template <class T> void g(T&&) {}" in TEST() local
889 match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
890 EXPECT_FALSE(isMutated(Results, AST.get())); in TEST()
892 AST = buildASTFromCode("template <class T> void g(T&& t) { t; }" in TEST()
894 Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
895 EXPECT_FALSE(isMutated(Results, AST.get())); in TEST()
897 AST = buildASTFromCode("template <class... Args> void g(Args&&...) {}" in TEST()
899 Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
900 EXPECT_FALSE(isMutated(Results, AST.get())); in TEST()
902 AST = buildASTFromCode("template <class... Args> void g(Args&&...) {}" in TEST()
904 Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
905 EXPECT_FALSE(isMutated(Results, AST.get())); in TEST()
907 AST = buildASTFromCode( in TEST()
911 Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
912 EXPECT_FALSE(isMutated(Results, AST.get())); in TEST()
914 AST = buildASTFromCode("struct S { template <class T> S(T&& t) { t; } };" in TEST()
916 Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
917 EXPECT_FALSE(isMutated(Results, AST.get())); in TEST()
919 AST = buildASTFromCode( in TEST()
922 Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
923 EXPECT_FALSE(isMutated(Results, AST.get())); in TEST()
925 AST = buildASTFromCode("template <class U> struct S {" in TEST()
928 Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
929 EXPECT_FALSE(isMutated(Results, AST.get())); in TEST()
931 AST = buildASTFromCode(StdRemoveReference + StdForward + in TEST()
938 Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
939 EXPECT_FALSE(isMutated(Results, AST.get())); in TEST()
945 const auto AST = buildASTFromCode("void f() { int x[2]; x[0] = 10; }"); in TEST() local
947 match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
948 EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("x[0] = 10")); in TEST()
952 const auto AST = buildASTFromCode("void f() { int x[2]; x[0]; }"); in TEST() local
954 match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
955 EXPECT_FALSE(isMutated(Results, AST.get())); in TEST()
961 auto AST = in TEST() local
965 match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
966 EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("x.vb.va.vi = 10")); in TEST()
968 AST = buildASTFromCodeWithArgs( in TEST()
971 Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
972 EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("x.y.z = 10")); in TEST()
974 AST = buildASTFromCodeWithArgs( in TEST()
978 Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
979 EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("x.y.z = 10")); in TEST()
983 auto AST = in TEST() local
987 match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
988 EXPECT_FALSE(isMutated(Results, AST.get())); in TEST()
990 AST = buildASTFromCodeWithArgs("template <class T> void f() { T x; x.y.z; }", in TEST()
992 Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
993 EXPECT_FALSE(isMutated(Results, AST.get())); in TEST()
995 AST = in TEST()
999 Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
1000 EXPECT_FALSE(isMutated(Results, AST.get())); in TEST()
1006 const auto AST = in TEST() local
1009 match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
1010 EXPECT_FALSE(isMutated(Results, AST.get())); in TEST()
1014 auto AST = in TEST() local
1017 match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
1018 EXPECT_THAT(mutatedBy(Results, AST.get()), in TEST()
1021 AST = buildASTFromCode("typedef int& IntRef;" in TEST()
1023 Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
1024 EXPECT_THAT(mutatedBy(Results, AST.get()), in TEST()
1029 const auto AST = in TEST() local
1032 match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
1033 EXPECT_THAT(mutatedBy(Results, AST.get()), in TEST()
1038 auto AST = in TEST() local
1041 match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
1042 EXPECT_FALSE(isMutated(Results, AST.get())); in TEST()
1044 AST = buildASTFromCode("typedef const int& CIntRef;" in TEST()
1046 Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
1047 EXPECT_FALSE(isMutated(Results, AST.get())); in TEST()
1053 const auto AST = buildASTFromCodeWithArgs( in TEST() local
1056 match(withEnclosingCompound(declRefTo("y")), AST->getASTContext()); in TEST()
1057 EXPECT_TRUE(isMutated(Results, AST.get())); in TEST()
1061 const auto AST = buildASTFromCodeWithArgs( in TEST() local
1064 match(withEnclosingCompound(declRefTo("y")), AST->getASTContext()); in TEST()
1065 EXPECT_TRUE(isMutated(Results, AST.get())); in TEST()
1069 const auto AST = buildASTFromCodeWithArgs( in TEST() local
1074 match(withEnclosingCompound(declRefTo("o2")), AST->getASTContext()); in TEST()
1075 EXPECT_TRUE(isMutated(Results, AST.get())); in TEST()
1079 const auto AST = buildASTFromCodeWithArgs( in TEST() local
1084 match(withEnclosingCompound(declRefTo("o2")), AST->getASTContext()); in TEST()
1085 EXPECT_FALSE(isMutated(Results, AST.get())); in TEST()
1089 const auto AST = in TEST() local
1094 match(withEnclosingCompound(declRefTo("o1")), AST->getASTContext()); in TEST()
1095 EXPECT_TRUE(isMutated(Results, AST.get())); in TEST()
1099 auto AST = buildASTFromCodeWithArgs( in TEST() local
1104 match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
1105 EXPECT_TRUE(isMutated(Results, AST.get())); in TEST()
1107 AST = buildASTFromCodeWithArgs( in TEST()
1110 Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
1111 EXPECT_TRUE(isMutated(Results, AST.get())); in TEST()
1115 const auto AST = in TEST() local
1121 match(withEnclosingCompound(declRefTo("o1")), AST->getASTContext()); in TEST()
1122 EXPECT_TRUE(isMutated(Results, AST.get())); in TEST()
1126 const auto AST = buildASTFromCodeWithArgs("class A { public: int mem;};" in TEST() local
1131 match(withEnclosingCompound(declRefTo("o1")), AST->getASTContext()); in TEST()
1132 EXPECT_TRUE(isMutated(Results, AST.get())); in TEST()
1136 auto AST = buildASTFromCodeWithArgs("int f() { int x, y; return (x, y); }", in TEST() local
1139 match(withEnclosingCompound(declRefTo("y")), AST->getASTContext()); in TEST()
1140 EXPECT_FALSE(isMutated(Results, AST.get())); in TEST()
1144 const auto AST = buildASTFromCodeWithArgs( in TEST() local
1147 match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
1148 EXPECT_TRUE(isMutated(Results, AST.get())); in TEST()
1152 const auto AST = in TEST() local
1157 match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
1158 EXPECT_TRUE(isMutated(Results, AST.get())); in TEST()
1168 const auto AST = buildASTFromCodeWithArgs( in TEST() local
1174 match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
1175 EXPECT_TRUE(isMutated(Results, AST.get())); in TEST()
1181 const auto AST = buildASTFromCodeWithArgs(Code, {"-Wno-unused-value"}); in TEST() local
1183 match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
1184 EXPECT_THAT(mutatedBy(Results, AST.get()), in TEST()
1191 const auto AST = buildASTFromCode("void f() { int x; [=]() { x; }; }"); in TEST() local
1193 match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
1194 EXPECT_FALSE(isMutated(Results, AST.get())); in TEST()
1198 const auto AST = buildASTFromCode("void f() { int x; [x]() { x; }; }"); in TEST() local
1200 match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
1201 EXPECT_FALSE(isMutated(Results, AST.get())); in TEST()
1205 const auto AST = buildASTFromCode("void f() { int x; [&]() { x = 10; }; }"); in TEST() local
1207 match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
1208 EXPECT_THAT(mutatedBy(Results, AST.get()), in TEST()
1213 const auto AST = buildASTFromCode("void f() { int x; [&x]() { x = 10; }; }"); in TEST() local
1215 match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
1216 EXPECT_THAT(mutatedBy(Results, AST.get()), in TEST()
1223 auto AST = in TEST() local
1226 match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
1227 EXPECT_THAT(mutatedBy(Results, AST.get()), in TEST()
1230 AST = buildASTFromCode("typedef int& IntRef;" in TEST()
1232 Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
1233 EXPECT_THAT(mutatedBy(Results, AST.get()), in TEST()
1238 const auto AST = in TEST() local
1241 match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
1242 EXPECT_TRUE(isMutated(Results, AST.get())); in TEST()
1246 auto AST = buildASTFromCode("void f() { int x[2]; for (int e : x) e = 10; }"); in TEST() local
1248 match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
1249 EXPECT_FALSE(isMutated(Results, AST.get())); in TEST()
1251 AST = in TEST()
1253 Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
1254 EXPECT_TRUE(isMutated(Results, AST.get())); in TEST()
1256 AST = buildASTFromCode( in TEST()
1259 Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
1260 EXPECT_TRUE(isMutated(Results, AST.get())); in TEST()
1264 auto AST = in TEST() local
1267 match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
1268 EXPECT_FALSE(isMutated(Results, AST.get())); in TEST()
1270 AST = buildASTFromCode("typedef const int& CIntRef;" in TEST()
1272 Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
1273 EXPECT_FALSE(isMutated(Results, AST.get())); in TEST()
1277 const auto AST = in TEST() local
1281 match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
1282 EXPECT_THAT(mutatedBy(Results, AST.get()), in TEST()
1287 const auto AST = buildASTFromCode("struct V { int* begin(); int* end(); };" in TEST() local
1290 match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
1291 EXPECT_TRUE(isMutated(Results, AST.get())); in TEST()
1295 const auto AST = buildASTFromCode( in TEST() local
1299 match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
1300 EXPECT_FALSE(isMutated(Results, AST.get())); in TEST()
1304 const auto AST = buildASTFromCode( in TEST() local
1308 match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
1309 EXPECT_FALSE(isMutated(Results, AST.get())); in TEST()
1315 auto AST = buildASTFromCode("void f() { int x, y; decltype(x = 10) z = y; }"); in TEST() local
1317 match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
1318 EXPECT_FALSE(isMutated(Results, AST.get())); in TEST()
1320 AST = buildASTFromCode("void f() { int x, y; __typeof(x = 10) z = y; }"); in TEST()
1321 Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
1322 EXPECT_FALSE(isMutated(Results, AST.get())); in TEST()
1324 AST = buildASTFromCode("void f() { int x, y; __typeof__(x = 10) z = y; }"); in TEST()
1325 Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
1326 EXPECT_FALSE(isMutated(Results, AST.get())); in TEST()
1328 AST = buildASTFromCode("void f() { int x; sizeof(x = 10); }"); in TEST()
1329 Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
1330 EXPECT_FALSE(isMutated(Results, AST.get())); in TEST()
1332 AST = buildASTFromCode("void f() { int x; alignof(x = 10); }"); in TEST()
1333 Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
1334 EXPECT_FALSE(isMutated(Results, AST.get())); in TEST()
1336 AST = buildASTFromCode("void f() { int x; noexcept(x = 10); }"); in TEST()
1337 Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
1338 EXPECT_FALSE(isMutated(Results, AST.get())); in TEST()
1340 AST = buildASTFromCodeWithArgs("namespace std { class type_info; }" in TEST()
1343 Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
1344 EXPECT_FALSE(isMutated(Results, AST.get())); in TEST()
1346 AST = buildASTFromCode( in TEST()
1348 Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
1349 EXPECT_FALSE(isMutated(Results, AST.get())); in TEST()
1353 auto AST = buildASTFromCode("void f() { int x; sizeof(int[x++]); }"); in TEST() local
1355 match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
1356 EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("x++")); in TEST()
1358 AST = buildASTFromCodeWithArgs( in TEST()
1363 Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
1364 EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("x.f()")); in TEST()
1381 auto AST = buildASTFromCode(UniquePtrDef + in TEST() local
1384 match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
1385 EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("* x = 10")); in TEST()
1387 AST = buildASTFromCode(UniquePtrDef + "void f() { UniquePtr<int> x; *x; }"); in TEST()
1388 Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
1389 EXPECT_FALSE(isMutated(Results, AST.get())); in TEST()
1391 AST = buildASTFromCode(UniquePtrDef + in TEST()
1393 Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
1394 EXPECT_FALSE(isMutated(Results, AST.get())); in TEST()
1396 AST = buildASTFromCode(UniquePtrDef + "struct S { int v; };" in TEST()
1398 Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
1399 EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("x")); in TEST()
1401 AST = buildASTFromCode(UniquePtrDef + in TEST()
1404 Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
1405 EXPECT_FALSE(isMutated(Results, AST.get())); in TEST()
1407 AST = in TEST()
1410 Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
1411 EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("x")); in TEST()
1413 AST = buildASTFromCode(UniquePtrDef + in TEST()
1416 Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
1417 EXPECT_FALSE(isMutated(Results, AST.get())); in TEST()
1419 AST = buildASTFromCodeWithArgs( in TEST()
1422 Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
1423 EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("x->mf()")); in TEST()
1436 auto AST = in TEST() local
1439 match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); in TEST()
1440 EXPECT_TRUE(isMutated(Results, AST.get())); in TEST()
1441 EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("(x)")); in TEST()