================ @@ -65,11 +66,25 @@ static void optimizeHeaderSearchOpts(HeaderSearchOptions &Opts, llvm::DenseSet<const serialization::ModuleFile *> Visited; std::function<void(const serialization::ModuleFile *)> VisitMF = [&](const serialization::ModuleFile *MF) { - VFSUsage |= MF->VFSUsage; Visited.insert(MF); - for (const serialization::ModuleFile *Import : MF->Imports) - if (!Visited.contains(Import)) - VisitMF(Import); + if (MF->Kind == serialization::MK_ImplicitModule) { + VFSUsage |= MF->VFSUsage; + // We only need to recurse into implicit modules. Other module types + // will have the correct set of VFSs for anything they depend on. + for (const serialization::ModuleFile *Import : MF->Imports) + if (!Visited.contains(Import)) + VisitMF(Import); + } else { + // This is not an implicitly built module, so it may have different + // VFS options. Fall back to a string comparison instead. + auto VFSMap = PrebuiltModuleVFSMap.find(MF->FileName); + if (VFSMap == PrebuiltModuleVFSMap.end()) + return; ---------------- jansvoboda11 wrote:
This almost makes it feel like it's okay to import a non-implicit module that we didn't visit when dealing with the PCH. I think it would be good to add a sanity check here by having an entry for each PCH dependency (that will map to empty set if no VFS overlay files were used) and assert here that `VFSMap != PrebuiltModuleVFSMap.end()`. https://github.com/llvm/llvm-project/pull/82294 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits