[clang-tools-extra] Create a new check to look for mis-use in calls that take iterators (PR #99917)

Nathan James via cfe-commits cfe-commits at lists.llvm.org
Sat Jul 27 11:54:08 PDT 2024


njames93 wrote:

@5chmidti I decided to run this version of the check on llvm and clang
https://gist.github.com/njames93/6f8863573972cb07c388ac19e8a20467

Seems like most of the warnings detected are when we are deliberately exceeding the bounds of a range when we know its a slice of a bigger range. Some of them are potentially cases where code could be refactored to better express it's intent, other instances already have comments to explain why we are exceeding the bounds

There were also some cases where classes had begin/end pairs that didn't return iterators, instead [just integral types](https://github.com/llvm/llvm-project/blob/main/llvm/lib/DWARFLinker/Parallel/DWARFLinkerCompileUnit.cpp#L682).
These cases could be silenced by changing the check to ensure we aren't looking for integral types, but I feel that's such an unlikely case that there's no need to worry about it

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


More information about the cfe-commits mailing list