1
0
mirror of https://github.com/golang/go synced 2024-10-01 09:48:32 -06:00
Commit Graph

17 Commits

Author SHA1 Message Date
Russ Cox
b752e9ffdf cmd/vet: diagnose use of unsafe.Pointer to convert integer to pointer
LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/100470044
2014-05-15 15:32:51 -04:00
Rob Pike
6bd3206b1f go.tools/cmd/vet: allow checks to be disabled explicitly as well as set explicitly
Now we can say
        vet -printf=false
to disable the printf test but run all others.
Implemented by creating a tri-state boolean flag that records whether it has been
set explicitly; before this, -printf=false was not distinguishable from not having
mentioned the printf flag at all.

Fixes golang/go#7422.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/72330043
2014-03-07 16:02:49 +11:00
Alan Donovan
ced954c167 go.tools/go/types: split Info.Objects map into Defs and Uses.
An identifier X in anonymous struct field struct{X} is both a
definition of a field (*Var) and reference to a type
(*TypeName).  Now that we have split the map, we can capture
both of these aspects.

Interestingly, every client but one was going to extra effort
to iterate over just the uses or just the defs; this
simplifies them.

Also, fix two bug related to tagless switches:
- An entry was being recorded in the Object map for a piece of
  synthetic syntax.
- The "true" identifier was being looked up in the current scope,
  which allowed perverse users to locally redefine it.  Now
  we use the bool (not untyped boolean) constant true, per the
  consequent clarification of the spec (issue 7404).

+ tests.

Fixes golang/go#7276

LGTM=gri
R=gri
CC=golang-codereviews
https://golang.org/cl/68270044
2014-02-27 13:21:59 -05:00
Rob Pike
ee3eeefaa3 cmd/vet: check for nil result set in isStringer
Fixes golang/go#7149.

LGTM=gri
R=golang-codereviews, gri
CC=golang-codereviews
https://golang.org/cl/68260044
2014-02-24 11:39:42 -08:00
Rob Pike
cde4d316d2 go.tools/cmd/vet: docs: explain the command line interface better
How it handles packages vs. directories vs. files was not explained.

LGTM=rsc
R=golang-codereviews, gobot, rsc
CC=golang-codereviews
https://golang.org/cl/67150043
2014-02-24 10:44:02 -08:00
Alan Donovan
64ec206bfd go.tools/go/types: combine Info.{Types,Values} maps.
This results in significant improvement to type-checking time:
it reduces by 4% the entire running time of ssa/stdlib_test
(GOMAXPROCS=8, n=7).

LGTM=gri
R=gri
CC=golang-codereviews
https://golang.org/cl/57770043
2014-01-28 16:46:24 -05:00
Josh Bleecher Snyder
866b24e166 cmd/vet: check for sync types being copied during function calls
Using a type containing a sync type directly
in a function call (whether as a receiver,
a param, or a return value) is an easy way
to accidentally copy a lock or other sync primitive.
Check for it.

The test as implemented does not provide 100%
coverage; see the discussion near the bottom of
testdata/copylock.go for shortcomings.

Fixes golang/go#6729.

R=adg, r, dsymonds
CC=golang-dev
https://golang.org/cl/23420043
2013-12-09 20:14:28 -08:00
Robert Griesemer
27563ff576 go.tools/go/types: move gcimporter to its own package
- fixed a couple of TODOs
- various cleanups along the way
- adjusted clients

Once submitted, clients of go/types that don't explicitly
specify Config.Import will need to add the extra import:

import _ "code.google.com/p/go.tools/go/gcimporter"

to install the default (gc) importer in go/types.

R=adonovan, gri
CC=golang-dev
https://golang.org/cl/26390043
2013-11-14 14:11:43 -08:00
Andrew Gerrand
61d86e98d5 go.tools/cmd/vet: check for recursive stringers
Fixes golang/go#6129.

R=r
CC=golang-dev
https://golang.org/cl/12936046
2013-08-21 11:07:53 +10:00
Andrew Gerrand
74ecc2c09b go.tools/cmd/vet: detect useless function comparisons
Also fix bug in types.go discovered by this check.

Fixes golang/go#5347.

R=golang-dev, dsymonds, r
CC=golang-dev
https://golang.org/cl/13102043
2013-08-20 16:11:01 +10:00
Rob Pike
aecec2f502 go.tools/cmd/vet: the composite test is about keys, not tags
Fix the confusion.
No semantic change, just some renamings.

Fixes golang/go#6017.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/12394043
2013-08-03 12:19:59 +10:00
David Symonds
75919c8eee cmd/vet: avoid panic if no valid inputs are found.
I'd like to make vet work as a filter, but passing /dev/stdin as a
command line argument doesn't work. This at least makes it not panic.

R=r
CC=golang-dev
https://golang.org/cl/11521045
2013-07-22 12:43:11 +10:00
Rob Pike
331c428e76 go.tools/cmd/vet: add check for shadowed variables
Experimental feature. It's too noisy yet to be enabled by default,
so it must be enabled explicitly by
        go tool vet -shadow *.go
or
        go tool vet -shadow directory
(The go command does not know about the -shadow flag.)

Fixes golang/go#5634.

R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/10409047
2013-06-21 11:27:53 -07:00
Rob Pike
86c0ff156c go.tools/cmd/vet: set the package name unconditionally
A better fix than the one in CL 10400044

R=gri
CC=golang-dev
https://golang.org/cl/10376044
2013-06-18 14:12:51 -07:00
Rob Pike
ce82fb0e23 go.tools/cmd/vet: use directory for pkg.path if path is "."
Before:
        math/big/nat_test.go:688: arg r for printf verb %s of wrong type: ..Word
After:
        math/big/nat_test.go:688: arg r for printf verb %s of wrong type: big.Word

R=gri
CC=golang-dev
https://golang.org/cl/10400044
2013-06-18 14:02:01 -07:00
Rob Pike
08cc526448 go.tools/cmd/vet: update to new go/types package
Now that it's in the same repository as the go/types package we can delete
the mechanism to build it without type checking.

Add a make rule to install it where the go tool can find it.
Why doesn't "go install" take a -o flag?

R=gri
CC=gobot, golang-dev
https://golang.org/cl/9526043
2013-05-20 12:20:05 -07:00
Rob Pike
01f8cd246d go.tools: add go/types, ssa, and cmd/vet
They will be deleted from their current homes once this has landed.
Changes made to import paths to make the code compile, and to find
errchk in the right place in cmd/vet's Makefile.
TODO in a later CL: tidy up vet.

R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/9495043
2013-05-17 13:20:39 -07:00