diff options
author | Andrew Wilkins <axwalk@gmail.com> | 2015-09-06 02:22:15 +0000 |
---|---|---|
committer | Andrew Wilkins <axwalk@gmail.com> | 2015-09-06 02:22:15 +0000 |
commit | 46dd28e2c09e049a3c5669c2a90f74b8c3bdcfde (patch) | |
tree | a95a66fea9f83dd38a854c00dcdb380c41197d45 /bindings | |
parent | 6456d06226cac950e12df13bb8bfa14be8ca4a1b (diff) | |
download | llvm-46dd28e2c09e049a3c5669c2a90f74b8c3bdcfde.tar.gz |
[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
Diffstat (limited to 'bindings')
-rw-r--r-- | bindings/go/llvm/DIBuilderBindings.cpp | 26 | ||||
-rw-r--r-- | bindings/go/llvm/DIBuilderBindings.h | 12 | ||||
-rw-r--r-- | bindings/go/llvm/dibuilder.go | 43 |
3 files changed, 59 insertions, 22 deletions
diff --git a/bindings/go/llvm/DIBuilderBindings.cpp b/bindings/go/llvm/DIBuilderBindings.cpp index 627c09131aa5..d9d0f7ac9648 100644 --- a/bindings/go/llvm/DIBuilderBindings.cpp +++ b/bindings/go/llvm/DIBuilderBindings.cpp @@ -83,21 +83,27 @@ LLVMMetadataRef LLVMDIBuilderCreateFunction( IsOptimized, unwrap<Function>(Func))); } -LLVMMetadataRef LLVMDIBuilderCreateLocalVariable( - LLVMDIBuilderRef Dref, unsigned, LLVMMetadataRef Scope, - const char *Name, LLVMMetadataRef File, unsigned Line, LLVMMetadataRef Ty, - int AlwaysPreserve, unsigned Flags, unsigned ArgNo) { - DIBuilder *D = unwrap(Dref); - // FIXME: Update the Go bindings to match the DIBuilder API. - if (ArgNo) - return wrap(D->createParameterVariable( - unwrap<DIScope>(Scope), Name, ArgNo, unwrap<DIFile>(File), Line, - unwrap<DIType>(Ty), AlwaysPreserve, Flags)); +LLVMMetadataRef +LLVMDIBuilderCreateAutoVariable(LLVMDIBuilderRef Dref, LLVMMetadataRef Scope, + const char *Name, LLVMMetadataRef File, + unsigned Line, LLVMMetadataRef Ty, + int AlwaysPreserve, unsigned Flags) { + DIBuilder *D = unwrap(Dref); return wrap(D->createAutoVariable(unwrap<DIScope>(Scope), Name, unwrap<DIFile>(File), Line, unwrap<DIType>(Ty), AlwaysPreserve, Flags)); } +LLVMMetadataRef LLVMDIBuilderCreateParameterVariable( + LLVMDIBuilderRef Dref, LLVMMetadataRef Scope, const char *Name, + unsigned ArgNo, LLVMMetadataRef File, unsigned Line, LLVMMetadataRef Ty, + int AlwaysPreserve, unsigned Flags) { + DIBuilder *D = unwrap(Dref); + return wrap(D->createParameterVariable( + unwrap<DIScope>(Scope), Name, ArgNo, unwrap<DIFile>(File), Line, + unwrap<DIType>(Ty), AlwaysPreserve, Flags)); +} + LLVMMetadataRef LLVMDIBuilderCreateBasicType(LLVMDIBuilderRef Dref, const char *Name, uint64_t SizeInBits, diff --git a/bindings/go/llvm/DIBuilderBindings.h b/bindings/go/llvm/DIBuilderBindings.h index a4fba2784185..ef6eda15e654 100644 --- a/bindings/go/llvm/DIBuilderBindings.h +++ b/bindings/go/llvm/DIBuilderBindings.h @@ -57,10 +57,16 @@ LLVMMetadataRef LLVMDIBuilderCreateFunction( LLVMMetadataRef CompositeType, int IsLocalToUnit, int IsDefinition, unsigned ScopeLine, unsigned Flags, int IsOptimized, LLVMValueRef Function); -LLVMMetadataRef LLVMDIBuilderCreateLocalVariable( - LLVMDIBuilderRef D, unsigned Tag, LLVMMetadataRef Scope, const char *Name, +LLVMMetadataRef +LLVMDIBuilderCreateAutoVariable(LLVMDIBuilderRef D, LLVMMetadataRef Scope, + const char *Name, LLVMMetadataRef File, + unsigned Line, LLVMMetadataRef Ty, + int AlwaysPreserve, unsigned Flags); + +LLVMMetadataRef LLVMDIBuilderCreateParameterVariable( + LLVMDIBuilderRef D, LLVMMetadataRef Scope, const char *Name, unsigned ArgNo, LLVMMetadataRef File, unsigned Line, LLVMMetadataRef Ty, int AlwaysPreserve, - unsigned Flags, unsigned ArgNo); + unsigned Flags); LLVMMetadataRef LLVMDIBuilderCreateBasicType(LLVMDIBuilderRef D, const char *Name, diff --git a/bindings/go/llvm/dibuilder.go b/bindings/go/llvm/dibuilder.go index f03f740b7770..4ec60738a7ae 100644 --- a/bindings/go/llvm/dibuilder.go +++ b/bindings/go/llvm/dibuilder.go @@ -216,9 +216,35 @@ func (d *DIBuilder) CreateFunction(diScope Metadata, f DIFunction) Metadata { return Metadata{C: result} } -// DILocalVariable holds the values for creating local variable debug metadata. -type DILocalVariable struct { - Tag dwarf.Tag +// DIAutoVariable holds the values for creating auto variable debug metadata. +type DIAutoVariable struct { + Name string + File Metadata + Line int + Type Metadata + AlwaysPreserve bool + Flags int +} + +// CreateAutoVariable creates local variable debug metadata. +func (d *DIBuilder) CreateAutoVariable(scope Metadata, v DIAutoVariable) Metadata { + name := C.CString(v.Name) + defer C.free(unsafe.Pointer(name)) + result := C.LLVMDIBuilderCreateAutoVariable( + d.ref, + scope.C, + name, + v.File.C, + C.unsigned(v.Line), + v.Type.C, + boolToCInt(v.AlwaysPreserve), + C.unsigned(v.Flags), + ) + return Metadata{C: result} +} + +// DIParameterVariable holds the values for creating parameter variable debug metadata. +type DIParameterVariable struct { Name string File Metadata Line int @@ -227,25 +253,24 @@ type DILocalVariable struct { Flags int // ArgNo is the 1-based index of the argument in the function's - // parameter list if it is an argument, or 0 otherwise. + // parameter list. ArgNo int } -// CreateLocalVariable creates local variable debug metadata. -func (d *DIBuilder) CreateLocalVariable(scope Metadata, v DILocalVariable) Metadata { +// CreateParameterVariable creates parameter variable debug metadata. +func (d *DIBuilder) CreateParameterVariable(scope Metadata, v DIParameterVariable) Metadata { name := C.CString(v.Name) defer C.free(unsafe.Pointer(name)) - result := C.LLVMDIBuilderCreateLocalVariable( + result := C.LLVMDIBuilderCreateParameterVariable( d.ref, - C.unsigned(v.Tag), scope.C, name, + C.unsigned(v.ArgNo), v.File.C, C.unsigned(v.Line), v.Type.C, boolToCInt(v.AlwaysPreserve), C.unsigned(v.Flags), - C.unsigned(v.ArgNo), ) return Metadata{C: result} } |