[PATCH] D145852: [Clang][AST] Fix __has_unique_object_representations computation for unnamed bitfields.

Roy Jacobson via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 13 10:15:48 PDT 2023


royjacobson marked 2 inline comments as done.
royjacobson added inline comments.


================
Comment at: clang/lib/AST/ASTContext.cpp:2817
+    // unique representation.
+    if (Field->isUnnamedBitfield() && BitfieldSize > 0)
+      return std::nullopt;
----------------
aaron.ballman wrote:
> I think the check for a non-zero bit-field width might not be completely correct in cases where it's used to split an allocation unit. I suggested a test case below.
That was actually fine: the padding bits would not be a part of the unnamed bit field so they're detected.

Then I realized that the surrounding code just sums the object representation bits and checks if that equals `sizeof(T)`. But unnamed fields don't contribute any bits to the object representation. So a simpler way to fix this is to return 0 unconditionally.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145852/new/

https://reviews.llvm.org/D145852



More information about the cfe-commits mailing list