[clang] [clang-tools-extra] [clangd] Handle C++20 annot_module_name token and don't discard successfully built modules when on fail (PR #187858)

Chuanqi Xu via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 23 19:51:31 PDT 2026


================
@@ -893,6 +902,16 @@ class TokenCollector::Builder {
 TokenBuffer TokenCollector::consume() && {
   PP.setTokenWatcher(nullptr);
   Collector->disable();
+
+  /// If the parser hit an module load fatal error, the TokenCollector will not
+  /// receive an EOF token; we need to add an EOF token to the end of the token
+  /// sequence.
+  if (PP.hadModuleLoaderFatalFailure() &&
----------------
ChuanqiXu9 wrote:

I don't think we should change the logics in `ModulesBuilder`. It is by design that FailedPrerequisiteModules doesn't change header search options. In another point of view, we made the change in Lexer and clangd crashes, so the root cause is in Lexer and not clangd.

And I think, for parsing C++20 named modules, we don't need to care about `PP.hadModuleLoaderFatalFailure()`. It shouldn't matter/count for lexing C++20 named modules.



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


More information about the cfe-commits mailing list