(StringLen (StringMake _ x)) == x, just like the rules we
currently have for slices.
This helps propagate string length knowledge to places which need it.
Change-Id: Ifdcf6d1f2d430c1c4bbac32e0ea74c188eae998e
Reviewed-on: https://go-review.googlesource.com/c/go/+/682777
Reviewed-by: Daniel Morsing <daniel.morsing@gmail.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Jorropo <jorropo.pgm@gmail.com>
// the mod instruction executes (and thus panics if the
// modulus is 0). See issue 67625.
ft.update(b, v, v.Args[1], unsigned, lt)
+ case OpStringLen:
+ if v.Args[0].Op == OpStringMake {
+ ft.update(b, v, v.Args[0].Args[1], signed, eq)
+ }
case OpSliceLen:
if v.Args[0].Op == OpSliceMake {
ft.update(b, v, v.Args[0].Args[1], signed, eq)
}
}
+func resliceString(s string) byte {
+ if len(s) >= 4 {
+ s = s[2:] // ERROR "Proved IsSliceInBounds" "Proved slicemask not needed"
+ s = s[1:] // ERROR "Proved IsSliceInBounds" "Proved slicemask not needed"
+ return s[0] // ERROR "Proved IsInBounds"
+ }
+ return 0
+}
+func resliceBytes(b []byte) byte {
+ if len(b) >= 4 {
+ b = b[2:] // ERROR "Proved IsSliceInBounds" "Proved slicemask not needed"
+ b = b[1:] // ERROR "Proved IsSliceInBounds" "Proved slicemask not needed"
+ return b[0] // ERROR "Proved IsInBounds"
+ }
+ return 0
+}
+
//go:noinline
func useInt(a int) {
}