[PATCH] D144870: [Clang][DebugInfo] Emit zero size bitfields in the debug info to delimit bitfields in different allocation units.

Juan Manuel Martinez CaamaƱo via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 27 02:09:11 PDT 2023


jmmartinez added inline comments.


================
Comment at: clang/lib/CodeGen/CGDebugInfo.cpp:1563
+
+  assert(PreviousBitfield->isBitField());
+
----------------
probinson wrote:
> Is this true for cases like
> ```
> struct nonadjacent {
>   char a : 8;
>   char : 0;
>   int b;
>   char d : 8;
> };
> ```
> where the field `d` has a predecessor that is not a bitfield? (This might be my ignorance of how Decls are put together, but asserting that `advance` is guaranteed to get you a bitfield just seems a little odd.)
In that case the assert is never reached.

When emiting the debug-info for `d`, when looking at the metadata generated for the previous field the function should exit early on this condition:
```
  if (!PreviousMDField || !PreviousMDField->isBitField() ||
      PreviousMDField->getSizeInBits() == 0)
    return nullptr;
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144870



More information about the cfe-commits mailing list