zeyi2 wrote:
The original bug report:
```
m@n:~/.../projects/llvm-project$ cat a.cpp
#include <initializer_list>
#include <vector>
bool f1(int a, int b, int c) {
for (const auto i : { a, b, c }) {
if (i == 0)
return true;
}
return false;
}
std::vector<int> g(int a, int b, int c) { return { a, b, c }; }
bool f2(int a, int b, int c) {
for (const auto i : g(a, b, c)) {
if (i == 0)
return true;
}
return false;
}
int main() {
return f2(1, 2, 3);
}
m@n:~/.../projects/llvm-project$ ./build/bin/clang-tidy
-checks="-*,readability-use-anyofallof" a.cpp -- -std=c++14
m@n:~/.../projects/llvm-project$ ./build/bin/clang-tidy
-checks="-*,readability-use-anyofallof" a.cpp -- -std=c++20
2 warnings generated.
/home/mitchell/Documents/projects/llvm-project/a.cpp:5:5: warning: replace loop
by 'std::ranges::any_of()' [readability-use-anyofallof]
5 | for (const auto i : { a, b, c }) {
| ^
/home/mitchell/Documents/projects/llvm-project/a.cpp:15:5: warning: replace
loop by 'std::ranges::any_of()' [readability-use-anyofallof]
15 | for (const auto i : g(a, b, c)) {
| ^
```
https://github.com/llvm/llvm-project/pull/185791
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits