diff --git a/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp b/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp --- a/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp +++ b/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp @@ -55,11 +55,6 @@ void ModuleDepCollector::addOutputPaths(CompilerInvocation &CI, ModuleDeps &Deps) { - // These are technically *inputs* to the compilation, but we populate them - // here in order to make \c getModuleContextHash() independent of - // \c lookupModuleOutput(). - addModuleFiles(CI, Deps.ClangModuleDeps); - CI.getFrontendOpts().OutputFile = Consumer.lookupModuleOutput(Deps.ID, ModuleOutputKind::ModuleFile); if (!CI.getDiagnosticOpts().DiagnosticSerializationFile.empty()) @@ -156,6 +151,9 @@ for (const auto &PrebuiltModule : Deps.PrebuiltModuleDeps) CI.getFrontendOpts().ModuleFiles.push_back(PrebuiltModule.PCMFile); + // Add module file inputs from dependencies. + addModuleFiles(CI, Deps.ClangModuleDeps); + // Remove any macro definitions that are explicitly ignored. if (!CI.getHeaderSearchOpts().ModulesIgnoreMacros.empty()) { llvm::erase_if(