[clang] [clang][modules] Support every import syntax in single-module-parse-mode (PR #179610)

Jan Svoboda via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 12 08:51:17 PST 2026


================
@@ -1988,6 +1988,23 @@ CompilerInstance::loadModule(SourceLocation ImportLoc,
     // * `Preprocessor::HandleHeaderIncludeOrImport` will never call this
     //   function as the `#include` or `#import` is textual.
 
+    MM.cacheModuleLoad(*Path[0].getIdentifierInfo(), Module);
+  } else if (getPreprocessorOpts().SingleModuleParseMode) {
+    // This mimics how findOrCompileModuleAndReadAST() finds the module.
+    Module = getPreprocessor().getHeaderSearchInfo().lookupModule(
+        ModuleName, ImportLoc, true, !IsInclusionDirective);
+    if (Module) {
+      // Mark the module and its submodules as if they were loaded from a PCM.
+      // This prevents emission of the "missing submodule" diagnostic below.
+      std::vector Worklist{Module};
----------------
jansvoboda11 wrote:

I didn't explicitly specify the type in order to avoid the `class` specifier, but I think we can also use `clang::Module*`. I'll put up a PR. Thanks for the heads-up.

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


More information about the cfe-commits mailing list