From: Keith Randall Date: Tue, 26 Apr 2016 21:09:58 +0000 (-0700) Subject: cmd/compile: a rule's line number is at its -> X-Git-Tag: go1.7beta1~478 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=3b0efa689ec7a32de30cbda2221452f57abb2532;p=gostls13.git cmd/compile: a rule's line number is at its -> Let's define the line number of a multiline rule as the line number on which the -> appears. This helps make the rule cover analysis look a bit nicer. Change-Id: I4ac4c09f2240285976590ecfd416bc4c05e78946 Reviewed-on: https://go-review.googlesource.com/22473 Reviewed-by: Josh Bleecher Snyder --- diff --git a/src/cmd/compile/internal/ssa/gen/rulegen.go b/src/cmd/compile/internal/ssa/gen/rulegen.go index 02a5da2a5a..5f7d1cf984 100644 --- a/src/cmd/compile/internal/ssa/gen/rulegen.go +++ b/src/cmd/compile/internal/ssa/gen/rulegen.go @@ -91,6 +91,7 @@ func genRules(arch arch) { scanner := bufio.NewScanner(text) rule := "" var lineno int + var ruleLineno int // line number of "->" for scanner.Scan() { lineno++ line := scanner.Text() @@ -107,6 +108,9 @@ func genRules(arch arch) { if !strings.Contains(rule, "->") { continue } + if ruleLineno == 0 { + ruleLineno = lineno + } if strings.HasSuffix(rule, "->") { continue } @@ -117,13 +121,14 @@ func genRules(arch arch) { if op[len(op)-1] == ')' { op = op[:len(op)-1] // rule has only opcode, e.g. (ConstNil) -> ... } - loc := fmt.Sprintf("%s.rules:%d", arch.name, lineno) + loc := fmt.Sprintf("%s.rules:%d", arch.name, ruleLineno) if isBlock(op, arch) { blockrules[op] = append(blockrules[op], Rule{rule: rule, loc: loc}) } else { oprules[op] = append(oprules[op], Rule{rule: rule, loc: loc}) } rule = "" + ruleLineno = 0 } if err := scanner.Err(); err != nil { log.Fatalf("scanner failed: %v\n", err)