Files
swift-mirror/test/DebugInfo/BoundGenericStruct.swift
Augusto Noronha 1bf6375b78 [DebugInfo] Generate full debug info for generic structs
Generate the full debug info for generic structs. The strategy is to
emit one full entry for the generic type with archetypes, and one
forward declaration per instantiation of the generic type.

For example, given:
```
struct Pair<T, U> {
  let t: T
  let u: U
}
let p1 = Pair<Int, Double>(t: 1, u: 4.2)
let p2 = Pair<String, Bool>(t: "Hello", u: true)
```

DebugInfo will have one entry for Pair<T, U> which includes descriptions
of its fields, one forward declaration of Pair<Int, Double> and one
forward declaration of Pair<String, Bool>. This information is enough
for the algorithms of RemoteMirrors to reconstruct type information for
the fully instantiated types.
2024-01-19 12:35:30 -08:00

28 lines
1.2 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
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, name: "$sSiD",
// DWARF: !DICompositeType(tag: DW_TAG_structure_type, name: "$s18BoundGenericStruct1SVySiGD",
// DWARF-SAME: templateParams: ![[PARAMS:[0-9]+]]
// DWARF: ![[PARAMS]] = !{![[INTPARAM:[0-9]+]]}
// DWARF: ![[INTPARAM]] = !DITemplateTypeParameter(type: ![[INT:[0-9]+]])
// DWARF: ![[INT]] = !DICompositeType(tag: DW_TAG_structure_type, name: "$sSiD",
// DWARF: !DICompositeType(tag: DW_TAG_structure_type, name: "S",
// DWARF-SAME: identifier: "$s18BoundGenericStruct1SVyxGD")
// DWARF: !DIDerivedType(tag: DW_TAG_member, name: "t"
// DWARF: !DICompositeType(tag: DW_TAG_structure_type, name: "$sxD"