Issue |
124906
|
Summary |
[clang-tidy] False negative modernize-use-ranges when using getter function
|
Labels |
clang-tidy
|
Assignees |
|
Reporter |
chrchr-github
|
~~~c++
#include <algorithm>
#include <ranges>
#include <vector>
struct S {
std::vector<int> v;
const std::vector<int>& get() const { return v; }
};
bool f(S& s) {
auto it = std::find(s.get().begin(), s.get().end(), 0); // no warning
auto it2 = std::find(s.v.begin(), s.v.end(), 0);
return it == it2;
}
~~~
~~~
<source>:12:16: warning: use a ranges version of this algorithm [modernize-use-ranges]
12 | auto it2 = std::find(s.v.begin(), s.v.end(), 0);
| ^~~~~~~~~ ~~~~~~~~~~~ ~~~~~~~~~
| std::ranges::find s.v
1 warning generated.
~~~
https://godbolt.org/z/EEvEnrWWs
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs