[clang] [StaticAnalyzer] Use llvm::is_contained (NFC) (PR #141371)

Kazu Hirata via cfe-commits cfe-commits at lists.llvm.org
Sat May 24 13:41:18 PDT 2025


https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/141371

None

>From 4b31c73fb378e6f3d3ea8b272574397c1ac8418e Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Sat, 24 May 2025 11:48:54 -0700
Subject: [PATCH] [StaticAnalyzer] Use llvm::is_contained (NFC)

---
 .../Checkers/RetainCountChecker/RetainCountDiagnostics.cpp  | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp b/clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp
index 77258958ae027..c9f5dc99aaf6b 100644
--- a/clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp
@@ -962,10 +962,8 @@ void RefLeakReport::findBindingToReport(CheckerContext &Ctx,
   // `AllocFirstBinding` to be one of them.  In situations like this,
   // it would still be the easiest case to explain to our users.
   if (!AllVarBindings.empty() &&
-      llvm::count_if(AllVarBindings,
-                     [this](const std::pair<const MemRegion *, SVal> Binding) {
-                       return Binding.first == AllocFirstBinding;
-                     }) == 0) {
+      !llvm::is_contained(llvm::make_first_range(AllVarBindings),
+                          AllocFirstBinding)) {
     // Let's pick one of them at random (if there is something to pick from).
     AllocBindingToReport = AllVarBindings[0].first;
 



More information about the cfe-commits mailing list