22 const auto MemberExprOrSourceObject = anyOf(
24 declRefExpr(to(decl(equalsBoundNode(std::string(
SourceDeclName))))));
26 const auto IsPartOfSource =
27 allOf(unless(hasDescendant(expr(unless(MemberExprOrSourceObject)))),
28 MemberExprOrSourceObject);
30 const auto IsSourceMutatingAssignment = traverse(
31 TK_AsIs, binaryOperation(hasOperatorName(
"="), hasLHS(IsPartOfSource))
34 const auto MemberExprOrSelf = anyOf(memberExpr(), cxxThisExpr());
36 const auto IsPartOfSelf = allOf(
37 unless(hasDescendant(expr(unless(MemberExprOrSelf)))), MemberExprOrSelf);
39 const auto IsSelfMutatingAssignment =
40 binaryOperation(isAssignmentOperator(), hasLHS(IsPartOfSelf));
42 const auto IsSelfMutatingMemberFunction =
43 functionDecl(hasBody(hasDescendant(IsSelfMutatingAssignment)));
45 const auto IsSourceMutatingMemberCall =
46 cxxMemberCallExpr(on(IsPartOfSource),
47 callee(IsSelfMutatingMemberFunction))
50 const auto MutatesSource = allOf(
52 0, parmVarDecl(hasType(lValueReferenceType())).bind(
SourceDeclName)),
53 anyOf(forEachDescendant(IsSourceMutatingAssignment),
54 forEachDescendant(IsSourceMutatingMemberCall)));
56 Finder->addMatcher(cxxConstructorDecl(isCopyConstructor(), MutatesSource),
59 Finder->addMatcher(cxxMethodDecl(isCopyAssignmentOperator(), MutatesSource),