File tree Expand file tree Collapse file tree 2 files changed +41
-1
lines changed
lib/SILOptimizer/Mandatory Expand file tree Collapse file tree 2 files changed +41
-1
lines changed Original file line number Diff line number Diff line change @@ -1047,7 +1047,15 @@ void LifetimeChecker::handleStoreUse(unsigned UseID) {
1047
1047
if (isFullyUninitialized) {
1048
1048
Use.Kind = DIUseKind::Initialization;
1049
1049
} else if (isFullyInitialized) {
1050
- Use.Kind = DIUseKind::Assign;
1050
+ // Only re-write assign_by_wrapper to assignment if all fields have been
1051
+ // initialized.
1052
+ if (isa<AssignByWrapperInst>(Use.Inst ) &&
1053
+ getAnyUninitializedMemberAtInst (Use.Inst , 0 ,
1054
+ TheMemory.getNumElements ()) != -1 ) {
1055
+ Use.Kind = DIUseKind::Initialization;
1056
+ } else {
1057
+ Use.Kind = DIUseKind::Assign;
1058
+ }
1051
1059
} else {
1052
1060
// If it is initialized on some paths, but not others, then we have an
1053
1061
// inconsistent initialization, which needs dynamic control logic in the
Original file line number Diff line number Diff line change @@ -501,6 +501,37 @@ public final class Synchronized<Value> {
501
501
}
502
502
}
503
503
504
+ struct SR_12341 {
505
+ @Wrapper var wrapped : Int = 10
506
+ var str : String
507
+
508
+ init ( ) {
509
+ wrapped = 42
510
+ str = " "
511
+ wrapped = 27
512
+ }
513
+
514
+ init ( condition: Bool ) {
515
+ wrapped = 42
516
+ wrapped = 27
517
+ str = " "
518
+ }
519
+ }
520
+
521
+ func testSR_12341( ) {
522
+ // CHECK: ## SR_12341
523
+ print ( " \n ## SR_12341 " )
524
+
525
+ // CHECK-NEXT: .. init 10
526
+ // CHECK-NEXT: .. init 42
527
+ // CHECK-NEXT: .. set 27
528
+ _ = SR_12341 ( )
529
+
530
+ // CHECK-NEXT: .. init 10
531
+ // CHECK-NEXT: .. init 42
532
+ // CHECK-NEXT: .. init 27
533
+ _ = SR_12341 ( condition: true )
534
+ }
504
535
505
536
testIntStruct ( )
506
537
testIntClass ( )
@@ -511,3 +542,4 @@ testOptIntStruct()
511
542
testDefaultNilOptIntStruct ( )
512
543
testComposed ( )
513
544
testWrapperInitWithDefaultArg ( )
545
+ testSR_12341 ( )
You can’t perform that action at this time.
0 commit comments