@@ -1199,12 +1199,22 @@ bool Preprocessor::HandleModuleContextualKeyword(
11991199 llvm::SaveAndRestore<bool > SavedParsingPreprocessorDirective (
12001200 CurPPLexer->ParsingPreprocessorDirective , true );
12011201
1202+ // The next token may be an angled string literal after import keyword.
1203+ llvm::SaveAndRestore<bool > SavedParsingFilemame (
1204+ CurPPLexer->ParsingFilename ,
1205+ Result.getIdentifierInfo ()->isModulesImport ());
1206+
1207+ std::optional<Token> NextTok =
1208+ CurLexer ? CurLexer->peekNextPPToken () : CurTokenLexer->peekNextPPToken ();
1209+ if (!NextTok)
1210+ return false ;
1211+
1212+ if (NextTok->is (tok::raw_identifier))
1213+ LookUpIdentifierInfo (*NextTok);
1214+
12021215 if (Result.getIdentifierInfo ()->isModulesImport ()) {
1203- // The next token may be an angled string literal.
1204- llvm::SaveAndRestore<bool > SavedParsingFilemame (CurPPLexer->ParsingFilename ,
1205- true );
1206- if (isNextPPTokenOneOf (tok::raw_identifier, tok::less, tok::string_literal,
1207- tok::colon, tok::header_name)) {
1216+ if (NextTok->isOneOf (tok::identifier, tok::less, tok::string_literal,
1217+ tok::colon, tok::header_name)) {
12081218 Result.setKind (tok::kw_import);
12091219 ModuleImportLoc = Result.getLocation ();
12101220 IsAtImport = false ;
@@ -1213,7 +1223,7 @@ bool Preprocessor::HandleModuleContextualKeyword(
12131223 }
12141224
12151225 if (Result.getIdentifierInfo ()->isModulesDeclaration () &&
1216- isNextPPTokenOneOf (tok::raw_identifier , tok::colon, tok::semi)) {
1226+ NextTok-> isOneOf (tok::identifier , tok::colon, tok::semi)) {
12171227 Result.setKind (tok::kw_module);
12181228 ModuleDeclLoc = Result.getLocation ();
12191229 return true ;
0 commit comments