llvm.org GIT mirror llvm / 46dd28e
[bindings] Update Go bindings to DIBuilder Summary: Update the Go bindings to DIBuilder to match the split of creating local variables into auto and parameter variables. Reviewers: pcc Subscribers: llvm-commits, axw Differential Revision: http://reviews.llvm.org/D11864 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@246935 91177308-0d34-0410-b5e6-96231b3b80d8 Andrew Wilkins 5 years ago
3 changed file(s) with 64 addition(s) and 27 deletion(s). Raw diff Collapse all Expand all
8282 IsOptimized, unwrap(Func)));
8383 }
8484
85 LLVMMetadataRef LLVMDIBuilderCreateLocalVariable(
86 LLVMDIBuilderRef Dref, unsigned, LLVMMetadataRef Scope,
87 const char *Name, LLVMMetadataRef File, unsigned Line, LLVMMetadataRef Ty,
88 int AlwaysPreserve, unsigned Flags, unsigned ArgNo) {
89 DIBuilder *D = unwrap(Dref);
90 // FIXME: Update the Go bindings to match the DIBuilder API.
91 if (ArgNo)
92 return wrap(D->createParameterVariable(
93 unwrap(Scope), Name, ArgNo, unwrap(File), Line,
94 unwrap(Ty), AlwaysPreserve, Flags));
85 LLVMMetadataRef
86 LLVMDIBuilderCreateAutoVariable(LLVMDIBuilderRef Dref, LLVMMetadataRef Scope,
87 const char *Name, LLVMMetadataRef File,
88 unsigned Line, LLVMMetadataRef Ty,
89 int AlwaysPreserve, unsigned Flags) {
90 DIBuilder *D = unwrap(Dref);
9591 return wrap(D->createAutoVariable(unwrap(Scope), Name,
9692 unwrap(File), Line,
9793 unwrap(Ty), AlwaysPreserve, Flags));
94 }
95
96 LLVMMetadataRef LLVMDIBuilderCreateParameterVariable(
97 LLVMDIBuilderRef Dref, LLVMMetadataRef Scope, const char *Name,
98 unsigned ArgNo, LLVMMetadataRef File, unsigned Line, LLVMMetadataRef Ty,
99 int AlwaysPreserve, unsigned Flags) {
100 DIBuilder *D = unwrap(Dref);
101 return wrap(D->createParameterVariable(
102 unwrap(Scope), Name, ArgNo, unwrap(File), Line,
103 unwrap(Ty), AlwaysPreserve, Flags));
98104 }
99105
100106 LLVMMetadataRef LLVMDIBuilderCreateBasicType(LLVMDIBuilderRef Dref,
5656 LLVMMetadataRef CompositeType, int IsLocalToUnit, int IsDefinition,
5757 unsigned ScopeLine, unsigned Flags, int IsOptimized, LLVMValueRef Function);
5858
59 LLVMMetadataRef LLVMDIBuilderCreateLocalVariable(
60 LLVMDIBuilderRef D, unsigned Tag, LLVMMetadataRef Scope, const char *Name,
59 LLVMMetadataRef
60 LLVMDIBuilderCreateAutoVariable(LLVMDIBuilderRef D, LLVMMetadataRef Scope,
61 const char *Name, LLVMMetadataRef File,
62 unsigned Line, LLVMMetadataRef Ty,
63 int AlwaysPreserve, unsigned Flags);
64
65 LLVMMetadataRef LLVMDIBuilderCreateParameterVariable(
66 LLVMDIBuilderRef D, LLVMMetadataRef Scope, const char *Name, unsigned ArgNo,
6167 LLVMMetadataRef File, unsigned Line, LLVMMetadataRef Ty, int AlwaysPreserve,
62 unsigned Flags, unsigned ArgNo);
68 unsigned Flags);
6369
6470 LLVMMetadataRef LLVMDIBuilderCreateBasicType(LLVMDIBuilderRef D,
6571 const char *Name,
215215 return Metadata{C: result}
216216 }
217217
218 // DILocalVariable holds the values for creating local variable debug metadata.
219 type DILocalVariable struct {
220 Tag dwarf.Tag
218 // DIAutoVariable holds the values for creating auto variable debug metadata.
219 type DIAutoVariable struct {
221220 Name string
222221 File Metadata
223222 Line int
224223 Type Metadata
225224 AlwaysPreserve bool
226225 Flags int
227
228 // ArgNo is the 1-based index of the argument in the function's
229 // parameter list if it is an argument, or 0 otherwise.
230 ArgNo int
231 }
232
233 // CreateLocalVariable creates local variable debug metadata.
234 func (d *DIBuilder) CreateLocalVariable(scope Metadata, v DILocalVariable) Metadata {
226 }
227
228 // CreateAutoVariable creates local variable debug metadata.
229 func (d *DIBuilder) CreateAutoVariable(scope Metadata, v DIAutoVariable) Metadata {
235230 name := C.CString(v.Name)
236231 defer C.free(unsafe.Pointer(name))
237 result := C.LLVMDIBuilderCreateLocalVariable(
238 d.ref,
239 C.unsigned(v.Tag),
232 result := C.LLVMDIBuilderCreateAutoVariable(
233 d.ref,
240234 scope.C,
241235 name,
242236 v.File.C,
244238 v.Type.C,
245239 boolToCInt(v.AlwaysPreserve),
246240 C.unsigned(v.Flags),
241 )
242 return Metadata{C: result}
243 }
244
245 // DIParameterVariable holds the values for creating parameter variable debug metadata.
246 type DIParameterVariable struct {
247 Name string
248 File Metadata
249 Line int
250 Type Metadata
251 AlwaysPreserve bool
252 Flags int
253
254 // ArgNo is the 1-based index of the argument in the function's
255 // parameter list.
256 ArgNo int
257 }
258
259 // CreateParameterVariable creates parameter variable debug metadata.
260 func (d *DIBuilder) CreateParameterVariable(scope Metadata, v DIParameterVariable) Metadata {
261 name := C.CString(v.Name)
262 defer C.free(unsafe.Pointer(name))
263 result := C.LLVMDIBuilderCreateParameterVariable(
264 d.ref,
265 scope.C,
266 name,
247267 C.unsigned(v.ArgNo),
268 v.File.C,
269 C.unsigned(v.Line),
270 v.Type.C,
271 boolToCInt(v.AlwaysPreserve),
272 C.unsigned(v.Flags),
248273 )
249274 return Metadata{C: result}
250275 }