[PATCH] D122822: [Clang][CodeGen]Add constant array support for __builtin_dump_sturct

Wang Yihan via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 31 07:47:22 PDT 2022


yihanaa created this revision.
yihanaa added reviewers: aaron.ballman, erichkeane, MaskRay.
yihanaa added a project: clang.
Herald added a subscriber: StephenFan.
Herald added a project: All.
yihanaa requested review of this revision.
Herald added a subscriber: cfe-commits.

Add constant array support for __builtin_dump_sturct. For N-dimensional arrays, the new dumpArray function dumps the elements of the array by generating N layers of 'for' loops.
for example:
The struct:

  struct Foo {
    int x;
  };
  
  struct S {
    int a[3];
    int b[2][2];
    struct Foo c[2];
  };

The dump result:

  struct S {
      int[3] a = [
          [0] = 1
          [1] = 2
          [2] = 3
      ]
      int[2][2] b = [
          [0] = [
              [0] = 1
              [1] = 2
          ]
          [1] = [
              [0] = 3
              [1] = 4
          ]
      ]
      struct Foo[2] c = [
          [0] = {
              int x = 1
          }
          [1] = {
              int x = 2
          }
      ]
  }


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D122822

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: D122822.419454.patch
Type: text/x-patch
Size: 30406 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220331/0d9f696d/attachment-0001.bin>


More information about the cfe-commits mailing list