[clang] [clang-tools-extra] [clangd] Handle C++20 annot_module_name token (PR #187858)

via cfe-commits cfe-commits at lists.llvm.org
Sun Mar 22 22:57:26 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() &&
----------------
yronglin wrote:

IIUC, the load failure came from `import NonExistent;`.

> If we won't load modules at all, why would we have a load failure?

Clangd will tigger parser/sema analysis and the we will try to load module in ParseModuleImport.

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


More information about the cfe-commits mailing list