@@ -79,7 +79,7 @@ extension SerializedDiagnostics {
79
79
/// Fix-its associated with the diagnostic.
80
80
public var fixIts : [ FixIt ]
81
81
82
- fileprivate init ( records: [ BitcodeElement . Record ] ,
82
+ fileprivate init ( records: [ SerializedDiagnostics . OwnedRecord ] ,
83
83
filenameMap: inout [ UInt64 : String ] ,
84
84
flagMap: inout [ UInt64 : String ] ,
85
85
categoryMap: inout [ UInt64 : String ] ) throws {
@@ -184,7 +184,7 @@ extension SerializedDiagnostics {
184
184
/// Clang includes this, it is set to 0 by Swift.
185
185
public var offset : UInt64
186
186
187
- fileprivate init ? ( fields: Slice < UnsafeBufferPointer < UInt64 > > ,
187
+ fileprivate init ? ( fields: ArraySlice < UInt64 > ,
188
188
filenameMap: [ UInt64 : String ] ) {
189
189
guard let filename = filenameMap [ fields [ fields. startIndex] ] else { return nil }
190
190
self . filename = filename
@@ -214,7 +214,7 @@ extension SerializedDiagnostics {
214
214
var flagMap = [ UInt64: String] ( )
215
215
var categoryMap = [ UInt64: String] ( )
216
216
217
- var currentDiagnosticRecords : [ BitcodeElement . Record ] = [ ]
217
+ var currentDiagnosticRecords : [ OwnedRecord ] = [ ]
218
218
219
219
func validate( signature: Bitcode . Signature ) throws {
220
220
guard signature == . init( string: " DIAG " ) else { throw Error . badMagic }
@@ -247,10 +247,44 @@ extension SerializedDiagnostics {
247
247
}
248
248
versionNumber = Int ( record. fields [ 0 ] )
249
249
case . diagnostic:
250
- currentDiagnosticRecords. append ( record)
250
+ currentDiagnosticRecords. append ( SerializedDiagnostics . OwnedRecord ( record) )
251
251
case nil :
252
252
throw Error . unexpectedTopLevelRecord
253
253
}
254
254
}
255
255
}
256
256
}
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