@@ -1876,22 +1876,25 @@ void PartialReinitChecker::performPartialReinitChecking(
1876
1876
// By computing the bits here directly, we do not need to worry about
1877
1877
// having to split contiguous ranges into separate representable SILTypes.
1878
1878
SmallBitVector neededElements (useState.getNumSubelements ());
1879
- auto range = *TypeTreeLeafTypeRange::get (value, useState.address );
1880
- for (unsigned index : range.getRange ()) {
1881
- emittedError = !liveness.findEarlierConsumingUse (
1882
- initToValues.first , index,
1883
- [&](SILInstruction *consumingInst) -> bool {
1884
- return !checkForPartialMutation (
1885
- useState, diagnosticEmitter, PartialMutation::Kind::Reinit,
1886
- initToValues.first , value->getType (),
1887
- TypeTreeLeafTypeRange (index, index + 1 ),
1888
- PartialMutation::reinit (*consumingInst));
1889
- });
1890
-
1891
- // If we emitted an error for this index break. We only want to emit one
1892
- // error per value.
1893
- if (emittedError)
1894
- break ;
1879
+ SmallVector<TypeTreeLeafTypeRange, 2 > ranges;
1880
+ TypeTreeLeafTypeRange::get (value, useState.address , ranges);
1881
+ for (auto range : ranges) {
1882
+ for (unsigned index : range.getRange ()) {
1883
+ emittedError = !liveness.findEarlierConsumingUse (
1884
+ initToValues.first , index,
1885
+ [&](SILInstruction *consumingInst) -> bool {
1886
+ return !checkForPartialMutation (
1887
+ useState, diagnosticEmitter, PartialMutation::Kind::Reinit,
1888
+ initToValues.first , value->getType (),
1889
+ TypeTreeLeafTypeRange (index, index + 1 ),
1890
+ PartialMutation::reinit (*consumingInst));
1891
+ });
1892
+
1893
+ // If we emitted an error for this index break. We only want to emit
1894
+ // one error per value.
1895
+ if (emittedError)
1896
+ break ;
1897
+ }
1895
1898
}
1896
1899
1897
1900
// If we emitted an error for this value break. We only want to emit one
@@ -1912,19 +1915,22 @@ void PartialReinitChecker::performPartialReinitChecking(
1912
1915
// By computing the bits here directly, we do not need to worry about
1913
1916
// having to split contiguous ranges into separate representable SILTypes.
1914
1917
SmallBitVector neededElements (useState.getNumSubelements ());
1915
- auto range = *TypeTreeLeafTypeRange::get (value, useState.address );
1916
- for (unsigned index : range.getRange ()) {
1917
- emittedError = !liveness.findEarlierConsumingUse (
1918
- reinitToValues.first , index,
1919
- [&](SILInstruction *consumingInst) -> bool {
1920
- return !checkForPartialMutation (
1921
- useState, diagnosticEmitter, PartialMutation::Kind::Reinit,
1922
- reinitToValues.first , value->getType (),
1923
- TypeTreeLeafTypeRange (index, index + 1 ),
1924
- PartialMutation::reinit (*consumingInst));
1925
- });
1926
- if (emittedError)
1927
- break ;
1918
+ SmallVector<TypeTreeLeafTypeRange, 2 > ranges;
1919
+ TypeTreeLeafTypeRange::get (value, useState.address , ranges);
1920
+ for (auto range : ranges) {
1921
+ for (unsigned index : range.getRange ()) {
1922
+ emittedError = !liveness.findEarlierConsumingUse (
1923
+ reinitToValues.first , index,
1924
+ [&](SILInstruction *consumingInst) -> bool {
1925
+ return !checkForPartialMutation (
1926
+ useState, diagnosticEmitter, PartialMutation::Kind::Reinit,
1927
+ reinitToValues.first , value->getType (),
1928
+ TypeTreeLeafTypeRange (index, index + 1 ),
1929
+ PartialMutation::reinit (*consumingInst));
1930
+ });
1931
+ if (emittedError)
1932
+ break ;
1933
+ }
1928
1934
}
1929
1935
if (emittedError)
1930
1936
break ;
0 commit comments