================
@@ -274,8 +288,8 @@ const Stmt *ExprMutationAnalyzer::findDirectMutation(const 
Expr *Exp) {
   const auto NonConstMethod = cxxMethodDecl(unless(isConst()));
 
   const auto AsNonConstThis = expr(anyOf(
-      cxxMemberCallExpr(callee(NonConstMethod),
-                        on(canResolveToExpr(equalsNode(Exp)))),
+      cxxMemberCallExpr(on(canResolveToExpr(equalsNode(Exp))),
+                        unless(isConstCallee())),
----------------
mzyKi wrote:

```unless(isConstCallee())``` This condition is unnecessary. I have tested your 
code in my machine.
In such testcase example,
```cpp
#include <iostream>

class X {
public:
  int a;
  int b;
};

void func(X &x, int X::*m) {
  /*const*/ X &tmp = x;

  tmp.*m = 77;
}

int main() {
  X x;
  x.a = 0;
  x.b = 0;

  std::cout << x.a << " " << x.b << std::endl;

  func(x, &X::a);

  std::cout << x.a << " " << x.b << std::endl;

  return 0;
}
```
 use ```cxxMemberCallExpr(callee(NonConstMethod),
                        on(canResolveToExpr(equalsNode(Exp)))),``` 
cxxMemberCallExpr matcher do not produce false positive




https://github.com/llvm/llvm-project/pull/66846
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to