mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[Serialization] Split ModuleFile fatal and non-fatal errors
`ModuleFile::error` was being used both for errors of initial parse and configuration (non-fatal) and format errors during actual deserialization (fatal, indicating a corrupted module). Split out the latter to `ModuleFile::fatal()` (to go with the existing `ModuleFile::fatal(llvm::Error)`) and be more consistent about explicitly setting statuses for the former. Since 'fatal()' is always fatal, this also allows deleting dummy recovery code that would never be used in practice.
This commit is contained in:
@@ -1251,7 +1251,7 @@ ModuleFile::ModuleFile(
|
||||
|
||||
if (!checkModuleSignature(cursor, SWIFTMODULE_SIGNATURE) ||
|
||||
!enterTopLevelModuleBlock(cursor, MODULE_BLOCK_ID)) {
|
||||
error();
|
||||
info.status = error(Status::Malformed);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1290,7 +1290,7 @@ ModuleFile::ModuleFile(
|
||||
|
||||
case INPUT_BLOCK_ID: {
|
||||
if (!hasValidControlBlock) {
|
||||
error();
|
||||
info.status = error(Status::Malformed);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1311,7 +1311,7 @@ ModuleFile::ModuleFile(
|
||||
auto importKind = getActualImportControl(rawImportControl);
|
||||
if (!importKind) {
|
||||
// We don't know how to import this dependency.
|
||||
error();
|
||||
info.status = error(Status::Malformed);
|
||||
return;
|
||||
}
|
||||
Dependencies.push_back({blobData, importKind.getValue(), scoped});
|
||||
@@ -1367,14 +1367,14 @@ ModuleFile::ModuleFile(
|
||||
}
|
||||
|
||||
if (next.Kind != llvm::BitstreamEntry::EndBlock)
|
||||
error();
|
||||
info.status = error(Status::Malformed);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case DECLS_AND_TYPES_BLOCK_ID: {
|
||||
if (!hasValidControlBlock) {
|
||||
error();
|
||||
info.status = error(Status::Malformed);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1383,11 +1383,11 @@ ModuleFile::ModuleFile(
|
||||
DeclTypeCursor = cursor;
|
||||
DeclTypeCursor.EnterSubBlock(DECLS_AND_TYPES_BLOCK_ID);
|
||||
if (DeclTypeCursor.advance().Kind == llvm::BitstreamEntry::Error)
|
||||
error();
|
||||
info.status = error(Status::Malformed);
|
||||
|
||||
// With the main cursor, skip over the block and continue.
|
||||
if (cursor.SkipBlock()) {
|
||||
error();
|
||||
info.status = error(Status::Malformed);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
@@ -1395,7 +1395,7 @@ ModuleFile::ModuleFile(
|
||||
|
||||
case IDENTIFIER_DATA_BLOCK_ID: {
|
||||
if (!hasValidControlBlock) {
|
||||
error();
|
||||
info.status = error(Status::Malformed);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1422,7 +1422,7 @@ ModuleFile::ModuleFile(
|
||||
}
|
||||
|
||||
if (next.Kind != llvm::BitstreamEntry::EndBlock) {
|
||||
error();
|
||||
info.status = error(Status::Malformed);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1431,7 +1431,7 @@ ModuleFile::ModuleFile(
|
||||
|
||||
case INDEX_BLOCK_ID: {
|
||||
if (!hasValidControlBlock || !readIndexBlock(cursor)) {
|
||||
error();
|
||||
info.status = error(Status::Malformed);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
@@ -1444,7 +1444,7 @@ ModuleFile::ModuleFile(
|
||||
|
||||
// With the main cursor, skip over the block and continue.
|
||||
if (cursor.SkipBlock()) {
|
||||
error();
|
||||
info.status = error(Status::Malformed);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
@@ -1457,7 +1457,7 @@ ModuleFile::ModuleFile(
|
||||
|
||||
// With the main cursor, skip over the block and continue.
|
||||
if (cursor.SkipBlock()) {
|
||||
error();
|
||||
info.status = error(Status::Malformed);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
@@ -1467,7 +1467,7 @@ ModuleFile::ModuleFile(
|
||||
// Unknown top-level block, possibly for use by a future version of the
|
||||
// module format.
|
||||
if (cursor.SkipBlock()) {
|
||||
error();
|
||||
info.status = error(Status::Malformed);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
@@ -1475,12 +1475,12 @@ ModuleFile::ModuleFile(
|
||||
}
|
||||
|
||||
if (topLevelEntry.Kind != llvm::BitstreamEntry::EndBlock) {
|
||||
error();
|
||||
info.status = error(Status::Malformed);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!readModuleDocIfPresent()) {
|
||||
error(Status::MalformedDocumentation);
|
||||
info.status = error(Status::MalformedDocumentation);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -1999,7 +1999,7 @@ ModuleFile::loadNamedMembers(const IterableDeclContext *IDC, DeclBaseName N,
|
||||
DeclMemberTablesCursor.JumpToBit(subTableOffset);
|
||||
auto entry = DeclMemberTablesCursor.advance();
|
||||
if (entry.Kind != llvm::BitstreamEntry::Record) {
|
||||
error();
|
||||
fatal();
|
||||
return None;
|
||||
}
|
||||
SmallVector<uint64_t, 64> scratch;
|
||||
|
||||
Reference in New Issue
Block a user