1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
//! Generation of DWARF debug info.
use super::*;

// Debug info flags.
pub type LLVMDIFlags = ::libc::c_int;
pub const LLVMDIFlagZero: LLVMDIFlags = 0;
pub const LLVMDIFlagPrivate: LLVMDIFlags = 1;
pub const LLVMDIFlagProtected: LLVMDIFlags = 2;
pub const LLVMDIFlagPublic: LLVMDIFlags = 3;
pub const LLVMDIFlagFwdDecl: LLVMDIFlags = 1 << 2;
pub const LLVMDIFlagAppleBlock: LLVMDIFlags = 1 << 3;
pub const LLVMDIFlagBlockByrefStruct: LLVMDIFlags = 1 << 4;
pub const LLVMDIFlagVirtual: LLVMDIFlags = 1 << 5;
pub const LLVMDIFlagArtificial: LLVMDIFlags = 1 << 6;
pub const LLVMDIFlagExplicit: LLVMDIFlags = 1 << 7;
pub const LLVMDIFlagPrototyped: LLVMDIFlags = 1 << 8;
pub const LLVMDIFlagObjcClassComplete: LLVMDIFlags = 1 << 9;
pub const LLVMDIFlagObjectPointer: LLVMDIFlags = 1 << 10;
pub const LLVMDIFlagVector: LLVMDIFlags = 1 << 11;
pub const LLVMDIFlagStaticMember: LLVMDIFlags = 1 << 12;
pub const LLVMDIFlagLValueReference: LLVMDIFlags = 1 << 13;
pub const LLVMDIFlagRValueReference: LLVMDIFlags = 1 << 14;
pub const LLVMDIFlagReserved: LLVMDIFlags = 1 << 15;
pub const LLVMDIFlagSingleInheritance: LLVMDIFlags = 1 << 16;
pub const LLVMDIFlagMultipleInheritance: LLVMDIFlags = 2 << 16;
pub const LLVMDIFlagVirtualInheritance: LLVMDIFlags = 3 << 16;
pub const LLVMDIFlagIntroducedVirtual: LLVMDIFlags = 1 << 18;
pub const LLVMDIFlagBitField: LLVMDIFlags = 1 << 19;
pub const LLVMDIFlagNoReturn: LLVMDIFlags = 1 << 20;
pub const LLVMDIFlagTypePassByValue: LLVMDIFlags = 1 << 22;
pub const LLVMDIFlagTypePassByReference: LLVMDIFlags = 1 << 23;
pub const LLVMDIFlagFixedEnum: LLVMDIFlags = 1 << 24;
pub const LLVMDIFlagThunk: LLVMDIFlags = 1 << 25;
pub const LLVMDIFlagTrivial: LLVMDIFlags = 1 << 26;
pub const LLVMDIFlagIndirectVirtualBase: LLVMDIFlags = (1 << 2) | (1 << 5);
pub const LLVMDIFlagAccessibility: LLVMDIFlags =
    LLVMDIFlagProtected | LLVMDIFlagPrivate | LLVMDIFlagPublic;
pub const LLVMDIFlagPtrToMemberRep: LLVMDIFlags =
    LLVMDIFlagSingleInheritance | LLVMDIFlagMultipleInheritance | LLVMDIFlagVirtualInheritance;

/// Source languages known by DWARF.
#[repr(C)]
pub enum LLVMDWARFSourceLanguage {
    LLVMDWARFSourceLanguageC89,
    LLVMDWARFSourceLanguageC,
    LLVMDWARFSourceLanguageAda83,
    LLVMDWARFSourceLanguageC_plus_plus,
    LLVMDWARFSourceLanguageCobol74,
    LLVMDWARFSourceLanguageCobol85,
    LLVMDWARFSourceLanguageFortran77,
    LLVMDWARFSourceLanguageFortran90,
    LLVMDWARFSourceLanguagePascal83,
    LLVMDWARFSourceLanguageModula2,
    // New in DWARF v3:
    LLVMDWARFSourceLanguageJava,
    LLVMDWARFSourceLanguageC99,
    LLVMDWARFSourceLanguageAda95,
    LLVMDWARFSourceLanguageFortran95,
    LLVMDWARFSourceLanguagePLI,
    LLVMDWARFSourceLanguageObjC,
    LLVMDWARFSourceLanguageObjC_plus_plus,
    LLVMDWARFSourceLanguageUPC,
    LLVMDWARFSourceLanguageD,
    // New in DWARF v4:
    LLVMDWARFSourceLanguagePython,
    // New in DWARF v5:
    LLVMDWARFSourceLanguageOpenCL,
    LLVMDWARFSourceLanguageGo,
    LLVMDWARFSourceLanguageModula3,
    LLVMDWARFSourceLanguageHaskell,
    LLVMDWARFSourceLanguageC_plus_plus_03,
    LLVMDWARFSourceLanguageC_plus_plus_11,
    LLVMDWARFSourceLanguageOCaml,
    LLVMDWARFSourceLanguageRust,
    LLVMDWARFSourceLanguageC11,
    LLVMDWARFSourceLanguageSwift,
    LLVMDWARFSourceLanguageJulia,
    LLVMDWARFSourceLanguageDylan,
    LLVMDWARFSourceLanguageC_plus_plus_14,
    LLVMDWARFSourceLanguageFortran03,
    LLVMDWARFSourceLanguageFortran08,
    LLVMDWARFSourceLanguageRenderScript,
    LLVMDWARFSourceLanguageBLISS,
    // Vendor extensions:
    LLVMDWARFSourceLanguageMips_Assembler,
    LLVMDWARFSourceLanguageGOOGLE_RenderScript,
    LLVMDWARFSourceLanguageBORLAND_Delphi,
}

/// The amount of debug information to emit.
#[repr(C)]
pub enum LLVMDWARFEmissionKind {
    LLVMDWARFEmissionKindNone = 0,
    LLVMDWARFEmissionKindFull,
    LLVMDWARFEmissionKindLineTablesOnly,
}

pub type LLVMDWARFTypeEncoding = ::libc::c_uint;

extern "C" {
    /// The current debug metadata version number.
    pub fn LLVMDebugMetadataVersion() -> ::libc::c_uint;
    /// The version of debug metadata that's present in the provided Module.
    pub fn LLVMGetModuleDebugMetadataVersion(Module: LLVMModuleRef) -> ::libc::c_uint;
    /// Strip debug info in the module if it exists.
    pub fn LLVMStripModuleDebugInfo(Module: LLVMModuleRef) -> LLVMBool;
    /// Construct a builder for a module, do not allow unresolved nodes.
    pub fn LLVMCreateDIBuilderDisallowUnresolved(M: LLVMModuleRef) -> LLVMDIBuilderRef;
    /// Construct a builder for a module and collect unresolved nodes.
    pub fn LLVMCreateDIBuilder(M: LLVMModuleRef) -> LLVMDIBuilderRef;
    /// Deallocate a builder and everything it owns.
    ///
    /// The builder must be finalized before this.
    pub fn LLVMDisposeDIBuilder(Builder: LLVMDIBuilderRef);
    /// Construct any deferred debug info descriptors.
    pub fn LLVMDIBuilderFinalize(Builder: LLVMDIBuilderRef);
    pub fn LLVMDIBuilderCreateCompileUnit(Builder: LLVMDIBuilderRef,
                                          Lang: LLVMDWARFSourceLanguage,
                                          FileRef: LLVMMetadataRef,
                                          Producer: *const ::libc::c_char,
                                          ProducerLen: ::libc::size_t,
                                          isOptimized: LLVMBool,
                                          Flags: *const ::libc::c_char,
                                          FlagsLen: ::libc::size_t,
                                          RuntimeVer: ::libc::c_uint,
                                          SplitName: *const ::libc::c_char,
                                          SplitNameLen: ::libc::size_t,
                                          Kind: LLVMDWARFEmissionKind,
                                          DWOId: ::libc::c_uint,
                                          SplitDebugInlining: LLVMBool,
                                          DebugInfoForProfiling: LLVMBool)
                                          -> LLVMMetadataRef;
    /// Create a file descriptor to hold debugging information for a file.
    pub fn LLVMDIBuilderCreateFile(Builder: LLVMDIBuilderRef,
                                   Filename: *const ::libc::c_char,
                                   FilenameLen: ::libc::size_t,
                                   Directory: *const ::libc::c_char,
                                   DirectoryLen: ::libc::size_t)
                                   -> LLVMMetadataRef;

    /// Creates a new descriptor for a module with the specified parent scope.
    pub fn LLVMDIBuilderCreateModule(Builder: LLVMDIBuilderRef,
                                     ParentScope: LLVMMetadataRef,
                                     Name: *const ::libc::c_char,
                                     NameLen: ::libc::size_t,
                                     ConfigMacros: *const ::libc::c_char,
                                     ConfigMacrosLen: ::libc::size_t,
                                     IncludePath: *const ::libc::c_char,
                                     IncludePathLen: ::libc::size_t,
                                     ISysRoot: *const ::libc::c_char,
                                     ISysRootLen: ::libc::size_t)
                                     -> LLVMMetadataRef;

    /// Creates a new descriptor for a namespace with the specified parent scope.
    pub fn LLVMDIBuilderCreateNameSpace(Builder: LLVMDIBuilderRef,
                                        ParentScope: LLVMMetadataRef,
                                        Name: *const ::libc::c_char,
                                        NameLen: ::libc::size_t,
                                        ExportSymbols: LLVMBool)
                                        -> LLVMMetadataRef;

    /// Create a new descriptor for the specified subprogram.
    pub fn LLVMDIBuilderCreateFunction(Builder: LLVMDIBuilderRef,
                                       Scope: LLVMMetadataRef,
                                       Name: *const ::libc::c_char,
                                       NameLen: ::libc::size_t,
                                       LinkageName: *const ::libc::c_char,
                                       LinkageNameLen: ::libc::size_t,
                                       File: LLVMMetadataRef,
                                       LineNo: ::libc::c_uint,
                                       Ty: LLVMMetadataRef,
                                       IsLocalToUnit: LLVMBool,
                                       IsDefinition: LLVMBool,
                                       ScopeLine: ::libc::c_uint,
                                       Flags: LLVMDIFlags,
                                       IsOptimized: LLVMBool)
                                       -> LLVMMetadataRef;

    /// Create a descriptor for a lexical block with the specified parent context.
    pub fn LLVMDIBuilderCreateLexicalBlock(Builder: LLVMDIBuilderRef,
                                           Scope: LLVMMetadataRef,
                                           File: LLVMMetadataRef,
                                           Line: ::libc::c_uint,
                                           Column: ::libc::c_uint)
                                           -> LLVMMetadataRef;

    /// Create a descriptor for a lexical block with a new file attached.
    pub fn LLVMDIBuilderCreateLexicalBlockFile(Builder: LLVMDIBuilderRef,
                                               Scope: LLVMMetadataRef,
                                               File: LLVMMetadataRef,
                                               Discriminator: ::libc::c_uint)
                                               -> LLVMMetadataRef;

    /// Create a descriptor for an imported namespace. Suitable for e.g. C++ using declarations.
    pub fn LLVMDIBuilderCreateImportedModuleFromNamespace(Builder: LLVMDIBuilderRef,
                                                          Scope: LLVMMetadataRef,
                                                          NS: LLVMMetadataRef,
                                                          File: LLVMMetadataRef,
                                                          Line: ::libc::c_uint)
                                                          -> LLVMMetadataRef;

    /// Create a descriptor for an imported module that aliases another imported entity descriptor.
    pub fn LLVMDIBuilderCreateImportedModuleFromAlias(Builder: LLVMDIBuilderRef,
                                                      Scope: LLVMMetadataRef,
                                                      ImportedEntity: LLVMMetadataRef,
                                                      File: LLVMMetadataRef,
                                                      Line: ::libc::c_uint)
                                                      -> LLVMMetadataRef;

    /// Create a descriptor for an imported module.
    pub fn LLVMDIBuilderCreateImportedModuleFromModule(Builder: LLVMDIBuilderRef,
                                                       Scope: LLVMMetadataRef,
                                                       M: LLVMMetadataRef,
                                                       File: LLVMMetadataRef,
                                                       Line: ::libc::c_uint)
                                                       -> LLVMMetadataRef;

    /// Create a descriptor for an imported function, type, or variable.
    ///
    /// Suitable for e.g. FORTRAN-style USE declarations.
    pub fn LLVMDIBuilderCreateImportedDeclaration(Builder: LLVMDIBuilderRef,
                                                  Scope: LLVMMetadataRef,
                                                  Decl: LLVMMetadataRef,
                                                  File: LLVMMetadataRef,
                                                  Line: ::libc::c_uint,
                                                  Name: *const ::libc::c_char,
                                                  NameLen: ::libc::size_t)
                                                  -> LLVMMetadataRef;

    /// Creates a new DebugLocation that describes a source location.
    pub fn LLVMDIBuilderCreateDebugLocation(Ctx: LLVMContextRef,
                                            Line: ::libc::c_uint,
                                            Column: ::libc::c_uint,
                                            Scope: LLVMMetadataRef,
                                            InlinedAt: LLVMMetadataRef)
                                            -> LLVMMetadataRef;


    /// Get the line number of this debug location.
    pub fn LLVMDILocationGetLine(Location: LLVMMetadataRef) -> ::libc::c_uint;

    /// Get the column number of this debug location.
    pub fn LLVMDILocationGetColumn(Location: LLVMMetadataRef) -> ::libc::c_uint;

    /// Get the local scope associated with this debug location.
    pub fn LLVMDILocationGetScope(Location: LLVMMetadataRef) -> LLVMMetadataRef;

    /// Create a type array.
    pub fn LLVMDIBuilderGetOrCreateTypeArray(Builder: LLVMDIBuilderRef,
                                             Data: *mut LLVMMetadataRef,
                                             NumElements: ::libc::size_t)
                                             -> LLVMMetadataRef;

    /// Create subroutine type.
    pub fn LLVMDIBuilderCreateSubroutineType(Builder: LLVMDIBuilderRef,
                                             File: LLVMMetadataRef,
                                             ParameterTypes: *mut LLVMMetadataRef,
                                             NumParameterTypes: ::libc::c_uint,
                                             Flags: LLVMDIFlags)
                                             -> LLVMMetadataRef;


    /// Create debugging information entry for an enumeration.
    pub fn LLVMDIBuilderCreateEnumerationType(Builder: LLVMDIBuilderRef,
                                              Scope: LLVMMetadataRef,
                                              Name: *const ::libc::c_char,
                                              NameLen: ::libc::size_t,
                                              File: LLVMMetadataRef,
                                              LineNumber: ::libc::c_uint,
                                              SizeInBits: u64,
                                              AlignInBits: u32,
                                              Elements: *mut LLVMMetadataRef,
                                              NumElements: ::libc::c_uint,
                                              ClassTy: LLVMMetadataRef)
                                              -> LLVMMetadataRef;

    /// Create debugging information entry for a union.
    pub fn LLVMDIBuilderCreateUnionType(Builder: LLVMDIBuilderRef,
                                        Scope: LLVMMetadataRef,
                                        Name: *const ::libc::c_char,
                                        NameLen: ::libc::size_t,
                                        File: LLVMMetadataRef,
                                        LineNumber: ::libc::c_uint,
                                        SizeInBits: u64,
                                        AlignInBits: u32,
                                        Flags: LLVMDIFlags,
                                        Elements: *mut LLVMMetadataRef,
                                        NumElements: ::libc::c_uint,
                                        RunTimeLang: ::libc::c_uint,
                                        UniqueId: *const ::libc::c_char,
                                        UniqueIdLen: ::libc::size_t)
                                        -> LLVMMetadataRef;

    /// Create debugging information entry for an array.
    pub fn LLVMDIBuilderCreateArrayType(Builder: LLVMDIBuilderRef,
                                        Size: u64,
                                        AlignInBits: u32,
                                        Ty: LLVMMetadataRef,
                                        Subscripts: *mut LLVMMetadataRef,
                                        NumSubscripts: ::libc::c_uint)
                                        -> LLVMMetadataRef;

    /// Create debugging information entry for a vector type.
    pub fn LLVMDIBuilderCreateVectorType(Builder: LLVMDIBuilderRef,
                                         Size: u64,
                                         AlignInBits: u32,
                                         Ty: LLVMMetadataRef,
                                         Subscripts: *mut LLVMMetadataRef,
                                         NumSubscripts: ::libc::c_uint)
                                         -> LLVMMetadataRef;

    /// Create a DWARF unspecified type.
    pub fn LLVMDIBuilderCreateUnspecifiedType(Builder: LLVMDIBuilderRef,
                                              Name: *const ::libc::c_char,
                                              NameLen: ::libc::size_t)
                                              -> LLVMMetadataRef;


    /// Create debugging information entry for a basic type.
    pub fn LLVMDIBuilderCreateBasicType(Builder: LLVMDIBuilderRef,
                                        Name: *const ::libc::c_char,
                                        NameLen: ::libc::size_t,
                                        SizeInBits: u64,
                                        Encoding: LLVMDWARFTypeEncoding)
                                        -> LLVMMetadataRef;

    /// Create debugging information entry for a pointer.
    pub fn LLVMDIBuilderCreatePointerType(Builder: LLVMDIBuilderRef,
                                          PointeeTy: LLVMMetadataRef,
                                          SizeInBits: u64,
                                          AlignInBits: u32,
                                          AddressSpace: ::libc::c_uint,
                                          Name: *const ::libc::c_char,
                                          NameLen: ::libc::size_t)
                                          -> LLVMMetadataRef;

    /// Create debugging information entry for a struct.
    pub fn LLVMDIBuilderCreateStructType(Builder: LLVMDIBuilderRef,
                                         Scope: LLVMMetadataRef,
                                         Name: *const ::libc::c_char,
                                         NameLen: ::libc::size_t,
                                         File: LLVMMetadataRef,
                                         LineNumber: ::libc::c_uint,
                                         SizeInBits: u64,
                                         AlignInBits: u32,
                                         Flags: LLVMDIFlags,
                                         DerivedFrom: LLVMMetadataRef,
                                         Elements: *mut LLVMMetadataRef,
                                         NumElements: ::libc::c_uint,
                                         RunTimeLang: ::libc::c_uint,
                                         VTableHolder: LLVMMetadataRef,
                                         UniqueId: *const ::libc::c_char,
                                         UniqueIdLen: ::libc::size_t)
                                         -> LLVMMetadataRef;

    /// Create debugging information entry for a member.
    pub fn LLVMDIBuilderCreateMemberType(Builder: LLVMDIBuilderRef,
                                         Scope: LLVMMetadataRef,
                                         Name: *const ::libc::c_char,
                                         NameLen: ::libc::size_t,
                                         File: LLVMMetadataRef,
                                         LineNo: ::libc::c_uint,
                                         SizeInBits: u64,
                                         AlignInBits: u32,
                                         OffsetInBits: u64,
                                         Flags: LLVMDIFlags,
                                         Ty: LLVMMetadataRef)
                                         -> LLVMMetadataRef;

    /// Create debugging information entry for a C++ static data member.
    pub fn LLVMDIBuilderCreateStaticMemberType(Builder: LLVMDIBuilderRef,
                                               Scope: LLVMMetadataRef,
                                               Name: *const ::libc::c_char,
                                               NameLen: ::libc::size_t,
                                               File: LLVMMetadataRef,
                                               LineNumber: ::libc::c_uint,
                                               Type: LLVMMetadataRef,
                                               Flags: LLVMDIFlags,
                                               ConstantVal: LLVMValueRef,
                                               AlignInBits: u32)
                                               -> LLVMMetadataRef;

    /// Create debugging information entry for a pointer to member.
    pub fn LLVMDIBuilderCreateMemberPointerType(Builder: LLVMDIBuilderRef,
                                                PointeeType: LLVMMetadataRef,
                                                ClassType: LLVMMetadataRef,
                                                SizeInBits: u64,
                                                AlignInBits: u32,
                                                Flags: LLVMDIFlags)
                                                -> LLVMMetadataRef;

    /// Create debugging information entry for Objective-C instance variable.
    pub fn LLVMDIBuilderCreateObjCIVar(Builder: LLVMDIBuilderRef,
                                       Name: *const ::libc::c_char,
                                       NameLen: ::libc::size_t,
                                       File: LLVMMetadataRef,
                                       LineNo: ::libc::c_uint,
                                       SizeInBits: u64,
                                       AlignInBits: u32,
                                       OffsetInBits: u64,
                                       Flags: LLVMDIFlags,
                                       Ty: LLVMMetadataRef,
                                       PropertyNode: LLVMMetadataRef)
                                       -> LLVMMetadataRef;

    /// Create debugging information entry for Objective-C property.
    pub fn LLVMDIBuilderCreateObjCProperty(Builder: LLVMDIBuilderRef,
                                           Name: *const ::libc::c_char,
                                           NameLen: ::libc::size_t,
                                           File: LLVMMetadataRef,
                                           LineNo: ::libc::c_uint,
                                           GetterName: *const ::libc::c_char,
                                           GetterNameLen: ::libc::size_t,
                                           SetterName: *const ::libc::c_char,
                                           SetterNameLen: ::libc::size_t,
                                           PropertyAttributes: ::libc::c_uint,
                                           Ty: LLVMMetadataRef)
                                           -> LLVMMetadataRef;

    /// Create a uniqued DIType* clone with FlagObjectPointer and FlagArtificial set.
    pub fn LLVMDIBuilderCreateObjectPointerType(Builder: LLVMDIBuilderRef,
                                                Type: LLVMMetadataRef)
                                                -> LLVMMetadataRef;

    /// Create debugging information entry for a qualified type, e.g. 'const int'.
    pub fn LLVMDIBuilderCreateQualifiedType(Builder: LLVMDIBuilderRef,
                                            Tag: ::libc::c_uint,
                                            Type: LLVMMetadataRef)
                                            -> LLVMMetadataRef;

    /// Create debugging information entry for a c++ style reference or rvalue reference type.
    pub fn LLVMDIBuilderCreateReferenceType(Builder: LLVMDIBuilderRef,
                                            Tag: ::libc::c_uint,
                                            Type: LLVMMetadataRef)
                                            -> LLVMMetadataRef;

    /// Create C++11 nullptr type.
    pub fn LLVMDIBuilderCreateNullPtrType(Builder: LLVMDIBuilderRef) -> LLVMMetadataRef;

    /// Create debugging information entry for a typedef.
    pub fn LLVMDIBuilderCreateTypedef(Builder: LLVMDIBuilderRef,
                                      Type: LLVMMetadataRef,
                                      Name: *const ::libc::c_char,
                                      NameLen: ::libc::size_t,
                                      File: LLVMMetadataRef,
                                      LineNo: ::libc::c_uint,
                                      Scope: LLVMMetadataRef)
                                      -> LLVMMetadataRef;

    /// Create debugging information entry to establish inheritance relationship between two types.
    pub fn LLVMDIBuilderCreateInheritance(Builder: LLVMDIBuilderRef,
                                          Ty: LLVMMetadataRef,
                                          BaseTy: LLVMMetadataRef,
                                          BaseOffset: u64,
                                          VBPtrOffset: u32,
                                          Flags: LLVMDIFlags)
                                          -> LLVMMetadataRef;

    /// Create a permanent forward-declared type.
    pub fn LLVMDIBuilderCreateForwardDecl(Builder: LLVMDIBuilderRef,
                                          Tag: ::libc::c_uint,
                                          Name: *const ::libc::c_char,
                                          NameLen: ::libc::size_t,
                                          Scope: LLVMMetadataRef,
                                          File: LLVMMetadataRef,
                                          Line: ::libc::c_uint,
                                          RuntimeLang: ::libc::c_uint,
                                          SizeInBits: u64,
                                          AlignInBits: u32,
                                          UniqueIdentifier: *const ::libc::c_char,
                                          UniqueIdentifierLen: ::libc::size_t)
                                          -> LLVMMetadataRef;

    /// Create a temporary forward-declared type.
    pub fn LLVMDIBuilderCreateReplaceableCompositeType(Builder: LLVMDIBuilderRef,
                                                       Tag: ::libc::c_uint,
                                                       Name: *const ::libc::c_char,
                                                       NameLen: ::libc::size_t,
                                                       Scope: LLVMMetadataRef,
                                                       File: LLVMMetadataRef,
                                                       Line: ::libc::c_uint,
                                                       RuntimeLang: ::libc::c_uint,
                                                       SizeInBits: u64,
                                                       AlignInBits: u32,
                                                       Flags: LLVMDIFlags,
                                                       UniqueIdentifier: *const ::libc::c_char,
                                                       UniqueIdentifierLen: ::libc::size_t)
                                                       -> LLVMMetadataRef;

    /// Create debugging information entry for a bit field member.
    pub fn LLVMDIBuilderCreateBitFieldMemberType(Builder: LLVMDIBuilderRef,
                                                 Scope: LLVMMetadataRef,
                                                 Name: *const ::libc::c_char,
                                                 NameLen: ::libc::size_t,
                                                 File: LLVMMetadataRef,
                                                 LineNumber: ::libc::c_uint,
                                                 SizeInBits: u64,
                                                 OffsetInBits: u64,
                                                 StorageOffsetInBits: u64,
                                                 Flags: LLVMDIFlags,
                                                 Type: LLVMMetadataRef)
                                                 -> LLVMMetadataRef;

    /// Create debugging information entry for a class.
    pub fn LLVMDIBuilderCreateClassType(Builder: LLVMDIBuilderRef,
                                        Scope: LLVMMetadataRef,
                                        Name: *const ::libc::c_char,
                                        NameLen: ::libc::size_t,
                                        File: LLVMMetadataRef,
                                        LineNumber: ::libc::c_uint,
                                        SizeInBits: u64,
                                        AlignInBits: u32,
                                        OffsetInBits: u64,
                                        Flags: LLVMDIFlags,
                                        DerivedFrom: LLVMMetadataRef,
                                        Elements: *mut LLVMMetadataRef,
                                        NumElements: ::libc::c_uint,
                                        VTableHolder: LLVMMetadataRef,
                                        TemplateParamsNode: LLVMMetadataRef,
                                        UniqueIdentifier: *const ::libc::c_char,
                                        UniqueIdentifierLen: ::libc::size_t)
                                        -> LLVMMetadataRef;

    /// Create a uniqued DIType* clone with FlagArtificial set.
    pub fn LLVMDIBuilderCreateArtificialType(Builder: LLVMDIBuilderRef,
                                             Type: LLVMMetadataRef)
                                             -> LLVMMetadataRef;

    /// Get the name of this DIType.
    pub fn LLVMDITypeGetName(DType: LLVMMetadataRef,
                             Length: *mut ::libc::size_t)
                             -> *const ::libc::c_char;

    /// Get the size of this DIType in bits.
    pub fn LLVMDITypeGetSizeInBits(DType: LLVMMetadataRef) -> u64;

    /// Get the offset of this DIType in bits.
    pub fn LLVMDITypeGetOffsetInBits(DType: LLVMMetadataRef) -> u64;

    /// Get the alignment of this DIType in bits.
    pub fn LLVMDITypeGetAlignInBits(DType: LLVMMetadataRef) -> u32;

    /// Get the source line where this DIType is declared.
    pub fn LLVMDITypeGetLine(DType: LLVMMetadataRef) -> ::libc::c_uint;

    /// Get the flags associated with this DIType.
    pub fn LLVMDITypeGetFlags(DType: LLVMMetadataRef) -> LLVMDIFlags;

    /// Create a descriptor for a value range.
    pub fn LLVMDIBuilderGetOrCreateSubrange(Builder: LLVMDIBuilderRef,
                                            LowerBound: i64,
                                            Count: i64)
                                            -> LLVMMetadataRef;

    /// Create an array of DI Nodes.
    pub fn LLVMDIBuilderGetOrCreateArray(Builder: LLVMDIBuilderRef,
                                         Data: *mut LLVMMetadataRef,
                                         NumElements: ::libc::size_t)
                                         -> LLVMMetadataRef;

    /// Create a new descriptor for the specified variable which has a complex
    pub fn LLVMDIBuilderCreateExpression(Builder: LLVMDIBuilderRef,
                                         Addr: *mut i64,
                                         Length: ::libc::size_t)
                                         -> LLVMMetadataRef;

    /// Create a new descriptor for the specified variable that does not have an
    pub fn LLVMDIBuilderCreateConstantValueExpression(Builder: LLVMDIBuilderRef,
                                                      Value: i64)
                                                      -> LLVMMetadataRef;

    /// Create a new descriptor for the specified variable.
    pub fn LLVMDIBuilderCreateGlobalVariableExpression(Builder: LLVMDIBuilderRef,
                                                       Scope: LLVMMetadataRef,
                                                       Name: *const ::libc::c_char,
                                                       NameLen: ::libc::size_t,
                                                       Linkage: *const ::libc::c_char,
                                                       LinkLen: ::libc::size_t,
                                                       File: LLVMMetadataRef,
                                                       LineNo: ::libc::c_uint,
                                                       Ty: LLVMMetadataRef,
                                                       LocalToUnit: LLVMBool,
                                                       Expr: LLVMMetadataRef,
                                                       Decl: LLVMMetadataRef,
                                                       AlignInBits: u32)
                                                       -> LLVMMetadataRef;

    /// Create a new temporary \c MDNode.  Suitable for use in constructing cyclic
    pub fn LLVMTemporaryMDNode(Ctx: LLVMContextRef,
                               Data: *mut LLVMMetadataRef,
                               NumElements: ::libc::size_t)
                               -> LLVMMetadataRef;

    /// Deallocate a temporary node.
    pub fn LLVMDisposeTemporaryMDNode(TempNode: LLVMMetadataRef);

    /// Replace all uses of temporary metadata.
    pub fn LLVMMetadataReplaceAllUsesWith(TempTargetMetadata: LLVMMetadataRef,
                                          Replacement: LLVMMetadataRef);

    /// Create a new descriptor for the specified global variable that is temporary
    pub fn LLVMDIBuilderCreateTempGlobalVariableFwdDecl(Builder: LLVMDIBuilderRef,
                                                        Scope: LLVMMetadataRef,
                                                        Name: *const ::libc::c_char,
                                                        NameLen: ::libc::size_t,
                                                        Linkage: *const ::libc::c_char,
                                                        LnkLen: ::libc::size_t,
                                                        File: LLVMMetadataRef,
                                                        LineNo: ::libc::c_uint,
                                                        Ty: LLVMMetadataRef,
                                                        LocalToUnit: LLVMBool,
                                                        Decl: LLVMMetadataRef,
                                                        AlignInBits: u32)
                                                        -> LLVMMetadataRef;

    /// Insert a new llvm.dbg.declare intrinsic call before the given instruction.
    pub fn LLVMDIBuilderInsertDeclareBefore(Builder: LLVMDIBuilderRef,
                                            Storage: LLVMValueRef,
                                            VarInfo: LLVMMetadataRef,
                                            Expr: LLVMMetadataRef,
                                            DebugLoc: LLVMMetadataRef,
                                            Instr: LLVMValueRef)
                                            -> LLVMValueRef;

    /// Insert a new llvm.dbg.declare intrinsic call at the end of the given basic block. If the basic block has a terminator instruction, the intrinsic is inserted before that terminator instruction.
    pub fn LLVMDIBuilderInsertDeclareAtEnd(Builder: LLVMDIBuilderRef,
                                           Storage: LLVMValueRef,
                                           VarInfo: LLVMMetadataRef,
                                           Expr: LLVMMetadataRef,
                                           DebugLoc: LLVMMetadataRef,
                                           Block: LLVMBasicBlockRef)
                                           -> LLVMValueRef;

    /// Insert a new llvm.dbg.value intrinsic call before the given instruction.
    pub fn LLVMDIBuilderInsertDbgValueBefore(Builder: LLVMDIBuilderRef,
                                             Val: LLVMValueRef,
                                             VarInfo: LLVMMetadataRef,
                                             Expr: LLVMMetadataRef,
                                             DebugLoc: LLVMMetadataRef,
                                             Instr: LLVMValueRef)
                                             -> LLVMValueRef;

    /// Insert a new llvm.dbg.value intrinsic call at the end of the given basic block. If the basic block has a terminator instruction, the intrinsic is inserted before that terminator instruction.
    pub fn LLVMDIBuilderInsertDbgValueAtEnd(Builder: LLVMDIBuilderRef,
                                            Val: LLVMValueRef,
                                            VarInfo: LLVMMetadataRef,
                                            Expr: LLVMMetadataRef,
                                            DebugLoc: LLVMMetadataRef,
                                            Block: LLVMBasicBlockRef)
                                            -> LLVMValueRef;

    /// Create a new descriptor for a local auto variable.
    pub fn LLVMDIBuilderCreateAutoVariable(Builder: LLVMDIBuilderRef,
                                           Scope: LLVMMetadataRef,
                                           Name: *const ::libc::c_char,
                                           NameLen: ::libc::size_t,
                                           File: LLVMMetadataRef,
                                           LineNo: ::libc::c_uint,
                                           Ty: LLVMMetadataRef,
                                           AlwaysPreserve: LLVMBool,
                                           Flags: LLVMDIFlags,
                                           AlignInBits: u32)
                                           -> LLVMMetadataRef;

    /// Create a new descriptor for a function parameter variable.
    pub fn LLVMDIBuilderCreateParameterVariable(Builder: LLVMDIBuilderRef,
                                                Scope: LLVMMetadataRef,
                                                Name: *const ::libc::c_char,
                                                NameLen: ::libc::size_t,
                                                ArgNo: ::libc::c_uint,
                                                File: LLVMMetadataRef,
                                                LineNo: ::libc::c_uint,
                                                Ty: LLVMMetadataRef,
                                                AlwaysPreserve: LLVMBool,
                                                Flags: LLVMDIFlags)
                                                -> LLVMMetadataRef;

    /// Get the metadata of the subprogram attached to a function.
    pub fn LLVMGetSubprogram(Func: LLVMValueRef) -> LLVMMetadataRef;

    /// Set the subprogram attached to a function.
    pub fn LLVMSetSubprogram(Func: LLVMValueRef, SP: LLVMMetadataRef);
}