[clang-tools-extra] [clang-tidy][readability-container-contains] Extend to any class with contains (PR #107521)

via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 6 07:22:45 PDT 2024


================
@@ -15,26 +15,25 @@ using namespace clang::ast_matchers;
 namespace clang::tidy::readability {
 
 void ContainerContainsCheck::registerMatchers(MatchFinder *Finder) {
-  const auto SupportedContainers = hasType(
-      hasUnqualifiedDesugaredType(recordType(hasDeclaration(cxxRecordDecl(
-          hasAnyName("::std::set", "::std::unordered_set", "::std::map",
-                     "::std::unordered_map", "::std::multiset",
-                     "::std::unordered_multiset", "::std::multimap",
-                     "::std::unordered_multimap"))))));
+  const auto HasContainsMethod = hasMethod(cxxMethodDecl(hasName("contains")));
----------------
EugeneZelenko wrote:

Should `contain` signature be checked?

https://github.com/llvm/llvm-project/pull/107521


More information about the cfe-commits mailing list