[PATCH] D125802: Fix std::has_unique_object_representations for _BitInt types with padding bits
Erich Keane via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue May 17 09:26:53 PDT 2022
erichkeane added a comment.
I think I agree with the justification here, though am a touch confused in the test. I'm also a touch concerned that we have getSubobjectSizeInBits returning a 'rounded up to power of 2' bit happening here. The bitfield case returns non-powers-of-two, but the _BitInt case does not.
================
Comment at: clang/lib/AST/ASTContext.cpp:2697
int64_t FieldSizeInBits =
Context.toBits(Context.getTypeSizeInChars(Field->getType()));
if (Field->isBitField()) {
----------------
This answer ends up being wrong in the case of _BitInt, consider _BitInt(7). Its field-size would be 7, yet this would result in 8. I'm not sure of the fallout of this though.
================
Comment at: clang/test/SemaCXX/has_unique_object_reps_bitint.cpp:7
+static_assert(__has_unique_object_representations(_BitInt(sizeof(int) * 8u)));
+static_assert(sizeof(_BitInt(24)) != 4 || !__has_unique_object_representations(_BitInt(24)));
+
----------------
Whats going on here? I don't particularly get the condition.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D125802/new/
https://reviews.llvm.org/D125802
More information about the cfe-commits
mailing list