mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd: update golang.org/x/tools to CL 645697, and revendor
go get golang.org/x/tools@9874647 # CL 645697 go mod tidy go mod vendor Fixes #71485 Change-Id: I72d8f82abd0c6e05f2698d8a372bf9485002d1b3 Reviewed-on: https://go-review.googlesource.com/c/go/+/645336 Reviewed-by: Carlos Amedee <carlos@golang.org> Auto-Submit: Robert Findley <rfindley@google.com> TryBot-Bypass: Robert Findley <rfindley@google.com>
This commit is contained in:
parent
ce7ea0a6a5
commit
77d20838e9
4 changed files with 38 additions and 18 deletions
|
|
@ -11,7 +11,7 @@ require (
|
||||||
golang.org/x/sys v0.28.0
|
golang.org/x/sys v0.28.0
|
||||||
golang.org/x/telemetry v0.0.0-20241204182053-c0ac0e154df3
|
golang.org/x/telemetry v0.0.0-20241204182053-c0ac0e154df3
|
||||||
golang.org/x/term v0.27.0
|
golang.org/x/term v0.27.0
|
||||||
golang.org/x/tools v0.28.0
|
golang.org/x/tools v0.28.1-0.20250131145412-98746475647e
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ golang.org/x/term v0.27.0 h1:WP60Sv1nlK1T6SupCHbXzSaN0b9wUmsPoRS9b61A23Q=
|
||||||
golang.org/x/term v0.27.0/go.mod h1:iMsnZpn0cago0GOrHO2+Y7u7JPn5AylBrcoWkElMTSM=
|
golang.org/x/term v0.27.0/go.mod h1:iMsnZpn0cago0GOrHO2+Y7u7JPn5AylBrcoWkElMTSM=
|
||||||
golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo=
|
golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo=
|
||||||
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
|
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
|
||||||
golang.org/x/tools v0.28.0 h1:WuB6qZ4RPCQo5aP3WdKZS7i595EdWqWR8vqJTlwTVK8=
|
golang.org/x/tools v0.28.1-0.20250131145412-98746475647e h1:6Kzwg7JxW2HRWToKpIKqlpF8l8XMasoALX3OcAMdgL8=
|
||||||
golang.org/x/tools v0.28.0/go.mod h1:dcIOrVd3mfQKTgrDVQHqCPMWy6lnhfhtX3hLXYVLfRw=
|
golang.org/x/tools v0.28.1-0.20250131145412-98746475647e/go.mod h1:dcIOrVd3mfQKTgrDVQHqCPMWy6lnhfhtX3hLXYVLfRw=
|
||||||
rsc.io/markdown v0.0.0-20240306144322-0bf8f97ee8ef h1:mqLYrXCXYEZOop9/Dbo6RPX11539nwiCNBb1icVPmw8=
|
rsc.io/markdown v0.0.0-20240306144322-0bf8f97ee8ef h1:mqLYrXCXYEZOop9/Dbo6RPX11539nwiCNBb1icVPmw8=
|
||||||
rsc.io/markdown v0.0.0-20240306144322-0bf8f97ee8ef/go.mod h1:8xcPgWmwlZONN1D9bjxtHEjrUtSEa3fakVF8iaewYKQ=
|
rsc.io/markdown v0.0.0-20240306144322-0bf8f97ee8ef/go.mod h1:8xcPgWmwlZONN1D9bjxtHEjrUtSEa3fakVF8iaewYKQ=
|
||||||
|
|
|
||||||
48
src/cmd/vendor/golang.org/x/tools/go/analysis/passes/printf/printf.go
generated
vendored
48
src/cmd/vendor/golang.org/x/tools/go/analysis/passes/printf/printf.go
generated
vendored
|
|
@ -25,6 +25,7 @@ import (
|
||||||
"golang.org/x/tools/go/ast/inspector"
|
"golang.org/x/tools/go/ast/inspector"
|
||||||
"golang.org/x/tools/go/types/typeutil"
|
"golang.org/x/tools/go/types/typeutil"
|
||||||
"golang.org/x/tools/internal/typeparams"
|
"golang.org/x/tools/internal/typeparams"
|
||||||
|
"golang.org/x/tools/internal/versions"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|
@ -108,12 +109,12 @@ func (f *isWrapper) String() string {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func run(pass *analysis.Pass) (interface{}, error) {
|
func run(pass *analysis.Pass) (any, error) {
|
||||||
res := &Result{
|
res := &Result{
|
||||||
funcs: make(map[*types.Func]Kind),
|
funcs: make(map[*types.Func]Kind),
|
||||||
}
|
}
|
||||||
findPrintfLike(pass, res)
|
findPrintfLike(pass, res)
|
||||||
checkCall(pass)
|
checkCalls(pass)
|
||||||
return res, nil
|
return res, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -182,7 +183,7 @@ func maybePrintfWrapper(info *types.Info, decl ast.Decl) *printfWrapper {
|
||||||
}
|
}
|
||||||
|
|
||||||
// findPrintfLike scans the entire package to find printf-like functions.
|
// findPrintfLike scans the entire package to find printf-like functions.
|
||||||
func findPrintfLike(pass *analysis.Pass, res *Result) (interface{}, error) {
|
func findPrintfLike(pass *analysis.Pass, res *Result) (any, error) {
|
||||||
// Gather potential wrappers and call graph between them.
|
// Gather potential wrappers and call graph between them.
|
||||||
byObj := make(map[*types.Func]*printfWrapper)
|
byObj := make(map[*types.Func]*printfWrapper)
|
||||||
var wrappers []*printfWrapper
|
var wrappers []*printfWrapper
|
||||||
|
|
@ -409,20 +410,29 @@ func stringConstantExpr(pass *analysis.Pass, expr ast.Expr) (string, bool) {
|
||||||
return "", false
|
return "", false
|
||||||
}
|
}
|
||||||
|
|
||||||
// checkCall triggers the print-specific checks if the call invokes a print function.
|
// checkCalls triggers the print-specific checks for calls that invoke a print
|
||||||
func checkCall(pass *analysis.Pass) {
|
// function.
|
||||||
|
func checkCalls(pass *analysis.Pass) {
|
||||||
inspect := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector)
|
inspect := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector)
|
||||||
nodeFilter := []ast.Node{
|
nodeFilter := []ast.Node{
|
||||||
|
(*ast.File)(nil),
|
||||||
(*ast.CallExpr)(nil),
|
(*ast.CallExpr)(nil),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var fileVersion string // for selectively suppressing checks; "" if unknown.
|
||||||
inspect.Preorder(nodeFilter, func(n ast.Node) {
|
inspect.Preorder(nodeFilter, func(n ast.Node) {
|
||||||
call := n.(*ast.CallExpr)
|
switch n := n.(type) {
|
||||||
fn, kind := printfNameAndKind(pass, call)
|
case *ast.File:
|
||||||
switch kind {
|
fileVersion = versions.Lang(versions.FileVersion(pass.TypesInfo, n))
|
||||||
case KindPrintf, KindErrorf:
|
|
||||||
checkPrintf(pass, kind, call, fn)
|
case *ast.CallExpr:
|
||||||
case KindPrint:
|
fn, kind := printfNameAndKind(pass, n)
|
||||||
checkPrint(pass, call, fn)
|
switch kind {
|
||||||
|
case KindPrintf, KindErrorf:
|
||||||
|
checkPrintf(pass, fileVersion, kind, n, fn)
|
||||||
|
case KindPrint:
|
||||||
|
checkPrint(pass, n, fn)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
@ -503,7 +513,7 @@ type formatState struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// checkPrintf checks a call to a formatted print routine such as Printf.
|
// checkPrintf checks a call to a formatted print routine such as Printf.
|
||||||
func checkPrintf(pass *analysis.Pass, kind Kind, call *ast.CallExpr, fn *types.Func) {
|
func checkPrintf(pass *analysis.Pass, fileVersion string, kind Kind, call *ast.CallExpr, fn *types.Func) {
|
||||||
idx := formatStringIndex(pass, call)
|
idx := formatStringIndex(pass, call)
|
||||||
if idx < 0 || idx >= len(call.Args) {
|
if idx < 0 || idx >= len(call.Args) {
|
||||||
return
|
return
|
||||||
|
|
@ -517,7 +527,17 @@ func checkPrintf(pass *analysis.Pass, kind Kind, call *ast.CallExpr, fn *types.F
|
||||||
// non-constant format string and no arguments:
|
// non-constant format string and no arguments:
|
||||||
// if msg contains "%", misformatting occurs.
|
// if msg contains "%", misformatting occurs.
|
||||||
// Report the problem and suggest a fix: fmt.Printf("%s", msg).
|
// Report the problem and suggest a fix: fmt.Printf("%s", msg).
|
||||||
if !suppressNonconstants && idx == len(call.Args)-1 {
|
//
|
||||||
|
// However, as described in golang/go#71485, this analysis can produce a
|
||||||
|
// significant number of diagnostics in existing code, and the bugs it
|
||||||
|
// finds are sometimes unlikely or inconsequential, and may not be worth
|
||||||
|
// fixing for some users. Gating on language version allows us to avoid
|
||||||
|
// breaking existing tests and CI scripts.
|
||||||
|
if !suppressNonconstants &&
|
||||||
|
idx == len(call.Args)-1 &&
|
||||||
|
fileVersion != "" && // fail open
|
||||||
|
versions.AtLeast(fileVersion, "go1.24") {
|
||||||
|
|
||||||
pass.Report(analysis.Diagnostic{
|
pass.Report(analysis.Diagnostic{
|
||||||
Pos: formatArg.Pos(),
|
Pos: formatArg.Pos(),
|
||||||
End: formatArg.End(),
|
End: formatArg.End(),
|
||||||
|
|
|
||||||
2
src/cmd/vendor/modules.txt
vendored
2
src/cmd/vendor/modules.txt
vendored
|
|
@ -73,7 +73,7 @@ golang.org/x/text/internal/tag
|
||||||
golang.org/x/text/language
|
golang.org/x/text/language
|
||||||
golang.org/x/text/transform
|
golang.org/x/text/transform
|
||||||
golang.org/x/text/unicode/norm
|
golang.org/x/text/unicode/norm
|
||||||
# golang.org/x/tools v0.28.0
|
# golang.org/x/tools v0.28.1-0.20250131145412-98746475647e
|
||||||
## explicit; go 1.22.0
|
## explicit; go 1.22.0
|
||||||
golang.org/x/tools/cmd/bisect
|
golang.org/x/tools/cmd/bisect
|
||||||
golang.org/x/tools/cover
|
golang.org/x/tools/cover
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue