Skip to content

Commit a503bd6

Browse files
committed
[Serialization] Intro the DESERIALIZATION_SAFETY record format
The DESERIALIZATION_SAFETY record will be used by the deserialization safety feature to identify decls that are unsafe to read so they can be skipped.
1 parent d95d093 commit a503bd6

File tree

4 files changed

+12
-1
lines changed

4 files changed

+12
-1
lines changed

lib/Serialization/DeclTypeRecordNodes.def

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,8 @@ OTHER(LOCAL_DISCRIMINATOR, 127)
182182
OTHER(PRIVATE_DISCRIMINATOR, 128)
183183
OTHER(FILENAME_FOR_PRIVATE, 129)
184184

185+
OTHER(DESERIALIZATION_SAFETY, 130)
186+
185187
// 140 is unused; was ABSTRACT_PROTOCOL_CONFORMANCE
186188
OTHER(NORMAL_PROTOCOL_CONFORMANCE, 141)
187189
OTHER(SPECIALIZED_PROTOCOL_CONFORMANCE, 142)

lib/Serialization/Deserialization.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5411,6 +5411,9 @@ llvm::Error DeclDeserializer::deserializeDeclCommon() {
54115411
IdentifierID filenameID;
54125412
decls_block::FilenameForPrivateLayout::readRecord(scratch, filenameID);
54135413
filenameForPrivate = MF.getIdentifierText(filenameID);
5414+
} else if (recordID == decls_block::DESERIALIZATION_SAFETY) {
5415+
IdentifierID declID;
5416+
decls_block::DeserializationSafetyLayout::readRecord(scratch, declID);
54145417
} else {
54155418
return llvm::Error::success();
54165419
}

lib/Serialization/ModuleFormat.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ const uint16_t SWIFTMODULE_VERSION_MAJOR = 0;
5858
/// describe what change you made. The content of this comment isn't important;
5959
/// it just ensures a conflict if two people change the module format.
6060
/// Don't worry about adhering to the 80-column limit for this line.
61-
const uint16_t SWIFTMODULE_VERSION_MINOR = 731; // macro definition
61+
const uint16_t SWIFTMODULE_VERSION_MINOR = 732; // deserialization safety
6262

6363
/// A standard hash seed used for all string hashes in a serialized module.
6464
///
@@ -1809,6 +1809,11 @@ namespace decls_block {
18091809
IdentifierIDField // the file name, as an identifier
18101810
>;
18111811

1812+
using DeserializationSafetyLayout = BCRecordLayout<
1813+
DESERIALIZATION_SAFETY,
1814+
IdentifierIDField // name to debug access to unsafe decl
1815+
>;
1816+
18121817
using NormalProtocolConformanceLayout = BCRecordLayout<
18131818
NORMAL_PROTOCOL_CONFORMANCE,
18141819
DeclIDField, // the protocol

lib/Serialization/Serialization.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5336,6 +5336,7 @@ void Serializer::writeAllDeclsAndTypes() {
53365336
registerDeclTypeAbbr<LocalDiscriminatorLayout>();
53375337
registerDeclTypeAbbr<PrivateDiscriminatorLayout>();
53385338
registerDeclTypeAbbr<FilenameForPrivateLayout>();
5339+
registerDeclTypeAbbr<DeserializationSafetyLayout>();
53395340
registerDeclTypeAbbr<MembersLayout>();
53405341
registerDeclTypeAbbr<XRefLayout>();
53415342

0 commit comments

Comments
 (0)