Files
swift-mirror/test/IRGen/preserve_for_debugger.swift
Augusto Noronha 529845056b Fix functions not being kept for debugger
At Onone, many types of functions (anything user written, compiler
generated setters and getters, etc), should be kept in the final
binary so they're accessible by the debugger.

rdar://126763340
2024-05-14 10:31:44 -07:00

67 lines
1.2 KiB
Swift

// RUN: %target-swiftc_driver %s -g -Onone -emit-ir | %FileCheck %s
// Check that unused globals are preserved at Onone.
private let number = 42
// CHECK: distinct !DIGlobalVariable(name: "number",
// Check that unused functions are preserved at Onone.
func unused() {
}
// CHECK: !DISubprogram(name: "unused", linkageName: "$s21preserve_for_debugger6unusedyyF"
// Property wrappers generate transparent getters, which we would like to check still exist at Onone.
@propertyWrapper
struct IntWrapper {
private var storage = 42
var wrappedValue: Int {
return storage
}
}
public class User {
@IntWrapper private var number: Int
func f() {
// Force the generation of the getter
_ = self.number
}
}
let c = User()
c.f()
// CHECK: !DISubprogram(name: "number.get"
protocol Foo {}
@propertyWrapper
struct Bar<ObjectType: Foo> {
var storage: ObjectType
public init(wrappedValue: ObjectType) {
storage = wrappedValue
}
public var wrappedValue: ObjectType {
return storage
}
}
class Baz: Foo {
let x = 42
}
struct Qux {
@Bar(wrappedValue: Baz()) private var baz: Baz
func f() {
print(self.baz) // break here
}
}
let qux = Qux()
qux.f()
// CHECK: !DISubprogram(name: "baz.get"