mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Turn (most) deserialization errors from a crash into a fatal diagnostic (NFC)
Currently, ModuleFileSharedCore::fatal() calls abort(), which may be reasonable in a swift-frontend invocation, but has dire consequences when the Swift frontend is embedded into another process, for example, LLDB where the abort() kills the entire debugging session. This patch introduces a few alternatives to the ModuleFile::fatal() familiy of functions that instead push a fatal diagnostic to the ASTContext's DiagnosticsEngine and return an llvm::Error so the error can be roperly communicated and the ASTContext can be wound down without killing the parent process. The transition is not complete, this patch does not yet handle fatalIfUnexpected(), for example. This patch is NFC for the Swift compiler: When DebuggerSupport in off ModuleFile::diagnoseFatal() will still call abort(), but if it is on, the error will be passed up, together with a pretty stack trace. rdar://64511878
This commit is contained in:
@@ -711,11 +711,13 @@ ModuleFile::loadNamedMembers(const IterableDeclContext *IDC, DeclBaseName N,
|
||||
DeclMembersTables[subTableOffset];
|
||||
if (!subTable) {
|
||||
BCOffsetRAII restoreOffset(DeclMemberTablesCursor);
|
||||
fatalIfNotSuccess(DeclMemberTablesCursor.JumpToBit(subTableOffset));
|
||||
if (diagnoseFatalIfNotSuccess(
|
||||
DeclMemberTablesCursor.JumpToBit(subTableOffset)))
|
||||
return results;
|
||||
llvm::BitstreamEntry entry =
|
||||
fatalIfUnexpected(DeclMemberTablesCursor.advance());
|
||||
if (entry.Kind != llvm::BitstreamEntry::Record) {
|
||||
fatal();
|
||||
diagnoseAndConsumeFatal();
|
||||
return results;
|
||||
}
|
||||
SmallVector<uint64_t, 64> scratch;
|
||||
|
||||
Reference in New Issue
Block a user