1
0
mirror of https://github.com/golang/go synced 2024-11-18 19:24:39 -07:00

go/ssa: fix vet issues

The new go/analysis/cmd/vet tool found a few issues. Fix them by
explicitly ignoring results where needed and renaming examples in
accordance to package testing's guidelines to make them appear on the
godoc pages.

This change doesn't touch go/ssa/interp/external.go because the
possible misuse of package unsafe there looks intentional.

Change-Id: Id63109e3797818a5e869fe8ed1bc1476959541f2
Reviewed-on: https://go-review.googlesource.com/c/147297
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
This commit is contained in:
Ainar Garipov 2018-11-03 13:45:46 +03:00 committed by Alan Donovan
parent fc67db3d9a
commit f1b4bd93c9
2 changed files with 6 additions and 6 deletions

View File

@ -49,7 +49,7 @@ func main() {
// with similar functionality. It is located at
// golang.org/x/tools/cmd/ssadump.
//
func ExampleBuildPackage() {
func Example_buildPackage() {
// Parse the source files.
fset := token.NewFileSet()
f, err := parser.ParseFile(fset, "hello.go", hello, parser.ParseComments)
@ -117,7 +117,7 @@ func ExampleBuildPackage() {
// This example builds SSA code for a set of packages using the
// x/tools/go/packages API. This is what you would typically use for a
// analysis capable of operating on a single package.
func ExampleLoadPackages() {
func Example_loadPackages() {
// Load, parse, and type-check the initial packages.
cfg := &packages.Config{Mode: packages.LoadSyntax}
initial, err := packages.Load(cfg, "fmt", "net/http")
@ -147,7 +147,7 @@ func ExampleLoadPackages() {
// This example builds SSA code for a set of packages plus all their dependencies,
// using the x/tools/go/packages API.
// This is what you'd typically use for a whole-program analysis.
func ExampleLoadWholeProgram() {
func Example_loadWholeProgram() {
// Load, parse, and type-check the whole program.
cfg := packages.Config{Mode: packages.LoadAllSyntax}
initial, err := packages.Load(&cfg, "fmt", "net/http")

View File

@ -408,8 +408,8 @@ func (s *sanity) checkFunction(fn *Function) bool {
s.errorf("nil Prog")
}
fn.String() // must not crash
fn.RelString(fn.pkg()) // must not crash
_ = fn.String() // must not crash
_ = fn.RelString(fn.pkg()) // must not crash
// All functions have a package, except delegates (which are
// shared across packages, or duplicated as weak symbols in a
@ -499,7 +499,7 @@ func sanityCheckPackage(pkg *Package) {
if pkg.Pkg == nil {
panic(fmt.Sprintf("Package %s has no Object", pkg))
}
pkg.String() // must not crash
_ = pkg.String() // must not crash
for name, mem := range pkg.Members {
if name != mem.Name() {