MCPcopy Index your code
hub / github.com/tinygo-org/tinygo / createSliceToArrayPointerCheck

Method createSliceToArrayPointerCheck

compiler/asserts.go:83–90  ·  view source on GitHub ↗

createSliceToArrayPointerCheck adds a check for slice-to-array pointer conversions. This conversion was added in Go 1.17. For details, see: https://tip.golang.org/ref/spec#Conversions_from_slice_to_array_pointer

(sliceLen llvm.Value, arrayLen int64)

Source from the content-addressed store, hash-verified

81// conversions. This conversion was added in Go 1.17. For details, see:
82// https://tip.golang.org/ref/spec#Conversions_from_slice_to_array_pointer
83func (b *builder) createSliceToArrayPointerCheck(sliceLen llvm.Value, arrayLen int64) {
84 // From the spec:
85 // > If the length of the slice is less than the length of the array, a
86 // > run-time panic occurs.
87 arrayLenValue := llvm.ConstInt(b.uintptrType, uint64(arrayLen), false)
88 isLess := b.CreateICmp(llvm.IntULT, sliceLen, arrayLenValue, "")
89 b.createRuntimeAssert(isLess, "slicetoarray", "sliceToArrayPointerPanic")
90}
91
92// createUnsafeSliceStringCheck inserts a runtime check used for unsafe.Slice
93// and unsafe.String. This function must panic if the ptr/len parameters are

Callers 1

createExprMethod · 0.95

Calls 1

createRuntimeAssertMethod · 0.95

Tested by

no test coverage detected