Skip to content

Commit 39f1305

Browse files
committed
[gopls-release-branch.0.5] all: merge master into gopls-release-branch.0.5
3db8fd2 internal/lsp: use a structured format for the server's version 8694a4a internal/lsp/source: don't find possible interface references to types 78b1585 internal/lsp/fake: reflect on-disk changes in clean buffers bc9fc8d internal/lsp: fix flickering analysis diagnostics bc3cf28 go/loader: loosen a test assertion on go/types error messages 22bd852 internal/lsp: remove organize imports action for go.mod aefe0b7 internal/lsp: set correct directness when adding new requires 330dc7d internal/lsp/cache: assign a static temp workspace dir to the first view b653051 internal/lsp/cmd: delete TestDefinitionHelpExample test ac612af internal/lsp: fix the logic to avoid duplicate file watching 6d1a7fa internal/imports: handle out of range panic in modInfo 7ad286a internal/lsp: check for nil snapshot in didModifyFiles c64668f internal/lsp: do not rename in compiler directive comments f46e424 internal/lsp/cache: handle nil pointer exception in missing module error 3f6de07 internal/lsp: make Diagnostics.CodeDescription a pointer 3288bc1 go/analysis: add frame pointer check for vet b53d4cb internal/lsp/cache: check for symlinks when checking "isSubdirectory" 8860a70 internal/lsp/cache: set a 15 minute deadline on calls to packages.Load 51cde52 internal/lsp: move initialization entirely into the snapshot 1f28ee6 internal/lsp: change `go mod vendor` warning into a diagnostic 582c62e go/analysis/singlechecker: fix whitespace in package documentation 4fc0492 internal/lsp/cache: keep a cached workspace module dir 3734b81 internal/lsp: delay longer in TestDebouncer d36b6f6 internal/memoize: add a final argument to Bind for cleaning up f239dba internal/lsp/cache: consider gopls.mod when finding workspace root d463eb0 internal/lsp/cache: introduce a workspace abstraction 443cd81 Revert "internal/lsp: move initialization entirely into the snapshot" deb1282 internal/lsp: move initialization entirely into the snapshot 8da1a62 internal/lsp/source/completion: remove "completion_" prefix from files 589136c cmd/fiximports,cmd/present,cmd/stringer: update links to pkg.go.dev cf7a54d internal/lsp/source: use bestMatch for fully qualified symbol style 63f8a17 internal/lsp: use the correct method name to register semantic tokens 2feb2bb internal/lsp: elide details for non-package files 186a743 internal/lsp/source: respect user's hover kind in signature help 061905c internal/lsp/cache: stop unnecessarily waiting for IWL c86e623 internal/lsp/source: add missing vet analyzers e7a17c4 internal/lsp/cache: preserve OS environment 690a3c2 go/analysis/passes/asmdecl: permit return jump without writing to results 2c11599 internal/lsp: use the go command to fix go.mod files 4972913 internal/lsp: unify go command invocation logic 832c4b4 internal/lsp/source: tweak the WorkspaceSymbols docstring 2b84a06 internal/lsp: use gocommand.Invocation more 5bbba66 internal/lsp/source: synchronous commands the default dc70f74 internal/lsp: correct typo 0dcbe36 gopls/doc: update links from godoc.org to pkg.go.dev eafbe7b internal/lsp/protocol/typescript: code for latest 3.16 LSP 8cd080b internal/lsp: handle nil pointer exceptions in check for Go files 0b86805 internal/lsp: finish work when synchronous commands complete 6312208 go/internal/gccgoimporter: support notinheap annotation 8dabb74 internal/lsp: update lsp protocol stubs to match LSP 3.16 revisions e84cfc6 all: clear GOMODCACHE in tests c8cfbd0 internal/lsp/source: handle nil pointer in rename_check.go 2f4fa18 go/packages: use native overlay support for 1.16 ffe8bce cmd/stress: print elapsed time, percentage failure 13b3b30 internal/lsp/semantic.go: remove global variable 9cf592e all: update all dependencies to latest pseudoversions Change-Id: I1e690a9cb361ed05cc1d184951e06b3e2099dc08
2 parents 036b6e7 + 3db8fd2 commit 39f1305

File tree

113 files changed

+3137
-1563
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

113 files changed

+3137
-1563
lines changed

cmd/fiximports/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ The package... arguments specify a list of packages
114114
in the style of the go tool; see "go help packages".
115115
Hint: use "all" or "..." to match the entire workspace.
116116
117-
For details, see http://godoc.org/golang.org/x/tools/cmd/fiximports.
117+
For details, see https://pkg.go.dev/golang.org/x/tools/cmd/fiximports
118118
119119
Flags:
120120
-n: dry run: show changes, but don't apply them

cmd/present/doc.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,6 @@ the generated output. The supported formats are:
4747
.article // article format, such as a blog post
4848
4949
The present file format is documented by the present package:
50-
http://godoc.org/golang.org/x/tools/present
50+
https://pkg.go.dev/golang.org/x/tools/present
5151
*/
5252
package main

cmd/stress/stress.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ func main() {
113113
}()
114114
}
115115
runs, fails := 0, 0
116+
start := time.Now()
116117
ticker := time.NewTicker(5 * time.Second).C
117118
for {
118119
select {
@@ -137,7 +138,12 @@ func main() {
137138
fmt.Printf("\n%s\n%s\n", f.Name(), out)
138139
}
139140
case <-ticker:
140-
fmt.Printf("%v runs so far, %v failures\n", runs, fails)
141+
elapsed := time.Since(start).Truncate(time.Second)
142+
var pct string
143+
if fails > 0 {
144+
pct = fmt.Sprintf(" (%0.2f%%)", 100.0*float64(fails)/float64(runs))
145+
}
146+
fmt.Printf("%v: %v runs so far, %v failures%s\n", elapsed, runs, fails, pct)
141147
}
142148
}
143149
}

cmd/stringer/stringer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ func Usage() {
9898
fmt.Fprintf(os.Stderr, "\tstringer [flags] -type T [directory]\n")
9999
fmt.Fprintf(os.Stderr, "\tstringer [flags] -type T files... # Must be a single package\n")
100100
fmt.Fprintf(os.Stderr, "For more information, see:\n")
101-
fmt.Fprintf(os.Stderr, "\thttp://godoc.org/golang.org/x/tools/cmd/stringer\n")
101+
fmt.Fprintf(os.Stderr, "\thttps://pkg.go.dev/golang.org/x/tools/cmd/stringer\n")
102102
fmt.Fprintf(os.Stderr, "Flags:\n")
103103
flag.PrintDefaults()
104104
}

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ go 1.12
55
require (
66
github.com/yuin/goldmark v1.2.1
77
golang.org/x/mod v0.3.0
8-
golang.org/x/net v0.0.0-20200822124328-c89045814202
9-
golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208
8+
golang.org/x/net v0.0.0-20201021035429-f5854403a974
9+
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9
1010
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1
1111
)

go.sum

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,20 @@ golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPh
66
golang.org/x/mod v0.3.0 h1:RM4zey1++hCTbCVQfnWeKs9/IEsaBLA8vTkd0WVtmH4=
77
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
88
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
9-
golang.org/x/net v0.0.0-20190620200207-3b0461eec859 h1:R/3boaszxrf1GEUWTVDzSKVwLmSJpwZ1yqXm8j0v2QI=
109
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
11-
golang.org/x/net v0.0.0-20200822124328-c89045814202 h1:VvcQYSHwXgi7W+TpUR6A9g6Up98WAHf3f/ulnJ62IyA=
12-
golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
13-
golang.org/x/sync v0.0.0-20190423024810-112230192c58 h1:8gQV6CLnAEikrhgkHFbMAEhagSSnXWGV915qUMm9mrU=
10+
golang.org/x/net v0.0.0-20201021035429-f5854403a974 h1:IX6qOQeG5uLjB/hjjwjedwfjND0hgjPMMyO1RoIXQNI=
11+
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
1412
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
15-
golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208 h1:qwRHBd0NqMbJxfbotnDhm2ByMI1Shq4Y6oRJo21SGJA=
16-
golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
17-
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a h1:1BGLXjeY4akVXGgbC9HugT3Jv3hCI0z56oJR5vAMgBU=
13+
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9 h1:SQFwaSi55rU7vdNs9Yr0Z324VNlrF+0wMqRXT4St8ck=
14+
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
1815
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
1916
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
20-
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
17+
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
2118
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
19+
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
20+
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
2221
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
2322
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
24-
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898 h1:/atklqdjdhuosWIl6AIbOeHJjicWYPqR9bpxqxYG2pA=
2523
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
2624
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
2725
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=

go/analysis/passes/asmdecl/asmdecl.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,8 @@ Files:
308308
continue
309309
}
310310

311-
if strings.Contains(line, "RET") {
311+
if strings.Contains(line, "RET") && !strings.Contains(line, "(SB)") {
312+
// RET f(SB) is a tail call. It is okay to not write the results.
312313
retLine = append(retLine, lineno)
313314
}
314315

go/analysis/passes/asmdecl/testdata/src/a/asm.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,5 @@ func fvariadic(int, ...int)
5151
func pickStableABI(x int)
5252
func pickInternalABI(x int)
5353
func pickFutureABI(x int)
54+
55+
func retjmp() int

go/analysis/passes/asmdecl/testdata/src/a/asm1.s

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,3 +345,7 @@ TEXT ·pickInternalABI<ABIInternal>(SB), NOSPLIT, $32
345345
TEXT ·pickFutureABI<ABISomethingNotyetInvented>(SB), NOSPLIT, $32
346346
MOVQ x+0(FP), AX
347347
RET
348+
349+
// return jump
350+
TEXT ·retjmp(SB), NOSPLIT, $0-8
351+
RET retjmp1(SB) // It's okay to not write results if there's a tail call.
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
// Copyright 2020 The Go Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE file.
4+
5+
// Package framepointer defines an Analyzer that reports assembly code
6+
// that clobbers the frame pointer before saving it.
7+
package framepointer
8+
9+
import (
10+
"go/build"
11+
"regexp"
12+
"strings"
13+
14+
"golang.org/x/tools/go/analysis"
15+
"golang.org/x/tools/go/analysis/passes/internal/analysisutil"
16+
)
17+
18+
const Doc = "report assembly that clobbers the frame pointer before saving it"
19+
20+
var Analyzer = &analysis.Analyzer{
21+
Name: "framepointer",
22+
Doc: Doc,
23+
Run: run,
24+
}
25+
26+
var (
27+
re = regexp.MustCompile
28+
asmWriteBP = re(`,\s*BP$`) // TODO: can have false positive, e.g. for TESTQ BP,BP. Seems unlikely.
29+
asmMentionBP = re(`\bBP\b`)
30+
asmControlFlow = re(`^(J|RET)`)
31+
)
32+
33+
func run(pass *analysis.Pass) (interface{}, error) {
34+
if build.Default.GOARCH != "amd64" { // TODO: arm64 also?
35+
return nil, nil
36+
}
37+
if build.Default.GOOS != "linux" && build.Default.GOOS != "darwin" {
38+
return nil, nil
39+
}
40+
41+
// Find assembly files to work on.
42+
var sfiles []string
43+
for _, fname := range pass.OtherFiles {
44+
if strings.HasSuffix(fname, ".s") {
45+
sfiles = append(sfiles, fname)
46+
}
47+
}
48+
49+
for _, fname := range sfiles {
50+
content, tf, err := analysisutil.ReadFile(pass.Fset, fname)
51+
if err != nil {
52+
return nil, err
53+
}
54+
55+
lines := strings.SplitAfter(string(content), "\n")
56+
active := false
57+
for lineno, line := range lines {
58+
lineno++
59+
60+
// Ignore comments and commented-out code.
61+
if i := strings.Index(line, "//"); i >= 0 {
62+
line = line[:i]
63+
}
64+
line = strings.TrimSpace(line)
65+
66+
// We start checking code at a TEXT line for a frameless function.
67+
if strings.HasPrefix(line, "TEXT") && strings.Contains(line, "(SB)") && strings.Contains(line, "$0") {
68+
active = true
69+
continue
70+
}
71+
if !active {
72+
continue
73+
}
74+
75+
if asmWriteBP.MatchString(line) { // clobber of BP, function is not OK
76+
pass.Reportf(analysisutil.LineStart(tf, lineno), "frame pointer is clobbered before saving")
77+
active = false
78+
continue
79+
}
80+
if asmMentionBP.MatchString(line) { // any other use of BP might be a read, so function is OK
81+
active = false
82+
continue
83+
}
84+
if asmControlFlow.MatchString(line) { // give up after any branch instruction
85+
active = false
86+
continue
87+
}
88+
}
89+
}
90+
return nil, nil
91+
}

0 commit comments

Comments
 (0)