Skip to content

Commit e31f9e9

Browse files
committed
all: merge master (86c93e8) into gopls-release-branch.0.12
Also add back the x/tools replace directive. For golang/go#60563 Merge List: + 2023-06-01 86c93e8 gopls: unimported completion should use the completion matcher + 2023-06-01 04ceacb gopls/internal/lsp/source: fix panic in typeDefinition on comparable + 2023-06-01 947adca gopls/internal/lsp/source/methodsets: comparable also has no package + 2023-06-01 c35c44f gopls/internal/lsp/cache: add assertions + 2023-06-01 0b4461b internal/diff: fix LineEdits bug in slow path + 2023-06-01 1943c1e internal/diff: fix LineEdits bug in fast path + 2023-06-01 c6d86c4 go/pointer: delete package + 2023-06-01 77fd064 go/types/objectpath: remove unnecessary unsafe import + 2023-06-01 0dda7d6 go/pointer: remove replace directive + 2023-05-31 98f1b4d gopls/internal/lsp/cache: check number of orphaned files after filtering + 2023-05-31 a260315 go/pointer: create submodule + 2023-05-31 96844c3 cmd/{guru,callgraph}: stop using go/pointer + 2023-05-31 cd694d8 go/packages: include "unsafe".GoFiles=["unsafe.go"] + 2023-05-30 33c741d gopls/internal/lsp: add min/max builtin + 2023-05-30 933c7cc internal/lsp/source: use exact match in import highlighting + 2023-05-26 5974258 gopls/internal/lsp: clear vuln diagnostics on config changes + 2023-05-26 f3faea1 go/packages: pass -pgo=off on go1.21 and later + 2023-05-26 5f74ec7 internal/lsp/debug: add links to profiles and GC + 2023-05-25 ed90c6d internal/diff: unexport various identifiers + 2023-05-25 827f5aa gopls/internal/lsp/source: test references bug on struct{p.T} + 2023-05-24 a12e1a6 go/ssa/interp: implement min/max builtins Change-Id: I1987a4b6f6d3b2727976a7a8f5766921738eb7f7
2 parents 2368504 + 86c93e8 commit e31f9e9

File tree

132 files changed

+701
-13785
lines changed

Some content is hidden

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

132 files changed

+701
-13785
lines changed

cmd/callgraph/main.go

Lines changed: 6 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,12 @@ package main // import "golang.org/x/tools/cmd/callgraph"
2020
// callee file/line/col
2121

2222
import (
23-
"bufio"
2423
"bytes"
2524
"flag"
2625
"fmt"
2726
"go/build"
2827
"go/token"
2928
"io"
30-
"log"
3129
"os"
3230
"runtime"
3331
"text/template"
@@ -39,25 +37,21 @@ import (
3937
"golang.org/x/tools/go/callgraph/static"
4038
"golang.org/x/tools/go/callgraph/vta"
4139
"golang.org/x/tools/go/packages"
42-
"golang.org/x/tools/go/pointer"
4340
"golang.org/x/tools/go/ssa"
4441
"golang.org/x/tools/go/ssa/ssautil"
4542
)
4643

4744
// flags
4845
var (
4946
algoFlag = flag.String("algo", "rta",
50-
`Call graph construction algorithm (static, cha, rta, vta, pta)`)
47+
`Call graph construction algorithm (static, cha, rta, vta)`)
5148

5249
testFlag = flag.Bool("test", false,
5350
"Loads test code (*_test.go) for imported packages")
5451

5552
formatFlag = flag.String("format",
5653
"{{.Caller}}\t--{{.Dynamic}}-{{.Line}}:{{.Column}}-->\t{{.Callee}}",
5754
"A template expression specifying how to format an edge")
58-
59-
ptalogFlag = flag.String("ptalog", "",
60-
"Location of the points-to analysis log file, or empty to disable logging.")
6155
)
6256

6357
func init() {
@@ -68,7 +62,7 @@ const Usage = `callgraph: display the call graph of a Go program.
6862
6963
Usage:
7064
71-
callgraph [-algo=static|cha|rta|vta|pta] [-test] [-format=...] package...
65+
callgraph [-algo=static|cha|rta|vta] [-test] [-format=...] package...
7266
7367
Flags:
7468
@@ -78,11 +72,10 @@ Flags:
7872
cha Class Hierarchy Analysis
7973
rta Rapid Type Analysis
8074
vta Variable Type Analysis
81-
pta inclusion-based Points-To Analysis
8275
8376
The algorithms are ordered by increasing precision in their
8477
treatment of dynamic calls (and thus also computational cost).
85-
RTA and PTA require a whole program (main or test), and
78+
RTA requires a whole program (main or test), and
8679
include only functions reachable from main.
8780
8881
-test Include the package's tests in the analysis.
@@ -132,9 +125,9 @@ Examples:
132125
$GOROOT/src/net/http/triv.go | sort | uniq
133126
134127
Show functions that make dynamic calls into the 'fmt' test package,
135-
using the pointer analysis algorithm:
128+
using the Rapid Type Analysis algorithm:
136129
137-
callgraph -format='{{.Caller}} -{{.Dynamic}}-> {{.Callee}}' -test -algo=pta fmt |
130+
callgraph -format='{{.Caller}} -{{.Dynamic}}-> {{.Callee}}' -test -algo=rta fmt |
138131
sed -ne 's/-dynamic-/--/p' |
139132
sed -ne 's/-->.*fmt_test.*$//p' | sort | uniq
140133
@@ -205,39 +198,7 @@ func doCallgraph(dir, gopath, algo, format string, tests bool, args []string) er
205198
cg = cha.CallGraph(prog)
206199

207200
case "pta":
208-
// Set up points-to analysis log file.
209-
var ptalog io.Writer
210-
if *ptalogFlag != "" {
211-
if f, err := os.Create(*ptalogFlag); err != nil {
212-
log.Fatalf("Failed to create PTA log file: %s", err)
213-
} else {
214-
buf := bufio.NewWriter(f)
215-
ptalog = buf
216-
defer func() {
217-
if err := buf.Flush(); err != nil {
218-
log.Printf("flush: %s", err)
219-
}
220-
if err := f.Close(); err != nil {
221-
log.Printf("close: %s", err)
222-
}
223-
}()
224-
}
225-
}
226-
227-
mains, err := mainPackages(pkgs)
228-
if err != nil {
229-
return err
230-
}
231-
config := &pointer.Config{
232-
Mains: mains,
233-
BuildCallGraph: true,
234-
Log: ptalog,
235-
}
236-
ptares, err := pointer.Analyze(config)
237-
if err != nil {
238-
return err // internal error in pointer analysis
239-
}
240-
cg = ptares.CallGraph
201+
return fmt.Errorf("pointer analysis is no longer supported (see Go issue #59676)")
241202

242203
case "rta":
243204
mains, err := mainPackages(pkgs)

cmd/callgraph/main_test.go

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,6 @@ func TestCallgraph(t *testing.T) {
6565
"pkg.main --> pkg.main2",
6666
"pkg.main2 --> (pkg.D).f",
6767
}},
68-
{"pta", false, []string{
69-
// pta distinguishes main->C, main2->D. Also has a root node.
70-
`<root> --> pkg.init`,
71-
`<root> --> pkg.main`,
72-
`pkg.main --> (pkg.C).f`,
73-
`pkg.main --> pkg.main2`,
74-
`pkg.main2 --> (pkg.D).f`,
75-
}},
7668
// tests: both the package's main and the test's main are called.
7769
// The callgraph includes all the guts of the "testing" package.
7870
{"rta", true, []string{
@@ -87,14 +79,6 @@ func TestCallgraph(t *testing.T) {
8779
`pkg.Example --> (pkg.C).f`,
8880
`pkg.main --> (pkg.C).f`,
8981
}},
90-
{"pta", true, []string{
91-
`<root> --> pkg.test.main`,
92-
`<root> --> pkg.main`,
93-
`pkg.test.main --> testing.MainStart`,
94-
`testing.runExample --> pkg.Example`,
95-
`pkg.Example --> (pkg.C).f`,
96-
`pkg.main --> (pkg.C).f`,
97-
}},
9882
} {
9983
const format = "{{.Caller}} --> {{.Callee}}"
10084
stdout = new(bytes.Buffer)

0 commit comments

Comments
 (0)