[PATCH] D144217: [clang-tidy] Fix false-positive in readability-container-size-empty
Piotr Zegar via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Feb 21 23:29:24 PST 2023
PiotrZSL added a comment.
In D144217#4143540 <https://reviews.llvm.org/D144217#4143540>, @carlosgalvezp wrote:
>> Perhaps, this can even be generalized to all types whose size() and empty() are constexpr.
Problem is that you can mark function constexpr, but it doesnt need to be constexpr evaluated:
struct C
{
constexpr C(int v) : v(v) {}
constexpr int size() const { return v; };
constexpr bool empty() const { return v == 0; };
constexpr void setSize(int vv) { v = vv; };
int v;
};
constexpr C value(6);
C non_const(6);
I would need to check if it's constexpr evaluated, but here we don't evaluate it. Alternative would be to check if method use only template arguments, but then it could use other const static or something...
This is why I decided to go with config. And still you may have other user provided classes that does not have empty/size constexpr.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D144217/new/
https://reviews.llvm.org/D144217
More information about the cfe-commits
mailing list