diff --git a/lib/IRGen/IRGenDebugInfo.cpp b/lib/IRGen/IRGenDebugInfo.cpp index e8b4f279d1cd7..8f31a88b29713 100644 --- a/lib/IRGen/IRGenDebugInfo.cpp +++ b/lib/IRGen/IRGenDebugInfo.cpp @@ -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(DC)) if (auto *Decl = IGM.getSILModule().lookUpFunction(SILDeclRef( cast(DC), SILDeclRef::Kind::Func))) @@ -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: @@ -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(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(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; diff --git a/test/DebugInfo/Errors.swift b/test/DebugInfo/Errors.swift index 41f5b31e732ac..9dc1f3b715d67 100644 --- a/test/DebugInfo/Errors.swift +++ b/test/DebugInfo/Errors.swift @@ -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" diff --git a/test/DebugInfo/NestedTypes.swift b/test/DebugInfo/NestedTypes.swift index eb4c82a85394e..de0ef99c4a077 100644 --- a/test/DebugInfo/NestedTypes.swift +++ b/test/DebugInfo/NestedTypes.swift @@ -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 { + var v : V + let u: U +} + +extension D { + struct V { + internal var obj: Int + } +} + +public let d = D(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]], + diff --git a/test/DebugInfo/typealias.swift b/test/DebugInfo/typealias.swift index 993cf2fa14e76..7942c96cbd20f 100644 --- a/test/DebugInfo/typealias.swift +++ b/test/DebugInfo/typealias.swift @@ -120,10 +120,11 @@ public protocol Down { } public typealias DependentAlias = 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 = 123 } }