[DebugInfo] Add size to class declarations in debug info.

This adds the size to forward declared class DITypes, if the size is known.

Fixes an issue where we determine whether to emit fragments based on the
type size, so fragments would sometimes be incorrectly emitted if there
was no size.

Bug: https://bugs.llvm.org/show_bug.cgi?id=47338

Differential Revision: https://reviews.llvm.org/D87062
This commit is contained in:
Amy Huang 2020-09-03 15:42:27 -07:00
parent bf41c4d29e
commit aaf1a96408
2 changed files with 5 additions and 1 deletions

View File

@ -1031,6 +1031,10 @@ CGDebugInfo::getOrCreateRecordFwdDecl(const RecordType *Ty,
uint64_t Size = 0;
uint32_t Align = 0;
const RecordDecl *D = RD->getDefinition();
if (D && D->isCompleteDefinition())
Size = CGM.getContext().getTypeSize(Ty);
llvm::DINode::DIFlags Flags = llvm::DINode::FlagFwdDecl;
// Add flag to nontrivial forward declarations. To be consistent with MSVC,

View File

@ -136,7 +136,7 @@ int main(int argc, char **argv) {
// CHECK: [[C_DTOR]] = !DISubprogram(name: "~C"
// CHECK: [[D:![0-9]+]] = !DICompositeType(tag: DW_TAG_structure_type, name: "D"
// CHECK-NOT: size:
// CHECK-SAME: size:
// CHECK-SAME: DIFlagFwdDecl
// CHECK-NOT: identifier:
// CHECK-SAME: ){{$}}