MCPcopy
hub / github.com/tinygo-org/tinygo / createNegativeShiftCheck

Method createNegativeShiftCheck

compiler/asserts.go:207–216  ·  view source on GitHub ↗

createNegativeShiftCheck creates an assertion that panics if the given shift value is negative. This function assumes that the shift value is signed.

(shift llvm.Value)

Source from the content-addressed store, hash-verified

205// createNegativeShiftCheck creates an assertion that panics if the given shift value is negative.
206// This function assumes that the shift value is signed.
207func (b *builder) createNegativeShiftCheck(shift llvm.Value) {
208 if b.info.nobounds {
209 // Function disabled bounds checking - skip shift check.
210 return
211 }
212
213 // isNegative = shift < 0
214 isNegative := b.CreateICmp(llvm.IntSLT, shift, llvm.ConstInt(shift.Type(), 0, false), "")
215 b.createRuntimeAssert(isNegative, "shift", "negativeShiftPanic")
216}
217
218// createDivideByZeroCheck asserts that y is not zero. If it is, a runtime panic
219// will be emitted. This follows the Go specification which says that a divide

Callers 1

createBinOpMethod · 0.95

Calls 2

createRuntimeAssertMethod · 0.95
TypeMethod · 0.45

Tested by

no test coverage detected