mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[DebugInfo] Properly nest types declared in extensions in the debug info
rdar://161923580
This commit is contained in:
@@ -729,6 +729,16 @@ private:
|
||||
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)))
|
||||
@@ -742,7 +752,6 @@ private:
|
||||
|
||||
// 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 @@ private:
|
||||
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;
|
||||
|
||||
@@ -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"
|
||||
|
||||
|
||||
@@ -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]],
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user