Skip to content

Commit

Permalink
cmd/vet: fix go vet on parentheses of assembly function flag
Browse files Browse the repository at this point in the history
Current implementation doesn't recognize parentheses that may appear in flags
of assembly function as shown below:

	TEXT ·makeFuncStub(SB),(NOSPLIT|WRAPPER),$24

It results in vet reporting false positives and a lot of whitelists are added
for suppressing the false alarms.

This CL fixes the issue and eliminates the redundant whitelists.

Change-Id: Idbc1b42965b31cea8ee7c23d1a6f62feb68e844c
Reviewed-on: https://go-review.googlesource.com/62850
Run-TryBot: Rob Pike <r@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
  • Loading branch information
Wei Xiao authored and robpike committed Sep 13, 2017
1 parent 9f1a719 commit 701d492
Show file tree
Hide file tree
Showing 9 changed files with 1 addition and 21 deletions.
2 changes: 0 additions & 2 deletions src/cmd/vet/all/whitelist/386.txt
Expand Up @@ -3,8 +3,6 @@
runtime/asm_ARCHSUFF.s: [GOARCH] cannot check cross-package assembly function: Compare is in package bytes

// reflect trampolines intentionally omit arg size. Same for morestack.
reflect/asm_386.s: [386] makeFuncStub: use of 4(SP) points beyond argument frame
reflect/asm_386.s: [386] methodValueCall: use of 4(SP) points beyond argument frame
runtime/asm_386.s: [386] morestack: use of 4(SP) points beyond argument frame
runtime/asm_386.s: [386] morestack: use of 8(SP) points beyond argument frame
runtime/asm_386.s: [386] morestack: use of 4(SP) points beyond argument frame
Expand Down
2 changes: 0 additions & 2 deletions src/cmd/vet/all/whitelist/amd64.txt
Expand Up @@ -5,8 +5,6 @@


// reflect trampolines intentionally omit arg size. Same for morestack.
reflect/asm_amd64.s: [amd64] makeFuncStub: use of 8(SP) points beyond argument frame
reflect/asm_amd64.s: [amd64] methodValueCall: use of 8(SP) points beyond argument frame
runtime/asm_amd64.s: [amd64] morestack: use of 8(SP) points beyond argument frame
runtime/asm_amd64.s: [amd64] morestack: use of 16(SP) points beyond argument frame
runtime/asm_amd64.s: [amd64] morestack: use of 8(SP) points beyond argument frame
Expand Down
2 changes: 0 additions & 2 deletions src/cmd/vet/all/whitelist/arm.txt
Expand Up @@ -3,8 +3,6 @@
runtime/asm_ARCHSUFF.s: [GOARCH] cannot check cross-package assembly function: Compare is in package bytes

// reflect trampolines intentionally omit arg size. Same for morestack.
reflect/asm_arm.s: [arm] makeFuncStub: use of 8(R13) points beyond argument frame
reflect/asm_arm.s: [arm] methodValueCall: use of 8(R13) points beyond argument frame
runtime/asm_arm.s: [arm] morestack: use of 4(R13) points beyond argument frame

// Intentionally missing declarations.
Expand Down
6 changes: 0 additions & 6 deletions src/cmd/vet/all/whitelist/arm64.txt
Expand Up @@ -2,12 +2,6 @@

runtime/asm_ARCHSUFF.s: [GOARCH] cannot check cross-package assembly function: Compare is in package bytes

// False positives.

// reflect trampolines intentionally omit arg size. Same for morestack.
reflect/asm_arm64.s: [arm64] makeFuncStub: use of 16(RSP) points beyond argument frame
reflect/asm_arm64.s: [arm64] methodValueCall: use of 16(RSP) points beyond argument frame

// Intentionally missing declarations.
runtime/asm_arm64.s: [arm64] abort: function abort missing Go declaration
runtime/asm_arm64.s: [arm64] addmoduledata: function addmoduledata missing Go declaration
Expand Down
2 changes: 0 additions & 2 deletions src/cmd/vet/all/whitelist/mips64x.txt
@@ -1,7 +1,5 @@
// mips64-specific vet whitelist. See readme.txt for details.

reflect/asm_mips64x.s: [GOARCH] makeFuncStub: use of 16(R29) points beyond argument frame
reflect/asm_mips64x.s: [GOARCH] methodValueCall: use of 16(R29) points beyond argument frame
runtime/asm_mips64x.s: [GOARCH] abort: function abort missing Go declaration
runtime/duff_mips64x.s: [GOARCH] duffzero: function duffzero missing Go declaration
runtime/tls_mips64x.s: [GOARCH] save_g: function save_g missing Go declaration
Expand Down
2 changes: 0 additions & 2 deletions src/cmd/vet/all/whitelist/mipsx.txt
@@ -1,7 +1,5 @@
// mips64-specific vet whitelist. See readme.txt for details.

reflect/asm_mipsx.s: [GOARCH] makeFuncStub: use of 8(R29) points beyond argument frame
reflect/asm_mipsx.s: [GOARCH] methodValueCall: use of 8(R29) points beyond argument frame
runtime/asm_mipsx.s: [GOARCH] abort: function abort missing Go declaration
runtime/tls_mipsx.s: [GOARCH] save_g: function save_g missing Go declaration
runtime/tls_mipsx.s: [GOARCH] load_g: function load_g missing Go declaration
Expand Down
2 changes: 0 additions & 2 deletions src/cmd/vet/all/whitelist/nacl_amd64p32.txt
@@ -1,8 +1,6 @@
// nacl/amd64p32-specific vet whitelist. See readme.txt for details.

// reflect trampolines intentionally omit arg size. Same for morestack.
reflect/asm_amd64p32.s: [amd64p32] makeFuncStub: use of 4(SP) points beyond argument frame
reflect/asm_amd64p32.s: [amd64p32] methodValueCall: use of 4(SP) points beyond argument frame
runtime/asm_amd64p32.s: [amd64p32] morestack: use of 8(SP) points beyond argument frame
runtime/asm_amd64p32.s: [amd64p32] morestack: use of 16(SP) points beyond argument frame
runtime/asm_amd64p32.s: [amd64p32] morestack: use of 8(SP) points beyond argument frame
Expand Down
2 changes: 0 additions & 2 deletions src/cmd/vet/all/whitelist/s390x.txt
@@ -1,5 +1,3 @@
reflect/asm_s390x.s: [s390x] makeFuncStub: use of 16(R15) points beyond argument frame
reflect/asm_s390x.s: [s390x] methodValueCall: use of 16(R15) points beyond argument frame
runtime/asm_s390x.s: [s390x] abort: function abort missing Go declaration
runtime/asm_s390x.s: [s390x] memeqbody: function memeqbody missing Go declaration
runtime/asm_s390x.s: [s390x] memeqbodyclc: function memeqbodyclc missing Go declaration
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/vet/asmdecl.go
Expand Up @@ -109,7 +109,7 @@ func init() {
var (
re = regexp.MustCompile
asmPlusBuild = re(`//\s+\+build\s+([^\n]+)`)
asmTEXT = re(`\bTEXT\b(.*)·([^\(]+)\(SB\)(?:\s*,\s*([0-9A-Z|+]+))?(?:\s*,\s*\$(-?[0-9]+)(?:-([0-9]+))?)?`)
asmTEXT = re(`\bTEXT\b(.*)·([^\(]+)\(SB\)(?:\s*,\s*([0-9A-Z|+()]+))?(?:\s*,\s*\$(-?[0-9]+)(?:-([0-9]+))?)?`)
asmDATA = re(`\b(DATA|GLOBL)\b`)
asmNamedFP = re(`([a-zA-Z0-9_\xFF-\x{10FFFF}]+)(?:\+([0-9]+))\(FP\)`)
asmUnnamedFP = re(`[^+\-0-9](([0-9]+)\(FP\))`)
Expand Down

0 comments on commit 701d492

Please sign in to comment.