Issue 185007
Summary [clang-tidy] readability-container-size-empty is oververbose
Labels clang-tidy
Assignees
Reporter Alcaro
    https://godbolt.org/z/dP56dT3ve

```
#include <vector>

bool thing(std::vector<int> foo)
{
    return foo.size() == 0;
}
```
--checks=readability-container-size-empty for clang-tidy, no particular flags needed for Clang.

Output:
```
<source>:5:12: warning: the 'empty' method should be used to check for emptiness instead of 'size' [readability-container-size-empty]
    5 |     return foo.size() == 0;
 |            ^~~~~~~~~~~~~~~
      | foo.empty()
/opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/16.0.1/../../../../include/c++/16.0.1/bits/stl_vector.h:1213:7: note: method 'vector'::empty() defined here
 1213 |       empty() const _GLIBCXX_NOEXCEPT
      |       ^
```
While I agree with replacing .size()==0 with .empty(), telling where .empty() is defined isn't particularly useful.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to