@@ -241,12 +241,15 @@ template <> struct ObjectTraits<LoadedModuleTraceFormat> {
241
241
static bool emitLoadedModuleTraceIfNeeded (ModuleDecl *mainModule,
242
242
DependencyTracker *depTracker,
243
243
StringRef loadedModuleTracePath) {
244
+ ASTContext &ctxt = mainModule->getASTContext ();
245
+ assert (!ctxt.hadError ()
246
+ && " We may not be able to emit a proper trace if there was an error." );
247
+
244
248
if (loadedModuleTracePath.empty ())
245
249
return false ;
246
250
std::error_code EC;
247
251
llvm::raw_fd_ostream out (loadedModuleTracePath, EC, llvm::sys::fs::F_Append);
248
252
249
- ASTContext &ctxt = mainModule->getASTContext ();
250
253
if (out.has_error () || EC) {
251
254
ctxt.Diags .diagnose (SourceLoc (), diag::error_opening_output,
252
255
loadedModuleTracePath, EC.message ());
@@ -271,7 +274,9 @@ static bool emitLoadedModuleTraceIfNeeded(ModuleDecl *mainModule,
271
274
if (loadedDecl == mainModule)
272
275
continue ;
273
276
assert (!loadedDecl->getModuleFilename ().empty ()
274
- && " Don't know how to handle modules with empty names." );
277
+ && (" Don't know how to handle modules with empty names."
278
+ " One potential reason for getting an empty module name might"
279
+ " be that the module could not be deserialized correctly." ));
275
280
pathToModuleDecl.insert (
276
281
std::make_pair (loadedDecl->getModuleFilename (), loadedDecl));
277
282
}
@@ -1089,15 +1094,15 @@ static bool performCompile(CompilerInstance &Instance,
1089
1094
1090
1095
emitReferenceDependenciesForAllPrimaryInputsIfNeeded (Invocation, Instance);
1091
1096
1092
- (void )emitLoadedModuleTraceForAllPrimariesIfNeeded (
1093
- Instance.getMainModule (), Instance.getDependencyTracker (), opts);
1094
-
1095
1097
if (Context.hadError ()) {
1096
1098
// Emit the index store data even if there were compiler errors.
1097
1099
(void )emitIndexData (Invocation, Instance);
1098
1100
return true ;
1099
1101
}
1100
1102
1103
+ (void )emitLoadedModuleTraceForAllPrimariesIfNeeded (
1104
+ Instance.getMainModule (), Instance.getDependencyTracker (), opts);
1105
+
1101
1106
// FIXME: This is still a lousy approximation of whether the module file will
1102
1107
// be externally consumed.
1103
1108
bool moduleIsPublic =
0 commit comments