Lines 18-52
using namespace llvm;
Link Here
|
18 |
#define LLVM_VERSION_LE(major, minor) \ |
18 |
#define LLVM_VERSION_LE(major, minor) \ |
19 |
(LLVM_VERSION_MAJOR < (major) || LLVM_VERSION_MAJOR == (major) && LLVM_VERSION_MINOR <= (minor)) |
19 |
(LLVM_VERSION_MAJOR < (major) || LLVM_VERSION_MAJOR == (major) && LLVM_VERSION_MINOR <= (minor)) |
|
|
20 |
#if LLVM_VERSION_LE(4, 0) |
20 |
typedef struct LLVMOpaqueDIBuilder *LLVMDIBuilderRef; |
21 |
typedef struct LLVMOpaqueDIBuilder *LLVMDIBuilderRef; |
21 |
DEFINE_SIMPLE_CONVERSION_FUNCTIONS(DIBuilder, LLVMDIBuilderRef) |
22 |
DEFINE_SIMPLE_CONVERSION_FUNCTIONS(DIBuilder, LLVMDIBuilderRef) |
22 |
#if LLVM_VERSION_EQ(3, 5) |
|
|
23 |
typedef LLVMValueRef LLVMMetadataRef; |
24 |
typedef Value Metadata; |
25 |
#define DIBuilderRef LLVMDIBuilderRef |
26 |
|
27 |
#else /* LLVM != 3.5 */ |
28 |
typedef struct LLVMOpaqueMetadata *LLVMMetadataRef; |
23 |
typedef struct LLVMOpaqueMetadata *LLVMMetadataRef; |
29 |
DEFINE_ISA_CONVERSION_FUNCTIONS(Metadata, LLVMMetadataRef) |
24 |
DEFINE_ISA_CONVERSION_FUNCTIONS(Metadata, LLVMMetadataRef) |
30 |
inline Metadata **unwrap(LLVMMetadataRef *Vals) { |
25 |
inline Metadata **unwrap(LLVMMetadataRef *Vals) { |
31 |
return reinterpret_cast<Metadata **>(Vals); |
26 |
return reinterpret_cast<Metadata **>(Vals); |
32 |
} |
27 |
} |
33 |
#endif /* LLVM == 3.5 */ |
28 |
#endif |
34 |
|
|
|
35 |
#if LLVM_VERSION_LE(3, 6) |
36 |
template <typename T> T unwrapDIptr(LLVMMetadataRef v) { |
37 |
return v ? T(unwrap<MDNode>(v)) : T(); |
38 |
} |
39 |
#define DIBuilderRef LLVMDIBuilderRef |
40 |
#else /* LLVM > 3.6 */ |
|
|
41 |
typedef DIBuilder *DIBuilderRef; |
29 |
typedef DIBuilder *DIBuilderRef; |
42 |
#define DIArray DINodeArray |
30 |
#define DIArray DINodeArray |
43 |
template <typename T> T *unwrapDIptr(LLVMMetadataRef v) { |
31 |
template <typename T> T *unwrapDIptr(LLVMMetadataRef v) { |
44 |
return (T *)(v ? unwrap<MDNode>(v) : NULL); |
32 |
return (T *)(v ? unwrap<MDNode>(v) : NULL); |
45 |
} |
33 |
} |
46 |
#endif /* LLVM <= 3.6 */ |
|
|
47 |
#if LLVM_VERSION_LE(3, 6) |
34 |
#if LLVM_VERSION_LE(3, 6) |
48 |
#define OperandBundleDef void |
35 |
#define OperandBundleDef void |
Lines 66-78
void LLVMDIBuilderFinalize(LLVMDIBuilderRef dref) { unwrap(dref)->finalize(); }
Link Here
|
66 |
LLVMMetadataRef LLVMDIBuilderCreateFile(DIBuilderRef Dref, const char *File, |
53 |
LLVMMetadataRef LLVMDIBuilderCreateFile(DIBuilderRef Dref, const char *File, |
67 |
const char *Dir) { |
54 |
const char *Dir) { |
68 |
#if LLVM_VERSION_LE(3, 6) |
|
|
69 |
DIBuilder *D = unwrap(Dref); |
70 |
DIFile F = D->createFile(File, Dir); |
71 |
return wrap(F); |
72 |
#else |
73 |
return wrap(Dref->createFile(File, Dir)); |
55 |
return wrap(Dref->createFile(File, Dir)); |
74 |
#endif |
|
|
75 |
} |
56 |
} |
76 |
LLVMMetadataRef LLVMDIBuilderCreateCompileUnit(DIBuilderRef Dref, unsigned Lang, |
57 |
LLVMMetadataRef LLVMDIBuilderCreateCompileUnit(DIBuilderRef Dref, unsigned Lang, |
Lines 82-101
LLVMMetadataRef LLVMDIBuilderCreateCompileUnit(DIBuilderRef Dref, unsigned Lang,
Link Here
|
82 |
int Optimized, |
63 |
int Optimized, |
83 |
const char *Flags, |
64 |
const char *Flags, |
84 |
unsigned RuntimeVersion) { |
65 |
unsigned RuntimeVersion) { |
85 |
#if LLVM_VERSION_LE(3, 6) |
66 |
#if LLVM_VERSION_LE(3, 9) |
86 |
DIBuilder *D = unwrap(Dref); |
|
|
87 |
DICompileUnit CU = D->createCompileUnit(Lang, File, Dir, Producer, Optimized, |
88 |
Flags, RuntimeVersion); |
89 |
return wrap(CU); |
90 |
#else |
91 |
# if LLVM_VERSION_LE(3, 9) |
92 |
return wrap(Dref->createCompileUnit(Lang, File, Dir, Producer, Optimized, |
67 |
return wrap(Dref->createCompileUnit(Lang, File, Dir, Producer, Optimized, |
93 |
Flags, RuntimeVersion)); |
68 |
Flags, RuntimeVersion)); |
94 |
# else |
69 |
#else |
95 |
DIFile *F = Dref->createFile(File, Dir); |
70 |
DIFile *F = Dref->createFile(File, Dir); |
96 |
return wrap(Dref->createCompileUnit(Lang, F, Producer, Optimized, |
71 |
return wrap(Dref->createCompileUnit(Lang, F, Producer, Optimized, |
97 |
Flags, RuntimeVersion)); |
72 |
Flags, RuntimeVersion)); |
98 |
# endif |
|
|
99 |
#endif |
73 |
#endif |
100 |
} |
74 |
} |
Lines 111-129
LLVMMetadataRef LLVMDIBuilderCreateFunction(
Link Here
|
111 |
#endif |
85 |
#endif |
112 |
bool IsOptimized, |
86 |
bool IsOptimized, |
113 |
LLVMValueRef Func) { |
87 |
LLVMValueRef Func) { |
114 |
#if LLVM_VERSION_LE(3, 6) |
|
|
115 |
DIBuilder *D = unwrap(Dref); |
116 |
DISubprogram Sub = D->createFunction( |
117 |
unwrapDI<DIDescriptor>(Scope), Name, LinkageName, unwrapDI<DIFile>(File), |
118 |
Line, unwrapDI<DICompositeType>(CompositeType), IsLocalToUnit, |
119 |
IsDefinition, ScopeLine, Flags, IsOptimized, unwrap<Function>(Func)); |
120 |
#else |
121 |
DISubprogram *Sub = Dref->createFunction( |
88 |
DISubprogram *Sub = Dref->createFunction( |
122 |
unwrapDI<DIScope>(Scope), Name, LinkageName, unwrapDI<DIFile>(File), Line, |
89 |
unwrapDI<DIScope>(Scope), Name, LinkageName, unwrapDI<DIFile>(File), Line, |
123 |
unwrapDI<DISubroutineType>(CompositeType), IsLocalToUnit, IsDefinition, |
90 |
unwrapDI<DISubroutineType>(CompositeType), IsLocalToUnit, IsDefinition, |
124 |
ScopeLine, Flags, IsOptimized); |
91 |
ScopeLine, Flags, IsOptimized); |
125 |
unwrap<Function>(Func)->setSubprogram(Sub); |
92 |
unwrap<Function>(Func)->setSubprogram(Sub); |
126 |
#endif |
|
|
127 |
return wrap(Sub); |
93 |
return wrap(Sub); |
128 |
} |
94 |
} |
Lines 132-149
LLVMMetadataRef LLVMDIBuilderCreateLexicalBlock(DIBuilderRef Dref,
Link Here
|
132 |
LLVMMetadataRef File, |
98 |
LLVMMetadataRef File, |
133 |
unsigned Line, |
99 |
unsigned Line, |
134 |
unsigned Column) { |
100 |
unsigned Column) { |
135 |
#if LLVM_VERSION_LE(3, 6) |
|
|
136 |
DIBuilder *D = unwrap(Dref); |
137 |
# if LLVM_VERSION_EQ(3, 5) |
138 |
DILexicalBlock LB = D->createLexicalBlock(unwrapDI<DIDescriptor>(Scope), unwrapDI<DIFile>(File), Line, Column, 0); |
139 |
# else /* LLVM <= 3.6 && LLVM != 3.5 */ |
140 |
DILexicalBlock LB = D->createLexicalBlock(unwrapDI<DIDescriptor>(Scope), unwrapDI<DIFile>(File), Line, Column); |
141 |
# endif |
142 |
return wrap(LB); |
143 |
#else /* LLVM > 3.6 */ |
144 |
return wrap(Dref->createLexicalBlock(unwrapDI<DIDescriptor>(Scope), |
101 |
return wrap(Dref->createLexicalBlock(unwrapDI<DIDescriptor>(Scope), |
145 |
unwrapDI<DIFile>(File), Line, Column)); |
102 |
unwrapDI<DIFile>(File), Line, Column)); |
146 |
#endif /* LLVM <= 3.6 */ |
|
|
147 |
} |
103 |
} |
148 |
LLVMMetadataRef LLVMDIBuilderCreateBasicType(DIBuilderRef Dref, |
104 |
LLVMMetadataRef LLVMDIBuilderCreateBasicType(DIBuilderRef Dref, |
Lines 151-221
LLVMMetadataRef LLVMDIBuilderCreateBasicType(DIBuilderRef Dref,
Link Here
|
151 |
uint64_t SizeInBits, |
107 |
uint64_t SizeInBits, |
152 |
uint64_t AlignInBits, |
108 |
uint64_t AlignInBits, |
153 |
unsigned Encoding) { |
109 |
unsigned Encoding) { |
154 |
#if LLVM_VERSION_LE(3, 6) |
110 |
#if LLVM_VERSION_LE(3, 9) |
155 |
DIBuilder *D = unwrap(Dref); |
|
|
156 |
DIBasicType T = D->createBasicType(Name, SizeInBits, AlignInBits, Encoding); |
157 |
return wrap(T); |
158 |
#else |
159 |
# if LLVM_VERSION_LE(3, 9) |
160 |
return wrap(Dref->createBasicType(Name, SizeInBits, AlignInBits, Encoding)); |
111 |
return wrap(Dref->createBasicType(Name, SizeInBits, AlignInBits, Encoding)); |
161 |
# else |
112 |
#else |
162 |
return wrap(Dref->createBasicType(Name, SizeInBits, Encoding)); |
113 |
return wrap(Dref->createBasicType(Name, SizeInBits, Encoding)); |
163 |
# endif |
|
|
164 |
#endif |
114 |
#endif |
165 |
} |
115 |
} |
166 |
LLVMMetadataRef LLVMDIBuilderGetOrCreateTypeArray(DIBuilderRef Dref, |
116 |
LLVMMetadataRef LLVMDIBuilderGetOrCreateTypeArray(DIBuilderRef Dref, |
167 |
LLVMMetadataRef *Data, |
117 |
LLVMMetadataRef *Data, |
168 |
unsigned Length) { |
118 |
unsigned Length) { |
169 |
#if LLVM_VERSION_LE(3, 6) |
|
|
170 |
DIBuilder *D = unwrap(Dref); |
171 |
# if LLVM_VERSION_EQ(3, 5) |
172 |
Value **DataValue = unwrap(Data); |
173 |
ArrayRef<Value *> Elements(DataValue, Length); |
174 |
DIArray A = D->getOrCreateArray(Elements); |
175 |
# else /* LLVM <= 3.6 && LLVM != 3.5 */ |
176 |
Metadata **DataValue = unwrap(Data); |
177 |
ArrayRef<Metadata *> Elements(DataValue, Length); |
178 |
DITypeArray A = D->getOrCreateTypeArray(Elements); |
179 |
# endif |
180 |
return wrap(A); |
181 |
#else /* LLVM > 3.6 */ |
182 |
Metadata **DataValue = unwrap(Data); |
119 |
Metadata **DataValue = unwrap(Data); |
183 |
return wrap( |
120 |
return wrap( |
184 |
Dref->getOrCreateTypeArray(ArrayRef<Metadata *>(DataValue, Length)) |
121 |
Dref->getOrCreateTypeArray(ArrayRef<Metadata *>(DataValue, Length)) |
185 |
.get()); |
122 |
.get()); |
186 |
#endif /* LLVM <= 3.6 */ |
|
|
187 |
} |
123 |
} |
188 |
LLVMMetadataRef LLVMDIBuilderGetOrCreateArray(DIBuilderRef Dref, |
124 |
LLVMMetadataRef LLVMDIBuilderGetOrCreateArray(DIBuilderRef Dref, |
189 |
LLVMMetadataRef *Data, |
125 |
LLVMMetadataRef *Data, |
190 |
unsigned Length) { |
126 |
unsigned Length) { |
191 |
#if LLVM_VERSION_LE(3, 6) |
|
|
192 |
DIBuilder *D = unwrap(Dref); |
193 |
ArrayRef<Metadata *> elements(unwrap(Data), Length); |
194 |
DIArray a = D->getOrCreateArray(elements); |
195 |
|
196 |
return wrap(a); |
197 |
#else |
198 |
Metadata **DataValue = unwrap(Data); |
127 |
Metadata **DataValue = unwrap(Data); |
199 |
return wrap( |
128 |
return wrap( |
200 |
Dref->getOrCreateArray(ArrayRef<Metadata *>(DataValue, Length)).get()); |
129 |
Dref->getOrCreateArray(ArrayRef<Metadata *>(DataValue, Length)).get()); |
201 |
#endif |
|
|
202 |
} |
130 |
} |
203 |
LLVMMetadataRef |
131 |
LLVMMetadataRef |
204 |
LLVMDIBuilderCreateSubroutineType(DIBuilderRef Dref, LLVMMetadataRef File, |
132 |
LLVMDIBuilderCreateSubroutineType(DIBuilderRef Dref, LLVMMetadataRef File, |
205 |
LLVMMetadataRef ParameterTypes) { |
133 |
LLVMMetadataRef ParameterTypes) { |
206 |
#if LLVM_VERSION_LE(3, 6) |
|
|
207 |
DIBuilder *D = unwrap(Dref); |
208 |
# if LLVM_VERSION_EQ(3, 5) |
209 |
DICompositeType CT = D->createSubroutineType(unwrapDI<DIFile>(File), unwrapDI<DIArray>(ParameterTypes)); |
210 |
# else /* LLVM <= 3.6 && LLVM != 3.5 */ |
211 |
DICompositeType CT = D->createSubroutineType(unwrapDI<DIFile>(File), unwrapDI<DITypeArray>(ParameterTypes)); |
212 |
# endif |
213 |
#else /* LLVM > 3.6 */ |
214 |
DISubroutineType *CT = Dref->createSubroutineType(DITypeRefArray(unwrap<MDTuple>(ParameterTypes))); |
134 |
DISubroutineType *CT = Dref->createSubroutineType(DITypeRefArray(unwrap<MDTuple>(ParameterTypes))); |
215 |
#endif /* LLVM <= 3.6 */ |
|
|
216 |
return wrap(CT); |
135 |
return wrap(CT); |
217 |
} |
136 |
} |
Lines 229-249
LLVMMetadataRef LLVMDIBuilderCreateAutoVariable(
Link Here
|
229 |
DINode::DIFlags Flags, |
148 |
DINode::DIFlags Flags, |
230 |
#endif |
149 |
#endif |
231 |
uint32_t AlignInBits) { |
150 |
uint32_t AlignInBits) { |
232 |
#if LLVM_VERSION_LE(3, 6) |
151 |
#if LLVM_VERSION_LE(3, 9) |
233 |
DIBuilder *D = unwrap(Dref); |
|
|
234 |
DIVariable V = D->createLocalVariable( |
235 |
llvm::dwarf::DW_TAG_auto_variable, unwrapDI<DIDescriptor>(Scope), Name, unwrapDI<DIFile>(File), Line, |
236 |
unwrapDI<DIType>(Ty), AlwaysPreserve, Flags, 0); |
237 |
#else |
238 |
# if LLVM_VERSION_LE(3, 9) |
239 |
DILocalVariable *V = Dref->createAutoVariable( |
152 |
DILocalVariable *V = Dref->createAutoVariable( |
240 |
unwrapDI<DIDescriptor>(Scope), Name, unwrapDI<DIFile>(File), Line, |
153 |
unwrapDI<DIDescriptor>(Scope), Name, unwrapDI<DIFile>(File), Line, |
241 |
unwrapDI<DIType>(Ty), AlwaysPreserve, Flags); |
154 |
unwrapDI<DIType>(Ty), AlwaysPreserve, Flags); |
242 |
# else |
155 |
#else |
243 |
DILocalVariable *V = Dref->createAutoVariable( |
156 |
DILocalVariable *V = Dref->createAutoVariable( |
244 |
unwrapDI<DIDescriptor>(Scope), Name, unwrapDI<DIFile>(File), Line, |
157 |
unwrapDI<DIDescriptor>(Scope), Name, unwrapDI<DIFile>(File), Line, |
245 |
unwrapDI<DIType>(Ty), AlwaysPreserve, Flags, AlignInBits); |
158 |
unwrapDI<DIType>(Ty), AlwaysPreserve, Flags, AlignInBits); |
246 |
# endif |
|
|
247 |
#endif |
159 |
#endif |
248 |
return wrap(V); |
160 |
return wrap(V); |
249 |
} |
161 |
} |
Lines 258-275
LLVMMetadataRef LLVMDIBuilderCreateParameterVariable(
Link Here
|
258 |
DINode::DIFlags Flags |
170 |
DINode::DIFlags Flags |
259 |
#endif |
171 |
#endif |
260 |
) { |
172 |
) { |
261 |
#if LLVM_VERSION_LE(3, 6) |
|
|
262 |
DIBuilder *D = unwrap(Dref); |
263 |
DIVariable V = D->createLocalVariable( |
264 |
llvm::dwarf::DW_TAG_arg_variable, unwrapDI<DIDescriptor>(Scope), Name, unwrapDI<DIFile>(File), Line, |
265 |
unwrapDI<DIType>(Ty), AlwaysPreserve, Flags, ArgNo); |
266 |
return wrap(V); |
267 |
#else |
268 |
DILocalVariable *V = Dref->createParameterVariable |
173 |
DILocalVariable *V = Dref->createParameterVariable |
269 |
(unwrapDI<DIDescriptor>(Scope), Name, ArgNo, unwrapDI<DIFile>(File), Line, |
174 |
(unwrapDI<DIDescriptor>(Scope), Name, ArgNo, unwrapDI<DIFile>(File), Line, |
270 |
unwrapDI<DIType>(Ty), AlwaysPreserve, Flags); |
175 |
unwrapDI<DIType>(Ty), AlwaysPreserve, Flags); |
271 |
return wrap(V); |
176 |
return wrap(V); |
272 |
#endif |
|
|
273 |
} |
177 |
} |
274 |
LLVMValueRef LLVMDIBuilderInsertDeclareAtEnd(DIBuilderRef Dref, |
178 |
LLVMValueRef LLVMDIBuilderInsertDeclareAtEnd(DIBuilderRef Dref, |
Lines 278-323
LLVMValueRef LLVMDIBuilderInsertDeclareAtEnd(DIBuilderRef Dref,
Link Here
|
278 |
LLVMMetadataRef Expr, |
182 |
LLVMMetadataRef Expr, |
279 |
LLVMValueRef DL, |
183 |
LLVMValueRef DL, |
280 |
LLVMBasicBlockRef Block) { |
184 |
LLVMBasicBlockRef Block) { |
281 |
#if LLVM_VERSION_EQ(3, 5) |
|
|
282 |
DIBuilder *D = unwrap(Dref); |
283 |
Instruction *Instr = |
284 |
D->insertDeclare(unwrap(Storage), unwrapDI<DIVariable>(VarInfo), |
285 |
unwrap(Block)); |
286 |
Instr->setDebugLoc(DebugLoc::getFromDILocation(cast<MDNode>(DL))); |
287 |
#endif |
288 |
|
289 |
#if LLVM_VERSION_EQ(3, 6) |
290 |
DIBuilder *D = unwrap(Dref); |
291 |
Instruction *Instr = |
292 |
D->insertDeclare(unwrap(Storage), unwrapDI<DIVariable>(VarInfo), |
293 |
unwrapDI<DIExpression>(Expr), unwrap(Block)); |
294 |
Instr->setDebugLoc(DebugLoc::getFromDILocation(cast<MDNode>(unwrap<MetadataAsValue>(DL)->getMetadata()))); |
295 |
#endif |
296 |
|
297 |
#if LLVM_VERSION_GE(3, 7) |
298 |
Instruction *Instr = |
185 |
Instruction *Instr = |
299 |
Dref->insertDeclare(unwrap(Storage), unwrap<DILocalVariable>(VarInfo), |
186 |
Dref->insertDeclare(unwrap(Storage), unwrap<DILocalVariable>(VarInfo), |
300 |
unwrapDI<DIExpression>(Expr), |
187 |
unwrapDI<DIExpression>(Expr), |
301 |
DebugLoc(cast<MDNode>(unwrap<MetadataAsValue>(DL)->getMetadata())), |
188 |
DebugLoc(cast<MDNode>(unwrap<MetadataAsValue>(DL)->getMetadata())), |
302 |
unwrap(Block)); |
189 |
unwrap(Block)); |
303 |
#endif |
|
|
304 |
|
305 |
return wrap(Instr); |
190 |
return wrap(Instr); |
306 |
} |
191 |
} |
307 |
LLVMMetadataRef LLVMDIBuilderCreateExpression(DIBuilderRef Dref, int64_t *Addr, |
192 |
LLVMMetadataRef LLVMDIBuilderCreateExpression(DIBuilderRef Dref, int64_t *Addr, |
308 |
size_t Length) { |
193 |
size_t Length) { |
309 |
#if LLVM_VERSION_LE(3, 6) |
|
|
310 |
# if LLVM_VERSION_EQ(3, 5) |
311 |
return nullptr; |
312 |
# else /* LLVM <= 3.6 && LLVM != 3.5 */ |
313 |
DIBuilder *D = unwrap(Dref); |
314 |
DIExpression Expr = D->createExpression(ArrayRef<int64_t>(Addr, Length)); |
315 |
return wrap(Expr); |
316 |
# endif |
317 |
#else /* LLVM > 3.6 */ |
318 |
return wrap(Dref->createExpression(ArrayRef<int64_t>(Addr, Length))); |
194 |
return wrap(Dref->createExpression(ArrayRef<int64_t>(Addr, Length))); |
319 |
#endif |
|
|
320 |
} |
195 |
} |
321 |
LLVMMetadataRef LLVMDIBuilderCreateEnumerationType( |
196 |
LLVMMetadataRef LLVMDIBuilderCreateEnumerationType( |
Lines 325-354
LLVMMetadataRef LLVMDIBuilderCreateEnumerationType(
Link Here
|
325 |
LLVMMetadataRef File, unsigned LineNumber, uint64_t SizeInBits, |
200 |
LLVMMetadataRef File, unsigned LineNumber, uint64_t SizeInBits, |
326 |
uint64_t AlignInBits, LLVMMetadataRef Elements, |
201 |
uint64_t AlignInBits, LLVMMetadataRef Elements, |
327 |
LLVMMetadataRef UnderlyingType) { |
202 |
LLVMMetadataRef UnderlyingType) { |
328 |
#if LLVM_VERSION_LE(3, 6) |
|
|
329 |
DIBuilder *D = unwrap(Dref); |
330 |
DICompositeType enumType = D->createEnumerationType( |
331 |
unwrapDI<DIDescriptor>(Scope), Name, unwrapDI<DIFile>(File), LineNumber, |
332 |
SizeInBits, AlignInBits, unwrapDI<DIArray>(Elements), |
333 |
unwrapDI<DIType>(UnderlyingType)); |
334 |
#else |
335 |
DICompositeType *enumType = Dref->createEnumerationType( |
203 |
DICompositeType *enumType = Dref->createEnumerationType( |
336 |
unwrapDI<DIDescriptor>(Scope), Name, unwrapDI<DIFile>(File), LineNumber, |
204 |
unwrapDI<DIDescriptor>(Scope), Name, unwrapDI<DIFile>(File), LineNumber, |
337 |
SizeInBits, AlignInBits, DINodeArray(unwrapDI<MDTuple>(Elements)), |
205 |
SizeInBits, AlignInBits, DINodeArray(unwrapDI<MDTuple>(Elements)), |
338 |
unwrapDI<DIType>(UnderlyingType)); |
206 |
unwrapDI<DIType>(UnderlyingType)); |
339 |
#endif |
|
|
340 |
return wrap(enumType); |
207 |
return wrap(enumType); |
341 |
} |
208 |
} |
342 |
LLVMMetadataRef LLVMDIBuilderCreateEnumerator(DIBuilderRef Dref, |
209 |
LLVMMetadataRef LLVMDIBuilderCreateEnumerator(DIBuilderRef Dref, |
343 |
const char *Name, int64_t Value) { |
210 |
const char *Name, int64_t Value) { |
344 |
#if LLVM_VERSION_LE(3, 6) |
|
|
345 |
DIBuilder *D = unwrap(Dref); |
346 |
DIEnumerator e = D->createEnumerator(Name, Value); |
347 |
return wrap(e); |
348 |
#else |
349 |
DIEnumerator *e = Dref->createEnumerator(Name, Value); |
211 |
DIEnumerator *e = Dref->createEnumerator(Name, Value); |
350 |
#endif |
|
|
351 |
return wrap(e); |
212 |
return wrap(e); |
352 |
} |
213 |
} |
Lines 367-388
LLVMDIBuilderCreateStructType(DIBuilderRef Dref,
Link Here
|
367 |
#endif |
228 |
#endif |
368 |
LLVMMetadataRef DerivedFrom, |
229 |
LLVMMetadataRef DerivedFrom, |
369 |
LLVMMetadataRef Elements) { |
230 |
LLVMMetadataRef Elements) { |
370 |
#if LLVM_VERSION_LE(3, 6) |
|
|
371 |
DIBuilder *D = unwrap(Dref); |
372 |
DICompositeType CT = D->createStructType( |
373 |
unwrapDI<DIDescriptor>(Scope), Name, unwrapDI<DIFile>(File), Line, |
374 |
SizeInBits, AlignInBits, Flags, unwrapDI<DIType>(DerivedFrom), |
375 |
unwrapDI<DIArray>(Elements)); |
376 |
#else |
377 |
DICompositeType *CT = Dref->createStructType( |
231 |
DICompositeType *CT = Dref->createStructType( |
378 |
unwrapDI<DIDescriptor>(Scope), Name, unwrapDI<DIFile>(File), Line, |
232 |
unwrapDI<DIDescriptor>(Scope), Name, unwrapDI<DIFile>(File), Line, |
379 |
SizeInBits, AlignInBits, Flags, unwrapDI<DIType>(DerivedFrom), |
233 |
SizeInBits, AlignInBits, Flags, unwrapDI<DIType>(DerivedFrom), |
380 |
DINodeArray(unwrapDI<MDTuple>(Elements))); |
234 |
DINodeArray(unwrapDI<MDTuple>(Elements))); |
381 |
#endif |
|
|
382 |
return wrap(CT); |
235 |
return wrap(CT); |
383 |
} |
236 |
} |
384 |
#if LLVM_VERSION_GE(3, 8) |
|
|
385 |
LLVMMetadataRef |
237 |
LLVMMetadataRef |
386 |
LLVMDIBuilderCreateReplaceableCompositeType(DIBuilderRef Dref, |
238 |
LLVMDIBuilderCreateReplaceableCompositeType(DIBuilderRef Dref, |
387 |
LLVMMetadataRef Scope, |
239 |
LLVMMetadataRef Scope, |
Lines 409-415
LLVMDIBuilderReplaceTemporary(DIBuilderRef Dref,
Link Here
|
409 |
llvm::TempMDNode fwd_decl(Node); |
261 |
llvm::TempMDNode fwd_decl(Node); |
410 |
Dref->replaceTemporary(std::move(fwd_decl), Type); |
262 |
Dref->replaceTemporary(std::move(fwd_decl), Type); |
411 |
} |
263 |
} |
412 |
#endif |
|
|
413 |
LLVMMetadataRef |
264 |
LLVMMetadataRef |
414 |
LLVMDIBuilderCreateMemberType(DIBuilderRef Dref, LLVMMetadataRef Scope, |
265 |
LLVMDIBuilderCreateMemberType(DIBuilderRef Dref, LLVMMetadataRef Scope, |
Lines 422-437
LLVMDIBuilderCreateMemberType(DIBuilderRef Dref, LLVMMetadataRef Scope,
Link Here
|
422 |
DINode::DIFlags Flags, |
273 |
DINode::DIFlags Flags, |
423 |
#endif |
274 |
#endif |
424 |
LLVMMetadataRef Ty) { |
275 |
LLVMMetadataRef Ty) { |
425 |
#if LLVM_VERSION_LE(3, 6) |
|
|
426 |
DIBuilder *D = unwrap(Dref); |
427 |
DIDerivedType DT = D->createMemberType( |
428 |
unwrapDI<DIDescriptor>(Scope), Name, unwrapDI<DIFile>(File), Line, |
429 |
SizeInBits, AlignInBits, OffsetInBits, Flags, unwrapDI<DIType>(Ty)); |
430 |
#else |
431 |
DIDerivedType *DT = Dref->createMemberType( |
276 |
DIDerivedType *DT = Dref->createMemberType( |
432 |
unwrapDI<DIDescriptor>(Scope), Name, unwrapDI<DIFile>(File), Line, |
277 |
unwrapDI<DIDescriptor>(Scope), Name, unwrapDI<DIFile>(File), Line, |
433 |
SizeInBits, AlignInBits, OffsetInBits, Flags, unwrapDI<DIType>(Ty)); |
278 |
SizeInBits, AlignInBits, OffsetInBits, Flags, unwrapDI<DIType>(Ty)); |
434 |
#endif |
|
|
435 |
return wrap(DT); |
279 |
return wrap(DT); |
436 |
} |
280 |
} |
Lines 440-478
LLVMMetadataRef LLVMDIBuilderCreatePointerType(DIBuilderRef Dref,
Link Here
|
440 |
uint64_t SizeInBits, |
284 |
uint64_t SizeInBits, |
441 |
uint64_t AlignInBits, |
285 |
uint64_t AlignInBits, |
442 |
const char *Name) { |
286 |
const char *Name) { |
443 |
#if LLVM_VERSION_LE(3, 6) |
|
|
444 |
DIBuilder *D = unwrap(Dref); |
445 |
DIDerivedType T = D->createPointerType(unwrapDI<DIType>(PointeeType), |
446 |
SizeInBits, AlignInBits, Name); |
447 |
#else |
448 |
DIDerivedType *T = Dref->createPointerType(unwrapDI<DIType>(PointeeType), |
287 |
DIDerivedType *T = Dref->createPointerType(unwrapDI<DIType>(PointeeType), |
449 |
SizeInBits, AlignInBits, Name); |
288 |
SizeInBits, AlignInBits, |
|
|
289 |
#if LLVM_VERSION_GE(5, 0) |
290 |
None, |
450 |
#endif |
291 |
#endif |
|
|
292 |
Name); |
451 |
return wrap(T); |
293 |
return wrap(T); |
452 |
} |
294 |
} |
453 |
LLVMMetadataRef LLVMTemporaryMDNode(LLVMContextRef C, LLVMMetadataRef *MDs, |
295 |
LLVMMetadataRef LLVMTemporaryMDNode(LLVMContextRef C, LLVMMetadataRef *MDs, |
454 |
unsigned Count) { |
296 |
unsigned Count) { |
455 |
#if LLVM_VERSION_LE(3, 6) |
|
|
456 |
return wrap(MDNode::getTemporary(*unwrap(C), |
457 |
ArrayRef<Metadata *>(unwrap(MDs), Count))); |
458 |
#else |
459 |
return wrap(MDTuple::getTemporary(*unwrap(C), |
297 |
return wrap(MDTuple::getTemporary(*unwrap(C), |
460 |
ArrayRef<Metadata *>(unwrap(MDs), Count)) |
298 |
ArrayRef<Metadata *>(unwrap(MDs), Count)) |
461 |
.release()); |
299 |
.release()); |
462 |
#endif |
|
|
463 |
} |
300 |
} |
464 |
void LLVMMetadataReplaceAllUsesWith(LLVMMetadataRef MD, LLVMMetadataRef New) { |
301 |
void LLVMMetadataReplaceAllUsesWith(LLVMMetadataRef MD, LLVMMetadataRef New) { |
465 |
#if LLVM_VERSION_LE(3, 6) |
|
|
466 |
# if LLVM_VERSION_EQ(3, 5) |
467 |
auto *Node = unwrap<MDNode>(MD); |
302 |
auto *Node = unwrap<MDNode>(MD); |
468 |
# else /* LLVM <= 3.6 && LLVM != 3.5 */ |
|
|
469 |
auto *Node = unwrap<MDNodeFwdDecl>(MD); |
470 |
# endif |
471 |
#else /* LLVM > 3.6 */ |
472 |
auto *Node = unwrap<MDNode>(MD); |
473 |
#endif |
474 |
Node->replaceAllUsesWith(unwrap<MDNode>(New)); |
303 |
Node->replaceAllUsesWith(unwrap<MDNode>(New)); |
475 |
MDNode::deleteTemporary(Node); |
304 |
MDNode::deleteTemporary(Node); |
476 |
} |
305 |
} |