@@ -3870,7 +3870,11 @@ static ParameterList *parseOptionalAccessorArgument(SourceLoc SpecifierLoc,
3870
3870
return ParameterList::create (P.Context , StartLoc, param, EndLoc);
3871
3871
}
3872
3872
3873
- static unsigned skipUntilMatchingRBrace (Parser &P) {
3873
+ static unsigned skipUntilMatchingRBrace (Parser &P,
3874
+ SyntaxParsingContext *&SyntaxContext) {
3875
+ SyntaxParsingContext BlockItemListContext (SyntaxContext,
3876
+ SyntaxKind::CodeBlockItemList);
3877
+ SyntaxParsingContext BodyContext (SyntaxContext, SyntaxKind::TokenList);
3874
3878
unsigned OpenBraces = 1 ;
3875
3879
while (OpenBraces != 0 && P.Tok .isNot (tok::eof)) {
3876
3880
if (P.consumeIf (tok::l_brace)) {
@@ -3888,9 +3892,11 @@ static unsigned skipUntilMatchingRBrace(Parser &P) {
3888
3892
return OpenBraces;
3889
3893
}
3890
3894
3891
- static unsigned skipBracedBlock (Parser &P) {
3895
+ static unsigned skipBracedBlock (Parser &P,
3896
+ SyntaxParsingContext *&SyntaxContext) {
3897
+ SyntaxParsingContext CodeBlockContext (SyntaxContext, SyntaxKind::CodeBlock);
3892
3898
P.consumeToken (tok::l_brace);
3893
- unsigned OpenBraces = skipUntilMatchingRBrace (P);
3899
+ unsigned OpenBraces = skipUntilMatchingRBrace (P, SyntaxContext );
3894
3900
if (P.consumeIf (tok::r_brace))
3895
3901
OpenBraces--;
3896
3902
return OpenBraces;
@@ -3904,7 +3910,7 @@ void Parser::consumeGetSetBody(AbstractFunctionDecl *AFD,
3904
3910
BodyRange.Start = Tok.getLoc ();
3905
3911
3906
3912
// Skip until the next '}' at the correct nesting level.
3907
- unsigned OpenBraces = skipUntilMatchingRBrace (*this );
3913
+ unsigned OpenBraces = skipUntilMatchingRBrace (*this , SyntaxContext );
3908
3914
3909
3915
if (OpenBraces != 1 ) {
3910
3916
// FIXME: implement some error recovery?
@@ -5102,7 +5108,7 @@ void Parser::consumeAbstractFunctionBody(AbstractFunctionDecl *AFD,
5102
5108
BodyRange.Start = Tok.getLoc ();
5103
5109
5104
5110
// Consume the '{', and find the matching '}'.
5105
- unsigned OpenBraces = skipBracedBlock (*this );
5111
+ unsigned OpenBraces = skipBracedBlock (*this , SyntaxContext );
5106
5112
if (OpenBraces != 0 && Tok.isNot (tok::code_complete)) {
5107
5113
assert (Tok.is (tok::eof));
5108
5114
// We hit EOF, and not every brace has a pair. Recover by searching
@@ -6458,7 +6464,7 @@ Parser::parseDeclPrecedenceGroup(ParseDeclOptions flags,
6458
6464
(void ) consumeIf (tok::r_brace);
6459
6465
} else if (Tok.isNot (tok::eof) && peekToken ().is (tok::l_brace)) {
6460
6466
consumeToken ();
6461
- skipBracedBlock (*this );
6467
+ skipBracedBlock (*this , SyntaxContext );
6462
6468
}
6463
6469
return nullptr ;
6464
6470
}
0 commit comments