1
0
mirror of https://github.com/golang/go synced 2024-10-03 19:21:21 -06:00
Commit Graph

148 Commits

Author SHA1 Message Date
Robert Griesemer
26e43779f1 Revert "cmd/vet: teach vet about ast.AliasSpec"
This reverts commit aa8c8e770e.

Reason: Decision to back out current alias implementation.

For #16339.

Change-Id: I4db9a8d6b3625c794be9d2f1ff0e9c047f383d28
Reviewed-on: https://go-review.googlesource.com/32827
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Chris Manghane <cmang@golang.org>
2016-11-05 00:18:05 +00:00
Vladimir Stefanovic
5bfafff03f cmd/vet: add support for GOARCH=mips{,le}
Change-Id: Ie7b40cc67e9901e252a4a48225bbd745a66d2673
Reviewed-on: https://go-review.googlesource.com/31511
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2016-11-04 18:26:49 +00:00
Josh Bleecher Snyder
e83911d6fc cmd/vet/all: add s390x support
Some of these whitelist entries could be
eliminated, e.g. by the addition of Go
declarations, but this is a start.

Change-Id: I2fb3234cf05ebc6b161aacac2d4c15d810d50527
Reviewed-on: https://go-review.googlesource.com/32671
Reviewed-by: Michael Munday <munday@ca.ibm.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-11-03 15:33:27 +00:00
Josh Bleecher Snyder
aa8c8e770e cmd/vet: teach vet about ast.AliasSpec
Fixes #17755

Change-Id: I1ad1edc382b1312d992963054eb82648cb5112d2
Reviewed-on: https://go-review.googlesource.com/32588
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2016-11-03 13:32:05 +00:00
Michael Munday
5513f855f6 cmd/vet: add test case for ppc64{,le}
Adapted from the mips64 test case.

Fixes #17745.

Change-Id: I46f0900028adb936dcab2cdc701ea11d0a3cb95e
Reviewed-on: https://go-review.googlesource.com/32611
Run-TryBot: Michael Munday <munday@ca.ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Rob Pike <r@golang.org>
2016-11-02 22:40:34 +00:00
Michael Munday
eed2bb71d2 cmd/vet: fix go vet on s390x assembly
Test adapted from the mips64 test.

Fixes #15454.

Change-Id: If890c2d18a4a03a08faaa2e674edd7223af60290
Reviewed-on: https://go-review.googlesource.com/22472
Run-TryBot: Michael Munday <munday@ca.ibm.com>
Reviewed-by: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-11-02 19:21:16 +00:00
Josh Bleecher Snyder
35d342eb7d cmd/vet/all: update whitelists
Change-Id: Ic66eb2939d83559610e62cbb181a8faa6193ecc4
Reviewed-on: https://go-review.googlesource.com/32426
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-10-31 19:26:59 +00:00
Russ Cox
e3324a4b66 cmd/vet: diagnose non-space-separated struct tag like json:"x",xml:"y"
This is not strictly illegal but it probably should be (too late)
and doesn't mean what it looks like it means:
the second key-value pair has the key ",xml".

Fixes #14466.

Change-Id: I174bccc23fd28affeb87f57f77c6591634ade641
Reviewed-on: https://go-review.googlesource.com/32031
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Quentin Smith <quentin@golang.org>
2016-10-26 13:37:51 +00:00
Russ Cox
a850dbdef2 cmd/vet: accept space-separated tag lists for compatibility with cmd/go
Fixes #17148.

Change-Id: I4c66aa0733c249ee6019d1c4e802a7e30457d4b6
Reviewed-on: https://go-review.googlesource.com/32030
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2016-10-25 20:42:01 +00:00
Matthew Dempsky
213ee3d20e go/types: match cmd/compile's alignment for complex64
Fixes #17584.

Change-Id: I3af31cc1f2e9c906f3b73e77f3b092624ba78fbe
Reviewed-on: https://go-review.googlesource.com/31939
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-10-25 16:33:01 +00:00
Josh Bleecher Snyder
eb6ae3ca7b cmd/vet/all: remove cmd/compile/internal/big special case
It no longer exists as of CL 31010.

Change-Id: Idd61f392544cad8b3f3f8d984dc5c953b473e2e5
Reviewed-on: https://go-review.googlesource.com/31934
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Rob Pike <r@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-10-25 14:59:27 +00:00
Josh Bleecher Snyder
5db7c6d32c cmd/vet/all: update whitelists
Change-Id: Ie505b5d8cdfe4ffda71f909d6f81603b6d752eed
Reviewed-on: https://go-review.googlesource.com/31937
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-10-25 14:50:18 +00:00
Alan Donovan
07a22dbd34 cmd/vet: cgo: emit no error for calls to C.CBytes
Fixes issue golang/go#17563

Change-Id: Ibb41ea9419907193526cc601f6afd07d8689b1fe
Reviewed-on: https://go-review.googlesource.com/31810
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-10-24 19:05:50 +00:00
David Symonds
5a0d50f4eb cmd/vet: fix formatting of headings in doc.go.
This will cause godoc to correctly render these docs,
since go/doc.ToHTML requires no punctuation for headings.

Change-Id: Ic95245147d3585f2ccc59d4424fcab17d2a5617b
Reviewed-on: https://go-review.googlesource.com/31319
Reviewed-by: Rob Pike <r@golang.org>
2016-10-18 00:06:20 +00:00
Alex Browne
4940a83790 cmd/vet: check for duplicate json, xml struct field tags
It is easy to make the mistake of duplicating json struct field
tags especially when copy/pasting. This commit causes go vet to
report the mistake. Only field tags in the same struct type are
considered, because that is the only case which is undoubtedly an
error.

Fixes #12791.

Change-Id: I4130e4c04b177694cc0daf8f1acaf0751d4f062b
Reviewed-on: https://go-review.googlesource.com/16704
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2016-10-13 02:08:58 +00:00
Aliaksandr Valialkin
ee8ec42929 cmd/vet: skip printf check for non-constant format string during failed import
Fixes #17006

Change-Id: I3c2060ca5384a4b9782a7d804305d2cf4388dd5a
Reviewed-on: https://go-review.googlesource.com/29014
Run-TryBot: Rob Pike <r@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2016-10-05 14:25:46 +00:00
Tormod Erevik Lea
b625810d28 cmd/vet: hard-code program name in usage message
Example on linux_amd64 for 'go tool vet -h':

Before:
	Usage of /usr/local/go/pkg/tool/linux_amd64/vet:
After:
	Usage of vet:

Change-Id: I11cb16b656bd097062d57a8c7441fbe66caaef78
Reviewed-on: https://go-review.googlesource.com/29294
Reviewed-by: Rob Pike <r@golang.org>
2016-09-19 20:26:36 +00:00
Rob Pike
892d146a7a cmd/vet: fix documentation for -structtags
Was missing a title in the documentation, so it formatted wrong.

Fixes #17124

Change-Id: Ie8a9c36fbc54eed7d8a761f89a088e582b8c062d
Reviewed-on: https://go-review.googlesource.com/29340
Reviewed-by: Andrew Gerrand <adg@golang.org>
2016-09-19 02:02:44 +00:00
Josh Bleecher Snyder
1c5ac0827d cmd/vet/all: check platforms concurrently
Change-Id: I63e7fd7f62aa80e1252b0c5b6c472439aa66da73
Reviewed-on: https://go-review.googlesource.com/29169
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-09-14 21:54:17 +00:00
Josh Bleecher Snyder
d72c2846f1 cmd/vet/all: update whitelist
CL 29110 brought the fix into the main tree.

Change-Id: I7bf02670d40f22d35c63e05173419fdee9f93462
Reviewed-on: https://go-review.googlesource.com/29161
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-09-14 18:37:55 +00:00
Josh Bleecher Snyder
f15915af4e cmd/vet: ignore printf failures in cmd
This is a temporary measure to work around #17057.
It will be reverted when #17057 is fixed.

Change-Id: I21c02f63f3530774c91065cfed5d9c566839ed9f
Reviewed-on: https://go-review.googlesource.com/28959
Reviewed-by: Rob Pike <r@golang.org>
2016-09-10 22:42:26 +00:00
Josh Bleecher Snyder
8e84a5dd47 cmd/vet/all/whitelist: add readme.txt
This was written for CL 27811,
but it got lost in the sea of new files.

Change-Id: I5c52cb23dda499b21a6bb32ed5c586779ccbc2f1
Reviewed-on: https://go-review.googlesource.com/28960
Reviewed-by: Rob Pike <r@golang.org>
2016-09-10 22:41:38 +00:00
Josh Bleecher Snyder
5de2e5b73e cmd/vet: add vet runner script for core
This CL adds a script to run vet on std and cmd.

There are a considerable number of false positives,
mostly from legitimate but unusual assembly in
the runtime and reflect packages.

There are also a few false positives that need fixes.
They are noted as such in the whitelists;
they're not worth holding this CL for.

The unsafe pointer check is disabled.
The false positive rate is just too high to be worth it.

There is no cmd/dist/test integration yet.
The tentative plan is that we'll check the local platform
during all.bash, and that there'll be a fast builder that
checks all platforms (to cover platforms that can't exec).

Fixes #11041

Change-Id: Iee4ed32b05447888368ed86088e3ed3771f84442
Reviewed-on: https://go-review.googlesource.com/27811
Reviewed-by: Rob Pike <r@golang.org>
2016-09-10 21:56:34 +00:00
Keith Randall
842b05832f all: use testing.GoToolPath instead of "go"
This change makes sure that tests are run with the correct
version of the go tool.  The correct version is the one that
we invoked with "go test", not the one that is first in our path.

Fixes #16577

Change-Id: If22c8f8c3ec9e7c35d094362873819f2fbb8559b
Reviewed-on: https://go-review.googlesource.com/28089
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-30 22:49:11 +00:00
Aliaksandr Valialkin
bd9aa9811d cmd/vet: check for copying of array of locks
Updates #14664

Change-Id: I1f7b1116cfe91466816c760f136ce566da3e80a9
Reviewed-on: https://go-review.googlesource.com/24340
Run-TryBot: Rob Pike <r@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2016-08-29 21:56:31 +00:00
Aliaksandr Valialkin
c9fbe0f293 cmd/vet: properly handle indexed arguments in printf
Fixes #15884

Change-Id: I33d98db861d74e3c37a546efaf83ce6f2f76d335
Reviewed-on: https://go-review.googlesource.com/24391
Run-TryBot: Rob Pike <r@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2016-08-29 21:56:04 +00:00
Josh Bleecher Snyder
ef6fde26e5 cmd/vet: handle multiple arches in asm build directives
If a build directive contains multiple arches,
try to match the build context.

Updates #11041

Change-Id: I03b5d7bfb29d1ff6c7d36a9d7c7fabfcc1d871c1
Reviewed-on: https://go-review.googlesource.com/27158
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2016-08-22 15:43:16 +00:00
Josh Bleecher Snyder
863ca99415 cmd/vet: fix mips64le arch name in asmdecl check
Updates #11041

Change-Id: Ic6df8ef25b7cf280db523950cd3640b060ad1a9b
Reviewed-on: https://go-review.googlesource.com/27157
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2016-08-22 15:42:59 +00:00
Josh Bleecher Snyder
f410a668ee cmd/vet: improve error message for cross-package assembly
bytes.Compare has its go prototype in package bytes,
but its implementation in package runtime.
vet used to complain that the prototype was missing.
Now instead:

runtime/asm_amd64.s:1483: [amd64] cannot check cross-package assembly function: Compare is in package bytes

Updates #11041

Change-Id: Ied44fac10d0916d7a34e552c02d052e16fca0c8c
Reviewed-on: https://go-review.googlesource.com/27153
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2016-08-22 15:42:45 +00:00
Josh Bleecher Snyder
0952a15cd1 cmd/vet: clean up printing errors with no position
Before:

: runtime/asm_amd64.s:345: [amd64] morestack: use of 8(SP) points beyond argument frame

After:

runtime/asm_amd64.s:345: [amd64] morestack: use of 8(SP) points beyond argument frame

Updates #11041

Change-Id: Ic87a6d1a2a7b2a8bf737407bc981b159825c84f2
Reviewed-on: https://go-review.googlesource.com/27152
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2016-08-22 15:42:30 +00:00
Josh Bleecher Snyder
4af1148079 cmd/vet: improve asmdecl parameter handling
The asmdecl check had hand-rolled code that
calculated the size and offset of parameters
based only on the AST.
It included a list of known named types.

This CL changes asmdecl to use go/types instead.
This allows us to easily handle named types.
It also adds support for structs, arrays,
and complex parameters.

It improves the default names given to unnamed
parameters. Previously, all anonymous arguments were
called "unnamed", and the first anonymous return
argument was called "ret".
Anonymous arguments are now called arg, arg1, arg2,
etc., depending on the index in the argument list.
Return arguments are ret, ret1, ret2.

This CL also fixes a bug in the printing of
composite data type sizes.

Updates #11041

Change-Id: I1085116a26fe6199480b680eff659eb9ab31769b
Reviewed-on: https://go-review.googlesource.com/27150
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2016-08-22 15:42:06 +00:00
Josh Bleecher Snyder
65c5d62420 cmd/vet: re-quote struct tags when printing errors
cmd/link/link_test.go contains several multi-line
struct tags. Going through an unquote/quote cycle
converts `a
b
c` to "a\nb\nc\n".

This keeps all vet error messages for the standard
library on a single line.

Updates #11041

Change-Id: Ifba1e87297a5174294d1fbf73463fd3db357464f
Reviewed-on: https://go-review.googlesource.com/27129
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2016-08-21 22:47:03 +00:00
Josh Bleecher Snyder
6ad76718cf cmd/vet: don't treat trailing % as possible formatting directive
Eliminates the following false positive:

cmd/go/go_test.go:1916: possible formatting directive in Error call

The line in question:

tg.t.Error("some coverage results are 0.0%")

Updates #11041

Change-Id: I3b7611fa3e0245714a19bd5388f21e39944f5296
Reviewed-on: https://go-review.googlesource.com/27128
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2016-08-21 22:45:38 +00:00
Josh Bleecher Snyder
794442375d cmd/vet: allow large shifts of constants
Large shifts of constants are frequently
used for fancy 32/64 bit detection.

This removes 14 false positives from the
standard library.

Updates #11041

Change-Id: Ib39346e5c161da04c38a6a3067932ef43bf74f2d
Reviewed-on: https://go-review.googlesource.com/27155
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-08-18 23:39:37 +00:00
Josh Bleecher Snyder
11e93aa24a cmd/vet: allow any printf verb with any interface
fmt treats interfaces as being transparent.
As a result, we cannot say with confidence
that any particular verb is wrong.

This fixes the following vet false positives
in the standard library:

database/sql/sql_test.go:210: arg dep for printf verb %p of wrong type: sql.finalCloser
fmt/fmt_test.go:1663: arg nil for printf verb %s of wrong type: untyped nil
go/ast/commentmap.go:328: arg node for printf verb %p of wrong type: ast.Node
net/http/transport_test.go:120: arg c for printf verb %p of wrong type: net.Conn
net/http/httptest/server.go:198: arg c for printf verb %p of wrong type: net.Conn
net/http/httputil/dump_test.go:258: arg body for printf verb %p of wrong type: io.Reader
reflect/set_test.go:81: arg x for printf verb %p of wrong type: io.Writer
reflect/set_test.go:141: arg bb for printf verb %p of wrong type: io.Reader

Updates #11041
Updates #16314

Change-Id: I76df01abb3c34a97b6960f551bed9c1c91377cfc
Reviewed-on: https://go-review.googlesource.com/27127
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2016-08-18 02:01:25 +00:00
Josh Bleecher Snyder
2b8e143dc3 cmd/vet: infer asm arch from build context
If we cannot infer the asm arch from the filename
or the build tags, assume that it is the
current build arch. Assembly files with no
restrictions ought to be usable on all arches.

Updates #11041

Change-Id: I0ae807dbbd5fb67ca21d0157fe180237a074113a
Reviewed-on: https://go-review.googlesource.com/27151
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2016-08-17 20:49:59 +00:00
Josh Bleecher Snyder
752e161587 cmd/vet: allow ^& uintptr arithmetic
The unsafe.Pointer check allows adding to
and subtracting from uintptrs in order to do
arithmetic.

Some code needs to round uintptrs.
Allow &^ for that purpose.

Updates #11041

Change-Id: Ib90dd2954bb6c78427058271e13f2ce4c4af38fb
Reviewed-on: https://go-review.googlesource.com/27156
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2016-08-17 20:48:57 +00:00
Ian Lance Taylor
003a68bc7f cmd/vet: remove copylock warning about result types and calls
Don't issue a copylock warning about a result type; the function may
return a composite literal with a zero value, which is OK.

Don't issue a copylock warning about a function call on the RHS, or an
indirection of a function call; the function may return a composite
literal with a zero value, which is OK.

Updates #16227.

Change-Id: I94f0e066bbfbca5d4f8ba96106210083e36694a2
Reviewed-on: https://go-review.googlesource.com/24711
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2016-07-04 03:23:23 +00:00
Alan Donovan
08086e6246 cmd/vet: lostcancel: treat naked return as a use of named results
+ test.

Fixes #16230

Change-Id: Idac995437146a9df9e73f094d2a31abc25b1fa62
Reviewed-on: https://go-review.googlesource.com/24681
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-06-30 21:53:32 +00:00
Brad Fitzpatrick
7ea62121a7 all: be consistent about spelling of cancelation
We had ~30 one way, and these four new occurrences the other way.

Updates #11626

Change-Id: Ic6403dc4905874916ae292ff739d33482ed8e5bf
Reviewed-on: https://go-review.googlesource.com/24683
Reviewed-by: Rob Pike <r@golang.org>
2016-06-30 21:09:56 +00:00
Konstantin Shaposhnikov
85a4f44745 cmd/vet: make checking example names in _test packages more robust
Prior to this change package "foo" had to be installed in order to check
example names in "foo_test" package.

However by the time "foo_test" package is checked a parsed "foo" package
has been already constructed. Use it to check example names.

Also change TestDivergentPackagesExamples test to pass directory of the
package to the vet tool as it is the most common way to invoke it. This
requires changes to errchk to add support for grabbing source files from
a directory.

Fixes #16189

Change-Id: Ief103d07b024822282b86c24250835cc591793e8
Reviewed-on: https://go-review.googlesource.com/24488
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-06-28 22:09:00 +00:00
Konstantin Shaposhnikov
e96b1ef99b cmd/vet: fix name check for examples in _test package
This fixes the obvious bug and makes go vet look for identifiers in foo
package when checking example names in foo_test package.

Note that for this check to work the foo package have to be
installed (using go install).

This commit however doesn't fix TestDivergentPackagesExamples test that
is not implemented correctly and passes only by chance.

Updates #16189

Change-Id: I5c2f675cd07e5b66cf0432b2b3e422ab45c3dedd
Reviewed-on: https://go-review.googlesource.com/24487
Reviewed-by: Dmitri Shuralyov <shurcool@gmail.com>
Run-TryBot: Rob Pike <r@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2016-06-27 15:40:09 +00:00
Alan Donovan
4764d6fd6e cmd/vet/internal/cfg: don't crash on malformed goto statement
Change-Id: Ib285c02e240f02e9d5511bd448163ec1d4e75516
Reviewed-on: https://go-review.googlesource.com/24323
Reviewed-by: Rob Pike <r@golang.org>
2016-06-22 17:09:26 +00:00
Alan Donovan
f2c13d713d cmd/vet: fix a crash in lostcancel check
Fixes issue 16143

Change-Id: Id9d257aee54d31fbf0d478cb07339729cd9712c0
Reviewed-on: https://go-review.googlesource.com/24325
Reviewed-by: Rob Pike <r@golang.org>
2016-06-22 16:57:45 +00:00
Alan Donovan
b65cb7f198 cmd/vet: -lostcancel: check for discarded result of context.WithCancel
The cfg subpackage builds a control flow graph of ast.Nodes.
The lostcancel module checks this graph to find paths, from a call to
WithCancel to a return statement, on which the cancel variable is
not used.  (A trivial case is simply assigning the cancel result to
the blank identifier.)

In a sample of 50,000 source files, the new check found 2068 blank
assignments and 118 return-before-cancel errors.  I manually inspected
20 of the latter and didn't find a single false positive among them.

Change-Id: I84cd49445f9f8d04908b04881eb1496a96611205
Reviewed-on: https://go-review.googlesource.com/24150
Reviewed-by: Robert Griesemer <gri@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2016-06-21 14:58:33 +00:00
Aliaksandr Valialkin
dcc42c7d11 cmd/vet: do not check print-like functions with unknown type
Fixes #15787

Change-Id: I559ba886527b474dbdd44fe884c78973b3012377
Reviewed-on: https://go-review.googlesource.com/23351
Run-TryBot: Rob Pike <r@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2016-05-24 16:13:44 +00:00
Aliaksandr Valialkin
c81a3532fe cmd/vet: check sync.* types' copying
Embed noLock struct into the following types, so `go vet -copylocks` catches
their copying additionally to types containing sync.Mutex:
  - sync.Cond
  - sync.WaitGroup
  - sync.Pool
  - atomic.Value

Fixes #14582

Change-Id: Icb543ef5ad10524ad239a15eec8a9b334b0e0660
Reviewed-on: https://go-review.googlesource.com/22015
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-05-06 16:43:51 +00:00
Shenghou Ma
7a964e1df4 cmd/vet: add mips64x assembly check support
Change-Id: I0a6a92604dbfa4b0f9c5ae483b574331f246dcad
Reviewed-on: https://go-review.googlesource.com/22502
Run-TryBot: Minux Ma <minux@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2016-05-04 16:50:13 +00:00
Brad Fitzpatrick
4d5ac10f69 cmd/vet: fix test's dependence on perl
Change-Id: I774dbd4f90ef271a0969c3c8e65d145669312e3e
Reviewed-on: https://go-review.googlesource.com/22745
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ross Light <light@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-05-03 23:59:56 +00:00
Aliaksandr Valialkin
22db3c5a62 cmd/vet: improve checking unkeyed fields in composite literals
- Simplified the code.

- Removed types for slice aliases from composite literals' whitelist, since they
are properly handled by vet.

Fixes #15408
Updates #9171
Updates #11041

Change-Id: Ia1806c9eb3f327c09d2e28da4ffdb233b5a159b0
Reviewed-on: https://go-review.googlesource.com/22318
Run-TryBot: Rob Pike <r@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2016-04-28 13:51:40 +00:00