mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Refactor and Break Down TypeSerializer
This class is a perennial source of bugs when we add new type nodes because there is no signal when you forget to update it since it's just comparing record IDs in the switch. Break this class down and add new macros that enforce structural checks and require exhaustiveness at compile time. This TYPE_LAYOUT(...) macro replaces the usual \c BCRecordLayout coding structure by enforcing structural checks for the definition of deserialization members. If you forget to define a TYPE_LAYOUT(...) for a TYPE(...) there will be a gnarly SFINAE error pointing at it in DeclTypeRecordNodes.def. This macro pairs with \c DESERIALIZE_TYPE(...) in Deserialization.cpp such that if you forget \c DESERIALIZE_TYPE(...) you will come up with a linker error.
This commit is contained in:
@@ -56,6 +56,9 @@ class ModuleFile
|
||||
friend class TypeDeserializer;
|
||||
friend class SILDeserializer;
|
||||
friend class ProtocolConformanceDeserializer;
|
||||
template <serialization::decls_block::detail::TypeRecords TypeRecord>
|
||||
friend class serialization::decls_block::detail::TypeRecordDispatch;
|
||||
friend struct serialization::decls_block::detail::function_deserializer;
|
||||
using Status = serialization::Status;
|
||||
using TypeID = serialization::TypeID;
|
||||
using ProtocolConformanceID = serialization::ProtocolConformanceID;
|
||||
|
||||
Reference in New Issue
Block a user