mirror of
https://github.com/apple/swift.git
synced 2026-06-20 15:42:51 +02:00
7a191e54a7
As a workaround for issues with uniquing, bound generics are emitted as a nested structure: - A sized outer structure with no name or identifier - A sizeless inner structure with the mangled name as the name and no identifier. The actual mechanism of connection for the inner and outer structures is that the outer structure has a single unnamed member whose type is the inner structure. However, LLVM CodeView emission treats unnamed members as anonymous structs and tries to inline their members into the parent. But since the inner struct has no members, the effect is that it gets dropped. This change names the inner struct with the mangled type name. This will have the effect of preserving the inner struct in CodeView output, and allow us to use a variation of the DWARF logic at https://github.com/swiftlang/llvm-project/blob/cd1235e59b87c84144802ab85592ee75a615f231/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserSwift.cpp#L166 to recognize and handle this pattern. More details and discussion at https://github.com/swiftlang/swift/issues/87093
56 lines
3.1 KiB
Swift
56 lines
3.1 KiB
Swift
// RUN: %target-swift-frontend %s -O -emit-ir -g -o - | %FileCheck %s
|
|
// RUN: %target-swift-frontend %s -emit-ir -gdwarf-types -o - | %FileCheck %s --check-prefix=DWARF
|
|
// RUN: %target-swift-frontend %s -O -emit-ir -g -debug-info-format=codeview -o - | %FileCheck %s --check-prefix=CV
|
|
public struct S<T> {
|
|
let t : T
|
|
}
|
|
|
|
public let s = S<Int>(t: 0)
|
|
|
|
// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "$s18BoundGenericStruct1SVySiGD",
|
|
// CHECK-SAME: templateParams: ![[PARAMS:[0-9]+]]
|
|
// CHECK: ![[PARAMS]] = !{![[INTPARAM:[0-9]+]]}
|
|
// CHECK: ![[INTPARAM]] = !DITemplateTypeParameter(type: ![[INT:[0-9]+]])
|
|
// CHECK: ![[INT]] = !DICompositeType(tag: DW_TAG_structure_type, {{.*}}"$sSiD"
|
|
|
|
// DWARF-DAG: !DICompositeType(tag: DW_TAG_structure_type, {{.*}}name: "$s18BoundGenericStruct1SVySiGD"{{.*}}templateParams: ![[PARAMS:[0-9]+]]
|
|
|
|
// DWARF-DAG: ![[PARAMS]] = !{![[INTPARAM:[0-9]+]]}
|
|
// DWARF-DAG: ![[INTPARAM]] = !DITemplateTypeParameter(type: ![[INT:[0-9]+]])
|
|
// DWARF-DAG: ![[INT]] = !DICompositeType(tag: DW_TAG_structure_type, name: "Int", {{.*}}"$sSiD"
|
|
|
|
// DWARF-DAG: !DICompositeType(tag: DW_TAG_structure_type, name: "S", {{.*}}identifier: "$s18BoundGenericStruct1SVyxGD")
|
|
// DWARF-DAG: !DIDerivedType(tag: DW_TAG_member, name: "t"
|
|
|
|
|
|
public struct S2<T> {
|
|
public struct Inner {
|
|
let t: T
|
|
}
|
|
}
|
|
public let inner = S2<Double>.Inner(t:4.2)
|
|
|
|
// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "Inner",
|
|
// CHECK-SAME: size: 64, {{.*}}identifier: "$s18BoundGenericStruct2S2V5InnerVySd_GD")
|
|
// CHECK: !DICompositeType(tag: DW_TAG_structure_type, {{.*}}flags: DIFlagFwdDecl, runtimeLang: DW_LANG_Swift, {{.*}}identifier: "$s18BoundGenericStruct2S2VyxGD"
|
|
|
|
// DWARF-DAG: !DICompositeType(tag: DW_TAG_structure_type, name: "$s18BoundGenericStruct2S2V5InnerVySd_GD", scope: ![[SCOPE1:[0-9]+]], {{.*}}flags: DIFlagFwdDecl, runtimeLang: DW_LANG_Swift, templateParams: ![[PARAMS2:[0-9]+]])
|
|
|
|
// DWARF-DAG: ![[SCOPE1]] = !DICompositeType(tag: DW_TAG_structure_type, {{.*}}identifier: "$s18BoundGenericStruct2S2VyxGD"
|
|
|
|
// DWARF-DAG: ![[PARAMS2]] = !{![[PARAMS3:[0-9]+]]}
|
|
// DWARF-DAG: ![[PARAMS3]] = !DITemplateTypeParameter(type: ![[PARAMS4:[0-9]+]])
|
|
// DWARF-DAG: ![[PARAMS4]] = !DICompositeType(tag: DW_TAG_structure_type, name: "Double"{{.*}} size: 64, {{.*}}runtimeLang: DW_LANG_Swift,{{.*}} identifier: "$sSdD")
|
|
|
|
// DWARF-DAG: ![[SPECIFICATION:[0-9]+]] = !DICompositeType(tag: DW_TAG_structure_type, name: "Inner", {{.*}}elements: ![[ELEMENTS1:[0-9]+]], runtimeLang: DW_LANG_Swift, identifier: "$s18BoundGenericStruct2S2V5InnerVyx_GD")
|
|
// DWARF-DAG: !DICompositeType(tag: DW_TAG_structure_type, {{.*}}line: 27, size: 64, {{.*}}specification: ![[SPECIFICATION]]
|
|
|
|
// DWARF-DAG: ![[ELEMENTS1]] = !{![[ELEMENTS2:[0-9]+]]}
|
|
|
|
// DWARF-DAG: ![[ELEMENTS2]] = !DIDerivedType(tag: DW_TAG_member, name: "t"
|
|
|
|
// In CodeView, the sized container's member is named with the mangled name
|
|
// so that it survives CodeView emission (unnamed members are dropped).
|
|
// CV: !DIDerivedType(tag: DW_TAG_member, name: "$s18BoundGenericStruct1SVySiGD", {{.*}}baseType: ![[INNER:[0-9]+]]
|
|
// CV: ![[INNER]] = !DICompositeType(tag: DW_TAG_structure_type, name: "$s18BoundGenericStruct1SVySiGD", {{.*}}DIFlagFwdDecl
|