================
@@ -318,17 +321,15 @@ void testPrivateContains(CustomMapPrivateContains<int,
int> &MyMap,
if (MyMap2.count(0)) {};
}
-struct MyString {};
-
struct WeirdNonMatchingContains {
unsigned count(char) const;
- bool contains(const MyString&) const;
+ bool contains(const std::string&) const;
};
-void testWeirdNonMatchingContains(WeirdNonMatchingContains &MyMap) {
- // No warning if there is no `contains` method with the right type.
- if (MyMap.count('a')) {};
-}
+// False positives: when count/find and contains take different types,
+// the check will suggest an invalid code transformation. These cases
+// should not exist in real code or be rare enough.
+// void f(WeirdNonMatchingContains MyMap) { MyMap.count('a'); }
----------------
localspook wrote:
I think (correct me if I'm wrong) we try to avoid commenting out false
positives/negatives and prefer writing out a test asserting the incorrect
behaviour (in this case, writing out `// CHECK-MESSAGES` and `//
CHECK-FIXES`). That way another PR can't accidentally fix the issue and make
the comment stale.
https://github.com/llvm/llvm-project/pull/157243
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits