[clang] [clang-tidy] Fix readability-use-anyofallof false positive for shared_ptr (PR #180007)

Baranov Victor via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 5 23:52:10 PST 2026


================
@@ -449,7 +449,13 @@ ExprMutationAnalyzer::Analyzer::findDirectMutation(const Expr *Exp) {
   const auto AsOperatorArrowThis = cxxOperatorCallExpr(
       hasOverloadedOperatorName("->"),
       callee(
-          cxxMethodDecl(ofClass(isMoveOnly()), returns(nonConstPointerType()))),
+          cxxMethodDecl(
+             anyOf(
+              ofClass(isMoveOnly()),
+              ofClass(hasAnyName("std::shared_ptr", "std::weak_ptr"))
----------------
vbvictor wrote:

We should not hard-code class names here.
Do we now why this bug happening with `shared_ptr` in particular and not with `unique_ptr`?
What is the difference between `unique_ptr` and `shared_ptr` in terms of this check? 

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


More information about the cfe-commits mailing list