@@ -3583,7 +3583,6 @@ ParserStatus Parser::parseLineDirective(bool isLine) {
3583
3583
3584
3584
unsigned StartLine = 0 ;
3585
3585
Optional<StringRef> Filename;
3586
- const char *LastTokTextEnd;
3587
3586
if (!isLine) {
3588
3587
// #sourceLocation()
3589
3588
// #sourceLocation(file: "foo", line: 42)
@@ -3640,10 +3639,10 @@ ParserStatus Parser::parseLineDirective(bool isLine) {
3640
3639
consumeToken (tok::integer_literal);
3641
3640
}
3642
3641
3643
- LastTokTextEnd = Tok.getText (). end ();
3644
- if ( parseToken (tok::r_paren , diag::sourceLocation_expected, " )" ))
3642
+ if ( Tok.isNot (tok::r_paren)) {
3643
+ diagnose (Tok , diag::sourceLocation_expected, " )" );
3645
3644
return makeParserError ();
3646
-
3645
+ }
3647
3646
} else { // Legacy #line syntax.
3648
3647
3649
3648
// #line\n returns to the main buffer.
@@ -3679,10 +3678,10 @@ ParserStatus Parser::parseLineDirective(bool isLine) {
3679
3678
" #line" );
3680
3679
if (!Filename.hasValue ())
3681
3680
return makeParserError ();
3682
- LastTokTextEnd = Tok.getText ().end ();
3683
- consumeToken (tok::string_literal);
3684
3681
}
3685
-
3682
+
3683
+ const char *LastTokTextEnd = Tok.getText ().end ();
3684
+
3686
3685
// Skip over trailing whitespace and a single \n to the start of the next
3687
3686
// line.
3688
3687
while (*LastTokTextEnd == ' ' || *LastTokTextEnd == ' \t ' )
@@ -3703,6 +3702,9 @@ ParserStatus Parser::parseLineDirective(bool isLine) {
3703
3702
Filename.getValue (), LineOffset);
3704
3703
assert (isNewFile);(void )isNewFile;
3705
3704
3705
+ // Lexing of next token must be deferred until after virtual file setup.
3706
+ consumeToken (isLine ? tok::string_literal : tok::r_paren);
3707
+
3706
3708
InPoundLineEnvironment = true ;
3707
3709
return makeParserSuccess ();
3708
3710
}
0 commit comments