Skip to content

Commit 3352e7d

Browse files
committed
[DebugInfo] Generate full debug info for classes
1 parent 2084da1 commit 3352e7d

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

lib/IRGen/IRGenDebugInfo.cpp

Lines changed: 21 additions & 5 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,
@@ -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));

test/DebugInfo/EagerTypeMetadata.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ public class C<T>
1313
}
1414
// CHECK: !DIDerivedType(tag: DW_TAG_typedef, name: "T",
1515
// CHECK-SAME: baseType: ![[PTRTY:[0-9]+]]
16-
// CHECK: ![[PTRTY]] = !DIDerivedType(tag: DW_TAG_pointer_type, name: "$sBpD", baseType: null, size: {{64|32}})
16+
// CHECK: ![[PTRTY]] = !DIDerivedType(tag: DW_TAG_pointer_type, name: "$sBpD", baseType: null, size: {{64|32}}, flags: DIFlagArtificial | DIFlagObjectPointer)
1717
// CHECK: ![[LOC]] = !DILocation(line: 0,
1818

0 commit comments

Comments
 (0)