llvm.org GIT mirror llvm / 78ef496
[bindings/go][NFC] Format code with go fmt Run go fmt (version 1.12) over the Go bindings. This cleans up lots of inconsistencies in the code, it does not change the code in a functional way. Differential Revision: https://reviews.llvm.org/D63057 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@363148 91177308-0d34-0410-b5e6-96231b3b80d8 Ayke van Laethem a month ago
3 changed file(s) with 66 addition(s) and 65 deletion(s). Raw diff Collapse all Expand all
304304
305305 // DIPointerType holds the values for creating pointer type debug metadata.
306306 type DIPointerType struct {
307 Pointee Metadata
308 SizeInBits uint64
309 AlignInBits uint32 // optional
307 Pointee Metadata
308 SizeInBits uint64
309 AlignInBits uint32 // optional
310310 AddressSpace uint32
311 Name string // optional
311 Name string // optional
312312 }
313313
314314 // CreatePointerType creates a type that represents a pointer to another type.
354354
355355 // DIStructType holds the values for creating struct type debug metadata.
356356 type DIStructType struct {
357 Name string
358 File Metadata
359 Line int
360 SizeInBits uint64
361 AlignInBits uint32
362 Flags int
363 DerivedFrom Metadata
364 Elements []Metadata
357 Name string
358 File Metadata
359 Line int
360 SizeInBits uint64
361 AlignInBits uint32
362 Flags int
363 DerivedFrom Metadata
364 Elements []Metadata
365365 VTableHolder Metadata // optional
366366 UniqueID string
367367 }
580580 }
581581
582582 func (v Value) SetSubprogram(sp Metadata) {
583 C.LLVMSetSubprogram(v.C, sp.C)
583 C.LLVMSetSubprogram(v.C, sp.C)
584584 }
585585
586586 func boolToCInt(v bool) C.int {
383383 }
384384
385385 func (c Context) CreateEnumAttribute(kind uint, val uint64) (a Attribute) {
386 a.C = C.LLVMCreateEnumAttribute(c.C, C.unsigned(kind), C.uint64_t(val))
387 return
386 a.C = C.LLVMCreateEnumAttribute(c.C, C.unsigned(kind), C.uint64_t(val))
387 return
388388 }
389389
390390 func (a Attribute) GetEnumKind() (id int) {
391 id = int(C.LLVMGetEnumAttributeKind(a.C))
392 return
391 id = int(C.LLVMGetEnumAttributeKind(a.C))
392 return
393393 }
394394
395395 func (a Attribute) GetEnumValue() (val uint64) {
396 val = uint64(C.LLVMGetEnumAttributeValue(a.C))
397 return
396 val = uint64(C.LLVMGetEnumAttributeValue(a.C))
397 return
398398 }
399399
400400 func (c Context) CreateStringAttribute(kind string, val string) (a Attribute) {
401 ckind := C.CString(kind)
402 defer C.free(unsafe.Pointer(ckind))
403 cval := C.CString(val)
404 defer C.free(unsafe.Pointer(cval))
405 a.C = C.LLVMCreateStringAttribute(c.C,
406 ckind, C.unsigned(len(kind)),
407 cval, C.unsigned(len(val)))
408 return
401 ckind := C.CString(kind)
402 defer C.free(unsafe.Pointer(ckind))
403 cval := C.CString(val)
404 defer C.free(unsafe.Pointer(cval))
405 a.C = C.LLVMCreateStringAttribute(c.C,
406 ckind, C.unsigned(len(kind)),
407 cval, C.unsigned(len(val)))
408 return
409409 }
410410
411411 func (a Attribute) GetStringKind() string {
412 length := C.unsigned(0)
413 ckind := C.LLVMGetStringAttributeKind(a.C, &length)
414 return C.GoStringN(ckind, C.int(length))
412 length := C.unsigned(0)
413 ckind := C.LLVMGetStringAttributeKind(a.C, &length)
414 return C.GoStringN(ckind, C.int(length))
415415 }
416416
417417 func (a Attribute) GetStringValue() string {
418 length := C.unsigned(0)
419 ckind := C.LLVMGetStringAttributeValue(a.C, &length)
420 return C.GoStringN(ckind, C.int(length))
418 length := C.unsigned(0)
419 ckind := C.LLVMGetStringAttributeValue(a.C, &length)
420 return C.GoStringN(ckind, C.int(length))
421421 }
422422
423423 func (a Attribute) IsEnum() bool {
424 return C.LLVMIsEnumAttribute(a.C) != 0;
424 return C.LLVMIsEnumAttribute(a.C) != 0
425425 }
426426
427427 func (a Attribute) IsString() bool {
428 return C.LLVMIsStringAttribute(a.C) != 0;
428 return C.LLVMIsStringAttribute(a.C) != 0
429429 }
430430
431431 //-------------------------------------------------------------------------
11491149 C.LLVMSetGC(v.C, cname)
11501150 }
11511151 func (v Value) AddAttributeAtIndex(i int, a Attribute) {
1152 C.LLVMAddAttributeAtIndex(v.C, C.LLVMAttributeIndex(i), a.C)
1152 C.LLVMAddAttributeAtIndex(v.C, C.LLVMAttributeIndex(i), a.C)
11531153 }
11541154 func (v Value) AddFunctionAttr(a Attribute) {
1155 v.AddAttributeAtIndex(C.LLVMAttributeFunctionIndex, a);
1155 v.AddAttributeAtIndex(C.LLVMAttributeFunctionIndex, a)
11561156 }
11571157 func (v Value) GetEnumAttributeAtIndex(i int, kind uint) (a Attribute) {
1158 a.C = C.LLVMGetEnumAttributeAtIndex(v.C, C.LLVMAttributeIndex(i), C.unsigned(kind))
1159 return
1158 a.C = C.LLVMGetEnumAttributeAtIndex(v.C, C.LLVMAttributeIndex(i), C.unsigned(kind))
1159 return
11601160 }
11611161 func (v Value) GetEnumFunctionAttribute(kind uint) Attribute {
1162 return v.GetEnumAttributeAtIndex(C.LLVMAttributeFunctionIndex, kind)
1162 return v.GetEnumAttributeAtIndex(C.LLVMAttributeFunctionIndex, kind)
11631163 }
11641164 func (v Value) GetStringAttributeAtIndex(i int, kind string) (a Attribute) {
1165 ckind := C.CString(kind)
1166 defer C.free(unsafe.Pointer(ckind))
1167 a.C = C.LLVMGetStringAttributeAtIndex(v.C, C.LLVMAttributeIndex(i),
1168 ckind, C.unsigned(len(kind)))
1169 return
1165 ckind := C.CString(kind)
1166 defer C.free(unsafe.Pointer(ckind))
1167 a.C = C.LLVMGetStringAttributeAtIndex(v.C, C.LLVMAttributeIndex(i),
1168 ckind, C.unsigned(len(kind)))
1169 return
11701170 }
11711171 func (v Value) RemoveEnumAttributeAtIndex(i int, kind uint) {
1172 C.LLVMRemoveEnumAttributeAtIndex(v.C, C.LLVMAttributeIndex(i), C.unsigned(kind))
1172 C.LLVMRemoveEnumAttributeAtIndex(v.C, C.LLVMAttributeIndex(i), C.unsigned(kind))
11731173 }
11741174 func (v Value) RemoveEnumFunctionAttribute(kind uint) {
1175 v.RemoveEnumAttributeAtIndex(C.LLVMAttributeFunctionIndex, kind);
1175 v.RemoveEnumAttributeAtIndex(C.LLVMAttributeFunctionIndex, kind)
11761176 }
11771177 func (v Value) RemoveStringAttributeAtIndex(i int, kind string) {
1178 ckind := C.CString(kind)
1179 defer C.free(unsafe.Pointer(ckind))
1180 C.LLVMRemoveStringAttributeAtIndex(v.C, C.LLVMAttributeIndex(i),
1181 ckind, C.unsigned(len(kind)))
1178 ckind := C.CString(kind)
1179 defer C.free(unsafe.Pointer(ckind))
1180 C.LLVMRemoveStringAttributeAtIndex(v.C, C.LLVMAttributeIndex(i),
1181 ckind, C.unsigned(len(kind)))
11821182 }
11831183 func (v Value) AddTargetDependentFunctionAttr(attr, value string) {
11841184 cattr := C.CString(attr)
12001200 }
12011201 return out
12021202 }
1203 func (v Value) Param(i int) (rv Value) { rv.C = C.LLVMGetParam(v.C, C.unsigned(i)); return }
1204 func (v Value) ParamParent() (rv Value) { rv.C = C.LLVMGetParamParent(v.C); return }
1205 func (v Value) FirstParam() (rv Value) { rv.C = C.LLVMGetFirstParam(v.C); return }
1206 func (v Value) LastParam() (rv Value) { rv.C = C.LLVMGetLastParam(v.C); return }
1207 func NextParam(v Value) (rv Value) { rv.C = C.LLVMGetNextParam(v.C); return }
1208 func PrevParam(v Value) (rv Value) { rv.C = C.LLVMGetPreviousParam(v.C); return }
1203 func (v Value) Param(i int) (rv Value) { rv.C = C.LLVMGetParam(v.C, C.unsigned(i)); return }
1204 func (v Value) ParamParent() (rv Value) { rv.C = C.LLVMGetParamParent(v.C); return }
1205 func (v Value) FirstParam() (rv Value) { rv.C = C.LLVMGetFirstParam(v.C); return }
1206 func (v Value) LastParam() (rv Value) { rv.C = C.LLVMGetLastParam(v.C); return }
1207 func NextParam(v Value) (rv Value) { rv.C = C.LLVMGetNextParam(v.C); return }
1208 func PrevParam(v Value) (rv Value) { rv.C = C.LLVMGetPreviousParam(v.C); return }
12091209 func (v Value) SetParamAlignment(align int) { C.LLVMSetParamAlignment(v.C, C.unsigned(align)) }
12101210
12111211 // Operations on basic blocks
13501350
13511351 // Metadata
13521352 type DebugLoc struct {
1353 Line, Col uint
1354 Scope Metadata
1355 InlinedAt Metadata
1356 }
1353 Line, Col uint
1354 Scope Metadata
1355 InlinedAt Metadata
1356 }
1357
13571358 func (b Builder) SetCurrentDebugLocation(line, col uint, scope, inlinedAt Metadata) {
13581359 C.LLVMGoSetCurrentDebugLocation(b.C, C.unsigned(line), C.unsigned(col), scope.C, inlinedAt.C)
13591360 }
1616 */
1717 import "C"
1818
19 func (pm PassManager) AddCoroEarlyPass() { C.LLVMAddCoroEarlyPass(pm.C) }
20 func (pm PassManager) AddCoroSplitPass() { C.LLVMAddCoroSplitPass(pm.C) }
21 func (pm PassManager) AddCoroElidePass() { C.LLVMAddCoroElidePass(pm.C) }
22 func (pm PassManager) AddCoroCleanupPass() { C.LLVMAddCoroCleanupPass(pm.C) }
19 func (pm PassManager) AddCoroEarlyPass() { C.LLVMAddCoroEarlyPass(pm.C) }
20 func (pm PassManager) AddCoroSplitPass() { C.LLVMAddCoroSplitPass(pm.C) }
21 func (pm PassManager) AddCoroElidePass() { C.LLVMAddCoroElidePass(pm.C) }
22 func (pm PassManager) AddCoroCleanupPass() { C.LLVMAddCoroCleanupPass(pm.C) }