Skip to content

Commit 38b49f9

Browse files
committed
[DebugInfo] Generate full debug info for classes
1 parent de7fcf3 commit 38b49f9

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

lib/IRGen/IRGenDebugInfo.cpp

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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,
@@ -1644,7 +1642,25 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
16441642
unsigned FwdDeclLine = 0;
16451643
assert(SizeInBits ==
16461644
CI.getTargetInfo().getPointerWidth(clang::LangAS::Default));
1647-
return createPointerSizedStruct(Scope, Decl->getNameStr(), L.File,
1645+
if (Opts.DebugInfoLevel > IRGenDebugInfoLevel::ASTTypes) {
1646+
auto *DIType = createStructType(
1647+
DbgTy, Decl, ClassTy, Scope, File, L.Line, SizeInBits, AlignInBits,
1648+
Flags, nullptr, llvm::dwarf::DW_LANG_Swift, MangledName);
1649+
auto SuperClassTy = ClassTy->getSuperclass();
1650+
if (DIType && SuperClassTy) {
1651+
auto SuperClassDbgTy = DebugTypeInfo::getFromTypeInfo(
1652+
SuperClassTy, IGM.getTypeInfoForUnlowered(SuperClassTy), IGM,
1653+
false);
1654+
1655+
llvm::DIType *SuperClassDITy = getOrCreateType(SuperClassDbgTy);
1656+
if (SuperClassDITy) {
1657+
DBuilder.retainType(DBuilder.createInheritance(
1658+
DIType, SuperClassDITy, 0, 0, llvm::DINode::FlagZero));
1659+
}
1660+
}
1661+
return DIType;
1662+
}
1663+
return createPointerSizedStruct(Scope, Decl->getNameStr(), File,
16481664
FwdDeclLine, Flags, MangledName);
16491665
}
16501666

0 commit comments

Comments
 (0)