[clang] 43854fa - [clang][deps] Add module files for input dependencies earlier

Ben Langmuir via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 24 08:45:48 PST 2023


Author: Ben Langmuir
Date: 2023-01-24T08:45:20-08:00
New Revision: 43854fa263d2c96aa9e6c2bc5eafd66ac9727641

URL: https://github.com/llvm/llvm-project/commit/43854fa263d2c96aa9e6c2bc5eafd66ac9727641
DIFF: https://github.com/llvm/llvm-project/commit/43854fa263d2c96aa9e6c2bc5eafd66ac9727641.diff

LOG: [clang][deps] Add module files for input dependencies earlier

I originally thought we needed to add module file inputs for modular
deps at the same time as outputs because they depend on the
lookupModuleOutput callback, but this is not the case: they only depend
on the callback results for other modules, which have already been
computed by this point. So move them earlier so that they're set in the
CompilerInvocation at the same time as other inputs. This makes the
code easier to understand.

This change is effectively NFC, though it technically changes the module
exact value of the context hash.

Differential Revision: https://reviews.llvm.org/D142392

Added: 
    

Modified: 
    clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp b/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
index 1ae35c2034027..f9708332f4eec 100644
--- a/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
+++ b/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
@@ -55,11 +55,6 @@ static std::vector<std::string> splitString(std::string S, char Separator) {
 
 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 @@ ModuleDepCollector::makeInvocationForModuleBuildWithoutOutputs(
   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(


        


More information about the cfe-commits mailing list