================ @@ -43,10 +43,18 @@ internal::Matcher<Expr> callToGet(const internal::Matcher<Decl> &OnClass) { .bind("redundant_get"); } -internal::Matcher<Decl> knownSmartptr() { +internal::Matcher<Decl> knownSmartptrAny() { return recordDecl(hasAnyName("::std::unique_ptr", "::std::shared_ptr")); } +internal::Matcher<Decl> knownSmartptrNonArray() { + return recordDecl(hasAnyName("::std::unique_ptr", "::std::shared_ptr"), + anyOf(has(cxxMethodDecl(hasName("operator*"))), + has(functionTemplateDecl(hasName("operator*")))), ---------------- kadircet wrote:
this is kind of nit-picky, so feel free to land as-is, but ... ugh it's annoying that default matchers don't handle function-template-decls. I think we can still move this into function below, with something like: ```cpp auto MatchesOpArrow = allOf(hasName("operator->"), returns(qualType(pointsTo(type().bind("op->Type"))))); auto MatchesOpStar = allOf(hasName("operator*"), returns(qualType(references(type().bind("op*Type"))))); const auto HasRelevantOps = allOf(anyOf(hasMethod(MatchesOpArrow), has(functionTemplateDecl(has(functionDecl(MatchesOpArrow))))), anyOf(hasMethod(MatchesOpStar), has(functionTemplateDecl(has(functionDecl(MatchesOpStar)))))); const auto QuacksLikeASmartptr = cxxRecordDecl(cxxRecordDecl().bind("duck_typing"), HasRelevantOps); ``` That way we can also improve `duck_typing` to cover those weird templated cases, while spelling names once. Later on in the relevant matchers can be expanded with `allOf(..., HasRelevantOps)` https://github.com/llvm/llvm-project/pull/141092 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits