Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 19 additions & 9 deletions lib/IRGen/IRGenDebugInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -729,6 +729,16 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
if (!DC)
return TheCU;

auto createContext = [&](NominalTypeDecl &NTD) {
GenericContextScope scope(
IGM, NTD.getGenericSignature().getCanonicalSignature());

auto Ty = NTD.getDeclaredInterfaceType();
// Create a Forward-declared type.
auto DbgTy = DebugTypeInfo::getForwardDecl(Ty);
return getOrCreateType(DbgTy);
};

if (isa<FuncDecl>(DC))
if (auto *Decl = IGM.getSILModule().lookUpFunction(SILDeclRef(
cast<AbstractFunctionDecl>(DC), SILDeclRef::Kind::Func)))
Expand All @@ -742,7 +752,6 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {

// We don't model these in DWARF.
case DeclContextKind::Initializer:
case DeclContextKind::ExtensionDecl:
case DeclContextKind::SubscriptDecl:
case DeclContextKind::EnumElementDecl:
case DeclContextKind::TopLevelCodeDecl:
Expand All @@ -761,16 +770,17 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
return getOrCreateContext(DC->getParent());
case DeclContextKind::MacroDecl:
return getOrCreateContext(DC->getParent());
case DeclContextKind::ExtensionDecl: {
auto *ED = cast<ExtensionDecl>(DC);
if (auto *NTD = ED->getExtendedNominal())
return createContext(*NTD);
return getOrCreateContext(DC->getParent());
}
case DeclContextKind::GenericTypeDecl: {
// The generic signature of this nominal type has no relation to the current
// function's generic signature.
// The generic signature of this nominal type has no relation to the
// current function's generic signature.
auto *NTD = cast<NominalTypeDecl>(DC);
GenericContextScope scope(IGM, NTD->getGenericSignature().getCanonicalSignature());

auto Ty = NTD->getDeclaredInterfaceType();
// Create a Forward-declared type.
auto DbgTy = DebugTypeInfo::getForwardDecl(Ty);
return getOrCreateType(DbgTy);
return createContext(*NTD);
}
}
return TheCU;
Expand Down
2 changes: 1 addition & 1 deletion test/DebugInfo/Errors.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ public enum E : Error { case Err }

// Function throws.
public func throwError() throws { throw E.Err }
// CHECK: !DISubprogram(name: "throwError", {{.*}}thrownTypes: ![[THROWN:.*]])
// CHECK-DAG: !DISubprogram(name: "throwError", {{.*}}thrownTypes: ![[THROWN:.*]])
// CHECK-DAG: ![[THROWN]] = !{![[ERROR:[0-9]+]]}
// CHECK-DAG: ![[ERROR]] = !DICompositeType(tag: DW_TAG_structure_type, name: "Error"

Expand Down
16 changes: 16 additions & 0 deletions test/DebugInfo/NestedTypes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,19 @@ public let e : Enum = .WithClass(C())
// CHECK: !DIDerivedType(tag: DW_TAG_member, name: "WithStruct",
// CHECK-SAME: size: 128)

public struct D<U> {
var v : V
let u: U
}

extension D {
struct V {
internal var obj: Int
}
}

public let d = D<Int>(v: D.V(obj: 1), u: 2)

// CHECK: ![[D:.*]] = !DICompositeType(tag: DW_TAG_structure_type, name: "D"
// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "V", scope: ![[D]],

3 changes: 2 additions & 1 deletion test/DebugInfo/typealias.swift
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,11 @@ public protocol Down {
}

public typealias DependentAlias<T : Up> = T.A.A
// CHECK-DAG: ![[DEPENDENTALIAS:.*]] = !DIDerivedType(tag: DW_TAG_typedef, name: "DependentAlias", {{.*}} baseType: ![[INTTYPE]])

extension Up where A.A == Int {
public func foo() {
// CHECK-DAG: !DILocalVariable(name: "gg",{{.*}} type: ![[INTTYPE]]
// CHECK-DAG: !DILocalVariable(name: "gg",{{.*}} type: ![[DEPENDENTALIAS]]
var gg: DependentAlias<Self> = 123
}
}
Expand Down