llvmbot wrote:

<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang-analysis

@llvm/pr-subscribers-clang

Author: Devanshi (Devanshi-cmd)

<details>
<summary>Changes</summary>

Fixes issue #<!-- -->179941 where `readability-use-anyofallof` was incorrectly 
suggesting `std::any_of` for loops that mutate data through `std::shared_ptr`. 
The checker detected mutations through `unique_ptr` but not `shared_ptr`, even 
though both use `operator-&gt;` the same way. Extended the mutation detection 
in `ExprMutationAnalyzer` to also match `std::shared_ptr` and `std::weak_ptr`.

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


1 Files Affected:

- (modified) clang/lib/Analysis/ExprMutationAnalyzer.cpp (+7-1) 


``````````diff
diff --git a/clang/lib/Analysis/ExprMutationAnalyzer.cpp 
b/clang/lib/Analysis/ExprMutationAnalyzer.cpp
index 86d7dcab807d3..1ae16e285effe 100644
--- a/clang/lib/Analysis/ExprMutationAnalyzer.cpp
+++ b/clang/lib/Analysis/ExprMutationAnalyzer.cpp
@@ -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"))
+            ),
+            returns(nonConstPointerType())
+          )),
       argumentCountIs(1), hasArgument(0, canResolveToExpr(Exp)));
 
   // Used as non-const-ref argument when calling a function.

``````````

</details>


https://github.com/llvm/llvm-project/pull/180007
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to