@@ -1079,8 +1079,6 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
10791079 llvm::dwarf::DW_TAG_structure_type, UniqueID, Scope, File, Line,
10801080 llvm::dwarf::DW_LANG_Swift, SizeInBits, 0 );
10811081 }
1082- if (OffsetInBits > SizeInBits)
1083- SizeInBits = OffsetInBits;
10841082
10851083 auto DITy = DBuilder.createStructType (
10861084 Scope, Name, File, Line, SizeInBits, AlignInBits, Flags, DerivedFrom,
@@ -1526,8 +1524,7 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
15261524 ? 0
15271525 : DbgTy.getAlignment ().getValue () * SizeOfByte;
15281526 unsigned Encoding = 0 ;
1529- uint32_t NumExtraInhabitants =
1530- DbgTy.getNumExtraInhabitants () ? *DbgTy.getNumExtraInhabitants () : 0 ;
1527+ uint32_t NumExtraInhabitants = DbgTy.getNumExtraInhabitants ().value_or (0 );
15311528
15321529 llvm::DINode::DIFlags Flags = llvm::DINode::FlagZero;
15331530
@@ -1644,6 +1641,25 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
16441641 unsigned FwdDeclLine = 0 ;
16451642 assert (SizeInBits ==
16461643 CI.getTargetInfo ().getPointerWidth (clang::LangAS::Default));
1644+ if (Opts.DebugInfoLevel > IRGenDebugInfoLevel::ASTTypes) {
1645+ auto *DIType = createStructType (
1646+ DbgTy, Decl, ClassTy, Scope, File, L.Line , SizeInBits, AlignInBits,
1647+ Flags, nullptr , llvm::dwarf::DW_LANG_Swift, MangledName);
1648+ assert (DIType && " Unexpected null DIType!" );
1649+ assert (DIType && " createStructType should never return null!" );
1650+ auto SuperClassTy = ClassTy->getSuperclass ();
1651+ if (SuperClassTy) {
1652+ auto SuperClassDbgTy = DebugTypeInfo::getFromTypeInfo (
1653+ SuperClassTy, IGM.getTypeInfoForUnlowered (SuperClassTy), IGM,
1654+ false );
1655+
1656+ llvm::DIType *SuperClassDITy = getOrCreateType (SuperClassDbgTy);
1657+ assert (SuperClassDITy && " getOrCreateType should never return null!" );
1658+ DBuilder.retainType (DBuilder.createInheritance (
1659+ DIType, SuperClassDITy, 0 , 0 , llvm::DINode::FlagZero));
1660+ }
1661+ return DIType;
1662+ }
16471663 return createPointerSizedStruct (Scope, Decl->getNameStr (), L.File ,
16481664 FwdDeclLine, Flags, MangledName);
16491665 }
@@ -2021,7 +2037,7 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
20212037 void createSpecialStlibBuiltinTypes () {
20222038 if (Opts.DebugInfoLevel <= IRGenDebugInfoLevel::ASTTypes)
20232039 return ;
2024- for (auto BuiltinType: IGM.getSpecialBuiltinTypes ()) {
2040+ for (auto BuiltinType: IGM.getOrCreateSpecialStlibBuiltinTypes ()) {
20252041 auto DbgTy = DebugTypeInfo::getFromTypeInfo (
20262042 BuiltinType, IGM.getTypeInfoForUnlowered (BuiltinType), IGM, false );
20272043 DBuilder.retainType (getOrCreateType (DbgTy));
0 commit comments