From c06a699fb69e17274905bc8d9942de4a4ab8b31b Mon Sep 17 00:00:00 2001 From: Cuong Manh Le Date: Fri, 16 Oct 2020 22:39:51 +0700 Subject: cmd/compile: remove deltaNewFile CL 196963 removed last usages of deltaNewFile, this CL remove it. While at it, move the comment to go/internal/gcimporter. Change-Id: Ieea47db405cf43744689f50b79be8ca710e21c85 Reviewed-on: https://go-review.googlesource.com/c/go/+/263077 Trust: Cuong Manh Le Run-TryBot: Cuong Manh Le TryBot-Result: Go Bot Reviewed-by: Matthew Dempsky --- src/go/internal/gcimporter/support.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/go/internal') diff --git a/src/go/internal/gcimporter/support.go b/src/go/internal/gcimporter/support.go index 2de7cacd2d..b8bb14dc49 100644 --- a/src/go/internal/gcimporter/support.go +++ b/src/go/internal/gcimporter/support.go @@ -17,7 +17,10 @@ func errorf(format string, args ...interface{}) { panic(fmt.Sprintf(format, args...)) } -const deltaNewFile = -64 // see cmd/compile/internal/gc/bexport.go +// deltaNewFile is a magic line delta offset indicating a new file. +// We use -64 because it is rare; see issue 20080 and CL 41619. +// -64 is the smallest int that fits in a single byte as a varint. +const deltaNewFile = -64 // Synthesize a token.Pos type fakeFileSet struct { -- cgit v1.2.1 From 1b09d430678d4a6f73b2443463d11f75851aba8a Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Fri, 16 Oct 2020 00:49:02 -0400 Subject: all: update references to symbols moved from io/ioutil to io The old ioutil references are still valid, but update our code to reflect best practices and get used to the new locations. Code compiled with the bootstrap toolchain (cmd/asm, cmd/dist, cmd/compile, debug/elf) must remain Go 1.4-compatible and is excluded. Also excluded vendored code. For #41190. Change-Id: I6d86f2bf7bc37a9d904b6cee3fe0c7af6d94d5b1 Reviewed-on: https://go-review.googlesource.com/c/go/+/263142 Trust: Russ Cox Run-TryBot: Russ Cox TryBot-Result: Go Bot Reviewed-by: Emmanuel Odeke --- src/go/internal/gccgoimporter/importer.go | 2 +- src/go/internal/gcimporter/gcimporter.go | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) (limited to 'src/go/internal') diff --git a/src/go/internal/gccgoimporter/importer.go b/src/go/internal/gccgoimporter/importer.go index 2494fd7b2a..94f2defd8d 100644 --- a/src/go/internal/gccgoimporter/importer.go +++ b/src/go/internal/gccgoimporter/importer.go @@ -221,7 +221,7 @@ func GetImporter(searchpaths []string, initmap map[*types.Package]InitData) Impo // Excluded for now: Standard gccgo doesn't support this import format currently. // case goimporterMagic: // var data []byte - // data, err = ioutil.ReadAll(reader) + // data, err = io.ReadAll(reader) // if err != nil { // return // } diff --git a/src/go/internal/gcimporter/gcimporter.go b/src/go/internal/gcimporter/gcimporter.go index fda15eaaae..b74daca246 100644 --- a/src/go/internal/gcimporter/gcimporter.go +++ b/src/go/internal/gcimporter/gcimporter.go @@ -12,7 +12,6 @@ import ( "go/token" "go/types" "io" - "io/ioutil" "os" "path/filepath" "strings" @@ -147,7 +146,7 @@ func Import(fset *token.FileSet, packages map[string]*types.Package, path, srcDi case "$$B\n": var data []byte - data, err = ioutil.ReadAll(buf) + data, err = io.ReadAll(buf) if err != nil { break } -- cgit v1.2.1 From 9fcb5e0c527337c830e95d48d4574930cac53093 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Tue, 27 Oct 2020 12:59:54 -0700 Subject: go/internal/gccgoimporter: support notinheap annotation The gofrontend has started emitting a notinheap annotation for types marked go:notinheap. For #41761 Change-Id: Ic8f7ffc32dbfe98ec09b3d835957f1be8e6c1208 Reviewed-on: https://go-review.googlesource.com/c/go/+/265702 Trust: Ian Lance Taylor Run-TryBot: Ian Lance Taylor TryBot-Result: Go Bot Reviewed-by: Than McIntosh --- src/go/internal/gccgoimporter/importer_test.go | 1 + src/go/internal/gccgoimporter/parser.go | 7 +++++++ src/go/internal/gccgoimporter/testdata/notinheap.go | 4 ++++ src/go/internal/gccgoimporter/testdata/notinheap.gox | 7 +++++++ 4 files changed, 19 insertions(+) create mode 100644 src/go/internal/gccgoimporter/testdata/notinheap.go create mode 100644 src/go/internal/gccgoimporter/testdata/notinheap.gox (limited to 'src/go/internal') diff --git a/src/go/internal/gccgoimporter/importer_test.go b/src/go/internal/gccgoimporter/importer_test.go index a74a456868..e4236a5867 100644 --- a/src/go/internal/gccgoimporter/importer_test.go +++ b/src/go/internal/gccgoimporter/importer_test.go @@ -97,6 +97,7 @@ var importerTests = [...]importerTest{ {pkgpath: "issue30628", name: "Apple", want: "type Apple struct{hey sync.RWMutex; x int; RQ [517]struct{Count uintptr; NumBytes uintptr; Last uintptr}}"}, {pkgpath: "issue31540", name: "S", gccgoVersion: 7, want: "type S struct{b int; map[Y]Z}"}, {pkgpath: "issue34182", name: "T1", want: "type T1 struct{f *T2}"}, + {pkgpath: "notinheap", name: "S", want: "type S struct{}"}, } func TestGoxImporter(t *testing.T) { diff --git a/src/go/internal/gccgoimporter/parser.go b/src/go/internal/gccgoimporter/parser.go index e2ef33f7ae..1b1d07d3f6 100644 --- a/src/go/internal/gccgoimporter/parser.go +++ b/src/go/internal/gccgoimporter/parser.go @@ -517,6 +517,13 @@ func (p *parser) parseNamedType(nlist []interface{}) types.Type { p.errorf("%v has nil type", obj) } + if p.tok == scanner.Ident && p.lit == "notinheap" { + p.next() + // The go/types package has no way of recording that + // this type is marked notinheap. Presumably no user + // of this package actually cares. + } + // type alias if p.tok == '=' { p.next() diff --git a/src/go/internal/gccgoimporter/testdata/notinheap.go b/src/go/internal/gccgoimporter/testdata/notinheap.go new file mode 100644 index 0000000000..b1ac967227 --- /dev/null +++ b/src/go/internal/gccgoimporter/testdata/notinheap.go @@ -0,0 +1,4 @@ +package notinheap + +//go:notinheap +type S struct{} diff --git a/src/go/internal/gccgoimporter/testdata/notinheap.gox b/src/go/internal/gccgoimporter/testdata/notinheap.gox new file mode 100644 index 0000000000..cc438e75e0 --- /dev/null +++ b/src/go/internal/gccgoimporter/testdata/notinheap.gox @@ -0,0 +1,7 @@ +v3; +package notinheap +pkgpath notinheap +init notinheap ~notinheap +types 3 2 30 18 +type 1 "S" notinheap +type 2 struct { } -- cgit v1.2.1