<div><div dir="auto">I think the problem is in lld, we don’t emit S_UDT symbols because it caused weird problems in WinDbg.  There’s a comment explaining it in PDB.cpp.  But after some recent fixes this may just work.  So we should probably try again to emit the S_UDT in lld, I think that should fix it</div></div><div><br><div class="gmail_quote"><div dir="ltr">On Fri, Jul 20, 2018 at 1:01 AM Hui Huang via Phabricator <<a href="mailto:reviews@reviews.llvm.org">reviews@reviews.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hui added inline comments.<br>
<br>
<br>
================<br>
Comment at: lit/SymbolFile/PDB/Inputs/ClassLayoutTest.cpp:37<br>
+  };<br>
+  union {  // Test unnamed union. MSVC treats it as `int a; float b;`<br>
+    int a;<br>
----------------<br>
aleksandr.urakov wrote:<br>
> Here is a problem. `MicrosoftRecordLayoutBuilder` asserts every field or base offset, but in our case fields `a` and `b` are treated as `struct Complex`'s fields, not `union`'s, so lldb crashes in debug on this. I can't find enough info in PDB to restore the unnamed union here. Do you have any ideas about it?<br>
<br>
Based on MSVC cl yielded PDB, you could have full information to restore the unnamed UDT.<br>
<br>
>From my experience, PDB yielded by clang-cl  (/Z7 or /Zi) is slightly different from the one by cl.<br>
<br>
Both contain information about forwarded unnamed UDT.<br>
However PDB yielded by clang-cl  more or less lacks the member information.  See below.<br>
<br>
The CodeView info is good. Maybe you need to look at LLC?<br>
<br>
CodeView <br>
<br>
```<br>
FieldList (0x1044) {<br>
    TypeLeafKind: LF_FIELDLIST (0x1203)<br>
    DataMember {<br>
      TypeLeafKind: LF_MEMBER (0x150D)<br>
      AccessSpecifier: Public (0x3)<br>
      Type: int (0x74)<br>
      FieldOffset: 0x0<br>
      Name: a<br>
    }<br>
    DataMember {<br>
      TypeLeafKind: LF_MEMBER (0x150D)<br>
      AccessSpecifier: Public (0x3)<br>
      Type: float (0x40)<br>
      FieldOffset: 0x0<br>
      Name: b<br>
    }<br>
  }<br>
<br>
Union (0x1045) {<br>
    TypeLeafKind: LF_UNION (0x1506)<br>
    MemberCount: 2<br>
    Properties [ (0x608)<br>
      HasUniqueName (0x200)<br>
      Nested (0x8)<br>
      Sealed (0x400)<br>
    ]<br>
    FieldList: <field list> (0x1044)<br>
    SizeOf: 4<br>
    Name: Complex::<unnamed-tag><br>
    LinkageName: .?AT<unnamed-type-$S2>@Complex@@<br>
  }<br>
<br>
```<br>
<br>
llvm-pdbutil  pdb  (clang-cl /z7)<br>
<br>
(found unnamed symbol, however size = 0, they will be just ignored. See PDBASTParser.cpp #259<br>
The size should not be zero) <br>
<br>
<br>
```<br>
    struct Complex::<unnamed-tag> [sizeof = 0] {}<br>
<br>
    union Complex::<unnamed-tag> [sizeof = 0] {}<br>
<br>
 struct Complex [sizeof = 728] {<br>
      data +0x00 [sizeof=720] _List* array[90]<br>
      data +0x2d0 [sizeof=4] int x<br>
      data +0x2d4 [sizeof=4] int a<br>
      data +0x2d4 [sizeof=4] float b<br>
    }<br>
<br>
```<br>
<br>
llvm-pdbutil pdb ( cl /z7)<br>
<br>
( you have full information to restore unnamed) <br>
```<br>
<br>
struct Complex [sizeof = 728] {<br>
      data +0x00 [sizeof=720] _List* array[90]<br>
      data +0x2d0 [sizeof=4] int x<br>
      data +0x2d4 [sizeof=4] int a<br>
      data +0x2d4 [sizeof=4] float b<br>
    }<br>
<br>
    Total padding 3 bytes (25% of class size)<br>
    Immediate padding 3 bytes (25% of class size)<br>
<br>
    struct Complex::<unnamed-tag> [sizeof = 4] {<br>
      data +0x00 [sizeof=4] int x<br>
    }<br>
<br>
    union Complex::<unnamed-tag> [sizeof = 4] {<br>
      data +0x00 [sizeof=4] int a<br>
      data +0x00 [sizeof=4] float b<br>
    }<br>
```<br>
<br>
<br>
<br>
<br>
<a href="https://reviews.llvm.org/D49410" rel="noreferrer" target="_blank">https://reviews.llvm.org/D49410</a><br>
<br>
<br>
<br>
</blockquote></div></div>