mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
The implementation was done quite a while ago. Now, that we have support in lldb (https://github.com/apple/llvm-project/pull/773), we can enable it by default in the compiler. LLDB now shows the runtime failure reason, for example: * thread #1, queue = 'com.apple.main-thread', stop reason = Swift runtime failure: arithmetic overflow frame #1: 0x0000000100000f0d a.out`testit(a=127) at trap_message.swift:4 1 2 @inline(never) 3 func testit(_ a: Int8) -> Int8 { -> 4 return a + 1 5 } 6 For details, see https://github.com/apple/swift/pull/25978 rdar://problem/51278690
17 lines
851 B
Swift
17 lines
851 B
Swift
// RUN: %target-swift-frontend -primary-file %s -g -emit-ir | %FileCheck %s
|
|
// RUN: %target-swift-frontend -primary-file %s -g -O -emit-ir | %FileCheck %s
|
|
// REQUIRES: optimized_stdlib
|
|
|
|
// CHECK-LABEL: define hidden swiftcc i8 @"$s16condfail_message6testitys4Int8VADF"(i8 %0)
|
|
// CHECK: call void @llvm.trap(), !dbg [[LOC:![0-9]+]]
|
|
|
|
func testit(_ a: Int8) -> Int8 {
|
|
return a + 1
|
|
}
|
|
|
|
// CHECK: [[CALLER_LOC:![0-9]+]] = !DILocation(line: 9, column: 12, scope: !{{.*}})
|
|
// CHECK: [[LOC]] = !DILocation(line: 0, scope: [[FAILURE_FUNC:![0-9]+]], inlinedAt: [[CALLER_LOC]])
|
|
// CHECK: [[FAILURE_FUNC]] = distinct !DISubprogram(name: "Swift runtime failure: arithmetic overflow", scope: {{.*}}, file: {{.*}}, type: [[FUNC_TYPE:![0-9]+]], flags: DIFlagArtificial, spFlags: DISPFlagDefinition, {{.*}})
|
|
// CHECK: [[FUNC_TYPE]] = !DISubroutineType(types: null)
|
|
|