go.tools/cmd/vet: don't panic on commented-out asm

Really two fixes: Don't panic on bad instructions and don't complain about commented out instructions.

LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/110070044
This commit is contained in:
Josh Bleecher Snyder 2014-06-20 16:52:48 -07:00
parent 9d6cc5fd08
commit 95a7aeb192
2 changed files with 5 additions and 1 deletions

View File

@ -423,7 +423,10 @@ func (f *File) asmParseDecl(decl *ast.FuncDecl) map[string]*asmFunc {
func asmCheckVar(badf func(string, ...interface{}), fn *asmFunc, line, expr string, off int, v *asmVar) {
m := asmOpcode.FindStringSubmatch(line)
if m == nil {
badf("cannot find assembly opcode")
if !strings.HasPrefix(strings.TrimSpace(line), "//") {
badf("cannot find assembly opcode")
}
return
}
// Determine operand sizes from instruction.

View File

@ -7,6 +7,7 @@
TEXT ·arg1(SB),0,$0-2
MOVB x+0(FP), AX
// MOVB x+0(FP), AX // commented out instructions used to panic
MOVB y+1(FP), BX
MOVW x+0(FP), AX // ERROR "\[amd64\] invalid MOVW of x\+0\(FP\); int8 is 1-byte value"
MOVW y+1(FP), AX // ERROR "invalid MOVW of y\+1\(FP\); uint8 is 1-byte value"