]> Cypherpunks repositories - gostls13.git/commitdiff
cmd: go get golang.org/x/tools@d88ec18 && go mod vendor
authorRuss Cox <rsc@golang.org>
Tue, 13 Oct 2020 18:19:20 +0000 (14:19 -0400)
committerRuss Cox <rsc@golang.org>
Wed, 14 Oct 2020 15:19:33 +0000 (15:19 +0000)
This brings in CL 261725, which applies the vet buildtag checker
to ignored files.

For #41184.

Change-Id: I5f241db5a71fa84d0af0b9e9f8a75ff5bb3dd116
Reviewed-on: https://go-review.googlesource.com/c/go/+/261958
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
src/cmd/go.mod
src/cmd/go.sum
src/cmd/vendor/golang.org/x/tools/go/analysis/analysis.go
src/cmd/vendor/golang.org/x/tools/go/analysis/doc.go
src/cmd/vendor/golang.org/x/tools/go/analysis/passes/buildtag/buildtag.go
src/cmd/vendor/golang.org/x/tools/go/analysis/unitchecker/unitchecker.go
src/cmd/vendor/modules.txt

index 56941b0541546232af2b7c5c633df0d2dbfad5b6..47165c2d66942c641f4097b87f9e3b45af564cdf 100644 (file)
@@ -9,5 +9,5 @@ require (
        golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a
        golang.org/x/mod v0.3.1-0.20200828183125-ce943fd02449
        golang.org/x/sys v0.0.0-20200923182605-d9f96fdee20d // indirect
-       golang.org/x/tools v0.0.0-20200918232735-d647fc253266
+       golang.org/x/tools v0.0.0-20201013174405-d88ec18c69c7
 )
index 2b505c4354037df56eaac1d79504c5eaccdca130..1cf0ab778b4a40aa50a91b483e1f13b13a01e635 100644 (file)
@@ -30,8 +30,8 @@ golang.org/x/sys v0.0.0-20200923182605-d9f96fdee20d h1:L/IKR6COd7ubZrs2oTnTi73Ih
 golang.org/x/sys v0.0.0-20200923182605-d9f96fdee20d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
 golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
-golang.org/x/tools v0.0.0-20200918232735-d647fc253266 h1:k7tVuG0g1JwmD3Jh8oAl1vQ1C3jb4Hi/dUl1wWDBJpQ=
-golang.org/x/tools v0.0.0-20200918232735-d647fc253266/go.mod h1:z6u4i615ZeAfBE4XtMziQW1fSVJXACjjbWkB/mvPzlU=
+golang.org/x/tools v0.0.0-20201013174405-d88ec18c69c7 h1:z+ozLsKwDztt1oIueYsv07oF+mXNYIiwU0PQVXwmhlo=
+golang.org/x/tools v0.0.0-20201013174405-d88ec18c69c7/go.mod h1:z6u4i615ZeAfBE4XtMziQW1fSVJXACjjbWkB/mvPzlU=
 golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
 golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
 golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
index 8c9977355c9daef6faef3f03395d7a77b12f5a0d..8c3c2e7ab950f2497e93c5a0d27a4bc05d9fbff1 100644 (file)
@@ -95,12 +95,13 @@ type Pass struct {
        Analyzer *Analyzer // the identity of the current analyzer
 
        // syntax and type information
-       Fset       *token.FileSet // file position information
-       Files      []*ast.File    // the abstract syntax tree of each file
-       OtherFiles []string       // names of non-Go files of this package
-       Pkg        *types.Package // type information about the package
-       TypesInfo  *types.Info    // type information about the syntax trees
-       TypesSizes types.Sizes    // function for computing sizes of types
+       Fset         *token.FileSet // file position information
+       Files        []*ast.File    // the abstract syntax tree of each file
+       OtherFiles   []string       // names of non-Go files of this package
+       IgnoredFiles []string       // names of ignored source files in this package
+       Pkg          *types.Package // type information about the package
+       TypesInfo    *types.Info    // type information about the syntax trees
+       TypesSizes   types.Sizes    // function for computing sizes of types
 
        // Report reports a Diagnostic, a finding about a specific location
        // in the analyzed source code such as a potential mistake.
index fb17a0e4154c16d31c8fd77fb958e0cc3944185e..9fa3302dfbe9950c7c843adae82e5a985e30155f 100644 (file)
@@ -121,13 +121,14 @@ package being analyzed, and provides operations to the Run function for
 reporting diagnostics and other information back to the driver.
 
        type Pass struct {
-               Fset       *token.FileSet
-               Files      []*ast.File
-               OtherFiles []string
-               Pkg        *types.Package
-               TypesInfo  *types.Info
-               ResultOf   map[*Analyzer]interface{}
-               Report     func(Diagnostic)
+               Fset         *token.FileSet
+               Files        []*ast.File
+               OtherFiles   []string
+               IgnoredFiles []string
+               Pkg          *types.Package
+               TypesInfo    *types.Info
+               ResultOf     map[*Analyzer]interface{}
+               Report       func(Diagnostic)
                ...
        }
 
@@ -139,6 +140,12 @@ files such as assembly that are part of this package. See the "asmdecl"
 or "buildtags" analyzers for examples of loading non-Go files and reporting
 diagnostics against them.
 
+The IgnoredFiles field provides the names, but not the contents,
+of ignored Go and non-Go source files that are not part of this package
+with the current build configuration but may be part of other build
+configurations. See the "buildtags" analyzer for an example of loading
+and checking IgnoredFiles.
+
 The ResultOf field provides the results computed by the analyzers
 required by this one, as expressed in its Analyzer.Requires field. The
 driver runs the required analyzers first and makes their results
index 78176f10114131f3ee5114e2fe049953b7c2b2f6..841b928578440879fc4111d08373bd9759e6f203 100644 (file)
@@ -9,6 +9,7 @@ import (
        "bytes"
        "fmt"
        "go/ast"
+       "go/parser"
        "strings"
        "unicode"
 
@@ -33,6 +34,20 @@ func runBuildTag(pass *analysis.Pass) (interface{}, error) {
                        return nil, err
                }
        }
+       for _, name := range pass.IgnoredFiles {
+               if strings.HasSuffix(name, ".go") {
+                       f, err := parser.ParseFile(pass.Fset, name, nil, parser.ParseComments)
+                       if err != nil {
+                               // Not valid Go source code - not our job to diagnose, so ignore.
+                               return nil, nil
+                       }
+                       checkGoFile(pass, f)
+               } else {
+                       if err := checkOtherFile(pass, name); err != nil {
+                               return nil, err
+                       }
+               }
+       }
        return nil, nil
 }
 
@@ -132,13 +147,6 @@ func checkLine(line string, pastCutoff bool) error {
 }
 
 func checkArguments(fields []string) error {
-       // The original version of this checker in vet could examine
-       // files with malformed build tags that would cause the file to
-       // be always ignored by "go build". However, drivers for the new
-       // analysis API will analyze only the files selected to form a
-       // package, so these checks will never fire.
-       // TODO(adonovan): rethink this.
-
        for _, arg := range fields[1:] {
                for _, elem := range strings.Split(arg, ",") {
                        if strings.HasPrefix(elem, "!!") {
index 2ed274949bdaf98d322f3b06e500eb9394c208c6..713e1380ef1063f9279e454cd68a9f8147a93296 100644 (file)
@@ -63,6 +63,7 @@ type Config struct {
        ImportPath                string
        GoFiles                   []string
        NonGoFiles                []string
+       IgnoredFiles              []string
        ImportMap                 map[string]string
        PackageFile               map[string]string
        Standard                  map[string]bool
@@ -333,6 +334,7 @@ func run(fset *token.FileSet, cfg *Config, analyzers []*analysis.Analyzer) ([]re
                                Fset:              fset,
                                Files:             files,
                                OtherFiles:        cfg.NonGoFiles,
+                               IgnoredFiles:      cfg.IgnoredFiles,
                                Pkg:               pkg,
                                TypesInfo:         info,
                                TypesSizes:        tc.Sizes,
index e2078b1a7fdb8225fb2739fa4527ba212c949756..e37cab806a93ab6bb016e645b7843c092e422aef 100644 (file)
@@ -45,7 +45,7 @@ golang.org/x/mod/zip
 golang.org/x/sys/internal/unsafeheader
 golang.org/x/sys/unix
 golang.org/x/sys/windows
-# golang.org/x/tools v0.0.0-20200918232735-d647fc253266
+# golang.org/x/tools v0.0.0-20201013174405-d88ec18c69c7
 ## explicit
 golang.org/x/tools/go/analysis
 golang.org/x/tools/go/analysis/internal/analysisflags