Skip to content

Commit 99b205f

Browse files
committed
all: merge master (e342718) into gopls-release-branch.0.8
Also add back a replace directive in go.mod. Updates golang/go#52015 Conflicts: - gopls/go.mod - gopls/go.sum - internal/lsp/testdata/rename/generics/generics.go.golden Merge List: + 2022-03-29 e342718 gopls/internal/vulncheck: skip vuln entries without callstacks + 2022-03-29 b22bc85 gopls/doc: update stale documentation on generics + 2022-03-25 e693fb4 go/internal/gcimporter: fix IImportBundle error text + 2022-03-25 ed5a15c go/internal/gcimporter: replace assert with more helpful panic + 2022-03-25 f4515dd go/packages: fix load with NeedTypes but not NeedImports + 2022-03-25 11930bd go/packages: fix handling of NeedExportFile in go list + 2022-03-25 e0095ae go/packages: fix precedence typo in needtypes calculation + 2022-03-25 e309672 go/packages: rename NeedExportsFile to NeedExportFile + 2022-03-25 54af36e internal/lsp: handle invalid URL args in command params + 2022-03-25 707beb0 internal/lsp/source: descend into fields and field lists in qualifyExpr + 2022-03-24 1e5ae83 internal/lsp/command: remove unnecessary json struct tag + 2022-03-24 b7db7eb internal/lsp/cmd: add vulncheck command + 2022-03-24 c62a3b3 gopls/internal/vulncheck: limit the included callstack count + 2022-03-24 78ff15e tools: fix some typos + 2022-03-24 f23240f gopls/go.mod: switch to golang.org/x/vuln/vulncheck + 2022-03-24 4adaded internal/lsp/source: handle empty strings in directoryFilters + 2022-03-24 2536df9 internal/lsp/source: include builtin name in hovered signature + 2022-03-24 cd31eaa internal/lsp/command: add RunVulncheckExp + 2022-03-24 4737f45 internal/lsp/command: add VulncheckArgs/Result types + 2022-03-24 84a0321 doc/generate.go: handle non-empty JSON tag correctly + 2022-03-24 4460e9b gopls/internal/vulncheck: copy x/vuln/cmd/govulncheck/cache.go + 2022-03-23 9fd677e gopls/internal/vulncheck: add cmd that runs govulncheck-like analysis + 2022-03-23 b169789 go/ssa: add position information for switch case conditions + 2022-03-23 9814b1b gopls: update settings link to code lenses + 2022-03-22 87a8611 x/tools/go/packages: add Embed support + 2022-03-22 1428e83 lsp/completion: fix bogus generic func conversion + 2022-03-22 cbdab03 lsp/completion: fix bogus type param candidate + 2022-03-22 3a6cbd6 lsp/completion: improve completion for func type params + 2022-03-21 c717623 go/analysis/passes/asmdecl: define register-ABI result registers for PPC64 + 2022-03-21 86b02b3 internal/lsp/cache: check for nil WorkFile.Go + 2022-03-18 5ea13d0 internal/lsp/source: move doc links to the bottom of hover + 2022-03-17 779dfa4 internal/lsp: invalidate package on go.mod change with go.work + 2022-03-17 c7b0e9a internal/lsp/template: fix processing of multi-line tokens + 2022-03-17 e998cd2 internal/lsp: remove unused code + 2022-03-17 877ec07 internal/lsp/cache: remove unused code + 2022-03-16 85d68bc internal/lsp: update LSP stubs, including provisional InlayHints + 2022-03-16 fb5dfde internal/imports: update stdlib index for 1.18 + 2022-03-16 d67eab4 go/types/objectpath: break cycles through type parameters in find + 2022-03-16 77aa08b internal/completion: default to regular completion for f.Fuzz without f.Add + 2022-03-15 6799a7a internal/lsp/source: canonicalize objects in reference/rename requests + 2022-03-15 54a569a internal/imports: use first quote when matching import path + 2022-03-14 40370f8 go/internal/gcimporter: add a test case for issue 51219 + 2022-03-14 24806f2 go/analysis: add tests check for calling *F methods in fuzz func + 2022-03-14 dff7c5f go/internal/gcimporter: guard against infinite recursion with recursive type parameters Change-Id: I14658ee3dbe4679d99f677880d0b75ae54830e43
2 parents 63bb270 + e342718 commit 99b205f

File tree

92 files changed

+2659
-583
lines changed

Some content is hidden

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

92 files changed

+2659
-583
lines changed

cmd/file2fuzz/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
//
1010
// file2fuzz [-o output] [input...]
1111
//
12-
// The defualt behavior is to read input from stdin and write the converted
12+
// The default behavior is to read input from stdin and write the converted
1313
// output to stdout. If any position arguments are provided stdin is ignored
1414
// and the arguments are assumed to be input files to convert.
1515
//

go/analysis/doc/suggested_fixes.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ Singlechecker and multichecker have the ```-fix``` flag, which will automaticall
9393
apply all fixes suggested by their analysis or analyses. This is intended to
9494
be used primarily by refactoring tools, because in general, like diagnostics,
9595
suggested fixes will need to be examined by a human who can decide whether
96-
they are relevent.
96+
they are relevant.
9797

9898
### gopls
9999

go/analysis/passes/asmdecl/asmdecl.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ var (
9090
asmArchMipsLE = asmArch{name: "mipsle", bigEndian: false, stack: "R29", lr: true}
9191
asmArchMips64 = asmArch{name: "mips64", bigEndian: true, stack: "R29", lr: true}
9292
asmArchMips64LE = asmArch{name: "mips64le", bigEndian: false, stack: "R29", lr: true}
93-
asmArchPpc64 = asmArch{name: "ppc64", bigEndian: true, stack: "R1", lr: true}
94-
asmArchPpc64LE = asmArch{name: "ppc64le", bigEndian: false, stack: "R1", lr: true}
93+
asmArchPpc64 = asmArch{name: "ppc64", bigEndian: true, stack: "R1", lr: true, retRegs: []string{"R3", "F1"}}
94+
asmArchPpc64LE = asmArch{name: "ppc64le", bigEndian: false, stack: "R1", lr: true, retRegs: []string{"R3", "F1"}}
9595
asmArchRISCV64 = asmArch{name: "riscv64", bigEndian: false, stack: "SP", lr: true}
9696
asmArchS390X = asmArch{name: "s390x", bigEndian: true, stack: "R15", lr: true}
9797
asmArchWasm = asmArch{name: "wasm", bigEndian: false, stack: "SP", lr: false}

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,3 +190,11 @@ TEXT ·returnnamed(SB),0,$0-41
190190

191191
TEXT ·returnintmissing(SB),0,$0-8
192192
RET // want `RET without writing to 8-byte ret\+0\(FP\)`
193+
194+
// writing to result in ABIInternal function
195+
TEXT ·returnABIInternal<ABIInternal>(SB), NOSPLIT, $8
196+
MOVD $123, R3
197+
RET
198+
TEXT ·returnmissingABIInternal<ABIInternal>(SB), NOSPLIT, $8
199+
MOVD $123, R10
200+
RET // want `RET without writing to result register`

go/analysis/passes/nilness/nilness.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ func eq(b *ssa.BasicBlock) (op *ssa.BinOp, tsucc, fsucc *ssa.BasicBlock) {
342342
// ChangeInterface, have transitive nilness, such that if you know the
343343
// underlying value is nil, you also know the value itself is nil, and vice
344344
// versa. This operation allows callers to match on any of the related values
345-
// in analyses, rather than just the one form of the value that happend to
345+
// in analyses, rather than just the one form of the value that happened to
346346
// appear in a comparison.
347347
//
348348
// This work must be in addition to unwrapping values within nilnessOf because

go/analysis/passes/nilness/testdata/src/a/a.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,3 +158,26 @@ func f9(x interface {
158158
func unknown() bool {
159159
return false
160160
}
161+
162+
func f10(a interface{}) {
163+
switch a.(type) {
164+
case nil:
165+
return
166+
}
167+
switch a.(type) {
168+
case nil: // want "impossible condition: non-nil == nil"
169+
return
170+
}
171+
}
172+
173+
func f11(a interface{}) {
174+
switch a {
175+
case nil:
176+
return
177+
}
178+
switch a {
179+
case 5,
180+
nil: // want "impossible condition: non-nil == nil"
181+
return
182+
}
183+
}

go/analysis/passes/structtag/testdata/src/a/a.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ type UnexpectedSpacetest struct {
124124
Q int `foo:" doesn't care "`
125125
}
126126

127-
// Nested fiels can be shadowed by fields further up. For example,
127+
// Nested fields can be shadowed by fields further up. For example,
128128
// ShadowingAnonJSON replaces the json:"a" field in AnonymousJSONField.
129129
// However, if the two conflicting fields appear at the same level like in
130130
// DuplicateWithAnotherPackage, we should error.

go/analysis/passes/tests/testdata/src/a/go118_test.go

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,17 @@ func FuzzFunc(f *testing.F) {
2020
}
2121

2222
func FuzzFuncWithArgs(f *testing.F) {
23-
f.Add() // want `wrong number of values in call to \(\*testing.F\)\.Add: 0, fuzz target expects 2`
24-
f.Add(1, 2, 3, 4) // want `wrong number of values in call to \(\*testing.F\)\.Add: 4, fuzz target expects 2`
25-
f.Add(5, 5) // want `mismatched type in call to \(\*testing.F\)\.Add: int, fuzz target expects \[\]byte`
26-
f.Add([]byte("hello"), 5) // want `mismatched types in call to \(\*testing.F\)\.Add: \[\[\]byte int\], fuzz target expects \[int \[\]byte\]`
27-
f.Add(5, []byte("hello")) // OK
28-
f.Fuzz(func(t *testing.T, i int, b []byte) {}) // OK "arguments in func are allowed"
23+
f.Add() // want `wrong number of values in call to \(\*testing.F\)\.Add: 0, fuzz target expects 2`
24+
f.Add(1, 2, 3, 4) // want `wrong number of values in call to \(\*testing.F\)\.Add: 4, fuzz target expects 2`
25+
f.Add(5, 5) // want `mismatched type in call to \(\*testing.F\)\.Add: int, fuzz target expects \[\]byte`
26+
f.Add([]byte("hello"), 5) // want `mismatched types in call to \(\*testing.F\)\.Add: \[\[\]byte int\], fuzz target expects \[int \[\]byte\]`
27+
f.Add(5, []byte("hello")) // OK
28+
f.Fuzz(func(t *testing.T, i int, b []byte) { // OK "arguments in func are allowed"
29+
f.Add(5, []byte("hello")) // want `fuzz target must not call any \*F methods`
30+
f.Name() // OK "calls to (*F).Failed and (*F).Name are allowed"
31+
f.Failed() // OK "calls to (*F).Failed and (*F).Name are allowed"
32+
f.Fuzz(func(t *testing.T) {}) // want `fuzz target must not call any \*F methods`
33+
})
2934
}
3035

3136
func FuzzArgFunc(f *testing.F) {

go/analysis/passes/tests/tests.go

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ func checkFuzz(pass *analysis.Pass, fn *ast.FuncDecl) {
9999
// 4. Second argument onwards should be of type []byte, string, bool, byte,
100100
// rune, float32, float64, int, int8, int16, int32, int64, uint, uint8, uint16,
101101
// uint32, uint64
102+
// 5. func() must not call any *F methods, e.g. (*F).Log, (*F).Error, (*F).Skip
103+
// The only *F methods that are allowed in the (*F).Fuzz function are (*F).Failed and (*F).Name.
102104
// Returns the list of parameters to the fuzz function, if they are valid fuzz parameters.
103105
func checkFuzzCall(pass *analysis.Pass, fn *ast.FuncDecl) (params *types.Tuple) {
104106
ast.Inspect(fn, func(n ast.Node) bool {
@@ -121,7 +123,7 @@ func checkFuzzCall(pass *analysis.Pass, fn *ast.FuncDecl) (params *types.Tuple)
121123
// Argument should be a function
122124
if !argOk {
123125
pass.ReportRangef(expr, "argument to Fuzz must be a function")
124-
return true
126+
return false
125127
}
126128
// ff Argument function should not return
127129
if tSign.Results().Len() != 0 {
@@ -130,12 +132,28 @@ func checkFuzzCall(pass *analysis.Pass, fn *ast.FuncDecl) (params *types.Tuple)
130132
// ff Argument function should have 1 or more argument
131133
if tSign.Params().Len() == 0 {
132134
pass.ReportRangef(expr, "fuzz target must have 1 or more argument")
133-
return true
135+
return false
134136
}
135137
ok := validateFuzzArgs(pass, tSign.Params(), expr)
136138
if ok && params == nil {
137139
params = tSign.Params()
138140
}
141+
// Inspect the function that was passed as an argument to make sure that
142+
// there are no calls to *F methods, except for Name and Failed.
143+
ast.Inspect(expr, func(n ast.Node) bool {
144+
if call, ok := n.(*ast.CallExpr); ok {
145+
if !isFuzzTargetDot(pass, call, "") {
146+
return true
147+
}
148+
if !isFuzzTargetDot(pass, call, "Name") && !isFuzzTargetDot(pass, call, "Failed") {
149+
pass.ReportRangef(call, "fuzz target must not call any *F methods")
150+
}
151+
}
152+
return true
153+
})
154+
// We do not need to look at any calls to f.Fuzz inside of a Fuzz call,
155+
// since they are not allowed.
156+
return false
139157
}
140158
return true
141159
})
@@ -202,7 +220,7 @@ func isFuzzTargetDot(pass *analysis.Pass, call *ast.CallExpr, name string) bool
202220
if !isTestingType(pass.TypesInfo.Types[selExpr.X].Type, "F") {
203221
return false
204222
}
205-
if selExpr.Sel.Name == name {
223+
if name == "" || selExpr.Sel.Name == name {
206224
return true
207225
}
208226
}

go/callgraph/vta/graph.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -640,7 +640,7 @@ func addReturnFlows(b *builder, r *ssa.Return, site ssa.Value) {
640640

641641
// addInFlowEdge adds s -> d to g if d is node that can have an inflow, i.e., a node
642642
// that represents an interface or an unresolved function value. Otherwise, there
643-
// is no interesting type flow so the edge is ommited.
643+
// is no interesting type flow so the edge is omitted.
644644
func (b *builder) addInFlowEdge(s, d node) {
645645
if hasInFlow(d) {
646646
b.graph.addEdge(b.representative(s), b.representative(d))

0 commit comments

Comments
 (0)