[clang-tools-extra] [clang-tidy] Add none_of suggestion to readability-use-anyofallof (PR #182065)

Baranov Victor via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 6 12:13:17 PST 2026


================
@@ -174,11 +174,20 @@ bool bad_any_of7() {
   return false;
 }
 
+bool good_none_of() {
+  int v[] = {1, 2, 3};
+  // CHECK-MESSAGES: :[[@LINE+1]]:3: warning: replace loop by 'std::none_of()' [readability-use-anyofallof]
+  for (int i : v)
+    if (i)
+      return false;
+  return true;
+}
----------------
vbvictor wrote:

Could we add test with other statements in loop like in
```
bool good_any_of_throw() {
  int v[] = {1, 2, 3};
  for (int i : v) {
    // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: replace loop by 'std::any_of()'
    if (i > 3)
      return true;
    if (i == 42)
      throw 0;
  }

  return false;
}
```

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


More information about the cfe-commits mailing list