@@ -685,7 +685,8 @@ static bool parseDeclSILOptional(
685685 AvailabilityRange *availability, bool *isWithoutActuallyEscapingThunk,
686686 SmallVectorImpl<std::string> *Semantics,
687687 SmallVectorImpl<ParsedSpecAttr> *SpecAttrs, ValueDecl **ClangDecl,
688- EffectsKind *MRK, SILParser &SP, SILModule &M) {
688+ EffectsKind *MRK, ActorIsolation *actorIsolation, SILParser &SP,
689+ SILModule &M) {
689690 while (SP.P .consumeIf (tok::l_square)) {
690691 if (isLet && SP.P .Tok .is (tok::kw_let)) {
691692 *isLet = true ;
@@ -784,7 +785,27 @@ static bool parseDeclSILOptional(
784785 *isPerformanceConstraint = true ;
785786 else if (markedAsUsed && SP.P .Tok .getText () == " used" )
786787 *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" ) {
788809 SP.P .consumeToken (tok::identifier);
789810 if (SP.P .Tok .getKind () != tok::string_literal) {
790811 SP.P .diagnose (SP.P .Tok , diag::expected_in_attribute_list);
@@ -798,8 +819,7 @@ static bool parseDeclSILOptional(
798819
799820 SP.P .parseToken (tok::r_square, diag::expected_in_attribute_list);
800821 continue ;
801- }
802- else if (inlineStrategy && SP.P .Tok .getText () == " always_inline" )
822+ } else if (inlineStrategy && SP.P .Tok .getText () == " always_inline" )
803823 *inlineStrategy = AlwaysInline;
804824 else if (MRK && SP.P .Tok .getText () == " readnone" )
805825 *MRK = EffectsKind::ReadNone;
@@ -7333,6 +7353,7 @@ bool SILParserState::parseDeclSIL(Parser &P) {
73337353 SILFunction *DynamicallyReplacedFunction = nullptr ;
73347354 SILFunction *AdHocWitnessFunction = nullptr ;
73357355 Identifier objCReplacementFor;
7356+ ActorIsolation actorIsolation;
73367357 if (parseSILLinkage (FnLinkage, P) ||
73377358 parseDeclSILOptional (
73387359 &isTransparent, &isSerialized, &isCanonical, &hasOwnershipSSA,
@@ -7344,7 +7365,7 @@ bool SILParserState::parseDeclSIL(Parser &P) {
73447365 &optimizationMode, &perfConstr, &isPerformanceConstraint,
73457366 &markedAsUsed, §ion, nullptr , &isWeakImported,
73467367 &needStackProtection, &availability, &isWithoutActuallyEscapingThunk,
7347- &Semantics, &SpecAttrs, &ClangDecl, &MRK, FunctionState, M) ||
7368+ &Semantics, &SpecAttrs, &ClangDecl, &MRK, &actorIsolation, FunctionState, M) ||
73487369 P.parseToken (tok::at_sign, diag::expected_sil_function_name) ||
73497370 P.parseIdentifier (FnName, FnNameLoc, /* diagnoseDollarPrefix=*/ false ,
73507371 diag::expected_sil_function_name) ||
@@ -7404,6 +7425,8 @@ bool SILParserState::parseDeclSIL(Parser &P) {
74047425 for (auto &Attr : Semantics) {
74057426 FunctionState.F ->addSemanticsAttr (Attr);
74067427 }
7428+ if (actorIsolation)
7429+ FunctionState.F ->setActorIsolation (actorIsolation);
74077430 // Now that we have a SILFunction parse the body, if present.
74087431
74097432 bool isDefinition = false ;
@@ -7593,11 +7616,11 @@ bool SILParserState::parseSILGlobal(Parser &P) {
75937616
75947617 SILParser State (P);
75957618 if (parseSILLinkage (GlobalLinkage, P) ||
7596- parseDeclSILOptional (nullptr , &isSerialized, nullptr , nullptr ,
7619+ parseDeclSILOptional (nullptr , &isSerialized, nullptr , nullptr , nullptr ,
75977620 nullptr , nullptr , nullptr , nullptr , nullptr , nullptr ,
75987621 nullptr , nullptr , nullptr , nullptr , nullptr , nullptr ,
7622+ nullptr , nullptr , nullptr , nullptr , nullptr , &isLet,
75997623 nullptr , nullptr , nullptr , nullptr , nullptr , nullptr ,
7600- &isLet, nullptr , nullptr , nullptr , nullptr , nullptr ,
76017624 nullptr , nullptr , nullptr , State, M) ||
76027625 P.parseToken (tok::at_sign, diag::expected_sil_value_name) ||
76037626 P.parseIdentifier (GlobalName, NameLoc, /* diagnoseDollarPrefix=*/ false ,
@@ -7651,7 +7674,7 @@ bool SILParserState::parseSILProperty(Parser &P) {
76517674 nullptr , nullptr , nullptr , nullptr , nullptr , nullptr ,
76527675 nullptr , nullptr , nullptr , nullptr , nullptr , nullptr ,
76537676 nullptr , nullptr , nullptr , nullptr , nullptr , nullptr ,
7654- nullptr , nullptr , SP, M))
7677+ nullptr , nullptr , nullptr , SP, M))
76557678 return true ;
76567679
76577680 ValueDecl *VD;
@@ -7721,7 +7744,7 @@ bool SILParserState::parseSILVTable(Parser &P) {
77217744 nullptr , nullptr , nullptr , nullptr , nullptr , nullptr ,
77227745 nullptr , nullptr , nullptr , nullptr , nullptr , nullptr ,
77237746 nullptr , nullptr , nullptr , nullptr , nullptr , nullptr ,
7724- nullptr , nullptr , VTableState, M))
7747+ nullptr , nullptr , nullptr , VTableState, M))
77257748 return true ;
77267749
77277750
@@ -7844,7 +7867,8 @@ bool SILParserState::parseSILMoveOnlyDeinit(Parser &parser) {
78447867 nullptr , nullptr , nullptr , nullptr , nullptr , nullptr ,
78457868 nullptr , nullptr , nullptr , nullptr , nullptr , nullptr ,
78467869 nullptr , nullptr , nullptr , nullptr , nullptr , nullptr ,
7847- nullptr , nullptr , moveOnlyDeinitTableState, M))
7870+ nullptr , nullptr , nullptr ,
7871+ moveOnlyDeinitTableState, M))
78487872 return true ;
78497873
78507874 // Parse the class name.
@@ -8373,12 +8397,12 @@ bool SILParserState::parseSILWitnessTable(Parser &P) {
83738397 parseSILLinkage (Linkage, P);
83748398
83758399 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))
83828406 return true ;
83838407
83848408 // Parse the protocol conformance.
0 commit comments