Skip to content

[Parse] <rdar://41154797> Detect eof in non-string-arg recovery loop in #error arg list. #17508

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

graydon
Copy link
Contributor

@graydon graydon commented Jun 26, 2018

The parser could hang while trying to recover from an unexpected token in the arg list of a pound-diagnostic, and met with and unterminated token. Fix this by noticing eof in the loop.

rdar://41154797

@graydon graydon requested a review from rintaro June 26, 2018 06:52
@graydon
Copy link
Contributor Author

graydon commented Jun 26, 2018

@swift-ci please test

Copy link
Member

@rintaro rintaro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thank you!

@@ -3285,7 +3285,7 @@ ParserResult<PoundDiagnosticDecl> Parser::parseDeclPoundDiagnostic() {
// Catch #warning(oops, forgot the quotes)
SourceLoc wordsStartLoc = Tok.getLoc();

while (!Tok.isAtStartOfLine() && Tok.isNot(tok::r_paren)) {
while (!Tok.isAtStartOfLine() && !Tok.isAny(tok::r_paren, tok::eof)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tok.isNot(tok::r_paren, tok::eof) should also work, but I personally prefer !Tok.isAny( 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants