================ @@ -15,26 +15,26 @@ 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(isConst(), returns(booleanType()), hasName("contains"))); + const auto ContainerWithContains = hasType( + hasUnqualifiedDesugaredType(recordType(hasDeclaration(cxxRecordDecl(anyOf( + HasContainsMethod, hasAnyBase(hasType(hasCanonicalType(hasDeclaration( + cxxRecordDecl(HasContainsMethod))))))))))); ---------------- 5chmidti wrote:
I'd go even further with checking if the `contains` function is possible to use: check that the function is not deleted, and check if the type of the parameter from the called method and that of the `contains` function are equal. https://github.com/llvm/llvm-project/pull/107521 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits