Skip to content

Commit 2dfd569

Browse files
[NFC] Don't crash when we see an empty filename for a module. (#30099)
Fixes rdar://problem/59769612.
1 parent 869e579 commit 2dfd569

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

lib/FrontendTool/FrontendTool.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -419,11 +419,16 @@ static bool emitLoadedModuleTraceIfNeeded(ModuleDecl *mainModule,
419419
llvm::report_fatal_error("Expected loaded modules to be non-null.");
420420
if (loadedDecl == mainModule)
421421
continue;
422-
if (loadedDecl->getModuleFilename().empty())
423-
llvm::report_fatal_error(
424-
"Don't know how to handle modules with empty names."
425-
" One potential reason for getting an empty module name might"
426-
" be that the module could not be deserialized correctly.");
422+
if (loadedDecl->getModuleFilename().empty()) {
423+
// FIXME: rdar://problem/59853077
424+
// Ideally, this shouldn't happen. As a temporary workaround, avoid
425+
// crashing with a message while we investigate the problem.
426+
llvm::errs() << "WARNING: Module '" << loadedDecl->getName().str()
427+
<< "' has an empty filename. This is probably an "
428+
<< "invariant violation.\n"
429+
<< "Please report it as a compiler bug.\n";
430+
continue;
431+
}
427432
pathToModuleDecl.insert(
428433
std::make_pair(loadedDecl->getModuleFilename(), loadedDecl));
429434
}

0 commit comments

Comments
 (0)