[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:44:40 PDT 2024
================
@@ -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)))))))))));
----------------
EugeneZelenko wrote:
And return type is `bool`.
https://github.com/llvm/llvm-project/pull/107521
More information about the cfe-commits
mailing list