@@ -223,54 +223,73 @@ struct ModuleRebuildInfo {
223
223
Forwarding,
224
224
Prebuilt
225
225
};
226
- struct OutOfDateModule {
226
+ enum class ReasonIgnored {
227
+ NotIgnored,
228
+ PublicFramework,
229
+ InterfacePreferred,
230
+ };
231
+ struct CandidateModule {
227
232
std::string path;
228
233
Optional<serialization::Status> serializationStatus;
229
234
ModuleKind kind;
235
+ ReasonIgnored reasonIgnored;
230
236
SmallVector<std::string, 10 > outOfDateDependencies;
231
237
SmallVector<std::string, 10 > missingDependencies;
232
238
};
233
- SmallVector<OutOfDateModule , 3 > outOfDateModules ;
239
+ SmallVector<CandidateModule , 3 > candidateModules ;
234
240
235
- OutOfDateModule & getOrInsertOutOfDateModule (StringRef path) {
236
- for (auto &mod : outOfDateModules ) {
241
+ CandidateModule & getOrInsertCandidateModule (StringRef path) {
242
+ for (auto &mod : candidateModules ) {
237
243
if (mod.path == path) return mod;
238
244
}
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 ();
241
252
}
242
253
243
254
// / Sets the kind of a module that failed to load.
244
255
void setModuleKind (StringRef path, ModuleKind kind) {
245
- getOrInsertOutOfDateModule (path).kind = kind;
256
+ getOrInsertCandidateModule (path).kind = kind;
246
257
}
247
258
248
259
// / Sets the serialization status of the module at \c path. If this is
249
260
// / anything other than \c Valid, a note will be added stating why the module
250
261
// / was invalid.
251
262
void setSerializationStatus (StringRef path, serialization::Status status) {
252
- getOrInsertOutOfDateModule (path).serializationStatus = status;
263
+ getOrInsertCandidateModule (path).serializationStatus = status;
253
264
}
254
265
255
266
// / Registers an out-of-date dependency at \c depPath for the module
256
267
// / at \c modulePath.
257
268
void addOutOfDateDependency (StringRef modulePath, StringRef depPath) {
258
- getOrInsertOutOfDateModule (modulePath)
269
+ getOrInsertCandidateModule (modulePath)
259
270
.outOfDateDependencies .push_back (depPath.str ());
260
271
}
261
272
262
273
// / Registers a missing dependency at \c depPath for the module
263
274
// / at \c modulePath.
264
275
void addMissingDependency (StringRef modulePath, StringRef depPath) {
265
- getOrInsertOutOfDateModule (modulePath)
276
+ getOrInsertCandidateModule (modulePath)
266
277
.missingDependencies .push_back (depPath.str ());
267
278
}
268
279
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
+
269
287
// / Determines if we saw the given module path and registered is as out of
270
288
// / date.
271
289
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)
274
293
return true ;
275
294
return false ;
276
295
}
@@ -310,9 +329,15 @@ struct ModuleRebuildInfo {
310
329
}
311
330
// We may have found multiple failing modules, that failed for different
312
331
// 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
+ }
316
341
317
342
// Diagnose any out-of-date dependencies in this module.
318
343
for (auto &dep : mod.outOfDateDependencies ) {
@@ -677,6 +702,7 @@ class ModuleInterfaceLoaderImpl {
677
702
}
678
703
679
704
std::pair<std::string, std::string> getCompiledModuleCandidates () {
705
+ using ReasonIgnored = ModuleRebuildInfo::ReasonIgnored;
680
706
std::pair<std::string, std::string> result;
681
707
// Should we attempt to load a swiftmodule adjacent to the swiftinterface?
682
708
bool shouldLoadAdjacentModule = !ctx.IgnoreAdjacentModules ;
@@ -690,6 +716,7 @@ class ModuleInterfaceLoaderImpl {
690
716
if (!ctx.SearchPathOpts .getSDKPath ().empty () &&
691
717
modulePath.startswith (publicFrameworksPath)) {
692
718
shouldLoadAdjacentModule = false ;
719
+ rebuildInfo.addIgnoredModule (modulePath, ReasonIgnored::PublicFramework);
693
720
}
694
721
695
722
switch (loadMode) {
@@ -702,6 +729,8 @@ class ModuleInterfaceLoaderImpl {
702
729
// skip the module adjacent to the interface, but use the caches if
703
730
// they're present.
704
731
shouldLoadAdjacentModule = false ;
732
+ rebuildInfo.addIgnoredModule (modulePath,
733
+ ReasonIgnored::InterfacePreferred);
705
734
break ;
706
735
case ModuleLoadingMode::PreferSerialized:
707
736
// The rest of the function should be covered by this.
0 commit comments