1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-22 09:38:01 +02:00

Added an 'unreachable' instruction for comprehensive switches

This commit is contained in:
Brian Fiete 2020-02-21 07:54:19 -08:00
parent cd9cf9f01f
commit b856f48006

View file

@ -4039,13 +4039,11 @@ void BfModule::Visit(BfSwitchStatement* switchStmt)
numExpressions += (int)switchCase->mCaseExpressions.size();
}
defaultBlock = mBfIRBuilder->CreateBlock("default");
if (switchStmt->mDefaultCase != NULL)
{
defaultBlock = mBfIRBuilder->CreateBlock("default");
blocks.push_back(defaultBlock);
}
else
defaultBlock = endBlock;
SizedArray<BfDeferredLocalAssignData, 8> deferredLocalAssignDataVec;
deferredLocalAssignDataVec.resize(blocks.size());
@ -4582,6 +4580,14 @@ void BfModule::Visit(BfSwitchStatement* switchStmt)
allHadReturns = false;
}
}
else
{
mBfIRBuilder->AddBlock(defaultBlock);
mBfIRBuilder->SetInsertPoint(defaultBlock);
if (isComprehensive)
mBfIRBuilder->CreateUnreachable();
mBfIRBuilder->CreateBr(endBlock);
}
if (isComprehensive)
{