Skip to content

Commit 644a7f8

Browse files
committed
[DI] Fail if _storage checking fails
If `_storage` checking fails, let's stop because otherwise DI would end up emitting extraneous errors about uninitialized `self.$_storage` which are consequence of `_storage` failures.
1 parent d6b6bbc commit 644a7f8

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

lib/SILOptimizer/Mandatory/DefiniteInitialization.cpp

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3869,8 +3869,21 @@ static bool checkDefiniteInitialization(SILFunction &Fn) {
38693869
// It has to be checked first because it injects initialization of
38703870
// `self.$storage`.
38713871
if (auto *storageVar = findLocalTypeWrapperStorageVar(Fn)) {
3872-
// Then process the memory object.
3873-
processMemoryObject(storageVar, blockStates);
3872+
{
3873+
auto &M = Fn.getModule();
3874+
3875+
DiagnosticTransaction T(M.getASTContext().Diags);
3876+
3877+
// process `_storage` object.
3878+
processMemoryObject(storageVar, blockStates);
3879+
3880+
// Stop if `_storage` initialization checking produced
3881+
// errors, otherwise DI is going to emit confusing
3882+
// "return without fully initialized self - self.$storage" error.
3883+
if (T.hasErrors())
3884+
return true;
3885+
}
3886+
38743887
storageVar->replaceAllUsesWith(storageVar->getOperand());
38753888
storageVar->eraseFromParent();
38763889
Changed = true;

0 commit comments

Comments
 (0)