File tree Expand file tree Collapse file tree 2 files changed +36
-1
lines changed
lib/SILOptimizer/Mandatory Expand file tree Collapse file tree 2 files changed +36
-1
lines changed Original file line number Diff line number Diff line change @@ -1937,7 +1937,10 @@ SILValue LifetimeChecker::handleConditionalInitAssign() {
1937
1937
B.setCurrentDebugScope (TheMemory.getFunction ().getDebugScope ());
1938
1938
SILType IVType =
1939
1939
SILType::getBuiltinIntegerType (NumMemoryElements, Module.getASTContext ());
1940
- auto *ControlVariableBox = B.createAllocStack (Loc, IVType);
1940
+ // Use an empty location for the alloc_stack. If Loc is variable declaration
1941
+ // the alloc_stack would look like the storage of that variable.
1942
+ auto *ControlVariableBox =
1943
+ B.createAllocStack (RegularLocation (SourceLoc ()), IVType);
1941
1944
1942
1945
// Find all the return blocks in the function, inserting a dealloc_stack
1943
1946
// before the return.
Original file line number Diff line number Diff line change
1
+ // RUN: %target-swift-frontend %s -emit-sil -g -o - | %FileCheck %s
2
+ public protocol DelegateA { }
3
+ public protocol DelegateB { }
4
+ public protocol WithDelegate
5
+ {
6
+ var delegate : DelegateA ? { get }
7
+ func f( ) throws -> Int
8
+ }
9
+ public enum Err : Swift . Error {
10
+ case s( Int )
11
+ }
12
+ public class C { }
13
+ public class M {
14
+ let field : C
15
+ var value : Int
16
+ // Verify that definite initialization doesn't create a bogus description of
17
+ // self pointing to the liveness bitvector.
18
+
19
+ // CHECK: sil @_TFC4main1McfzT4fromPS_12WithDelegate__S0_
20
+ // CHECK: bb0
21
+ // CHECK-NEXT: %2 = alloc_stack $Builtin.Int2
22
+ // CHECK-NOT: let
23
+ // CHECK-NOT: name
24
+ // CHECK: scope
25
+ public init ( from d: WithDelegate ) throws {
26
+ guard let delegate = d. delegate as? DelegateB
27
+ else { throw Err . s ( 0 ) }
28
+ self . field = C ( )
29
+ let i : Int = try d. f ( )
30
+ value = i
31
+ }
32
+ }
You can’t perform that action at this time.
0 commit comments