@@ -680,11 +680,13 @@ static bool parseDeclSILOptional(
680
680
SILFunction::Purpose *specialPurpose, Inline_t *inlineStrategy,
681
681
OptimizationMode *optimizationMode, PerformanceConstraints *perfConstraints,
682
682
bool *isPerformanceConstraint, bool *markedAsUsed, StringRef *section,
683
- bool *isLet, bool *isWeakImported, bool *needStackProtection, bool *isSpecialized,
684
- AvailabilityRange *availability, bool *isWithoutActuallyEscapingThunk,
683
+ bool *isLet, bool *isWeakImported, bool *needStackProtection,
684
+ bool *isSpecialized, AvailabilityRange *availability,
685
+ bool *isWithoutActuallyEscapingThunk,
685
686
SmallVectorImpl<std::string> *Semantics,
686
687
SmallVectorImpl<ParsedSpecAttr> *SpecAttrs, ValueDecl **ClangDecl,
687
- EffectsKind *MRK, SILParser &SP, SILModule &M) {
688
+ EffectsKind *MRK, ActorIsolation *actorIsolation, SILParser &SP,
689
+ SILModule &M) {
688
690
while (SP.P .consumeIf (tok::l_square)) {
689
691
if (isLet && SP.P .Tok .is (tok::kw_let)) {
690
692
*isLet = true ;
@@ -785,7 +787,27 @@ static bool parseDeclSILOptional(
785
787
*isPerformanceConstraint = true ;
786
788
else if (markedAsUsed && SP.P .Tok .getText () == " used" )
787
789
*markedAsUsed = true ;
788
- else if (section && SP.P .Tok .getText () == " section" ) {
790
+ else if (actorIsolation && SP.P .Tok .getText () == " isolation" ) {
791
+ SP.P .consumeToken (tok::identifier);
792
+ if (SP.P .Tok .getKind () != tok::string_literal) {
793
+ SP.P .diagnose (SP.P .Tok , diag::expected_in_attribute_list);
794
+ return true ;
795
+ }
796
+ StringRef rawString = SP.P .Tok .getText ().drop_front ().drop_back ();
797
+ // TODO: By using a raw string here, we can perhaps put in a simple string
798
+ // representation of an actor that can be parsed back. For now this is
799
+ // just a quick hack so we can write tests.
800
+ auto optIsolation = ActorIsolation::forSILString (
801
+ SP.P .Context .getIdentifier (rawString).str ());
802
+ if (!optIsolation) {
803
+ SP.P .diagnose (SP.P .Tok , diag::expected_in_attribute_list);
804
+ return true ;
805
+ }
806
+ *actorIsolation = *optIsolation;
807
+ SP.P .consumeToken (tok::string_literal);
808
+ SP.P .parseToken (tok::r_square, diag::expected_in_attribute_list);
809
+ continue ;
810
+ } else if (section && SP.P .Tok .getText () == " section" ) {
789
811
SP.P .consumeToken (tok::identifier);
790
812
if (SP.P .Tok .getKind () != tok::string_literal) {
791
813
SP.P .diagnose (SP.P .Tok , diag::expected_in_attribute_list);
@@ -799,8 +821,7 @@ static bool parseDeclSILOptional(
799
821
800
822
SP.P .parseToken (tok::r_square, diag::expected_in_attribute_list);
801
823
continue ;
802
- }
803
- else if (inlineStrategy && SP.P .Tok .getText () == " always_inline" )
824
+ } else if (inlineStrategy && SP.P .Tok .getText () == " always_inline" )
804
825
*inlineStrategy = AlwaysInline;
805
826
else if (MRK && SP.P .Tok .getText () == " readnone" )
806
827
*MRK = EffectsKind::ReadNone;
@@ -7320,6 +7341,7 @@ bool SILParserState::parseDeclSIL(Parser &P) {
7320
7341
SILFunction *DynamicallyReplacedFunction = nullptr ;
7321
7342
SILFunction *AdHocWitnessFunction = nullptr ;
7322
7343
Identifier objCReplacementFor;
7344
+ ActorIsolation actorIsolation;
7323
7345
if (parseSILLinkage (FnLinkage, P) ||
7324
7346
parseDeclSILOptional (
7325
7347
&isTransparent, &isSerialized, &isCanonical, &hasOwnershipSSA,
@@ -7330,8 +7352,9 @@ bool SILParserState::parseDeclSIL(Parser &P) {
7330
7352
&objCReplacementFor, &specialPurpose, &inlineStrategy,
7331
7353
&optimizationMode, &perfConstr, &isPerformanceConstraint,
7332
7354
&markedAsUsed, §ion, nullptr , &isWeakImported,
7333
- &needStackProtection, nullptr , &availability, &isWithoutActuallyEscapingThunk,
7334
- &Semantics, &SpecAttrs, &ClangDecl, &MRK, FunctionState, M) ||
7355
+ &needStackProtection, nullptr , &availability,
7356
+ &isWithoutActuallyEscapingThunk, &Semantics, &SpecAttrs, &ClangDecl,
7357
+ &MRK, &actorIsolation, FunctionState, M) ||
7335
7358
P.parseToken (tok::at_sign, diag::expected_sil_function_name) ||
7336
7359
P.parseIdentifier (FnName, FnNameLoc, /* diagnoseDollarPrefix=*/ false ,
7337
7360
diag::expected_sil_function_name) ||
@@ -7391,6 +7414,8 @@ bool SILParserState::parseDeclSIL(Parser &P) {
7391
7414
for (auto &Attr : Semantics) {
7392
7415
FunctionState.F ->addSemanticsAttr (Attr);
7393
7416
}
7417
+ if (actorIsolation)
7418
+ FunctionState.F ->setActorIsolation (actorIsolation);
7394
7419
// Now that we have a SILFunction parse the body, if present.
7395
7420
7396
7421
bool isDefinition = false ;
@@ -7580,11 +7605,11 @@ bool SILParserState::parseSILGlobal(Parser &P) {
7580
7605
7581
7606
SILParser State (P);
7582
7607
if (parseSILLinkage (GlobalLinkage, P) ||
7583
- parseDeclSILOptional (nullptr , &isSerialized, nullptr , nullptr ,
7608
+ parseDeclSILOptional (nullptr , &isSerialized, nullptr , nullptr , nullptr ,
7584
7609
nullptr , nullptr , nullptr , nullptr , nullptr , nullptr ,
7585
7610
nullptr , nullptr , nullptr , nullptr , nullptr , nullptr ,
7611
+ nullptr , nullptr , nullptr , nullptr , nullptr , &isLet,
7586
7612
nullptr , nullptr , nullptr , nullptr , nullptr , nullptr ,
7587
- &isLet, nullptr , nullptr , nullptr , nullptr , nullptr ,
7588
7613
nullptr , nullptr , nullptr , nullptr , State, M) ||
7589
7614
P.parseToken (tok::at_sign, diag::expected_sil_value_name) ||
7590
7615
P.parseIdentifier (GlobalName, NameLoc, /* diagnoseDollarPrefix=*/ false ,
@@ -7638,7 +7663,7 @@ bool SILParserState::parseSILProperty(Parser &P) {
7638
7663
nullptr , nullptr , nullptr , nullptr , nullptr , nullptr ,
7639
7664
nullptr , nullptr , nullptr , nullptr , nullptr , nullptr ,
7640
7665
nullptr , nullptr , nullptr , nullptr , nullptr , nullptr ,
7641
- nullptr , nullptr , nullptr , SP, M))
7666
+ nullptr , nullptr , nullptr , nullptr , SP, M))
7642
7667
return true ;
7643
7668
7644
7669
ValueDecl *VD;
@@ -7708,7 +7733,7 @@ bool SILParserState::parseSILVTable(Parser &P) {
7708
7733
nullptr , nullptr , nullptr , nullptr , nullptr , nullptr ,
7709
7734
nullptr , nullptr , nullptr , nullptr , nullptr , nullptr ,
7710
7735
nullptr , nullptr , nullptr , nullptr , nullptr , nullptr ,
7711
- nullptr , nullptr , nullptr , VTableState, M))
7736
+ nullptr , nullptr , nullptr , nullptr , VTableState, M))
7712
7737
return true ;
7713
7738
7714
7739
@@ -7831,7 +7856,8 @@ bool SILParserState::parseSILMoveOnlyDeinit(Parser &parser) {
7831
7856
nullptr , nullptr , nullptr , nullptr , nullptr , nullptr ,
7832
7857
nullptr , nullptr , nullptr , nullptr , nullptr , nullptr ,
7833
7858
nullptr , nullptr , nullptr , nullptr , nullptr , nullptr ,
7834
- nullptr , nullptr , nullptr , moveOnlyDeinitTableState, M))
7859
+ nullptr , nullptr , nullptr , nullptr ,
7860
+ moveOnlyDeinitTableState, M))
7835
7861
return true ;
7836
7862
7837
7863
// Parse the class name.
@@ -8371,12 +8397,12 @@ bool SILParserState::parseSILWitnessTable(Parser &P) {
8371
8397
8372
8398
SerializedKind_t isSerialized = IsNotSerialized;
8373
8399
bool isSpecialized = false ;
8374
- if (parseDeclSILOptional (nullptr , &isSerialized, nullptr , nullptr , nullptr ,
8375
- nullptr , nullptr , nullptr , nullptr , nullptr , nullptr ,
8376
- nullptr , nullptr , nullptr , nullptr , nullptr , nullptr ,
8377
- nullptr , nullptr , nullptr , nullptr , nullptr , nullptr ,
8378
- nullptr , nullptr , &isSpecialized, nullptr , nullptr , nullptr ,
8379
- nullptr , 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 , &isSpecialized, nullptr , nullptr ,
8405
+ nullptr , nullptr , nullptr , nullptr , nullptr , WitnessState, M))
8380
8406
return true ;
8381
8407
8382
8408
// Parse the protocol conformance.
0 commit comments