================
@@ -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'); }
----------------
nicovank wrote:
Checked a few cases from [this
search](https://github.com/search?q=repo%3Allvm%2Fllvm-project+PATH%3Aclang-tools-extra%2Ftest%2Fclang-tidy%2Fcheckers+%22false+positive%22&type=code)
and seems like that's right! Changing.
https://github.com/llvm/llvm-project/pull/157243
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits