@@ -79,7 +79,7 @@ extension SerializedDiagnostics {
7979 /// Fix-its associated with the diagnostic.
8080 public var fixIts : [ FixIt ]
8181
82- fileprivate init ( records: [ BitcodeElement . Record ] ,
82+ fileprivate init ( records: [ SerializedDiagnostics . OwnedRecord ] ,
8383 filenameMap: inout [ UInt64 : String ] ,
8484 flagMap: inout [ UInt64 : String ] ,
8585 categoryMap: inout [ UInt64 : String ] ) throws {
@@ -184,7 +184,7 @@ extension SerializedDiagnostics {
184184 /// Clang includes this, it is set to 0 by Swift.
185185 public var offset : UInt64
186186
187- fileprivate init ? ( fields: Slice < UnsafeBufferPointer < UInt64 > > ,
187+ fileprivate init ? ( fields: ArraySlice < UInt64 > ,
188188 filenameMap: [ UInt64 : String ] ) {
189189 guard let filename = filenameMap [ fields [ fields. startIndex] ] else { return nil }
190190 self . filename = filename
@@ -214,7 +214,7 @@ extension SerializedDiagnostics {
214214 var flagMap = [ UInt64: String] ( )
215215 var categoryMap = [ UInt64: String] ( )
216216
217- var currentDiagnosticRecords : [ BitcodeElement . Record ] = [ ]
217+ var currentDiagnosticRecords : [ OwnedRecord ] = [ ]
218218
219219 func validate( signature: Bitcode . Signature ) throws {
220220 guard signature == . init( string: " DIAG " ) else { throw Error . badMagic }
@@ -247,10 +247,44 @@ extension SerializedDiagnostics {
247247 }
248248 versionNumber = Int ( record. fields [ 0 ] )
249249 case . diagnostic:
250- currentDiagnosticRecords. append ( record)
250+ currentDiagnosticRecords. append ( SerializedDiagnostics . OwnedRecord ( record) )
251251 case nil :
252252 throw Error . unexpectedTopLevelRecord
253253 }
254254 }
255255 }
256256}
257+
258+ extension SerializedDiagnostics {
259+ struct OwnedRecord {
260+ public enum Payload {
261+ case none
262+ case array( [ UInt64 ] )
263+ case char6String( String )
264+ case blob( [ UInt8 ] )
265+
266+ init ( _ payload: BitcodeElement . Record . Payload ) {
267+ switch payload {
268+ case . none:
269+ self = . none
270+ case . array( let a) :
271+ self = . array( Array ( a) )
272+ case . char6String( let s) :
273+ self = . char6String( s)
274+ case . blob( let b) :
275+ self = . blob( Array ( b) )
276+ }
277+ }
278+ }
279+
280+ public var id : UInt64
281+ public var fields : [ UInt64 ]
282+ public var payload : Payload
283+
284+ init ( _ record: BitcodeElement . Record ) {
285+ self . id = record. id
286+ self . fields = Array ( record. fields)
287+ self . payload = Payload ( record. payload)
288+ }
289+ }
290+ }
0 commit comments