Commit a48a15cd authored by Daniel Martí's avatar Daniel Martí

cmd/vendor: update to golang.org/x/tools@e5f3ab76

To pull in the fix for #28858, which we want to include for Go 1.12.

Fixes #28858.

Change-Id: Id4964cfd38e3d44d6317a2ee124fe2d35038b5fd
Reviewed-on: https://go-review.googlesource.com/c/152277
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarAlan Donovan <adonovan@google.com>
parent 54cbc5b4
...@@ -18,7 +18,7 @@ string. It uses heuristics that do not guarantee all reports are ...@@ -18,7 +18,7 @@ string. It uses heuristics that do not guarantee all reports are
genuine problems, but it can find errors not caught by the compilers. genuine problems, but it can find errors not caught by the compilers.
` `
// Help implements the help subcommand for a multichecker or vet-lite // Help implements the help subcommand for a multichecker or unitchecker
// style command. The optional args specify the analyzers to describe. // style command. The optional args specify the analyzers to describe.
// Help calls log.Fatal if no such analyzer exists. // Help calls log.Fatal if no such analyzer exists.
func Help(progname string, analyzers []*analysis.Analyzer, args []string) { func Help(progname string, analyzers []*analysis.Analyzer, args []string) {
......
...@@ -714,7 +714,7 @@ var printVerbs = []printVerb{ ...@@ -714,7 +714,7 @@ var printVerbs = []printVerb{
// '#' is alternate format for several verbs. // '#' is alternate format for several verbs.
// ' ' is spacer for numbers // ' ' is spacer for numbers
{'%', noFlag, 0}, {'%', noFlag, 0},
{'b', numFlag, argInt | argFloat | argComplex}, {'b', numFlag, argInt | argFloat | argComplex | argPointer},
{'c', "-", argRune | argInt}, {'c', "-", argRune | argInt},
{'d', numFlag, argInt | argPointer}, {'d', numFlag, argInt | argPointer},
{'e', sharpNumFlag, argFloat | argComplex}, {'e', sharpNumFlag, argFloat | argComplex},
...@@ -723,7 +723,7 @@ var printVerbs = []printVerb{ ...@@ -723,7 +723,7 @@ var printVerbs = []printVerb{
{'F', sharpNumFlag, argFloat | argComplex}, {'F', sharpNumFlag, argFloat | argComplex},
{'g', sharpNumFlag, argFloat | argComplex}, {'g', sharpNumFlag, argFloat | argComplex},
{'G', sharpNumFlag, argFloat | argComplex}, {'G', sharpNumFlag, argFloat | argComplex},
{'o', sharpNumFlag, argInt}, {'o', sharpNumFlag, argInt | argPointer},
{'p', "-#", argPointer}, {'p', "-#", argPointer},
{'q', " -+.0#", argRune | argInt | argString}, {'q', " -+.0#", argRune | argInt | argString},
{'s', " -+.0", argString}, {'s', " -+.0", argString},
......
...@@ -56,11 +56,11 @@ func matchArgTypeInternal(pass *analysis.Pass, t printfArgType, typ types.Type, ...@@ -56,11 +56,11 @@ func matchArgTypeInternal(pass *analysis.Pass, t printfArgType, typ types.Type,
switch typ := typ.(type) { switch typ := typ.(type) {
case *types.Signature: case *types.Signature:
return t&argPointer != 0 return t == argPointer
case *types.Map: case *types.Map:
// Recur: map[int]int matches %d. return t == argPointer ||
return t&argPointer != 0 || // Recur: map[int]int matches %d.
(matchArgTypeInternal(pass, t, typ.Key(), arg, inProgress) && matchArgTypeInternal(pass, t, typ.Elem(), arg, inProgress)) (matchArgTypeInternal(pass, t, typ.Key(), arg, inProgress) && matchArgTypeInternal(pass, t, typ.Elem(), arg, inProgress))
case *types.Chan: case *types.Chan:
...@@ -72,17 +72,20 @@ func matchArgTypeInternal(pass *analysis.Pass, t printfArgType, typ types.Type, ...@@ -72,17 +72,20 @@ func matchArgTypeInternal(pass *analysis.Pass, t printfArgType, typ types.Type,
return true // %s matches []byte return true // %s matches []byte
} }
// Recur: []int matches %d. // Recur: []int matches %d.
return t&argPointer != 0 || matchArgTypeInternal(pass, t, typ.Elem(), arg, inProgress) return matchArgTypeInternal(pass, t, typ.Elem(), arg, inProgress)
case *types.Slice: case *types.Slice:
// Same as array. // Same as array.
if types.Identical(typ.Elem().Underlying(), types.Typ[types.Byte]) && t&argString != 0 { if types.Identical(typ.Elem().Underlying(), types.Typ[types.Byte]) && t&argString != 0 {
return true // %s matches []byte return true // %s matches []byte
} }
if t == argPointer {
return true // %p prints a slice's 0th element
}
// Recur: []int matches %d. But watch out for // Recur: []int matches %d. But watch out for
// type T []T // type T []T
// If the element is a pointer type (type T[]*T), it's handled fine by the Pointer case below. // If the element is a pointer type (type T[]*T), it's handled fine by the Pointer case below.
return t&argPointer != 0 || matchArgTypeInternal(pass, t, typ.Elem(), arg, inProgress) return matchArgTypeInternal(pass, t, typ.Elem(), arg, inProgress)
case *types.Pointer: case *types.Pointer:
// Ugly, but dealing with an edge case: a known pointer to an invalid type, // Ugly, but dealing with an edge case: a known pointer to an invalid type,
......
// +build ignore
// This file provides an example command for static checkers
// conforming to the golang.org/x/tools/go/analysis API.
// It serves as a model for the behavior of the cmd/vet tool in $GOROOT.
// Being based on the unitchecker driver, it must be run by go vet:
//
// $ go build -o unitchecker main.go
// $ go vet -vettool=unitchecker my/project/...
//
// For a checker also capable of running standalone, use multichecker.
package main
import (
"golang.org/x/tools/go/analysis/unitchecker"
"golang.org/x/tools/go/analysis/passes/asmdecl"
"golang.org/x/tools/go/analysis/passes/assign"
"golang.org/x/tools/go/analysis/passes/atomic"
"golang.org/x/tools/go/analysis/passes/bools"
"golang.org/x/tools/go/analysis/passes/buildtag"
"golang.org/x/tools/go/analysis/passes/cgocall"
"golang.org/x/tools/go/analysis/passes/composite"
"golang.org/x/tools/go/analysis/passes/copylock"
"golang.org/x/tools/go/analysis/passes/httpresponse"
"golang.org/x/tools/go/analysis/passes/loopclosure"
"golang.org/x/tools/go/analysis/passes/lostcancel"
"golang.org/x/tools/go/analysis/passes/nilfunc"
"golang.org/x/tools/go/analysis/passes/printf"
"golang.org/x/tools/go/analysis/passes/shift"
"golang.org/x/tools/go/analysis/passes/stdmethods"
"golang.org/x/tools/go/analysis/passes/structtag"
"golang.org/x/tools/go/analysis/passes/tests"
"golang.org/x/tools/go/analysis/passes/unmarshal"
"golang.org/x/tools/go/analysis/passes/unreachable"
"golang.org/x/tools/go/analysis/passes/unsafeptr"
"golang.org/x/tools/go/analysis/passes/unusedresult"
)
func main() {
unitchecker.Main(
asmdecl.Analyzer,
assign.Analyzer,
atomic.Analyzer,
bools.Analyzer,
buildtag.Analyzer,
cgocall.Analyzer,
composite.Analyzer,
copylock.Analyzer,
httpresponse.Analyzer,
loopclosure.Analyzer,
lostcancel.Analyzer,
nilfunc.Analyzer,
printf.Analyzer,
shift.Analyzer,
stdmethods.Analyzer,
structtag.Analyzer,
tests.Analyzer,
unmarshal.Analyzer,
unreachable.Analyzer,
unsafeptr.Analyzer,
unusedresult.Analyzer,
)
}
...@@ -112,7 +112,7 @@ Usage of %[1]s: ...@@ -112,7 +112,7 @@ Usage of %[1]s:
os.Exit(0) os.Exit(0)
} }
if len(args) != 1 || !strings.HasSuffix(args[0], ".cfg") { if len(args) != 1 || !strings.HasSuffix(args[0], ".cfg") {
log.Fatalf("invalid command: want .cfg file (this reduced version of %s is intended to be run only by the 'go vet' command)", progname) log.Fatalf(`invoking "go tool vet" directly is unsupported; use "go vet"`)
} }
Run(args[0], analyzers) Run(args[0], analyzers)
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment