[clang] [Modules] Fix ModuleDeclState transition when module is used as a regular identifier (PR #71134)

Chuanqi Xu via cfe-commits cfe-commits at lists.llvm.org
Thu Nov 2 20:52:05 PDT 2023


================
@@ -957,26 +957,27 @@ void Preprocessor::Lex(Token &Result) {
       ModuleDeclState.handlePeriod();
       break;
     case tok::identifier:
-      if (Result.getIdentifierInfo()->isModulesImport()) {
-        TrackGMFState.handleImport(StdCXXImportSeqState.afterTopLevelSeq());
-        StdCXXImportSeqState.handleImport();
-        if (StdCXXImportSeqState.afterImportSeq()) {
-          ModuleImportLoc = Result.getLocation();
-          NamedModuleImportPath.clear();
-          IsAtImport = false;
-          ModuleImportExpectsIdentifier = true;
-          CurLexerKind = CLK_LexAfterModuleImport;
-        }
-        break;
-      } else if (Result.getIdentifierInfo() == getIdentifierInfo("module")) {
-        TrackGMFState.handleModule(StdCXXImportSeqState.afterTopLevelSeq());
-        ModuleDeclState.handleModule();
-        break;
-      } else {
-        ModuleDeclState.handleIdentifier(Result.getIdentifierInfo());
-        if (ModuleDeclState.isModuleCandidate())
+      if (StdCXXImportSeqState.atTopLevel()) {
----------------
ChuanqiXu9 wrote:

I spent some time to understand the rationale here. How about add a comment like: "Otherwise we're in the unclosed brackets, then the modules related identifiers are not meaningful."

https://github.com/llvm/llvm-project/pull/71134


More information about the cfe-commits mailing list