@@ -82,13 +82,17 @@ public struct DebugInfoFlags: OptionSet {
82
82
83
83
/// Source languages known by DWARF.
84
84
public enum DWARFSourceLanguage {
85
+ case ada83
86
+
87
+ case ada95
88
+
85
89
case c
86
90
87
91
case c89
88
92
89
- case c11
93
+ case c99
90
94
91
- case ada83
95
+ case c11
92
96
93
97
case cPlusPlus
94
98
@@ -106,16 +110,16 @@ public enum DWARFSourceLanguage {
106
110
107
111
case fortran90
108
112
113
+ case fortran03
114
+
115
+ case fortran08
116
+
109
117
case pascal83
110
118
111
119
case modula2
112
120
113
121
case java
114
122
115
- case c99
116
-
117
- case ada95
118
-
119
123
case fortran95
120
124
121
125
case PLI
@@ -147,10 +151,6 @@ public enum DWARFSourceLanguage {
147
151
case julia
148
152
149
153
case dylan
150
-
151
- case fortran03
152
-
153
- case fortran08
154
154
155
155
case renderScript
156
156
@@ -163,6 +163,53 @@ public enum DWARFSourceLanguage {
163
163
case googleRenderScript
164
164
165
165
case borlandDelphi
166
+
167
+
168
+ private static let languageMapping : [ DWARFSourceLanguage : LLVMDWARFSourceLanguage ] = [
169
+ . c: LLVMDWARFSourceLanguageC, . c89: LLVMDWARFSourceLanguageC89,
170
+ . c99: LLVMDWARFSourceLanguageC99, . c11: LLVMDWARFSourceLanguageC11,
171
+ . ada83: LLVMDWARFSourceLanguageAda83,
172
+ . cPlusPlus: LLVMDWARFSourceLanguageC_plus_plus,
173
+ . cPlusPlus03: LLVMDWARFSourceLanguageC_plus_plus_03,
174
+ . cPlusPlus11: LLVMDWARFSourceLanguageC_plus_plus_11,
175
+ . cPlusPlus14: LLVMDWARFSourceLanguageC_plus_plus_14,
176
+ . cobol74: LLVMDWARFSourceLanguageCobol74,
177
+ . cobol85: LLVMDWARFSourceLanguageCobol85,
178
+ . fortran77: LLVMDWARFSourceLanguageFortran77,
179
+ . fortran90: LLVMDWARFSourceLanguageFortran90,
180
+ . pascal83: LLVMDWARFSourceLanguagePascal83,
181
+ . modula2: LLVMDWARFSourceLanguageModula2,
182
+ . java: LLVMDWARFSourceLanguageJava,
183
+ . ada95: LLVMDWARFSourceLanguageAda95,
184
+ . fortran95: LLVMDWARFSourceLanguageFortran95,
185
+ . PLI: LLVMDWARFSourceLanguagePLI,
186
+ . objC: LLVMDWARFSourceLanguageObjC,
187
+ . objCPlusPlus: LLVMDWARFSourceLanguageObjC_plus_plus,
188
+ . UPC: LLVMDWARFSourceLanguageUPC,
189
+ . D: LLVMDWARFSourceLanguageD,
190
+ . python: LLVMDWARFSourceLanguagePython,
191
+ . openCL: LLVMDWARFSourceLanguageOpenCL,
192
+ . go: LLVMDWARFSourceLanguageGo,
193
+ . modula3: LLVMDWARFSourceLanguageModula3,
194
+ . haskell: LLVMDWARFSourceLanguageHaskell,
195
+ . ocaml: LLVMDWARFSourceLanguageOCaml,
196
+ . rust: LLVMDWARFSourceLanguageRust,
197
+ . swift: LLVMDWARFSourceLanguageSwift,
198
+ . julia: LLVMDWARFSourceLanguageJulia,
199
+ . dylan: LLVMDWARFSourceLanguageDylan,
200
+ . fortran03: LLVMDWARFSourceLanguageFortran03,
201
+ . fortran08: LLVMDWARFSourceLanguageFortran08,
202
+ . renderScript: LLVMDWARFSourceLanguageRenderScript,
203
+ . BLISS: LLVMDWARFSourceLanguageBLISS,
204
+ . mipsAssembler: LLVMDWARFSourceLanguageMips_Assembler,
205
+ . googleRenderScript: LLVMDWARFSourceLanguageGOOGLE_RenderScript,
206
+ . borlandDelphi: LLVMDWARFSourceLanguageBORLAND_Delphi,
207
+ ]
208
+
209
+ /// Retrieves the corresponding `LLVMDWARFSourceLanguage`.
210
+ public var llvm : LLVMDWARFSourceLanguage {
211
+ return DWARFSourceLanguage . languageMapping [ self ] !
212
+ }
166
213
}
167
214
168
215
/// Qualifiers for types, e.g. \c const.
@@ -403,6 +450,16 @@ public enum DWARFEmissionKind {
403
450
case none
404
451
case full
405
452
case lineTablesOnly
453
+
454
+ private static let emissionMapping : [ DWARFEmissionKind : LLVMDWARFEmissionKind ] = [
455
+ . none: LLVMDWARFEmissionNone, . full: LLVMDWARFEmissionFull,
456
+ . lineTablesOnly: LLVMDWARFEmissionLineTablesOnly,
457
+ ]
458
+
459
+ /// Retrieves the corresponding `LLVMDWARFEmissionKind`.
460
+ public var llvm : LLVMDWARFEmissionKind {
461
+ return DWARFEmissionKind . emissionMapping [ self ] !
462
+ }
406
463
}
407
464
408
465
public protocol Metadata {
@@ -461,6 +518,15 @@ public struct DIModule: Metadata {
461
518
}
462
519
}
463
520
521
+ public struct DICompileUnit : Metadata {
522
+ internal let llvm : LLVMMetadataRef
523
+
524
+ public func asMetadata( ) -> LLVMMetadataRef {
525
+ return llvm
526
+ }
527
+ }
528
+
529
+
464
530
public struct DebugLocation : Metadata {
465
531
internal let llvm : LLVMMetadataRef
466
532
@@ -480,6 +546,55 @@ public final class DIBuilder {
480
546
self . llvm = LLVMDIBuilderCreate ( module. llvm, allowUnresolved ? 1 : 0 )
481
547
}
482
548
549
+ /// A CompileUnit provides an anchor for all debugging
550
+ /// information generated during this instance of compilation.
551
+ /// \param Lang Source programming language, eg.
552
+ /// \c LLVMDWARFSourceLanguageC99
553
+ /// \param File File info.
554
+ /// \param Producer Identify the producer of debugging information
555
+ /// and code. Usually this is a compiler
556
+ /// version string.
557
+ /// \param isOptimized A boolean flag which indicates whether optimization
558
+ /// is enabled or not.
559
+ /// \param Flags This string lists command line options. This
560
+ /// string is directly embedded in debug info
561
+ /// output which may be used by a tool
562
+ /// analyzing generated debugging information.
563
+ /// \param RuntimeVer This indicates runtime version for languages like
564
+ /// Objective-C.
565
+ /// \param SplitName The name of the file that we'll split debug info
566
+ /// out into.
567
+ /// \param Kind The kind of debug information to generate.
568
+ /// \param DWOId The DWOId if this is a split skeleton compile unit.
569
+ /// \param SplitDebugInlining Whether to emit inline debug info.
570
+ /// \param DebugInfoForProfiling Whether to emit extra debug info for
571
+ /// profile collection.
572
+ public func createCompileUnit(
573
+ for lang: DWARFSourceLanguage ,
574
+ in file: FileMetadata ,
575
+ identity: String = " " ,
576
+ optimized: Bool ,
577
+ flags: [ String ] ,
578
+ runtimeVersion: Int ,
579
+ splitName: String ,
580
+ kind: DWARFEmissionKind ,
581
+ DWOId: UInt64 ,
582
+ splitDebugInlining: Bool ,
583
+ debugInfoForProfiling: Bool
584
+ ) -> DICompileUnit {
585
+ guard let cu = LLVMDIBuilderCreateCompileUnit (
586
+ self . llvm, lang. llvm, file. llvm, identity,
587
+ optimized ? 1 : 0 ,
588
+ flags. joined ( separator: " " ) , UInt32 ( runtimeVersion) , splitName,
589
+ kind. llvm, DWOId,
590
+ splitDebugInlining ? 1 : 0 ,
591
+ debugInfoForProfiling ? 1 : 0
592
+ ) else {
593
+ fatalError ( )
594
+ }
595
+ return DICompileUnit ( llvm: cu)
596
+ }
597
+
483
598
/// Creates a new DebugLocation that describes a source location.
484
599
public func createDebugLocation( at loc : ( line: Int , column: Int ) , in scope: Scope , inlinedAt: Scope ? = nil ) -> DebugLocation {
485
600
guard let loc = LLVMDIBuilderCreateDebugLocation ( self . module. context. llvm, UInt32 ( loc. line) , UInt32 ( loc. column) , scope. llvm, inlinedAt? . llvm) else {
@@ -563,30 +678,7 @@ public final class DIBuilder {
563
678
}
564
679
565
680
/*
566
- /// A CompileUnit provides an anchor for all debugging
567
- /// information generated during this instance of compilation.
568
- /// \param Lang Source programming language, eg.
569
- /// \c LLVMDWARFSourceLanguageC99
570
- /// \param File File info.
571
- /// \param Producer Identify the producer of debugging information
572
- /// and code. Usually this is a compiler
573
- /// version string.
574
- /// \param isOptimized A boolean flag which indicates whether optimization
575
- /// is enabled or not.
576
- /// \param Flags This string lists command line options. This
577
- /// string is directly embedded in debug info
578
- /// output which may be used by a tool
579
- /// analyzing generated debugging information.
580
- /// \param RuntimeVer This indicates runtime version for languages like
581
- /// Objective-C.
582
- /// \param SplitName The name of the file that we'll split debug info
583
- /// out into.
584
- /// \param Kind The kind of debug information to generate.
585
- /// \param DWOId The DWOId if this is a split skeleton compile unit.
586
- /// \param SplitDebugInlining Whether to emit inline debug info.
587
- /// \param DebugInfoForProfiling Whether to emit extra debug info for
588
- /// profile collection.
589
- public func LLVMDIBuilderCreateCompileUnit(_ Builder: LLVMDIBuilderRef!, _ Lang: LLVMDWARFSourceLanguage, _ FileRef: LLVMMetadataRef!, _ Producer: UnsafePointer<Int8>!, _ isOptimized: UInt8, _ Flags: UnsafePointer<Int8>!, _ RuntimeVer: UInt32, _ SplitName: UnsafePointer<Int8>!, _ Kind: LLVMDWARFEmissionKind, _ DWOId: UInt64, _ SplitDebugInlining: UInt8, _ DebugInfoForProfiling: UInt8) -> LLVMMetadataRef!
681
+
590
682
591
683
/// Create a new descriptor for the specified subprogram.
592
684
/// See comments in DISubprogram* for descriptions of these fields.
0 commit comments