Avoid inferring new submodules for headers in ASTWriter's collection of
affecting modulemap files, since we don't want to pick up dependencies
that didn't actually exist during parsing.
rdar://
109112624
Differential Revision: https://reviews.llvm.org/D150151
/// Retrieve all the modules corresponding to the given file.
///
+ /// \param AllowCreation Whether to allow inference of a new submodule, or to
+ /// only return existing known modules.
+ ///
/// \ref findModuleForHeader should typically be used instead of this.
ArrayRef<ModuleMap::KnownHeader>
- findAllModulesForHeader(const FileEntry *File) const;
+ findAllModulesForHeader(const FileEntry *File,
+ bool AllowCreation = true) const;
/// Read the contents of the given module map file.
///
/// and does not consult the external source. (Those checks are the
/// responsibility of \ref HeaderSearch.)
///
+ /// \param AllowCreation Whether to allow inference of a new submodule, or to
+ /// only return existing known modules.
+ ///
/// Typically, \ref findModuleForHeader should be used instead, as it picks
/// the preferred module for the header.
- ArrayRef<KnownHeader> findAllModulesForHeader(const FileEntry *File);
+ ArrayRef<KnownHeader> findAllModulesForHeader(const FileEntry *File,
+ bool AllowCreation = true);
/// Like \ref findAllModulesForHeader, but do not attempt to infer module
/// ownership from umbrella headers if we've not already done so.
}
ArrayRef<ModuleMap::KnownHeader>
-HeaderSearch::findAllModulesForHeader(const FileEntry *File) const {
+HeaderSearch::findAllModulesForHeader(const FileEntry *File,
+ bool AllowCreation) const {
if (ExternalSource) {
// Make sure the external source has handled header info about this file,
// which includes whether the file is part of a module.
(void)getExistingFileInfo(File);
}
- return ModMap.findAllModulesForHeader(File);
+ return ModMap.findAllModulesForHeader(File, AllowCreation);
}
static bool suggestModule(HeaderSearch &HS, const FileEntry *File,
}
ArrayRef<ModuleMap::KnownHeader>
-ModuleMap::findAllModulesForHeader(const FileEntry *File) {
+ModuleMap::findAllModulesForHeader(const FileEntry *File, bool AllowCreation) {
HeadersMap::iterator Known = findKnownHeader(File);
if (Known != Headers.end())
return Known->second;
- if (findOrCreateModuleForHeaderInUmbrellaDir(File))
+ if (AllowCreation && findOrCreateModuleForHeaderInUmbrellaDir(File))
return Headers.find(File)->second;
return std::nullopt;
if (!HFI || (HFI->isModuleHeader && !HFI->isCompilingModuleHeader))
continue;
- for (const auto &KH : HS.findAllModulesForHeader(File)) {
+ for (const auto &KH :
+ HS.findAllModulesForHeader(File, /*AllowCreation=*/false)) {
if (!KH.getModule())
continue;
ModulesToProcess.push_back(KH.getModule());