[clang] [clang][modules] Only compute affecting module maps with implicit search (PR #87849)

Richard Smith via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 16 16:15:02 PDT 2024


================
@@ -161,8 +161,13 @@ static TypeCode getTypeCodeForTypeClass(Type::TypeClass id) {
 
 namespace {
 
-std::set<const FileEntry *> GetAffectingModuleMaps(const Preprocessor &PP,
-                                                   Module *RootModule) {
+std::optional<std::set<const FileEntry *>>
+GetAffectingModuleMaps(const Preprocessor &PP, Module *RootModule) {
+  // Without implicit module map search, there's no good reason to know about
+  // any module maps that are not affecting.
+  if (!PP.getHeaderSearchInfo().getHeaderSearchOpts().ImplicitModuleMaps)
+    return std::nullopt;
----------------
zygoloid wrote:

I don't think this is correct -- we can know about non-affecting module map files because they were specified on the command line using `-fmodule-map-file=` and either weren't actually used or (as happens in our case) we got the same information from a PCM file and so didn't need the module map file.

I think this check is a regression; can it be removed?

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


More information about the cfe-commits mailing list