<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/100742>100742</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang-tidy] False negative modernize-loop-convert for array size returned by member function
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang-tidy
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
chrchr-github
</td>
</tr>
</table>
<pre>
Only one warning is shown for this code:
~~~c++
void g(int);
enum { G_SIZE = 4 };
static constexpr int a[G_SIZE]{};
constexpr int getSize() { return G_SIZE; }
void f() {
for (int i = 0; i < ::getSize(); ++i) { // warning
g(a[i]);
}
}
struct S {
enum { S_SIZE = 4 };
static constexpr int b[S_SIZE]{};
constexpr int getSize() { return S_SIZE; }
void f() {
for (int i = 0; i < S::getSize(); ++i) { // FN
g(b[i]);
}
}
};
~~~
https://godbolt.org/z/cnsTxrYdG
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUlEGPmzoUhX_NZXOVyNgQkgWL4eUxepvXBd20mwqMAVdgR7bJTLLIb6_sJJOknVHbKEqM8b3nnA_s2lrZKyFySAtIt1E9u0GbnA-GD2bRSzfMTdTo9pB_UuMBtRL4UhslVY_Soh30i8JOG3SDtMh1K4A9AdkCeTqdThxo4b_heq9liz3QtVQO6AbYZf78K9Q8IWQFPn-r_vv6LwLbYoKQbd_WWVc7yZFrZZ143RmUymENaXGugHQLWXFf8LiyF66SRwF0DXQTlIxws1EXQWBFULuzFAx3t4LzLCKGwOcgKINT4sv98B_0-dnTg1roHUjIqzbQEmh5RXnr7D-ekc8lfaQ7UP7ezeKjV-vMzB1Wdz7fiFYfEfUN36XaQFpUH1DFP8Ra_YrV630M9Xdgq78iW_7_2PkKtnkP7IPDB8TXJafT6TwYnNtZ7yTI9Lpt9OiW2vRAyyPQkiv7-dV8aZ-jNmfthm3qSORxRikhZE2zaMj5qmlpx9J41SVpyhhZxZTFKyE23aqJ-SaSOSU0IRldxYyxJFuSeN11NE0Tzte8iQUkREy1HJfjuJ-8diStnUUeE5IlNBrrRow2bGhK-VirfuFkewBK_QY3ua9aNHNvISGjtM7e-jjpxnAU3JWlWyzr0QpUoq-d3AucdCuMkkexGLXeLbhWe2FceHi1MfUBrTyKy3sgWmwOOImpEQa7WXEntYpmM-Y_kQwnzZLrCWjp_Vz-FjujvwvugJYhpAVaXnLuc_ojAAD__xrUV9w">