Skip to content

Commit 960f0f4

Browse files
committed
x/tools: remove dead code
These unused functions and methods were discovered by a (work in progress) dead function analyzer. Change-Id: Iaa9c5fd4f06bdcd5d7c6e194bcc24d6b37df8f4c Reviewed-on: https://go-review.googlesource.com/c/tools/+/639675 Auto-Submit: Alan Donovan <[email protected]> Reviewed-by: Robert Findley <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]>
1 parent b0dc9b1 commit 960f0f4

File tree

17 files changed

+8
-122
lines changed

17 files changed

+8
-122
lines changed

cmd/splitdwarf/splitdwarf.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,7 @@ func CreateMmapFile(outDwarf string, size int64) (*os.File, []byte) {
358358
return dwarfFile, buffer
359359
}
360360

361+
// (dead code; retained for debugging)
361362
func describe(exem *macho.FileTOC) {
362363
note("Type = %s, Flags=0x%x", exem.Type, uint32(exem.Flags))
363364
for i, l := range exem.Loads {

cmd/ssadump/main.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -188,11 +188,6 @@ func doMain() error {
188188
// e.g. --flag=one --flag=two would produce []string{"one", "two"}.
189189
type stringListValue []string
190190

191-
func newStringListValue(val []string, p *[]string) *stringListValue {
192-
*p = val
193-
return (*stringListValue)(p)
194-
}
195-
196191
func (ss *stringListValue) Get() interface{} { return []string(*ss) }
197192

198193
func (ss *stringListValue) String() string { return fmt.Sprintf("%q", *ss) }

cmd/stringer/endtoend_test.go

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -93,20 +93,6 @@ func typeName(fname string) string {
9393
return fmt.Sprintf("%c%s", base[0]+'A'-'a', base[1:len(base)-len(".go")])
9494
}
9595

96-
func moreTests(t *testing.T, dirname, prefix string) []string {
97-
x, err := os.ReadDir(dirname)
98-
if err != nil {
99-
// error, but try the rest of the tests
100-
t.Errorf("can't read type param tess from %s: %v", dirname, err)
101-
return nil
102-
}
103-
names := make([]string, len(x))
104-
for i, f := range x {
105-
names[i] = prefix + "/" + f.Name()
106-
}
107-
return names
108-
}
109-
11096
// TestTags verifies that the -tags flag works as advertised.
11197
func TestTags(t *testing.T) {
11298
stringer := stringerPath(t)

container/intsets/sparse.go

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -287,14 +287,6 @@ func (s *Sparse) next(b *block) *block {
287287
return b.next
288288
}
289289

290-
// prev returns the previous block in the list, or end if b is the first block.
291-
func (s *Sparse) prev(b *block) *block {
292-
if b.prev == &s.root {
293-
return &none
294-
}
295-
return b.prev
296-
}
297-
298290
// IsEmpty reports whether the set s is empty.
299291
func (s *Sparse) IsEmpty() bool {
300292
return s.root.next == nil || s.root.offset == MaxInt
@@ -1077,6 +1069,7 @@ func (s *Sparse) AppendTo(slice []int) []int {
10771069
// -- Testing/debugging ------------------------------------------------
10781070

10791071
// check returns an error if the representation invariants of s are violated.
1072+
// (unused; retained for debugging)
10801073
func (s *Sparse) check() error {
10811074
s.init()
10821075
if s.root.empty() {

copyright/copyright.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
"strings"
1717
)
1818

19+
// (used only by tests)
1920
func checkCopyright(dir string) ([]string, error) {
2021
var files []string
2122
err := filepath.WalkDir(dir, func(path string, d fs.DirEntry, err error) error {

go/analysis/internal/analysisflags/flags.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -250,21 +250,12 @@ const (
250250
setFalse
251251
)
252252

253-
func triStateFlag(name string, value triState, usage string) *triState {
254-
flag.Var(&value, name, usage)
255-
return &value
256-
}
257-
258253
// triState implements flag.Value, flag.Getter, and flag.boolFlag.
259254
// They work like boolean flags: we can say vet -printf as well as vet -printf=true
260255
func (ts *triState) Get() interface{} {
261256
return *ts == setTrue
262257
}
263258

264-
func (ts triState) isTrue() bool {
265-
return ts == setTrue
266-
}
267-
268259
func (ts *triState) Set(value string) error {
269260
b, err := strconv.ParseBool(value)
270261
if err != nil {

go/expect/expect.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,3 @@ func MatchBefore(fset *token.FileSet, readFile ReadFile, end token.Pos, pattern
120120
}
121121
return f.Pos(startOffset + matchStart), f.Pos(startOffset + matchEnd), nil
122122
}
123-
124-
func lineEnd(f *token.File, line int) token.Pos {
125-
if line >= f.LineCount() {
126-
return token.Pos(f.Base() + f.Size())
127-
}
128-
return f.LineStart(line + 1)
129-
}

go/packages/gopackages/main.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -248,11 +248,6 @@ func (app *application) print(lpkg *packages.Package) {
248248
// e.g. --flag=one --flag=two would produce []string{"one", "two"}.
249249
type stringListValue []string
250250

251-
func newStringListValue(val []string, p *[]string) *stringListValue {
252-
*p = val
253-
return (*stringListValue)(p)
254-
}
255-
256251
func (ss *stringListValue) Get() interface{} { return []string(*ss) }
257252

258253
func (ss *stringListValue) String() string { return fmt.Sprintf("%q", *ss) }

go/packages/packages_test.go

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2999,30 +2999,6 @@ func constant(p *packages.Package, name string) *types.Const {
29992999
return c.(*types.Const)
30003000
}
30013001

3002-
func copyAll(srcPath, dstPath string) error {
3003-
return filepath.Walk(srcPath, func(path string, info os.FileInfo, _ error) error {
3004-
if info.IsDir() {
3005-
return nil
3006-
}
3007-
contents, err := os.ReadFile(path)
3008-
if err != nil {
3009-
return err
3010-
}
3011-
rel, err := filepath.Rel(srcPath, path)
3012-
if err != nil {
3013-
return err
3014-
}
3015-
dstFilePath := strings.Replace(filepath.Join(dstPath, rel), "definitelynot_go.mod", "go.mod", -1)
3016-
if err := os.MkdirAll(filepath.Dir(dstFilePath), 0755); err != nil {
3017-
return err
3018-
}
3019-
if err := os.WriteFile(dstFilePath, contents, 0644); err != nil {
3020-
return err
3021-
}
3022-
return nil
3023-
})
3024-
}
3025-
30263002
func TestExportFile(t *testing.T) {
30273003
// This used to trigger the log.Fatal in loadFromExportData.
30283004
// See go.dev/issue/45584.

go/ssa/dom.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,7 @@ func printDomTreeText(buf *bytes.Buffer, v *BasicBlock, indent int) {
318318

319319
// printDomTreeDot prints the dominator tree of f in AT&T GraphViz
320320
// (.dot) format.
321+
// (unused; retained for debugging)
321322
func printDomTreeDot(buf *bytes.Buffer, f *Function) {
322323
fmt.Fprintln(buf, "//", f)
323324
fmt.Fprintln(buf, "digraph domtree {")

0 commit comments

Comments
 (0)