@@ -547,12 +547,12 @@ namespace {
547
547
void handleInOutUse (const DIMemoryUse &Use);
548
548
void handleEscapeUse (const DIMemoryUse &Use);
549
549
550
- void handleLoadUseFailure (const DIMemoryUse &InstInfo ,
550
+ void handleLoadUseFailure (const DIMemoryUse &Use ,
551
551
bool SuperInitDone,
552
552
bool FailedSelfUse);
553
553
554
- void handleSelfInitUse (DIMemoryUse &InstInfo );
555
- void updateInstructionForInitState (DIMemoryUse &InstInfo );
554
+ void handleSelfInitUse (DIMemoryUse &Use );
555
+ void updateInstructionForInitState (DIMemoryUse &Use );
556
556
557
557
558
558
void processUninitializedRelease (SILInstruction *Release,
@@ -928,17 +928,17 @@ void LifetimeChecker::emitSelfConsumedDiagnostic(SILInstruction *Inst) {
928
928
}
929
929
930
930
void LifetimeChecker::handleStoreUse (unsigned UseID) {
931
- DIMemoryUse &InstInfo = Uses[UseID];
931
+ DIMemoryUse &Use = Uses[UseID];
932
932
933
933
// Determine the liveness state of the element that we care about.
934
- auto Liveness = getLivenessAtInst (InstInfo .Inst , InstInfo .FirstElement ,
935
- InstInfo .NumElements );
934
+ auto Liveness = getLivenessAtInst (Use .Inst , Use .FirstElement ,
935
+ Use .NumElements );
936
936
937
937
// Check to see if the stored location is either fully uninitialized or fully
938
938
// initialized.
939
939
bool isFullyInitialized = true ;
940
940
bool isFullyUninitialized = true ;
941
- for (unsigned i = InstInfo .FirstElement , e = i+InstInfo .NumElements ;
941
+ for (unsigned i = Use .FirstElement , e = i+Use .NumElements ;
942
942
i != e;++i) {
943
943
auto DI = Liveness.get (i);
944
944
if (DI != DIKind::Yes)
@@ -948,41 +948,41 @@ void LifetimeChecker::handleStoreUse(unsigned UseID) {
948
948
}
949
949
950
950
if (TheMemory.isNonRootClassSelf ()) {
951
- if (getSelfInitializedAtInst (InstInfo .Inst ) != DIKind::Yes) {
952
- auto SelfLiveness = getLivenessAtInst (InstInfo .Inst ,
951
+ if (getSelfInitializedAtInst (Use .Inst ) != DIKind::Yes) {
952
+ auto SelfLiveness = getLivenessAtInst (Use .Inst ,
953
953
0 , TheMemory.NumElements );
954
954
if (SelfLiveness.isAllYes ()) {
955
- emitSelfConsumedDiagnostic (InstInfo .Inst );
955
+ emitSelfConsumedDiagnostic (Use .Inst );
956
956
return ;
957
957
}
958
958
}
959
959
}
960
960
961
961
// If this is a partial store into a struct and the whole struct hasn't been
962
962
// initialized, diagnose this as an error.
963
- if (InstInfo .Kind == DIUseKind::PartialStore && !isFullyInitialized) {
964
- assert (InstInfo .NumElements == 1 && " partial stores are intra-element" );
965
- diagnoseInitError (InstInfo , diag::struct_not_fully_initialized);
963
+ if (Use .Kind == DIUseKind::PartialStore && !isFullyInitialized) {
964
+ assert (Use .NumElements == 1 && " partial stores are intra-element" );
965
+ diagnoseInitError (Use , diag::struct_not_fully_initialized);
966
966
return ;
967
967
}
968
968
969
969
// If this is a store to a 'let' property in an initializer, then we only
970
970
// allow the assignment if the property was completely uninitialized.
971
971
// Overwrites are not permitted.
972
- if (InstInfo .Kind == DIUseKind::PartialStore || !isFullyUninitialized) {
973
- for (unsigned i = InstInfo .FirstElement , e = i+InstInfo .NumElements ;
972
+ if (Use .Kind == DIUseKind::PartialStore || !isFullyUninitialized) {
973
+ for (unsigned i = Use .FirstElement , e = i+Use .NumElements ;
974
974
i != e; ++i) {
975
975
if (Liveness.get (i) == DIKind::No || !TheMemory.isElementLetProperty (i))
976
976
continue ;
977
977
978
978
// Don't emit errors for unreachable code, or if we have already emitted
979
979
// a diagnostic.
980
- if (!shouldEmitError (InstInfo .Inst ))
980
+ if (!shouldEmitError (Use .Inst ))
981
981
continue ;
982
982
983
983
std::string PropertyName;
984
984
auto *VD = TheMemory.getPathStringToElement (i, PropertyName);
985
- diagnose (Module, InstInfo .Inst ->getLoc (),
985
+ diagnose (Module, Use .Inst ->getLoc (),
986
986
diag::immutable_property_already_initialized, PropertyName);
987
987
988
988
if (auto *Var = dyn_cast<VarDecl>(VD)) {
@@ -998,31 +998,31 @@ void LifetimeChecker::handleStoreUse(unsigned UseID) {
998
998
// If this is an initialization or a normal assignment, upgrade the store to
999
999
// an initialization or assign in the uses list so that clients know about it.
1000
1000
if (isFullyUninitialized) {
1001
- InstInfo .Kind = DIUseKind::Initialization;
1001
+ Use .Kind = DIUseKind::Initialization;
1002
1002
} else if (isFullyInitialized) {
1003
- InstInfo .Kind = DIUseKind::Assign;
1003
+ Use .Kind = DIUseKind::Assign;
1004
1004
} else {
1005
1005
// If it is initialized on some paths, but not others, then we have an
1006
1006
// inconsistent initialization, which needs dynamic control logic in the
1007
1007
// general case.
1008
1008
1009
1009
// This is classified as InitOrAssign (not PartialStore), so there are only
1010
1010
// a few instructions that could reach here.
1011
- assert (InstInfo .Kind == DIUseKind::InitOrAssign &&
1011
+ assert (Use .Kind == DIUseKind::InitOrAssign &&
1012
1012
" should only have inconsistent InitOrAssign's here" );
1013
1013
1014
1014
// If this access stores something of non-trivial type, then keep track of
1015
1015
// it for later. Once we've collected all of the conditional init/assigns,
1016
1016
// we can insert a single control variable for the memory object for the
1017
1017
// whole function.
1018
- if (!InstInfo .onlyTouchesTrivialElements (TheMemory))
1018
+ if (!Use .onlyTouchesTrivialElements (TheMemory))
1019
1019
HasConditionalInitAssign = true ;
1020
1020
return ;
1021
1021
}
1022
1022
1023
1023
// Otherwise, we have a definite init or assign. Make sure the instruction
1024
1024
// itself is tagged properly.
1025
- updateInstructionForInitState (InstInfo );
1025
+ updateInstructionForInitState (Use );
1026
1026
}
1027
1027
1028
1028
void LifetimeChecker::handleInOutUse (const DIMemoryUse &Use) {
@@ -1650,8 +1650,8 @@ void LifetimeChecker::handleLoadUseFailure(const DIMemoryUse &Use,
1650
1650
1651
1651
// / handleSelfInitUse - When processing a 'self' argument on a class, this is
1652
1652
// / a call to self.init or super.init.
1653
- void LifetimeChecker::handleSelfInitUse (DIMemoryUse &InstInfo ) {
1654
- auto *Inst = InstInfo .Inst ;
1653
+ void LifetimeChecker::handleSelfInitUse (DIMemoryUse &Use ) {
1654
+ auto *Inst = Use .Inst ;
1655
1655
1656
1656
assert (TheMemory.isAnyInitSelf ());
1657
1657
assert (!TheMemory.isClassInitSelf () || TheMemory.isNonRootClassSelf ());
@@ -1684,8 +1684,8 @@ void LifetimeChecker::handleSelfInitUse(DIMemoryUse &InstInfo) {
1684
1684
assert (TheMemory.NumElements == 1 && " delegating inits have a single elt" );
1685
1685
1686
1686
// Lower Assign instructions if needed.
1687
- if (isa<AssignInst>(InstInfo .Inst ))
1688
- updateInstructionForInitState (InstInfo );
1687
+ if (isa<AssignInst>(Use .Inst ))
1688
+ updateInstructionForInitState (Use );
1689
1689
} else {
1690
1690
// super.init also requires that all ivars are initialized before the
1691
1691
// superclass initializer runs.
@@ -1694,10 +1694,10 @@ void LifetimeChecker::handleSelfInitUse(DIMemoryUse &InstInfo) {
1694
1694
1695
1695
// If the super.init call is implicit generated, produce a specific
1696
1696
// diagnostic.
1697
- bool isImplicit = InstInfo .Inst ->getLoc ().getSourceLoc ().isInvalid ();
1697
+ bool isImplicit = Use .Inst ->getLoc ().getSourceLoc ().isInvalid ();
1698
1698
auto diag = isImplicit ? diag::ivar_not_initialized_at_implicit_superinit :
1699
1699
diag::ivar_not_initialized_at_superinit;
1700
- return diagnoseInitError (InstInfo , diag);
1700
+ return diagnoseInitError (Use , diag);
1701
1701
}
1702
1702
1703
1703
// Otherwise everything is good!
@@ -1709,15 +1709,15 @@ void LifetimeChecker::handleSelfInitUse(DIMemoryUse &InstInfo) {
1709
1709
// / from being InitOrAssign to some concrete state, update it for that state.
1710
1710
// / This includes rewriting them from assign instructions into their composite
1711
1711
// / operations.
1712
- void LifetimeChecker::updateInstructionForInitState (DIMemoryUse &InstInfo ) {
1713
- SILInstruction *Inst = InstInfo .Inst ;
1712
+ void LifetimeChecker::updateInstructionForInitState (DIMemoryUse &Use ) {
1713
+ SILInstruction *Inst = Use .Inst ;
1714
1714
1715
1715
IsInitialization_t InitKind;
1716
- if (InstInfo .Kind == DIUseKind::Initialization ||
1717
- InstInfo .Kind == DIUseKind::SelfInit)
1716
+ if (Use .Kind == DIUseKind::Initialization ||
1717
+ Use .Kind == DIUseKind::SelfInit)
1718
1718
InitKind = IsInitialization;
1719
1719
else {
1720
- assert (InstInfo .Kind == DIUseKind::Assign);
1720
+ assert (Use .Kind == DIUseKind::Assign);
1721
1721
InitKind = IsNotInitialization;
1722
1722
}
1723
1723
@@ -1751,8 +1751,8 @@ void LifetimeChecker::updateInstructionForInitState(DIMemoryUse &InstInfo) {
1751
1751
if (auto *AI = dyn_cast<AssignInst>(Inst)) {
1752
1752
// Remove this instruction from our data structures, since we will be
1753
1753
// removing it.
1754
- auto Kind = InstInfo .Kind ;
1755
- InstInfo .Inst = nullptr ;
1754
+ auto Kind = Use .Kind ;
1755
+ Use .Inst = nullptr ;
1756
1756
NonLoadUses.erase (Inst);
1757
1757
1758
1758
PartialInitializationKind PartialInitKind;
@@ -1767,8 +1767,8 @@ void LifetimeChecker::updateInstructionForInitState(DIMemoryUse &InstInfo) {
1767
1767
: PartialInitializationKind::IsNotInitialization);
1768
1768
}
1769
1769
1770
- unsigned FirstElement = InstInfo .FirstElement ;
1771
- unsigned NumElements = InstInfo .NumElements ;
1770
+ unsigned FirstElement = Use .FirstElement ;
1771
+ unsigned NumElements = Use .NumElements ;
1772
1772
1773
1773
SmallVector<SILInstruction*, 4 > InsertedInsts;
1774
1774
SILBuilderWithScope B (Inst, &InsertedInsts);
0 commit comments