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

Richard Smith - zygoloid via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 31 15:48:35 PDT 2022


rsmith added inline comments.


================
Comment at: clang/lib/CodeGen/CGBuiltin.cpp:2113-2117
     if (CanonicalType->isRecordType()) {
-      TmpRes = dumpRecord(CGF, CanonicalType, FieldPtr, Align, Func, Lvl + 1);
+      TmpRes = dumpRecord(CGF, CanonicalType, FieldLV, Align, Func, Lvl + 1);
       Res = CGF.Builder.CreateAdd(TmpRes, Res);
       continue;
     }
----------------
After this patch, this case no longer prints the field name. Eg: https://godbolt.org/z/o7vcbWaEf

```
#include <stdio.h>

struct A {};

struct B {
    A a;
};


int main() {
    B x;
    __builtin_dump_struct(&x, &printf);
}
```

now prints:

```
B {
    A {
    }
}
```

This seems like an important regression; please can you take a look? This also suggests to me that there's a hole in our test coverage.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122248



More information about the cfe-commits mailing list