return string(b)
}
- m := f("v001100110110110010100100")
- t.Logf(m)
-
- mCount := strings.Count(m, "loopvarhash triggered cmd/compile/internal/loopvar/testdata/inlines/main.go:27:6 001100110110110010100100")
- otherCount := strings.Count(m, "loopvarhash")
- if mCount < 1 {
- t.Errorf("did not see triggered main.go:27:6")
- }
- if mCount != otherCount {
- t.Errorf("too many matches")
- }
+ for _, arg := range []string{"v001100110110110010100100", "vx336ca4"} {
+ m := f(arg)
+ t.Logf(m)
+
+ mCount := strings.Count(m, "loopvarhash triggered cmd/compile/internal/loopvar/testdata/inlines/main.go:27:6 001100110110110010100100")
+ otherCount := strings.Count(m, "loopvarhash")
+ if mCount < 1 {
+ t.Errorf("%s: did not see triggered main.go:27:6", arg)
+ }
+ if mCount != otherCount {
+ t.Errorf("%s: too many matches", arg)
+ }
- mCount = strings.Count(m, "cmd/compile/internal/loopvar/testdata/inlines/main.go:27:6 [bisect-match 0x7802e115b9336ca4]")
- otherCount = strings.Count(m, "[bisect-match ")
- if mCount < 1 {
- t.Errorf("did not see bisect-match for main.go:27:6")
- }
- if mCount != otherCount {
- t.Errorf("too many matches")
- }
+ mCount = strings.Count(m, "cmd/compile/internal/loopvar/testdata/inlines/main.go:27:6 [bisect-match 0x7802e115b9336ca4]")
+ otherCount = strings.Count(m, "[bisect-match ")
+ if mCount < 1 {
+ t.Errorf("%s: did not see bisect-match for main.go:27:6", arg)
+ }
+ if mCount != otherCount {
+ t.Errorf("%s: too many matches", arg)
+ }
- // This next test carefully dodges a bug-to-be-fixed with inlined locations for ir.Names.
- if !strings.Contains(m, ", 100, 100, 100, 100") {
- t.Errorf("Did not see expected value of m run")
+ // This next test carefully dodges a bug-to-be-fixed with inlined locations for ir.Names.
+ if !strings.Contains(m, ", 100, 100, 100, 100") {
+ t.Errorf("%s: did not see expected value of m run", arg)
+ }
}
}
result := true
bits := uint64(0)
start := 0
+ wid := 1 // 1-bit (binary); sometimes 4-bit (hex)
for i := 0; i <= len(p); i++ {
// Imagine a trailing - at the end of the pattern to flush final suffix
c := byte('-')
if i < len(p) {
c = p[i]
}
+ if i == start && wid == 1 && c == 'x' { // leading x for hex
+ start = i + 1
+ wid = 4
+ continue
+ }
switch c {
default:
return nil, &parseError{"invalid pattern syntax: " + pattern}
+ case '2', '3', '4', '5', '6', '7', '8', '9':
+ if wid != 4 {
+ return nil, &parseError{"invalid pattern syntax: " + pattern}
+ }
+ fallthrough
case '0', '1':
- bits = bits<<1 | uint64(c-'0')
+ bits <<= wid
+ bits |= uint64(c - '0')
+ case 'a', 'b', 'c', 'd', 'e', 'f', 'A', 'B', 'C', 'D', 'E', 'F':
+ if wid != 4 {
+ return nil, &parseError{"invalid pattern syntax: " + pattern}
+ }
+ bits <<= 4
+ bits |= uint64(c&^0x20 - 'A' + 10)
case 'y':
if i+1 < len(p) && (p[i+1] == '0' || p[i+1] == '1') {
return nil, &parseError{"invalid pattern syntax: " + pattern}
return nil, &parseError{"invalid pattern syntax (+ after -): " + pattern}
}
if i > 0 {
- n := i - start
+ n := (i - start) * wid
if n > 64 {
return nil, &parseError{"pattern bits too long: " + pattern}
}
bits = 0
result = c == '+'
start = i + 1
+ wid = 1
}
}
return m, nil