@@ -2072,6 +2072,9 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
2072
2072
require (!structDecl->hasUnreferenceableStorage (),
2073
2073
" Cannot build a struct with unreferenceable storage from elements "
2074
2074
" using StructInst" );
2075
+ require (!structDecl->isResilient (F.getModule ().getSwiftModule (),
2076
+ F.getResilienceExpansion ()),
2077
+ " cannot access storage of resilient struct" );
2075
2078
require (SI->getType ().isObject (),
2076
2079
" StructInst must produce an object" );
2077
2080
@@ -2374,6 +2377,9 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
2374
2377
" result of struct_extract cannot be address" );
2375
2378
StructDecl *sd = operandTy.getStructOrBoundGenericStruct ();
2376
2379
require (sd, " must struct_extract from struct" );
2380
+ require (!sd->isResilient (F.getModule ().getSwiftModule (),
2381
+ F.getResilienceExpansion ()),
2382
+ " cannot access storage of resilient struct" );
2377
2383
require (!EI->getField ()->isStatic (),
2378
2384
" cannot get address of static property with struct_element_addr" );
2379
2385
require (EI->getField ()->hasStorage (),
@@ -2415,6 +2421,9 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
2415
2421
" must derive struct_element_addr from address" );
2416
2422
StructDecl *sd = operandTy.getStructOrBoundGenericStruct ();
2417
2423
require (sd, " struct_element_addr operand must be struct address" );
2424
+ require (!sd->isResilient (F.getModule ().getSwiftModule (),
2425
+ F.getResilienceExpansion ()),
2426
+ " cannot access storage of resilient struct" );
2418
2427
require (EI->getType ().isAddress (),
2419
2428
" result of struct_element_addr must be address" );
2420
2429
require (!EI->getField ()->isStatic (),
@@ -2465,7 +2474,16 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
2465
2474
ClassDecl *cd = operandTy.getClassOrBoundGenericClass ();
2466
2475
require (cd, " ref_tail_addr operand must be a class instance" );
2467
2476
}
2468
-
2477
+
2478
+ void checkDestructureStructInst (DestructureStructInst *DSI) {
2479
+ SILType operandTy = DSI->getOperand ()->getType ();
2480
+ StructDecl *sd = operandTy.getStructOrBoundGenericStruct ();
2481
+ require (sd, " must struct_extract from struct" );
2482
+ require (!sd->isResilient (F.getModule ().getSwiftModule (),
2483
+ F.getResilienceExpansion ()),
2484
+ " cannot access storage of resilient struct" );
2485
+ }
2486
+
2469
2487
SILType getMethodSelfType (CanSILFunctionType ft) {
2470
2488
return fnConv.getSILType (ft->getParameters ().back ());
2471
2489
}
0 commit comments