[PATCH] D41874: [CodeView] Class record member counts should include base classes and virtual base classes

Brock Wyma via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 9 11:40:12 PST 2018


bwyma created this revision.
bwyma added reviewers: aaboud, rnk.

As the FIXME in vftables.ll suggests the member count for class records is incorrect.  The member count should also include the base classes and virtual base classes present in the field list to match what Visual Studio is doing.

`

  FieldList (0x1018) {
    TypeLeafKind: LF_FIELDLIST (0x1203)
    BaseClass { ... }             # 1
    BaseClass { ... }             # 2
    DataMember { ... }            # 3
    OneMethod { ... }             # 4     
    OneMethod { ... }             # 5
  } 
  Struct (0x1019) { 
    TypeLeafKind: LF_STRUCTURE (0x1505) 
    MemberCount: 5                        # SHOULD BE "5", NOT "3"
    FieldList: <field list> (0x1018) 
    ...
  } 

`


https://reviews.llvm.org/D41874

Files:
  lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
  test/DebugInfo/COFF/types-data-members.ll
  test/DebugInfo/COFF/vftables.ll


Index: lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
===================================================================
--- lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
+++ lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
@@ -1956,13 +1956,15 @@
           VBTableIndex);
 
       ContinuationBuilder.writeMemberType(VBCR);
+      MemberCount++;
     } else {
       assert(I->getOffsetInBits() % 8 == 0 &&
              "bases must be on byte boundaries");
       BaseClassRecord BCR(translateAccessFlags(Ty->getTag(), I->getFlags()),
                           getTypeIndex(I->getBaseType()),
                           I->getOffsetInBits() / 8);
       ContinuationBuilder.writeMemberType(BCR);
+      MemberCount++;
     }
   }
 
Index: test/DebugInfo/COFF/types-data-members.ll
===================================================================
--- test/DebugInfo/COFF/types-data-members.ll
+++ test/DebugInfo/COFF/types-data-members.ll
@@ -298,7 +298,7 @@
 ; CHECK:   }
 ; CHECK:   Struct (0x1016) {
 ; CHECK:     TypeLeafKind: LF_STRUCTURE (0x1505)
-; CHECK:     MemberCount: 2
+; CHECK:     MemberCount: 4
 ; CHECK:     Properties [ (0x200)
 ; CHECK:       HasUniqueName (0x200)
 ; CHECK:     ]
Index: test/DebugInfo/COFF/vftables.ll
===================================================================
--- test/DebugInfo/COFF/vftables.ll
+++ test/DebugInfo/COFF/vftables.ll
@@ -117,11 +117,9 @@
 ; CHECK-NEXT:    }
 ; CHECK-NOT:     VFPtr
 
-; FIXME: Is the MemberCount correct?
-
 ; CHECK:        Struct ({{.*}}) {
 ; CHECK-NEXT:     TypeLeafKind: LF_STRUCTURE (0x1505)
-; CHECK-NEXT:     MemberCount: 3
+; CHECK-NEXT:     MemberCount: 5
 ; CHECK-NEXT:     Properties [ (0x200)
 ; CHECK-NEXT:       HasUniqueName (0x200)
 ; CHECK-NEXT:     ]
@@ -145,7 +143,7 @@
 
 ; CHECK:        Struct ({{.*}}) {
 ; CHECK-NEXT:     TypeLeafKind: LF_STRUCTURE (0x1505)
-; CHECK-NEXT:     MemberCount: 3
+; CHECK-NEXT:     MemberCount: 4
 ; CHECK-NEXT:     Properties [ (0x200)
 ; CHECK-NEXT:       HasUniqueName (0x200)
 ; CHECK-NEXT:     ]


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D41874.129131.patch
Type: text/x-patch
Size: 2020 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180109/09a4cdbc/attachment.bin>


More information about the llvm-commits mailing list