Files
swift-mirror/test/IRGen/condfail_message.swift
Erik Eckstein 56ecb8fc9b Enable better runtime failure messages
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
2020-02-18 12:03:57 +01:00

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)