-
Notifications
You must be signed in to change notification settings - Fork 25
/
M3DIBuilder.cpp
1478 lines (1348 loc) · 67.3 KB
/
M3DIBuilder.cpp
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
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// File: projects/Modula3Extras/lib/cbindings/LLVMDIBuilder.cpp
// Implementation of a C binding to DIBuilder.
// Derived From:
//===--- llvm/DIBuilder.h - Debug Information Builder -----------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file defines a DIBuilder that is useful for creating debugging
// information entries in LLVM IR form.
//
//===----------------------------------------------------------------------===//
#include "./M3DIBuilder.h" // This binding's header:
#include "llvm/IR/Metadata.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/Value.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/Instruction.h"
#include "llvm/IR/BasicBlock.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/IR/DebugInfo.h"
#include "llvm/Support/CBindingWrapping.h"
#include "llvm/IR/DIBuilder.h" // The C++ code this binds to.
// wrap and unwrap functions for DI* types.
// These are for DIBuilder types that are classes containing a single
// data member of type DINode.
inline LLVMDITypeRef wrapDITypeRef(llvm::DITypeRef TR) {
llvm::Metadata *Val = TR; // Implied conversion
LLVMDITypeRef Result;
Result.Val = reinterpret_cast<LLVMMetadataPtr>(Val);
return Result;
}
inline llvm::DITypeRef unwrapDITypeRef(LLVMDITypeRef wrapped) {
llvm::Metadata *Val = reinterpret_cast<llvm::Metadata*>(wrapped.Val);
// ^Implied conversion.
llvm::DITypeRef Result = llvm::DIType(reinterpret_cast<llvm::MDNode*>(Val));
// ^Implied conversion.
return Result;
}
#define DEFINE_DI_MDNODE_CONVERSION_FUNCTIONS(Ty)\
inline Ty wrap(llvm::Ty DINode) {\
llvm::MDNode *DbgPtr = DINode;\
Ty Result;\
Result.DbgPtr = reinterpret_cast<LLVMMDNodePtr>(DbgPtr);\
return Result;\
}\
inline llvm::Ty unwrap(Ty LLVMDINode) {\
llvm::MDNode *DbgPtr = reinterpret_cast<llvm::MDNode*>(LLVMDINode.DbgPtr);\
return llvm::Ty(DbgPtr);\
}
DEFINE_DI_MDNODE_CONVERSION_FUNCTIONS(DIBasicType)
DEFINE_DI_MDNODE_CONVERSION_FUNCTIONS(DICompileUnit)
DEFINE_DI_MDNODE_CONVERSION_FUNCTIONS(DICompositeType)
DEFINE_DI_MDNODE_CONVERSION_FUNCTIONS(DIDerivedType)
DEFINE_DI_MDNODE_CONVERSION_FUNCTIONS(DIDescriptor)
DEFINE_DI_MDNODE_CONVERSION_FUNCTIONS(DIFile)
DEFINE_DI_MDNODE_CONVERSION_FUNCTIONS(DIEnumerator)
DEFINE_DI_MDNODE_CONVERSION_FUNCTIONS(DIType)
DEFINE_DI_MDNODE_CONVERSION_FUNCTIONS(DITypeArray)
DEFINE_DI_MDNODE_CONVERSION_FUNCTIONS(DIArray)
DEFINE_DI_MDNODE_CONVERSION_FUNCTIONS(DIGlobalVariable)
DEFINE_DI_MDNODE_CONVERSION_FUNCTIONS(DIExpression)
DEFINE_DI_MDNODE_CONVERSION_FUNCTIONS(DIImportedEntity)
DEFINE_DI_MDNODE_CONVERSION_FUNCTIONS(DINameSpace)
DEFINE_DI_MDNODE_CONVERSION_FUNCTIONS(DIVariable)
DEFINE_DI_MDNODE_CONVERSION_FUNCTIONS(DISubrange)
DEFINE_DI_MDNODE_CONVERSION_FUNCTIONS(DILexicalBlockFile)
DEFINE_DI_MDNODE_CONVERSION_FUNCTIONS(DILexicalBlock)
DEFINE_DI_MDNODE_CONVERSION_FUNCTIONS(DIScope)
DEFINE_DI_MDNODE_CONVERSION_FUNCTIONS(DISubprogram)
DEFINE_DI_MDNODE_CONVERSION_FUNCTIONS(DITemplateTypeParameter)
DEFINE_DI_MDNODE_CONVERSION_FUNCTIONS(DITemplateValueParameter)
DEFINE_DI_MDNODE_CONVERSION_FUNCTIONS(DIObjCProperty)
// [un]wrap functions missing from Core.h:
DEFINE_SIMPLE_CONVERSION_FUNCTIONS(llvm::Constant, LLVMConstantRef)
// [un]wrap functions for DIBUILDER:
// These are the same as would be generated by
// DEFINE_SIMPLE_CONVERSION_FUNCTIONS(llvm::DIBuilder, LLVMDIBuilderRef),
// except they have probably non-overloaded names:
inline llvm::DIBuilder *unwrapBuilder(LLVMDIBuilderRef wrapped) {
return reinterpret_cast<llvm::DIBuilder *>(wrapped);
}
inline LLVMDIBuilderRef wrapDIBuilder(const llvm::DIBuilder *unwrapped) {
return reinterpret_cast<LLVMDIBuilderRef>(const_cast<llvm::DIBuilder*>(unwrapped));
}
// unwrap functions for misc. types in llvm:
const char NullChar = 0;
const char * NullCharPtr = & NullChar;
#if 0
// From DIBuilderBindings.cpp:
template <typename T> T unwrapDI(LLVMMetadataPtr v) {
return v ? T(unwrap<llvm::MDNode>(v)) : T();
}
#endif
inline llvm::StringRef unwrapStringRef(LLVMStringRef R) {
if (R->Data == NULL) { return llvm::StringRef (NullCharPtr, 0); }
else { return llvm::StringRef (R->Data, R->Length); }
}
inline llvm::Value ** unwrapValueRefStar(LLVMValueRef * RefPtr) {
return reinterpret_cast<llvm::Value **>(RefPtr);
}
inline llvm::Metadata **unwrapMetadataPtrPtr(LLVMMetadataPtr *Node) {
return reinterpret_cast<llvm::Metadata **>(Node);
}
inline llvm::ArrayRef<llvm::Metadata *> unwrapAOfM(LLVMArrayRefOfMetadataPtr R){
return llvm::ArrayRef<llvm::Metadata *> (unwrapMetadataPtrPtr(R.Data), R.Length);
}
inline llvm::ArrayRef<int64_t> unwrapAOfI64(LLVMArrayRefOfint64_t R){
return llvm::ArrayRef<int64_t> (R.Data, R.Length);
}
inline llvm::MDNode *unwrapMDNodePtr(LLVMMDNodePtr Node) {
return reinterpret_cast<llvm::MDNode *>(Node);
}
#if 0
inline llvm::DITypeRef unwrapDITypeRef(LLVMDITypeRef Node) {
return reinterpret_cast<llvm::DITypeRef>(Node);
}
#endif
#if 0
inline LLVMDITypeRef wrapDITypeRef (llvm::DITypeRef Node) {
llvm::Metadata *Val = Node; // Implicitly converted.
LLVMDITypeRef Result;
Result.Val = reinterpret_cast<LLVMMetadataPtr>(Val);
return Result;
}
inline llvm::DITypeRef unwrapDITypeRef (LLVMDITypeRef LLVMDINode) {
llvm::Metadata *Val = reinterpret_cast<llvm::Metadata*>(LLVMDINode.Val);
return llvm::TypeRef(Val);
}
#endif
//template<typename T> inline T *unwrap(LLVMValueRef P) {
// return reinterpret_cast<T*>(unwrap(P));
// TODO: ^dynamic_cast would provide detection of type errors in clients of
// this binding, but it is disallowed because the build system apparently
// specifies -fno-rtti. But there are other instances of dynamic_cast
// in this code base. Ferret this out.
//}
/// Constructor of a DIBuilder.
LLVMDIBuilderRef
DIBBuilderCreate(LLVMModuleRef Mod, LLVMBool AllowUnresolved) {
return wrapDIBuilder
(new llvm::DIBuilder(*llvm::unwrap(Mod), AllowUnresolved));
}
/// finalize - Construct any deferred debug info descriptors.
void DIBfinalize(LLVMDIBuilderRef Builder) {
unwrapBuilder(Builder)-> finalize();
}
/// Free - Deallocate a DIBuilder
void DIBFree(LLVMDIBuilderRef Builder) {
llvm::DIBuilder *B = unwrapBuilder(Builder);
free(B);
}
/* The debug info node constructors: */
/// NOTE: Unlike regular llvm IR nodes, the DI* types are small classes that
/// contain a pointer to an MDNode. They are passed in and returned by value,
/// as structs, with no pointer thereto. Thus, they require no [un]wrap.
/// createCompileUnit - A CompileUnit provides an anchor for all debugging
/// information generated during this instance of compilation.
/// @param Lang Source programming language, eg. dwarf::DW_LANG_C99
/// @param File File name
/// @param Dir Directory
/// @param Producer String identify producer of debugging information.
/// Usually this is a compiler version string.
/// @param isOptimized A boolean flag which indicates whether optimization
/// is ON or not.
/// @param Flags This string lists command line options. This string is
/// directly embedded in debug info output which may be used
/// by a tool analyzing generated debugging information.
/// @param RV This indicates runtime version for languages like
/// Objective-C.
/// @param SplitName The name of the file that we'll split debug info out
/// into.
LLVMDICompileUnit DIBcreateCompileUnit(LLVMDIBuilderRef Builder,
unsigned Lang,
LLVMStringRef File,
LLVMStringRef Dir,
LLVMStringRef Producer,
LLVMBool isOptimized,
LLVMStringRef Flags,
unsigned RV,
LLVMStringRef SplitName,
llvm::DIBuilder::DebugEmissionKind Kind,
LLVMBool EmitDebugInfo) {
return wrap(unwrapBuilder(Builder)-> createCompileUnit(
/*unsigned*/ Lang,
unwrapStringRef(File),
unwrapStringRef(Dir),
unwrapStringRef(Producer),
/*LLVMBool*/ isOptimized,
unwrapStringRef(Flags),
/*unsigned*/ RV,
unwrapStringRef(SplitName),
Kind,
EmitDebugInfo));
}
/// createFile - Create a file descriptor to hold debugging information
/// for a file.
LLVMDIFile DIBcreateFile(LLVMDIBuilderRef Builder,
LLVMStringRef Filename,
LLVMStringRef Directory) {
return wrap(unwrapBuilder(Builder)-> createFile(
unwrapStringRef(Filename),
unwrapStringRef(Directory)));
}
/// createEnumerator - Create a single enumerator value.
LLVMDIEnumerator DIBcreateEnumerator(LLVMDIBuilderRef Builder,
LLVMStringRef Name,
int64_t Val) {
return wrap(unwrapBuilder(Builder)-> createEnumerator(
unwrapStringRef(Name),
/*int64_t*/ Val));
}
/// \brief Create a DWARF unspecified type.
LLVMDIBasicType DIBcreateUnspecifiedType(LLVMDIBuilderRef Builder,
LLVMStringRef Name) {
return wrap(unwrapBuilder(Builder)-> createUnspecifiedType(
unwrapStringRef(Name)));
}
/// \brief Create C++11 nullptr type.
LLVMDIBasicType DIBcreateNullPtrType(LLVMDIBuilderRef Builder) {
return wrap(unwrapBuilder(Builder)-> createNullPtrType());
}
/// createBasicType - Create debugging information entry for a basic
/// type.
/// @param Name Type name.
/// @param SizeInBits Size of the type.
/// @param AlignInBits Type alignment.
/// @param Encoding DWARF encoding code, e.g. dwarf::DW_ATE_float.
LLVMDIBasicType DIBcreateBasicType(LLVMDIBuilderRef Builder,
LLVMStringRef Name,
uint64_t SizeInBits,
uint64_t AlignInBits,
unsigned Encoding) {
return wrap(unwrapBuilder(Builder)-> createBasicType(
unwrapStringRef(Name),
/*uint64_t*/ SizeInBits,
/*uint64_t*/ AlignInBits,
/*unsigned*/ Encoding));
}
/// createQualifiedType - Create debugging information entry for a qualified
/// type, e.g. 'const int'.
/// @param Tag Tag identifing type, e.g. dwarf::TAG_volatile_type
/// @param FromTy Base Type.
LLVMDIDerivedType DIBcreateQualifiedType(LLVMDIBuilderRef Builder,
unsigned Tag,
LLVMDIType FromTy) {
return wrap(unwrapBuilder(Builder)-> createQualifiedType(
/*unsigned*/ Tag,
unwrap(/*LLVMDIType*/ FromTy)));
}
/// createPointerType - Create debugging information entry for a pointer.
/// @param PointeeTy Type pointed by this pointer.
/// @param SizeInBits Size.
/// @param AlignInBits Alignment. (optional)
/// @param Name Pointer type name. (optional)
LLVMDIDerivedType DIBcreatePointerType(LLVMDIBuilderRef Builder,
LLVMDIType PointeeTy,
uint64_t SizeInBits,
uint64_t AlignInBits,
LLVMStringRef Name) {
return wrap(unwrapBuilder(Builder)-> createPointerType(
unwrap(/*LLVMDIType*/ PointeeTy),
/*uint64_t*/ SizeInBits,
/*uint64_t*/ AlignInBits,
unwrapStringRef(Name)));
}
/// \brief Create debugging information entry for a pointer to member.
/// @param PointeeTy Type pointed to by this pointer.
/// @param Class Type for which this pointer points to members of.
/// @param SizeInBits Size.
/// @param AlignInBits Alignment. (optional)
LLVMDIDerivedType DIBcreateMemberPointerType(LLVMDIBuilderRef Builder,
LLVMDIType PointeeTy,
LLVMDIType Class,
uint64_t SizeInBits,
uint64_t AlignInBits) {
return wrap(unwrapBuilder(Builder)-> createMemberPointerType(
unwrap(/*LLVMDIType*/ PointeeTy),
unwrap(/*LLVMDIType*/ Class),
/*uint64_t*/ SizeInBits,
/*uint64_t*/ AlignInBits));
}
/// createReferenceType - Create debugging information entry for a c++
/// style reference or rvalue reference type.
LLVMDIDerivedType DIBcreateReferenceType(LLVMDIBuilderRef Builder,
unsigned Tag,
LLVMDIType RTy) {
return wrap(unwrapBuilder(Builder)-> createReferenceType(
/*unsigned*/ Tag,
unwrap(/*LLVMDIType*/ RTy)));
}
/// createTypedef - Create debugging information entry for a typedef.
/// @param Ty Original type.
/// @param Name Typedef name.
/// @param File File where this type is defined.
/// @param LineNo Line number.
/// @param Context The surrounding context for the typedef.
LLVMDIDerivedType DIBcreateTypedef( LLVMDIBuilderRef Builder,
LLVMDIType Ty,
LLVMStringRef Name,
LLVMDIFile File,
unsigned LineNo,
LLVMDIDescriptor Context) {
return wrap(unwrapBuilder(Builder)-> createTypedef(
unwrap(/*LLVMDIType*/ Ty),
unwrapStringRef(Name),
unwrap(/*LLVMDIFile*/ File),
/*unsigned*/ LineNo,
unwrap(/*LLVMDIDescriptor*/ Context)));
}
/// createFriend - Create debugging information entry for a 'friend'.
LLVMDIDerivedType DIBcreateFriend( LLVMDIBuilderRef Builder,
LLVMDIType Ty,
LLVMDIType FriendTy) {
return wrap(unwrapBuilder(Builder)-> createFriend(
unwrap(/*LLVMDIType*/ Ty),
unwrap(/*LLVMDIType*/ FriendTy)));
}
/// createInheritance - Create debugging information entry to establish
/// inheritance relationship between two types.
/// @param Ty Original type.
/// @param BaseTy Base type. Ty is inherits from base.
/// @param BaseOffset Base offset.
/// @param Flags Flags to describe inheritance attribute,
/// e.g. private
LLVMDIDerivedType DIBcreateInheritance(LLVMDIBuilderRef Builder,
LLVMDIType Ty,
LLVMDIType BaseTy,
uint64_t BaseOffset,
unsigned Flags) {
return wrap(unwrapBuilder(Builder)-> createInheritance(
unwrap(/*LLVMDIType*/ Ty),
unwrap(/*LLVMDIType*/ BaseTy),
/*uint64_t*/ BaseOffset,
/*unsigned*/ Flags));
}
/// createMemberType - Create debugging information entry for a member.
/// @param Scope Member scope.
/// @param Name Member name.
/// @param File File where this member is defined.
/// @param LineNo Line number.
/// @param SizeInBits Member size.
/// @param AlignInBits Member alignment.
/// @param OffsetInBits Member offset.
/// @param Flags Flags to encode member attribute, e.g. private
/// @param Ty Parent type.
LLVMDIDerivedType DIBcreateMemberType(LLVMDIBuilderRef Builder,
LLVMDIDescriptor Scope,
LLVMStringRef Name,
LLVMDIFile File,
unsigned LineNo,
uint64_t SizeInBits,
uint64_t AlignInBits,
uint64_t OffsetInBits,
unsigned Flags,
LLVMDIType Ty) {
return wrap(unwrapBuilder(Builder)-> createMemberType(
unwrap(/*LLVMDIDescriptor*/ Scope),
unwrapStringRef(Name),
unwrap(/*LLVMDIFile*/ File),
/*unsigned*/ LineNo,
/*uint64_t*/ SizeInBits,
/*uint64_t*/ AlignInBits,
/*uint64_t*/ OffsetInBits,
/*unsigned*/ Flags,
unwrap(/*LLVMDIType*/ Ty)));
}
/// createStaticMemberType - Create debugging information entry for a
/// C++ static data member.
/// @param Scope Member scope.
/// @param Name Member name.
/// @param File File where this member is declared.
/// @param LineNo Line number.
/// @param Ty Type of the static member.
/// @param Flags Flags to encode member attribute, e.g. private.
/// @param Val Const initializer of the member.
LLVMDIDerivedType DIBcreateStaticMemberType(LLVMDIBuilderRef Builder,
LLVMDIDescriptor Scope,
LLVMStringRef Name,
LLVMDIFile File,
unsigned LineNo,
LLVMDIType Ty,
unsigned Flags,
LLVMConstantRef Val) {
return wrap(unwrapBuilder(Builder)-> createStaticMemberType(
unwrap(/*LLVMDIDescriptor*/ Scope),
unwrapStringRef(Name),
unwrap(/*LLVMDIFile*/ File),
/*unsigned*/ LineNo,
unwrap(/*LLVMDIType*/ Ty),
/*unsigned*/ Flags,
unwrap(/*LLVMConstantRef*/ Val)));
}
/// createObjCIVar - Create debugging information entry for Objective-C
/// instance variable.
/// @param Name Member name.
/// @param File File where this member is defined.
/// @param LineNo Line number.
/// @param SizeInBits Member size.
/// @param AlignInBits Member alignment.
/// @param OffsetInBits Member offset.
/// @param Flags Flags to encode member attribute, e.g. private
/// @param Ty Parent type.
/// @param PropertyNode Property associated with this ivar.
LLVMDIDerivedType DIBcreateObjCIVar(LLVMDIBuilderRef Builder,
LLVMStringRef Name,
LLVMDIFile File,
unsigned LineNo,
uint64_t SizeInBits,
uint64_t AlignInBits,
uint64_t OffsetInBits,
unsigned Flags,
LLVMDIType Ty,
LLVMMDNodePtr PropertyNode) {
return wrap(unwrapBuilder(Builder)-> createObjCIVar(
unwrapStringRef(Name),
unwrap(/*LLVMDIFile*/ File),
/*unsigned*/ LineNo,
/*uint64_t*/ SizeInBits,
/*uint64_t*/ AlignInBits,
/*uint64_t*/ OffsetInBits,
/*unsigned*/ Flags,
unwrap(/*LLVMDIType*/ Ty),
unwrapMDNodePtr(PropertyNode)));
}
/// createObjCProperty - Create debugging information entry for Objective-C
/// property.
/// @param Name Property name.
/// @param File File where this property is defined.
/// @param LineNumber Line number.
/// @param GetterName Name of the Objective C property getter selector.
/// @param SetterName Name of the Objective C property setter selector.
/// @param PropertyAttributes Objective C property attributes.
/// @param Ty Type.
LLVMDIObjCProperty DIBcreateObjCProperty(LLVMDIBuilderRef Builder,
LLVMStringRef Name,
LLVMDIFile File,
unsigned LineNumber,
LLVMStringRef GetterName,
LLVMStringRef SetterName,
unsigned PropertyAttributes,
LLVMDIType Ty) {
return wrap(unwrapBuilder(Builder)-> createObjCProperty(
unwrapStringRef(Name),
unwrap(/*LLVMDIFile*/ File),
/*unsigned*/ LineNumber,
unwrapStringRef(GetterName),
unwrapStringRef(SetterName),
/*unsigned*/ PropertyAttributes,
unwrap(/*LLVMDIType*/ Ty)));
}
/// createClassType - Create debugging information entry for a class.
/// @param Scope Scope in which this class is defined.
/// @param Name class name.
/// @param File File where this member is defined.
/// @param LineNumber Line number.
/// @param SizeInBits Member size.
/// @param AlignInBits Member alignment.
/// @param OffsetInBits Member offset.
/// @param Flags Flags to encode member attribute, e.g. private
/// @param Elements class members.
/// @param VTableHolder Debug info of the base class that contains vtable
/// for this type. This is used in
/// DW_AT_containing_type. See DWARF documentation
/// for more info.
/// @param TemplateParms Template type parameters.
/// @param UniqueIdentifier A unique identifier for the class.
LLVMDICompositeType DIBcreateClassType(LLVMDIBuilderRef Builder,
LLVMDIDescriptor Scope,
LLVMStringRef Name,
LLVMDIFile File,
unsigned LineNumber,
uint64_t SizeInBits,
uint64_t AlignInBits,
uint64_t OffsetInBits,
unsigned Flags,
LLVMDIType DerivedFrom,
LLVMDIArray Elements,
LLVMDIType VTableHolder,
LLVMMDNodePtr TemplateParms,
LLVMStringRef UniqueIdentifier) {
return wrap(unwrapBuilder(Builder)-> createClassType(
unwrap(/*LLVMDIDescriptor*/ Scope),
unwrapStringRef(Name),
unwrap(/*LLVMDIFile*/ File),
/*unsigned*/ LineNumber,
/*uint64_t*/ SizeInBits,
/*uint64_t*/ AlignInBits,
/*uint64_t*/ OffsetInBits,
/*unsigned*/ Flags,
unwrap(/*LLVMDIType*/ DerivedFrom),
unwrap(/*LLVMDIArray*/ Elements),
unwrap(/*LLVMDIType*/ VTableHolder),
unwrapMDNodePtr(TemplateParms),
unwrapStringRef(UniqueIdentifier)));
}
/// createStructType - Create debugging information entry for a struct.
/// @param Scope Scope in which this struct is defined.
/// @param Name Struct name.
/// @param File File where this member is defined.
/// @param LineNumber Line number.
/// @param SizeInBits Member size.
/// @param AlignInBits Member alignment.
/// @param Flags Flags to encode member attribute, e.g. private
/// @param Elements Struct elements.
/// @param RunTimeLang Optional parameter, Objective-C runtime version.
/// @param UniqueIdentifier A unique identifier for the struct.
LLVMDICompositeType DIBcreateStructType(LLVMDIBuilderRef Builder,
LLVMDIDescriptor Scope,
LLVMStringRef Name,
LLVMDIFile File,
unsigned LineNumber,
uint64_t SizeInBits,
uint64_t AlignInBits,
unsigned Flags,
LLVMDIType DerivedFrom,
LLVMDIArray Elements,
unsigned RunTimeLang,
LLVMDIType VTableHolder,
LLVMStringRef UniqueIdentifier) {
return wrap(unwrapBuilder(Builder)-> createStructType(
unwrap(/*LLVMDIDescriptor*/ Scope),
unwrapStringRef(Name),
unwrap(/*LLVMDIFile*/ File),
/*unsigned*/ LineNumber,
/*uint64_t*/ SizeInBits,
/*uint64_t*/ AlignInBits,
/*unsigned*/ Flags,
unwrap(/*LLVMDIType*/ DerivedFrom),
unwrap(/*LLVMDIArray*/ Elements),
/*unsigned*/ RunTimeLang,
unwrap(/*LLVMDIType*/ VTableHolder),
unwrapStringRef(UniqueIdentifier)));
}
/// createUnionType - Create debugging information entry for an union.
/// @param Scope Scope in which this union is defined.
/// @param Name Union name.
/// @param File File where this member is defined.
/// @param LineNumber Line number.
/// @param SizeInBits Member size.
/// @param AlignInBits Member alignment.
/// @param Flags Flags to encode member attribute, e.g. private
/// @param Elements Union elements.
/// @param RunTimeLang Optional parameter, Objective-C runtime version.
/// @param UniqueIdentifier A unique identifier for the union.
LLVMDICompositeType DIBcreateUnionType(LLVMDIBuilderRef Builder,
LLVMDIDescriptor Scope,
LLVMStringRef Name,
LLVMDIFile File,
unsigned LineNumber,
uint64_t SizeInBits,
uint64_t AlignInBits,
unsigned Flags,
LLVMDIArray Elements,
unsigned RunTimeLang,
LLVMStringRef UniqueIdentifier) {
return wrap(unwrapBuilder(Builder)-> createUnionType(
unwrap(/*LLVMDIDescriptor*/ Scope),
unwrapStringRef(Name),
unwrap(/*LLVMDIFile*/ File),
/*unsigned*/ LineNumber,
/*uint64_t*/ SizeInBits,
/*uint64_t*/ AlignInBits,
/*unsigned*/ Flags,
unwrap(/*LLVMDIArray*/ Elements),
/*unsigned*/ RunTimeLang,
unwrapStringRef(UniqueIdentifier)));
}
/// createTemplateTypeParameter - Create debugging information for template
/// type parameter.
/// @param Scope Scope in which this type is defined.
/// @param Name Type parameter name.
/// @param Ty Parameter type.
/// @param File File where this type parameter is defined.
/// @param LineNo Line number.
/// @param ColumnNo Column Number.
LLVMDITemplateTypeParameter DIBcreateTemplateTypeParameter(LLVMDIBuilderRef Builder,
LLVMDIDescriptor Scope,
LLVMStringRef Name,
LLVMDIType Ty,
LLVMMDNodePtr File,
unsigned LineNo,
unsigned ColumnNo) {
return wrap(unwrapBuilder(Builder)-> createTemplateTypeParameter(
unwrap(/*LLVMDIDescriptor*/ Scope),
unwrapStringRef(Name),
unwrap(/*LLVMDIType*/ Ty),
unwrapMDNodePtr(File),
/*unsigned*/ LineNo,
/*unsigned*/ ColumnNo));
}
/// createTemplateValueParameter - Create debugging information for template
/// value parameter.
/// @param Scope Scope in which this type is defined.
/// @param Name Value parameter name.
/// @param Ty Parameter type.
/// @param Val Constant parameter value.
/// @param File File where this type parameter is defined.
/// @param LineNo Line number.
/// @param ColumnNo Column Number.
LLVMDITemplateValueParameter DIBcreateTemplateValueParameter(LLVMDIBuilderRef Builder,
LLVMDIDescriptor Scope,
LLVMStringRef Name,
LLVMDIType Ty,
LLVMConstantRef Val,
LLVMMDNodePtr File,
unsigned LineNo,
unsigned ColumnNo) {
return wrap(unwrapBuilder(Builder)-> createTemplateValueParameter(
unwrap(/*LLVMDIDescriptor*/ Scope),
unwrapStringRef(Name),
unwrap(/*LLVMDIType*/ Ty),
unwrap(/*LLVMConstantRef*/ Val),
unwrapMDNodePtr(File),
/*unsigned*/ LineNo,
/*unsigned*/ ColumnNo));
}
/// \brief Create debugging information for a template template parameter.
/// @param Scope Scope in which this type is defined.
/// @param Name Value parameter name.
/// @param Ty Parameter type.
/// @param Val The fully qualified name of the template.
/// @param File File where this type parameter is defined.
/// @param LineNo Line number.
/// @param ColumnNo Column Number.
LLVMDITemplateValueParameter DIBcreateTemplateTemplateParameter(LLVMDIBuilderRef Builder,
LLVMDIDescriptor Scope,
LLVMStringRef Name,
LLVMDIType Ty,
LLVMStringRef Val,
LLVMMDNodePtr File,
unsigned LineNo,
unsigned ColumnNo) {
return wrap(unwrapBuilder(Builder)-> createTemplateTemplateParameter(
unwrap(/*LLVMDIDescriptor*/ Scope),
unwrapStringRef(Name),
unwrap(/*LLVMDIType*/ Ty),
unwrapStringRef(Val),
unwrapMDNodePtr(File),
/*unsigned*/ LineNo,
/*unsigned*/ ColumnNo));
}
/// \brief Create debugging information for a template parameter pack.
/// @param Scope Scope in which this type is defined.
/// @param Name Value parameter name.
/// @param Ty Parameter type.
/// @param Val An array of types in the pack.
/// @param File File where this type parameter is defined.
/// @param LineNo Line number.
/// @param ColumnNo Column Number.
LLVMDITemplateValueParameter DIBcreateTemplateParameterPack(LLVMDIBuilderRef Builder,
LLVMDIDescriptor Scope,
LLVMStringRef Name,
LLVMDIType Ty,
LLVMDIArray Val,
LLVMMDNodePtr File,
unsigned LineNo,
unsigned ColumnNo) {
return wrap(unwrapBuilder(Builder)-> createTemplateParameterPack(
unwrap(/*LLVMDIDescriptor*/ Scope),
unwrapStringRef(Name),
unwrap(/*LLVMDIType*/ Ty),
unwrap(/*LLVMDIArray*/ Val),
unwrapMDNodePtr(File),
/*unsigned*/ LineNo,
/*unsigned*/ ColumnNo));
}
/// createArrayType - Create debugging information entry for an array.
/// @param Size Array size.
/// @param AlignInBits Alignment.
/// @param Ty Element type.
/// @param Subscripts Subscripts.
LLVMDICompositeType DIBcreateArrayType(LLVMDIBuilderRef Builder,
uint64_t Size,
uint64_t AlignInBits,
LLVMDIType Ty,
LLVMDIArray Subscripts) {
return wrap(unwrapBuilder(Builder)-> createArrayType(
/*uint64_t*/ Size,
/*uint64_t*/ AlignInBits,
unwrap(/*LLVMDIType*/ Ty),
unwrap(/*LLVMDIArray*/ Subscripts)));
}
/// createVectorType - Create debugging information entry for a vector type.
/// @param Size Array size.
/// @param AlignInBits Alignment.
/// @param Ty Element type.
/// @param Subscripts Subscripts.
LLVMDICompositeType DIBcreateVectorType(LLVMDIBuilderRef Builder,
uint64_t Size,
uint64_t AlignInBits,
LLVMDIType Ty,
LLVMDIArray Subscripts) {
return wrap(unwrapBuilder(Builder)-> createVectorType(
/*uint64_t*/ Size,
/*uint64_t*/ AlignInBits,
unwrap(/*LLVMDIType*/ Ty),
unwrap(/*LLVMDIArray*/ Subscripts)));
}
/// createEnumerationType - Create debugging information entry for an
/// enumeration.
/// @param Scope Scope in which this enumeration is defined.
/// @param Name Union name.
/// @param File File where this member is defined.
/// @param LineNumber Line number.
/// @param SizeInBits Member size.
/// @param AlignInBits Member alignment.
/// @param Elements Enumeration elements.
/// @param UnderlyingType Underlying type of a C++11/ObjC fixed enum.
/// @param UniqueIdentifier A unique identifier for the enum.
LLVMDICompositeType DIBcreateEnumerationType(LLVMDIBuilderRef Builder,
LLVMDIDescriptor Scope,
LLVMStringRef Name,
LLVMDIFile File,
unsigned LineNumber,
uint64_t SizeInBits,
uint64_t AlignInBits,
LLVMDIArray Elements,
LLVMDIType UnderlyingType,
LLVMStringRef UniqueIdentifier) {
return wrap(unwrapBuilder(Builder)-> createEnumerationType(
unwrap(/*LLVMDIDescriptor*/ Scope),
unwrapStringRef(Name),
unwrap(/*LLVMDIFile*/ File),
/*unsigned*/ LineNumber,
/*uint64_t*/ SizeInBits,
/*uint64_t*/ AlignInBits,
unwrap(/*LLVMDIArray*/ Elements),
unwrap(/*LLVMDIType*/ UnderlyingType),
unwrapStringRef(UniqueIdentifier)));
}
/// createSubroutineType - Create subroutine type.
/// @param File File in which this subroutine is defined.
/// @param ParameterTypes An array of subroutine parameter types. This
/// includes return type at 0th index.
/// @param Flags E.g.: LValueReference.
/// These flags are used to emit dwarf attributes.
LLVMDICompositeType DIBcreateSubroutineType(LLVMDIBuilderRef Builder,
LLVMDIFile File,
LLVMDITypeArray ParameterTypes,
unsigned Flags) {
return wrap(unwrapBuilder(Builder)-> createSubroutineType(
unwrap(/*LLVMDIFile*/ File),
unwrap(/*LLVMDITypeArray*/ ParameterTypes),
/*unsigned*/ Flags ));
}
/// createArtificialType - Create a new LLVMDIType with "artificial" flag set.
LLVMDIType DIBcreateArtificialType( LLVMDIBuilderRef Builder,
LLVMDIType Ty) {
return wrap(unwrapBuilder(Builder)-> createArtificialType( unwrap(/*LLVMDIType*/ Ty)));
}
/// createObjectPointerType - Create a new LLVMDIType with the "object pointer"
/// flag set.
LLVMDIType DIBcreateObjectPointerType(LLVMDIBuilderRef Builder,
LLVMDIType Ty) {
return wrap(unwrapBuilder(Builder)-> createObjectPointerType( unwrap(/*LLVMDIType*/ Ty)));
}
/// Create a permanent forward-declared type.
LLVMDICompositeType DIBcreateForwardDecl(LLVMDIBuilderRef Builder,
unsigned Tag,
LLVMStringRef Name,
LLVMDIDescriptor Scope,
LLVMDIFile F,
unsigned Line,
unsigned RuntimeLang,
uint64_t SizeInBits,
uint64_t AlignInBits,
LLVMStringRef UniqueIdentifier) {
return wrap(unwrapBuilder(Builder)-> createForwardDecl(
/*unsigned*/ Tag,
unwrapStringRef(Name),
unwrap(/*LLVMDIDescriptor*/ Scope),
unwrap(/*LLVMDIFile*/ F),
/*unsigned*/ Line,
/*unsigned*/ RuntimeLang,
/*uint64_t*/ SizeInBits,
/*uint64_t*/ AlignInBits,
unwrapStringRef(UniqueIdentifier)));
}
/// createForwardDecl - Create a temporary forward-declared type.
LLVMDICompositeType DIBcreateReplaceableForwardDecl(LLVMDIBuilderRef Builder,
unsigned Tag,
LLVMStringRef Name,
LLVMDIDescriptor Scope,
LLVMDIFile F,
unsigned Line,
unsigned RuntimeLang,
uint64_t SizeInBits,
uint64_t AlignInBits,
LLVMStringRef UniqueIdentifier) {
return wrap(unwrapBuilder(Builder)-> createReplaceableForwardDecl(
/*unsigned*/ Tag,
unwrapStringRef(Name),
unwrap(/*LLVMDIDescriptor*/ Scope),
unwrap(/*LLVMDIFile*/ F),
/*unsigned*/ Line,
/*unsigned*/ RuntimeLang,
/*uint64_t*/ SizeInBits,
/*uint64_t*/ AlignInBits,
unwrapStringRef(UniqueIdentifier)));
}
/// retainType - Retain DIType in a module even if it is not referenced
/// through debug info anchors.
void DIBretainType(LLVMDIBuilderRef Builder, LLVMDIType T) {
return unwrapBuilder(Builder)-> retainType( unwrap(/*LLVMDIType*/ T));
}
/// createUnspecifiedParameter - Create unspecified type descriptor
/// for a subroutine type.
LLVMDIBasicType DIBcreateUnspecifiedParameter(LLVMDIBuilderRef Builder) {
return wrap(unwrapBuilder(Builder)-> createUnspecifiedParameter());
}
/// getOrCreateArray - Get a DIArray, create one if required.
LLVMDIArray DIBgetOrCreateArray(LLVMDIBuilderRef Builder,
LLVMArrayRefOfMetadataPtr Elements) {
return wrap(unwrapBuilder(Builder)-> getOrCreateArray
(unwrapAOfM(/*LLVMArrayRefOfMetadataPtr*/ Elements)));
}
/// getOrCreateSubrange - Create a descriptor for a value range. This
/// implicitly uniques the values returned.
LLVMDISubrange DIBgetOrCreateSubrange(LLVMDIBuilderRef Builder,
int64_t Lo,
int64_t Count) {
return wrap(unwrapBuilder(Builder)-> getOrCreateSubrange(
/*int64_t*/ Lo,
/*int64_t*/ Count));
}
/// \brief Create a new descriptor for the specified global.
/// @param Name Name of the variable.
/// @param LinkageName Mangled variable name.
/// @param File File where this variable is defined.
/// @param LineNo Line number.
/// @param Ty Variable Type.
/// @param isLocalToUnit Boolean flag indicate whether this variable is
/// externally visible or not.
/// @param Val llvm::Value of the variable.
LLVMDIGlobalVariable
DIBcreateGlobalVariable
(LLVMDIBuilderRef Builder,
LLVMDIDescriptor Context,
LLVMStringRef Name,
LLVMStringRef LinkageName,
LLVMDIFile File,
unsigned LineNo,
LLVMDITypeRef Ty,
LLVMBool isLocalToUnit,
LLVMConstantRef Val,
LLVMMDNodePtr Decl) {
return wrap(unwrapBuilder(Builder)-> createGlobalVariable(
unwrap(/*LLVMDIDescriptor*/ Context),
unwrapStringRef(Name),
unwrapStringRef(LinkageName),
unwrap(/*LLVMDIFile*/ File),
/*unsigned*/ LineNo,
unwrapDITypeRef(/*LLVMDITypeRef*/ Ty),
/*LLVMBool*/ isLocalToUnit,
unwrap(/*LLVMConstantRef*/ Val),
unwrapMDNodePtr(Decl)));
}
/// createTempGlobalVariableFwdDecl - Identical to createGlobalVariable
/// except that the resulting DbgNode is temporary and meant to be RAUWed.
LLVMDIGlobalVariable
DIBcreateTempGlobalVariableFwdDecl
(LLVMDIBuilderRef Builder,
LLVMDIDescriptor Context,
LLVMStringRef Name,
LLVMStringRef LinkageName,
LLVMDIFile File,
unsigned LineNo,
LLVMDITypeRef Ty,
LLVMBool isLocalToUnit,
LLVMConstantRef Val,
LLVMMDNodePtr Decl) {
return wrap(unwrapBuilder(Builder)-> createGlobalVariable(
unwrap(/*LLVMDIDescriptor*/ Context),
unwrapStringRef(Name),
unwrapStringRef(LinkageName),
unwrap(/*LLVMDIFile*/ File),
/*unsigned*/ LineNo,
unwrapDITypeRef(/*LLVMDITypeRef*/ Ty),
/*LLVMBool*/ isLocalToUnit,
unwrap(/*LLVMConstantRef*/ Val),
unwrapMDNodePtr(Decl)));
}
/// createLocalVariable - Create a new descriptor for the specified
/// local variable.
/// @param Tag Dwarf TAG. Usually DW_TAG_auto_variable or
/// DW_TAG_arg_variable.
/// @param Scope Variable scope.
/// @param Name Variable name.
/// @param File File where this variable is defined.
/// @param LineNo Line number.
/// @param Ty Variable Type
/// @param AlwaysPreserve Boolean. Set to true if debug info for this
/// variable should be preserved in optimized build.
/// @param Flags Flags, e.g. artificial variable.
/// @param ArgNo If this variable is an argument then this argument's
/// number. 1 indicates 1st argument.
LLVMDIVariable DIBcreateLocalVariable(LLVMDIBuilderRef Builder,
unsigned Tag,
LLVMDIDescriptor Scope,
LLVMStringRef Name,
LLVMDIFile File,
unsigned LineNo,
LLVMDITypeRef Ty,