@@ -223,54 +223,73 @@ struct ModuleRebuildInfo {
223223 Forwarding,
224224 Prebuilt
225225 };
226- struct OutOfDateModule {
226+ enum class ReasonIgnored {
227+ NotIgnored,
228+ PublicFramework,
229+ InterfacePreferred,
230+ };
231+ struct CandidateModule {
227232 std::string path;
228233 Optional<serialization::Status> serializationStatus;
229234 ModuleKind kind;
235+ ReasonIgnored reasonIgnored;
230236 SmallVector<std::string, 10 > outOfDateDependencies;
231237 SmallVector<std::string, 10 > missingDependencies;
232238 };
233- SmallVector<OutOfDateModule , 3 > outOfDateModules ;
239+ SmallVector<CandidateModule , 3 > candidateModules ;
234240
235- OutOfDateModule & getOrInsertOutOfDateModule (StringRef path) {
236- for (auto &mod : outOfDateModules ) {
241+ CandidateModule & getOrInsertCandidateModule (StringRef path) {
242+ for (auto &mod : candidateModules ) {
237243 if (mod.path == path) return mod;
238244 }
239- outOfDateModules.push_back ({path.str (), None, ModuleKind::Normal, {}, {}});
240- return outOfDateModules.back ();
245+ candidateModules.push_back ({path.str (),
246+ None,
247+ ModuleKind::Normal,
248+ ReasonIgnored::NotIgnored,
249+ {},
250+ {}});
251+ return candidateModules.back ();
241252 }
242253
243254 // / Sets the kind of a module that failed to load.
244255 void setModuleKind (StringRef path, ModuleKind kind) {
245- getOrInsertOutOfDateModule (path).kind = kind;
256+ getOrInsertCandidateModule (path).kind = kind;
246257 }
247258
248259 // / Sets the serialization status of the module at \c path. If this is
249260 // / anything other than \c Valid, a note will be added stating why the module
250261 // / was invalid.
251262 void setSerializationStatus (StringRef path, serialization::Status status) {
252- getOrInsertOutOfDateModule (path).serializationStatus = status;
263+ getOrInsertCandidateModule (path).serializationStatus = status;
253264 }
254265
255266 // / Registers an out-of-date dependency at \c depPath for the module
256267 // / at \c modulePath.
257268 void addOutOfDateDependency (StringRef modulePath, StringRef depPath) {
258- getOrInsertOutOfDateModule (modulePath)
269+ getOrInsertCandidateModule (modulePath)
259270 .outOfDateDependencies .push_back (depPath.str ());
260271 }
261272
262273 // / Registers a missing dependency at \c depPath for the module
263274 // / at \c modulePath.
264275 void addMissingDependency (StringRef modulePath, StringRef depPath) {
265- getOrInsertOutOfDateModule (modulePath)
276+ getOrInsertCandidateModule (modulePath)
266277 .missingDependencies .push_back (depPath.str ());
267278 }
268279
280+ // / Sets the reason that the module at \c path was ignored. If this is
281+ // / anything besides \c NotIgnored a note will be added stating why the module
282+ // / was ignored.
283+ void addIgnoredModule (StringRef modulePath, ReasonIgnored reasonIgnored) {
284+ getOrInsertCandidateModule (modulePath).reasonIgnored = reasonIgnored;
285+ }
286+
269287 // / Determines if we saw the given module path and registered is as out of
270288 // / date.
271289 bool sawOutOfDateModule (StringRef modulePath) {
272- for (auto &mod : outOfDateModules)
273- if (mod.path == modulePath)
290+ for (auto &mod : candidateModules)
291+ if (mod.path == modulePath &&
292+ mod.reasonIgnored == ReasonIgnored::NotIgnored)
274293 return true ;
275294 return false ;
276295 }
@@ -310,9 +329,15 @@ struct ModuleRebuildInfo {
310329 }
311330 // We may have found multiple failing modules, that failed for different
312331 // reasons. Emit a note for each of them.
313- for (auto &mod : outOfDateModules) {
314- diags.diagnose (loc, diag::out_of_date_module_here,
315- (unsigned )mod.kind , mod.path );
332+ for (auto &mod : candidateModules) {
333+ // If a the compiled module was ignored, diagnose the reason.
334+ if (mod.reasonIgnored != ReasonIgnored::NotIgnored) {
335+ diags.diagnose (loc, diag::compiled_module_ignored_reason, mod.path ,
336+ (unsigned )mod.reasonIgnored );
337+ } else {
338+ diags.diagnose (loc, diag::out_of_date_module_here, (unsigned )mod.kind ,
339+ mod.path );
340+ }
316341
317342 // Diagnose any out-of-date dependencies in this module.
318343 for (auto &dep : mod.outOfDateDependencies ) {
@@ -677,6 +702,7 @@ class ModuleInterfaceLoaderImpl {
677702 }
678703
679704 std::pair<std::string, std::string> getCompiledModuleCandidates () {
705+ using ReasonIgnored = ModuleRebuildInfo::ReasonIgnored;
680706 std::pair<std::string, std::string> result;
681707 // Should we attempt to load a swiftmodule adjacent to the swiftinterface?
682708 bool shouldLoadAdjacentModule = !ctx.IgnoreAdjacentModules ;
@@ -690,6 +716,7 @@ class ModuleInterfaceLoaderImpl {
690716 if (!ctx.SearchPathOpts .getSDKPath ().empty () &&
691717 modulePath.startswith (publicFrameworksPath)) {
692718 shouldLoadAdjacentModule = false ;
719+ rebuildInfo.addIgnoredModule (modulePath, ReasonIgnored::PublicFramework);
693720 }
694721
695722 switch (loadMode) {
@@ -702,6 +729,8 @@ class ModuleInterfaceLoaderImpl {
702729 // skip the module adjacent to the interface, but use the caches if
703730 // they're present.
704731 shouldLoadAdjacentModule = false ;
732+ rebuildInfo.addIgnoredModule (modulePath,
733+ ReasonIgnored::InterfacePreferred);
705734 break ;
706735 case ModuleLoadingMode::PreferSerialized:
707736 // The rest of the function should be covered by this.
0 commit comments