mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
* [SILGenFunction] Don't create redundant nested debug scopes
Instead of emitting:
```
sil_scope 4 { loc "main.swift":6:19 parent 3 }
sil_scope 5 { loc "main.swift":7:3 parent 4 }
sil_scope 6 { loc "main.swift":7:3 parent 5 }
sil_scope 7 { loc "main.swift":7:3 parent 5 }
sil_scope 8 { loc "main.swift":9:5 parent 4 }
```
Emit:
```
sil_scope 4 { loc "main.swift":6:19 parent 3 }
sil_scope 5 { loc "main.swift":7:3 parent 4 }
sil_scope 6 { loc "main.swift":9:5 parent 5 }
```
* [IRGenSIL] Diagnose conflicting shadow copies
If we attempt to store a value with the wrong type into a slot reserved
for a shadow copy, diagnose what went wrong.
* [SILGenPattern] Defer debug description of case variables
Create unique nested debug scopes for a switch, each of its case labels,
and each of its case bodies. This looks like:
```
switch ... { // Enter scope 1.
case ... : // Enter scope 2, nested within scope 1.
<body-1> // Enter scope 3, nested within scope 2.
case ... : // Enter scope 4, nested within scope 1.
<body-2> // Enter scope 5, nested within scope 4.
}
```
Use the new scope structure to defer emitting debug descriptions of case
bindings. Specifically, defer the work until we can nest the scope for a
case body under the scope for a pattern match.
This fixes SR-7973, a problem where it was impossible to inspect a case
binding in lldb when stopped at a case with multiple items.
Previously, we would emit the debug descriptions too early (in the
pattern match), leading to duplicate/conflicting descriptions. The only
reason that the ambiguous description was allowed to compile was because
the debug scopes were nested incorrectly.
rdar://41048339
* Update tests
55 lines
1.5 KiB
Swift
55 lines
1.5 KiB
Swift
// RUN: %target-swift-frontend %s -emit-ir -g -o - | %FileCheck %s
|
|
|
|
@frozen
|
|
public struct UnicodeScalar {
|
|
var _value: UInt32
|
|
public var value: UInt32 { return _value }
|
|
}
|
|
|
|
public func mangle(s: [UnicodeScalar]) -> [UnicodeScalar] {
|
|
let replacementUnichar = UnicodeScalar(_value: 0)
|
|
var mangledUnichars: [UnicodeScalar] = s.map {
|
|
switch $0.value {
|
|
case
|
|
// A-Z
|
|
0x0041...0x005A,
|
|
// a-z
|
|
0x0061...0x007A,
|
|
// 0-9
|
|
0x0030...0x0039,
|
|
// _
|
|
0x005F,
|
|
// Latin (1)
|
|
0x00AA...0x00AA:
|
|
return $0
|
|
default:
|
|
return replacementUnichar
|
|
}
|
|
}
|
|
return mangledUnichars
|
|
}
|
|
|
|
// The patterns in the first case statement each define an anonymous variable,
|
|
// which shares the storage with the expression in the switch statement.
|
|
|
|
// Do we care to expose these via lldb?
|
|
|
|
// CHECK: define {{.*}}@"$s11patternvars6mangle1sSayAA13UnicodeScalarVGAF_tFA2EXEfU_"
|
|
// CHECK: %[[VAL:[0-9]+]] = call swiftcc i32 @"$s11patternvars13UnicodeScalarV5values6UInt32Vvg"(i32 %0)
|
|
// CHECK: {{[0-9]+}}:
|
|
// CHECK-NOT: call void @llvm.dbg.value
|
|
// CHECK-NOT: call void asm sideeffect "", "r"
|
|
|
|
// CHECK: {{[0-9]+}}:
|
|
// CHECK-NOT: call void @llvm.dbg.value
|
|
// CHECK-NOT: call void asm sideeffect "", "r"
|
|
|
|
// CHECK: {{[0-9]+}}:
|
|
// CHECK-NOT: call void @llvm.dbg.value
|
|
// CHECK-NOT: call void asm sideeffect "", "r"
|
|
|
|
// CHECK: {{[0-9]+}}:
|
|
// CHECK-NOT: call void @llvm.dbg.value
|
|
// CHECK-NOT: call void asm sideeffect "", "r"
|
|
|