@@ -1728,6 +1728,9 @@ class SILBuilder {
17281728 EnumElementDecl *Element, SILType Ty,
17291729 ValueOwnershipKind forwardingOwnershipKind) {
17301730 ASSERT (isLoadableOrOpaque (Ty));
1731+ // Assert that this works and does not crash.
1732+ (void )getModule ().getCaseIndex (Element);
1733+
17311734 return insert (new (getModule ())
17321735 EnumInst (getSILDebugLocation (Loc), Operand, Element, Ty,
17331736 forwardingOwnershipKind));
@@ -1751,6 +1754,9 @@ class SILBuilder {
17511754 SILValue Operand,
17521755 EnumElementDecl *Element,
17531756 SILType Ty) {
1757+ // Assert that this works and does not crash.
1758+ (void )getModule ().getCaseIndex (Element);
1759+
17541760 return insert (new (getModule ()) InitEnumDataAddrInst (
17551761 getSILDebugLocation (Loc), Operand, Element, Ty));
17561762 }
@@ -1776,6 +1782,9 @@ class SILBuilder {
17761782 EnumElementDecl *Element, SILType Ty,
17771783 ValueOwnershipKind forwardingOwnershipKind) {
17781784 ASSERT (isLoadableOrOpaque (Ty));
1785+ // Assert that this works and does not crash.
1786+ (void )getModule ().getCaseIndex (Element);
1787+
17791788 return insert (new (getModule ()) UncheckedEnumDataInst (
17801789 getSILDebugLocation (Loc), Operand, Element, Ty,
17811790 forwardingOwnershipKind));
@@ -1791,6 +1800,9 @@ class SILBuilder {
17911800 UncheckedTakeEnumDataAddrInst *
17921801 createUncheckedTakeEnumDataAddr (SILLocation Loc, SILValue Operand,
17931802 EnumElementDecl *Element, SILType Ty) {
1803+ // Assert that this works and does not crash.
1804+ (void )getModule ().getCaseIndex (Element);
1805+
17941806 return insert (new (getModule ()) UncheckedTakeEnumDataAddrInst (
17951807 getSILDebugLocation (Loc), Operand, Element, Ty));
17961808 }
@@ -1805,6 +1817,9 @@ class SILBuilder {
18051817
18061818 InjectEnumAddrInst *createInjectEnumAddr (SILLocation Loc, SILValue Operand,
18071819 EnumElementDecl *Element) {
1820+ // Assert that this works and does not crash.
1821+ (void )getModule ().getCaseIndex (Element);
1822+
18081823 return insert (new (getModule ()) InjectEnumAddrInst (
18091824 getSILDebugLocation (Loc), Operand, Element));
18101825 }
0 commit comments