[PATCH] D108544: [clang][deps] Avoid generating arguments for missing module map files
Jan Svoboda via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Aug 23 05:04:09 PDT 2021
jansvoboda11 created this revision.
jansvoboda11 added reviewers: Bigcheese, dexonsmith, arphaman.
jansvoboda11 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
Only modules that were built from preprocessed sources have `PresumedModuleMapFile`. Encode the optionality into the type system and avoid generating the `-fmodule-map-file=` arguments in such cases.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D108544
Files:
clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
Index: clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
===================================================================
--- clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
+++ clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
@@ -35,7 +35,9 @@
// Report the prebuilt modules this module uses.
for (const auto &PrebuiltModule : Deps.PrebuiltModuleDeps) {
CI.getFrontendOpts().ModuleFiles.push_back(PrebuiltModule.PCMFile);
- CI.getFrontendOpts().ModuleMapFiles.push_back(PrebuiltModule.ModuleMapFile);
+ if (PrebuiltModule.ModuleMapFile)
+ CI.getFrontendOpts().ModuleMapFiles.push_back(
+ *PrebuiltModule.ModuleMapFile);
}
CI.getPreprocessorOpts().ImplicitPCHInclude.clear();
Index: clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
===================================================================
--- clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
+++ clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
@@ -39,7 +39,8 @@
for (const PrebuiltModuleDep &PMD : PrebuiltModuleDeps) {
Args.push_back("-fmodule-file=" + PMD.ModuleName + "=" + PMD.PCMFile);
- Args.push_back("-fmodule-map-file=" + PMD.ModuleMapFile);
+ if (PMD.ModuleMapFile)
+ Args.push_back("-fmodule-map-file=" + *PMD.ModuleMapFile);
}
return Args;
Index: clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
===================================================================
--- clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
+++ clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
@@ -32,12 +32,14 @@
struct PrebuiltModuleDep {
std::string ModuleName;
std::string PCMFile;
- std::string ModuleMapFile;
+ Optional<std::string> ModuleMapFile;
explicit PrebuiltModuleDep(const Module *M)
: ModuleName(M->getTopLevelModuleName()),
PCMFile(M->getASTFile()->getName()),
- ModuleMapFile(M->PresumedModuleMapFile) {}
+ ModuleMapFile(M->PresumedModuleMapFile.empty()
+ ? None
+ : Optional<std::string>(M->PresumedModuleMapFile)) {}
};
/// This is used to identify a specific module.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D108544.368068.patch
Type: text/x-patch
Size: 2241 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210823/017e94f2/attachment-0001.bin>
More information about the cfe-commits
mailing list