================
@@ -405,7 +411,13 @@ void UseAfterMoveFinder::getDeclRefs(
                         DeclRefs](const ArrayRef<BoundNodes> Matches) {
       for (const auto &Match : Matches) {
         const auto *DeclRef = Match.getNodeAs<DeclRefExpr>("declref");
+        const auto *Member = Match.getNodeAs<MemberExpr>("member-expr");
         const auto *Operator = 
Match.getNodeAs<CXXOperatorCallExpr>("operator");
+        // Non-moved member as the move only implies a base class.
+        if (Member && MovedAs &&
+            !MovedAs->hasMemberName(Member->getMemberDecl()->getIdentifier())) 
{
----------------
localspook wrote:

Matching based on identifier name may lead to a false positive if there's 
shadowing going on, e.g.:
```cpp
struct A {
  int a;
};

struct B : A {
  int a; // Shadows the base member.
};

B b;
A foo = std::move(b);
b.a; // FP?
```
Since we already have an FP on this though, up to you if you want to fix it, I 
won't block the PR over it

https://github.com/llvm/llvm-project/pull/189638
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to