[PATCH] D122248: [clang][CodeGen]Fix clang crash and add bitfield support in __builtin_dump_struct

Wang Yihan via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 23 10:47:28 PDT 2022


yihanaa updated this revision to Diff 417687.
yihanaa added a comment.

1. Support zero-width bitfield.
2. Supported unnamed bitfield.
3. Add a release notes.

The builtin function __builtin_dump_struct behaves for zero-width bitfield and unnamed bitfield as follows

  void test8(void) {
    struct T8A {
      unsigned c : 1;
      unsigned : 3;
      unsigned : 0;
      unsigned b;
    };
  
    struct T8A a = {
      .b = 2022,
    };
  
    __builtin_dump_struct(&a, &printf);
  }
  
  int main() {
    test8();
  }

Output:

  struct T8A {
  unsigned int c : 0
  unsigned int  : 0
  unsigned int b : 2022
  }


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122248

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/dump-struct-builtin.c

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D122248.417687.patch
Type: text/x-patch
Size: 25747 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220323/c092179b/attachment-0001.bin>


More information about the cfe-commits mailing list