[PATCH] D24349: [clang-tidy] Extend readability-container-size-empty to arbitrary class with size() and empty()

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 8 14:13:10 PDT 2016


aaron.ballman added a comment.

In https://reviews.llvm.org/D24349#537595, @xazax.hun wrote:

> In https://reviews.llvm.org/D24349#537594, @omtcyfz wrote:
>
> > In https://reviews.llvm.org/D24349#537589, @Eugene.Zelenko wrote:
> >
> > > If size() and empty() change object's state, it may be not equivalent replacement.
> >
> >
> > True. But my point is that they are not required to do that if they're just not marked `const`.
>
>
> I agree with Eugene. But I think a good consensus could be to warn on the non-const case but do not do the rewrite. What do you think?


I think that's reasonable, depending on whether we find false positives with the warning as well (I have a slight concern about `size()` and `empty()` being unrelated operations on a non-container class that someone writes).


Repository:
  rL LLVM

https://reviews.llvm.org/D24349





More information about the cfe-commits mailing list