| Issue |
234990
|
| Summary |
[clang-tidy] modernize-loop-convert: loops not detected when the iterator type has a non-trivial destructor
|
| Labels |
clang-tidy
|
| Assignees |
|
| Reporter |
kmate19
|
version: clang-tidy 22.1.6 on x64 windows (also reproduced on osx arm64 with the same version)
```cpp
struct It {
int *p;
~It() {} // remove this line and the loop is flagged
int &operator*() const { return *p; }
It &operator++() { ++p; return *this; }
bool operator!=(It const &o) const { return p != o.p; }
};
struct C {
int d[4];
It begin() { return {d}; }
It end() { return {d + 4}; }
};
int f(C &c) {
int s = 0;
for (It it = c.begin(); it != c.end(); ++it) s += *it;
return s;
}
```
```console
clang-tidy --checks='-*,modernize-loop-convert' dtor.cpp -- -std=c++20
```
expected: `use range-based for loop instead`ctual:** no output (also at `MinConfidence: risky`). Without the destructor, the warning appears.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs