From 95a7aeb19222c24f73133a4a64ee263ac39a80a2 Mon Sep 17 00:00:00 2001 From: Josh Bleecher Snyder Date: Fri, 20 Jun 2014 16:52:48 -0700 Subject: [PATCH] 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 --- cmd/vet/asmdecl.go | 5 ++++- cmd/vet/testdata/asm1.s | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/cmd/vet/asmdecl.go b/cmd/vet/asmdecl.go index c32ed993..37259f47 100644 --- a/cmd/vet/asmdecl.go +++ b/cmd/vet/asmdecl.go @@ -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. diff --git a/cmd/vet/testdata/asm1.s b/cmd/vet/testdata/asm1.s index 8cd9eeab..071ce3c5 100644 --- a/cmd/vet/testdata/asm1.s +++ b/cmd/vet/testdata/asm1.s @@ -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"