Skip to content

[4.1][Lexer] Don't setEscapedIdentifier(true) for tok::eof at ArtificialEOF #14552

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
merged 3 commits into from
Feb 13, 2018

Conversation

rintaro
Copy link
Member

@rintaro rintaro commented Feb 12, 2018

Cherry-pick of #14505 (and #13631 which #14505 depends on)

Explanation: Fix an assertion failure in SourceKit. During parsing for SourceKit, the parser tokenizes comments as tokens by re-lexing the source range of them. If the comment happens to be followed by escaped identifier, the Lexer tokenize the escaped identifier as EOF, and it used to mistakingly mark them as escaped identifier, that behavior used to cause an assertion failure (!value || Kind == tok::identifier) && "only identifiers can be escaped identifiers". The normal compiler has no path for hitting this defects.
Scope: SourceKit with assertion enabled. If assertion was disabled, it didn't crash.
Risk: Low. isEscapedIdentifer flag has no meanings for tok::eof tokens.
Testing: Added regression test for SourceKit.
Reviewer: @akyrtzi
SR / Radar: SR-6926 rdar://problem/37290899

@rintaro rintaro changed the title 4.1 lex escaped eof [4.1][Lexer] Don't setEscapedIdentifier(true) for tok::eof at ArtificialEOF Feb 12, 2018
@rintaro rintaro force-pushed the 4.1-lex-escaped-eof branch from 0825dd2 to 368d93b Compare February 12, 2018 09:24
@swiftlang swiftlang deleted a comment from swift-ci Feb 12, 2018
@swiftlang swiftlang deleted a comment from swift-ci Feb 12, 2018
@rintaro
Copy link
Member Author

rintaro commented Feb 12, 2018

@swift-ci Please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 0825dd23040581686fdae26fb0a30247e4d41264

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 0825dd23040581686fdae26fb0a30247e4d41264

omochi and others added 3 commits February 12, 2018 18:42
https://bugs.swift.org/browse/SR-6926

This happens when the Parser re-lexing comment tokens that sets
ArtificialEOF at the end of comment range.
It used to cause an assertion failure:
(!value || Kind == tok::identifier) && "only identifiers can be escaped identifiers"
@rintaro rintaro force-pushed the 4.1-lex-escaped-eof branch from 368d93b to 339b47d Compare February 12, 2018 10:14
@rintaro
Copy link
Member Author

rintaro commented Feb 12, 2018

@swift-ci Please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 368d93ba1f6722cc76e9d78214dc2f4ad96aa10d

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 368d93ba1f6722cc76e9d78214dc2f4ad96aa10d

@rintaro
Copy link
Member Author

rintaro commented Feb 12, 2018

@akyrtzi Could you review this for 4.1 branch?

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.

4 participants