@@ -685,7 +685,8 @@ static bool parseDeclSILOptional(
685
685
AvailabilityRange *availability, bool *isWithoutActuallyEscapingThunk,
686
686
SmallVectorImpl<std::string> *Semantics,
687
687
SmallVectorImpl<ParsedSpecAttr> *SpecAttrs, ValueDecl **ClangDecl,
688
- EffectsKind *MRK, SILParser &SP, SILModule &M) {
688
+ EffectsKind *MRK, ActorIsolation *actorIsolation, SILParser &SP,
689
+ SILModule &M) {
689
690
while (SP.P .consumeIf (tok::l_square)) {
690
691
if (isLet && SP.P .Tok .is (tok::kw_let)) {
691
692
*isLet = true ;
@@ -784,7 +785,27 @@ static bool parseDeclSILOptional(
784
785
*isPerformanceConstraint = true ;
785
786
else if (markedAsUsed && SP.P .Tok .getText () == " used" )
786
787
*markedAsUsed = true ;
787
- else if (section && SP.P .Tok .getText () == " section" ) {
788
+ else if (actorIsolation && SP.P .Tok .getText () == " isolation" ) {
789
+ SP.P .consumeToken (tok::identifier);
790
+ if (SP.P .Tok .getKind () != tok::string_literal) {
791
+ SP.P .diagnose (SP.P .Tok , diag::expected_in_attribute_list);
792
+ return true ;
793
+ }
794
+ StringRef rawString = SP.P .Tok .getText ().drop_front ().drop_back ();
795
+ // TODO: By using a raw string here, we can perhaps put in a simple string
796
+ // representation of an actor that can be parsed back. For now this is
797
+ // just a quick hack so we can write tests.
798
+ auto optIsolation = ActorIsolation::forSILString (
799
+ SP.P .Context .getIdentifier (rawString).str ());
800
+ if (!optIsolation) {
801
+ SP.P .diagnose (SP.P .Tok , diag::expected_in_attribute_list);
802
+ return true ;
803
+ }
804
+ *actorIsolation = *optIsolation;
805
+ SP.P .consumeToken (tok::string_literal);
806
+ SP.P .parseToken (tok::r_square, diag::expected_in_attribute_list);
807
+ continue ;
808
+ } else if (section && SP.P .Tok .getText () == " section" ) {
788
809
SP.P .consumeToken (tok::identifier);
789
810
if (SP.P .Tok .getKind () != tok::string_literal) {
790
811
SP.P .diagnose (SP.P .Tok , diag::expected_in_attribute_list);
@@ -798,8 +819,7 @@ static bool parseDeclSILOptional(
798
819
799
820
SP.P .parseToken (tok::r_square, diag::expected_in_attribute_list);
800
821
continue ;
801
- }
802
- else if (inlineStrategy && SP.P .Tok .getText () == " always_inline" )
822
+ } else if (inlineStrategy && SP.P .Tok .getText () == " always_inline" )
803
823
*inlineStrategy = AlwaysInline;
804
824
else if (MRK && SP.P .Tok .getText () == " readnone" )
805
825
*MRK = EffectsKind::ReadNone;
@@ -7333,6 +7353,7 @@ bool SILParserState::parseDeclSIL(Parser &P) {
7333
7353
SILFunction *DynamicallyReplacedFunction = nullptr ;
7334
7354
SILFunction *AdHocWitnessFunction = nullptr ;
7335
7355
Identifier objCReplacementFor;
7356
+ ActorIsolation actorIsolation;
7336
7357
if (parseSILLinkage (FnLinkage, P) ||
7337
7358
parseDeclSILOptional (
7338
7359
&isTransparent, &isSerialized, &isCanonical, &hasOwnershipSSA,
@@ -7344,7 +7365,7 @@ bool SILParserState::parseDeclSIL(Parser &P) {
7344
7365
&optimizationMode, &perfConstr, &isPerformanceConstraint,
7345
7366
&markedAsUsed, §ion, nullptr , &isWeakImported,
7346
7367
&needStackProtection, &availability, &isWithoutActuallyEscapingThunk,
7347
- &Semantics, &SpecAttrs, &ClangDecl, &MRK, FunctionState, M) ||
7368
+ &Semantics, &SpecAttrs, &ClangDecl, &MRK, &actorIsolation, FunctionState, M) ||
7348
7369
P.parseToken (tok::at_sign, diag::expected_sil_function_name) ||
7349
7370
P.parseIdentifier (FnName, FnNameLoc, /* diagnoseDollarPrefix=*/ false ,
7350
7371
diag::expected_sil_function_name) ||
@@ -7404,6 +7425,8 @@ bool SILParserState::parseDeclSIL(Parser &P) {
7404
7425
for (auto &Attr : Semantics) {
7405
7426
FunctionState.F ->addSemanticsAttr (Attr);
7406
7427
}
7428
+ if (actorIsolation)
7429
+ FunctionState.F ->setActorIsolation (actorIsolation);
7407
7430
// Now that we have a SILFunction parse the body, if present.
7408
7431
7409
7432
bool isDefinition = false ;
@@ -7593,11 +7616,11 @@ bool SILParserState::parseSILGlobal(Parser &P) {
7593
7616
7594
7617
SILParser State (P);
7595
7618
if (parseSILLinkage (GlobalLinkage, P) ||
7596
- parseDeclSILOptional (nullptr , &isSerialized, nullptr , nullptr ,
7619
+ parseDeclSILOptional (nullptr , &isSerialized, nullptr , nullptr , nullptr ,
7597
7620
nullptr , nullptr , nullptr , nullptr , nullptr , nullptr ,
7598
7621
nullptr , nullptr , nullptr , nullptr , nullptr , nullptr ,
7622
+ nullptr , nullptr , nullptr , nullptr , nullptr , &isLet,
7599
7623
nullptr , nullptr , nullptr , nullptr , nullptr , nullptr ,
7600
- &isLet, nullptr , nullptr , nullptr , nullptr , nullptr ,
7601
7624
nullptr , nullptr , nullptr , State, M) ||
7602
7625
P.parseToken (tok::at_sign, diag::expected_sil_value_name) ||
7603
7626
P.parseIdentifier (GlobalName, NameLoc, /* diagnoseDollarPrefix=*/ false ,
@@ -7651,7 +7674,7 @@ bool SILParserState::parseSILProperty(Parser &P) {
7651
7674
nullptr , nullptr , nullptr , nullptr , nullptr , nullptr ,
7652
7675
nullptr , nullptr , nullptr , nullptr , nullptr , nullptr ,
7653
7676
nullptr , nullptr , nullptr , nullptr , nullptr , nullptr ,
7654
- nullptr , nullptr , SP, M))
7677
+ nullptr , nullptr , nullptr , SP, M))
7655
7678
return true ;
7656
7679
7657
7680
ValueDecl *VD;
@@ -7721,7 +7744,7 @@ bool SILParserState::parseSILVTable(Parser &P) {
7721
7744
nullptr , nullptr , nullptr , nullptr , nullptr , nullptr ,
7722
7745
nullptr , nullptr , nullptr , nullptr , nullptr , nullptr ,
7723
7746
nullptr , nullptr , nullptr , nullptr , nullptr , nullptr ,
7724
- nullptr , nullptr , VTableState, M))
7747
+ nullptr , nullptr , nullptr , VTableState, M))
7725
7748
return true ;
7726
7749
7727
7750
@@ -7844,7 +7867,8 @@ bool SILParserState::parseSILMoveOnlyDeinit(Parser &parser) {
7844
7867
nullptr , nullptr , nullptr , nullptr , nullptr , nullptr ,
7845
7868
nullptr , nullptr , nullptr , nullptr , nullptr , nullptr ,
7846
7869
nullptr , nullptr , nullptr , nullptr , nullptr , nullptr ,
7847
- nullptr , nullptr , moveOnlyDeinitTableState, M))
7870
+ nullptr , nullptr , nullptr ,
7871
+ moveOnlyDeinitTableState, M))
7848
7872
return true ;
7849
7873
7850
7874
// Parse the class name.
@@ -8373,12 +8397,12 @@ bool SILParserState::parseSILWitnessTable(Parser &P) {
8373
8397
parseSILLinkage (Linkage, P);
8374
8398
8375
8399
SerializedKind_t isSerialized = IsNotSerialized;
8376
- if (parseDeclSILOptional (nullptr , &isSerialized, nullptr , nullptr , nullptr ,
8377
- nullptr , nullptr , nullptr , nullptr , nullptr , nullptr ,
8378
- nullptr , nullptr , nullptr , nullptr , nullptr , nullptr ,
8379
- nullptr , nullptr , nullptr , nullptr , nullptr , nullptr ,
8380
- nullptr , nullptr , nullptr , nullptr , nullptr , nullptr ,
8381
- nullptr , nullptr , WitnessState, M))
8400
+ if (parseDeclSILOptional (
8401
+ nullptr , &isSerialized , nullptr , nullptr , nullptr , nullptr , nullptr ,
8402
+ nullptr , nullptr , nullptr , nullptr , nullptr , nullptr , nullptr ,
8403
+ nullptr , nullptr , nullptr , nullptr , nullptr , nullptr , nullptr ,
8404
+ nullptr , nullptr , nullptr , nullptr , nullptr , nullptr ,
8405
+ nullptr , nullptr , nullptr , nullptr , nullptr , WitnessState, M))
8382
8406
return true ;
8383
8407
8384
8408
// Parse the protocol conformance.
0 commit comments