diff options
author | Ian Lance Taylor <iant@golang.org> | 2021-01-27 17:55:50 -0800 |
---|---|---|
committer | Ian Lance Taylor <iant@golang.org> | 2021-01-29 11:04:55 -0800 |
commit | 726b7aa004d6885388a76521222602b8552a41ee (patch) | |
tree | 5179037ef840a43dcea0f3be4e07dbcbcfcb2c4a /libgo/go/golang.org/x/tools | |
parent | 91a95ad2ae0e0f2fa953fafe55ff2ec32c8277d5 (diff) | |
download | gcc-726b7aa004d6885388a76521222602b8552a41ee.tar.gz |
libgo: update to Go1.16rc1
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/287493
Diffstat (limited to 'libgo/go/golang.org/x/tools')
11 files changed, 78 insertions, 56 deletions
diff --git a/libgo/go/golang.org/x/tools/go/analysis/analysis.go b/libgo/go/golang.org/x/tools/go/analysis/analysis.go index 8c3c2e7ab95..d11505a165c 100644 --- a/libgo/go/golang.org/x/tools/go/analysis/analysis.go +++ b/libgo/go/golang.org/x/tools/go/analysis/analysis.go @@ -1,3 +1,7 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + package analysis import ( diff --git a/libgo/go/golang.org/x/tools/go/analysis/diagnostic.go b/libgo/go/golang.org/x/tools/go/analysis/diagnostic.go index 57eaf6faa2a..cd462a0cb55 100644 --- a/libgo/go/golang.org/x/tools/go/analysis/diagnostic.go +++ b/libgo/go/golang.org/x/tools/go/analysis/diagnostic.go @@ -1,3 +1,7 @@ +// Copyright 2019 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + package analysis import "go/token" diff --git a/libgo/go/golang.org/x/tools/go/analysis/doc.go b/libgo/go/golang.org/x/tools/go/analysis/doc.go index 9fa3302dfbe..94a3bd5d07c 100644 --- a/libgo/go/golang.org/x/tools/go/analysis/doc.go +++ b/libgo/go/golang.org/x/tools/go/analysis/doc.go @@ -1,3 +1,7 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + /* Package analysis defines the interface between a modular static diff --git a/libgo/go/golang.org/x/tools/go/analysis/internal/analysisflags/help.go b/libgo/go/golang.org/x/tools/go/analysis/internal/analysisflags/help.go index c5a70f3b7d6..ce92892c817 100644 --- a/libgo/go/golang.org/x/tools/go/analysis/internal/analysisflags/help.go +++ b/libgo/go/golang.org/x/tools/go/analysis/internal/analysisflags/help.go @@ -1,3 +1,7 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + package analysisflags import ( diff --git a/libgo/go/golang.org/x/tools/go/analysis/passes/internal/analysisutil/util.go b/libgo/go/golang.org/x/tools/go/analysis/passes/internal/analysisutil/util.go index 80c9476fcdd..ac37e4784e1 100644 --- a/libgo/go/golang.org/x/tools/go/analysis/passes/internal/analysisutil/util.go +++ b/libgo/go/golang.org/x/tools/go/analysis/passes/internal/analysisutil/util.go @@ -1,3 +1,7 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + // Package analysisutil defines various helper functions // used by two or more packages beneath go/analysis. package analysisutil diff --git a/libgo/go/golang.org/x/tools/go/analysis/passes/printf/types.go b/libgo/go/golang.org/x/tools/go/analysis/passes/printf/types.go index bd8a594ef57..6a5fae44f46 100644 --- a/libgo/go/golang.org/x/tools/go/analysis/passes/printf/types.go +++ b/libgo/go/golang.org/x/tools/go/analysis/passes/printf/types.go @@ -1,3 +1,7 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + package printf import ( diff --git a/libgo/go/golang.org/x/tools/go/analysis/passes/structtag/structtag.go b/libgo/go/golang.org/x/tools/go/analysis/passes/structtag/structtag.go index 02555648a0b..f0b15051c52 100644 --- a/libgo/go/golang.org/x/tools/go/analysis/passes/structtag/structtag.go +++ b/libgo/go/golang.org/x/tools/go/analysis/passes/structtag/structtag.go @@ -207,12 +207,12 @@ var ( ) // validateStructTag parses the struct tag and returns an error if it is not -// in the canonical format, as defined by reflect.StructTag. +// in the canonical format, which is a space-separated list of key:"value" +// settings. The value may contain spaces. func validateStructTag(tag string) error { // This code is based on the StructTag.Get code in package reflect. n := 0 - var keys []string for ; tag != ""; n++ { if n > 0 && tag != "" && tag[0] != ' ' { // More restrictive than reflect, but catches likely mistakes @@ -240,27 +240,14 @@ func validateStructTag(tag string) error { if i == 0 { return errTagKeySyntax } - if i+1 >= len(tag) || tag[i] < ' ' || tag[i] == 0x7f { + if i+1 >= len(tag) || tag[i] != ':' { return errTagSyntax } - key := tag[:i] - keys = append(keys, key) - tag = tag[i:] - - // If we found a space char here - assume that we have a tag with - // multiple keys. - if tag[0] == ' ' { - continue - } - - // Spaces were filtered above so we assume that here we have - // only valid tag value started with `:"`. - if tag[0] != ':' || tag[1] != '"' { + if tag[i+1] != '"' { return errTagValueSyntax } - - // Remove the colon leaving tag at the start of the quoted string. - tag = tag[1:] + key := tag[:i] + tag = tag[i+1:] // Scan quoted string to find value. i = 1 @@ -276,56 +263,51 @@ func validateStructTag(tag string) error { qvalue := tag[:i+1] tag = tag[i+1:] - wholeValue, err := strconv.Unquote(qvalue) + value, err := strconv.Unquote(qvalue) if err != nil { return errTagValueSyntax } - for _, key := range keys { - if !checkTagSpaces[key] { - continue - } - - value := wholeValue - switch key { - case "xml": - // If the first or last character in the XML tag is a space, it is - // suspicious. - if strings.Trim(value, " ") != value { - return errTagValueSpace - } + if !checkTagSpaces[key] { + continue + } - // If there are multiple spaces, they are suspicious. - if strings.Count(value, " ") > 1 { - return errTagValueSpace - } + switch key { + case "xml": + // If the first or last character in the XML tag is a space, it is + // suspicious. + if strings.Trim(value, " ") != value { + return errTagValueSpace + } - // If there is no comma, skip the rest of the checks. - comma := strings.IndexRune(value, ',') - if comma < 0 { - continue - } + // If there are multiple spaces, they are suspicious. + if strings.Count(value, " ") > 1 { + return errTagValueSpace + } - // If the character before a comma is a space, this is suspicious. - if comma > 0 && value[comma-1] == ' ' { - return errTagValueSpace - } - value = value[comma+1:] - case "json": - // JSON allows using spaces in the name, so skip it. - comma := strings.IndexRune(value, ',') - if comma < 0 { - continue - } - value = value[comma+1:] + // If there is no comma, skip the rest of the checks. + comma := strings.IndexRune(value, ',') + if comma < 0 { + continue } - if strings.IndexByte(value, ' ') >= 0 { + // If the character before a comma is a space, this is suspicious. + if comma > 0 && value[comma-1] == ' ' { return errTagValueSpace } + value = value[comma+1:] + case "json": + // JSON allows using spaces in the name, so skip it. + comma := strings.IndexRune(value, ',') + if comma < 0 { + continue + } + value = value[comma+1:] } - keys = keys[:0] + if strings.IndexByte(value, ' ') >= 0 { + return errTagValueSpace + } } return nil } diff --git a/libgo/go/golang.org/x/tools/go/analysis/unitchecker/unitchecker112.go b/libgo/go/golang.org/x/tools/go/analysis/unitchecker/unitchecker112.go index 683b7e91d25..9051456e396 100644 --- a/libgo/go/golang.org/x/tools/go/analysis/unitchecker/unitchecker112.go +++ b/libgo/go/golang.org/x/tools/go/analysis/unitchecker/unitchecker112.go @@ -1,3 +1,7 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + // +build go1.12 package unitchecker diff --git a/libgo/go/golang.org/x/tools/go/analysis/validate.go b/libgo/go/golang.org/x/tools/go/analysis/validate.go index ad0e7276c91..23e57bf02b6 100644 --- a/libgo/go/golang.org/x/tools/go/analysis/validate.go +++ b/libgo/go/golang.org/x/tools/go/analysis/validate.go @@ -1,3 +1,7 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + package analysis import ( diff --git a/libgo/go/golang.org/x/tools/go/ast/astutil/util.go b/libgo/go/golang.org/x/tools/go/ast/astutil/util.go index 7630629824a..919d5305ab4 100644 --- a/libgo/go/golang.org/x/tools/go/ast/astutil/util.go +++ b/libgo/go/golang.org/x/tools/go/ast/astutil/util.go @@ -1,3 +1,7 @@ +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + package astutil import "go/ast" diff --git a/libgo/go/golang.org/x/tools/go/ast/inspector/typeof.go b/libgo/go/golang.org/x/tools/go/ast/inspector/typeof.go index d61301b133d..b6b00cf2e1e 100644 --- a/libgo/go/golang.org/x/tools/go/ast/inspector/typeof.go +++ b/libgo/go/golang.org/x/tools/go/ast/inspector/typeof.go @@ -1,3 +1,7 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + package inspector // This file defines func typeOf(ast.Node) uint64. |