Commit Graph

891 Commits

Author SHA1 Message Date
Ian Cottrell 475b7a1e12 go/packages: fix the gopackages command
It got broken when we renamed all the modes, and because it is just an
example binary it is not testsed.

Change-Id: Ia6608af574d0abebb4fe0d967e1bed88af6563bd
Reviewed-on: https://go-review.googlesource.com/125937
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
2018-07-25 23:55:34 +00:00
Ian Cottrell b1e4acd68a go/packages: alter the internal api to go list
This separates the go list specific behavior from the generalised go/packages
loading behaviour, to enable alternate build system back ends.

Change-Id: I07e7649f8f2afc7470a3ee3d0d743cbbcc6f713e
Reviewed-on: https://go-review.googlesource.com/125715
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
2018-07-25 20:44:53 +00:00
Ian Cottrell 14e571052b go/packages: fix internal go list function signatures
After a discussion in cl/125535 this is a proposal to clean up some
internal function signatures that were becomming unwieldy.

Change-Id: I37a9e525ab18dface9ea9fb0b0ec68ac942ee632
Reviewed-on: https://go-review.googlesource.com/125659
Reviewed-by: Michael Matloob <matloob@golang.org>
2018-07-25 19:03:22 +00:00
Michael Matloob 526516e9c4 go/packages: support pre go1.10.4 using go/loader
If go list fails because it doesn't support the new flags added
for Go 1.11 (which will be also released in Go 1.10.4) try again
using the Loader to approximate the packages requested.

This implementation is incomplete. It will never support test packages
because of the two phase test loading process of the Loader. It
also doesn't reliably have access to export data so it will
always do an upgraded whole-program query. But we'll try to get
the best level of support we can for the go/packages interface
given the limitations of the loader.

Once Go 1.12 is released, we'll delete this support. By then, most
Go users should have at least switched to Go 1.10.4.

Change-Id: I5248e20980032695a86b052caa9ff368ecf7b142
Reviewed-on: https://go-review.googlesource.com/125616
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2018-07-25 00:20:46 +00:00
Ian Cottrell 214274eeeb go/packages: changes to the API per CL 125305
Collapse the main entry points to the single Load function.
Make public the Mode enumeration in the Config.
Add a lowest level mode that does not do the import graph.
Remove PkgPath.
Remove the DisableCgo option.
Rename some fields of Package:
  Srcs -> GoFiles
  OtherSrcs -> OtherFiles
  Type -> Types
  Files -> Syntax
  Info -> TypesInfo
delete the All function

Change-Id: I54e5dc3ca5cb0b7e33fe6aa6f70cc66e18ea8cac
Reviewed-on: https://go-review.googlesource.com/125535
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
2018-07-25 00:10:29 +00:00
Ian Cottrell ded554d068 go/packages: splitting the scratch fields out of Package
This makes Package a struct we can re-use in other places/algorithms.

Change-Id: I2e095a624bf44223319ba1ea3d60deb727b38f81
Reviewed-on: https://go-review.googlesource.com/124855
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
2018-07-23 20:42:46 +00:00
Russ Cox 96ee42108a go/packages: revise documentation
I made a pass through the documentation trying to simplify
and make it more accessible to readers who are unfamiliar
with all the ins and outs of the implementation.

I also added TODOs about things I don't understand
and names that we should think about changing.

Change-Id: I633316bd407f3360eb8a683bc8d85fba93ca381e
Reviewed-on: https://go-review.googlesource.com/125305
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
2018-07-23 18:30:23 +00:00
Michael Matloob 54f9f5980a go/packages: remove Package.IsTest field
We have not yet settled on the meaning of Package.IsTest, and more
deeply which packages are test and which are non test packages.

This change will remove Package.IsTest in the meantime to avoid
confusion. We may later add a boolean or some other way to distinguish
test and non-test packages.

Change-Id: If6b128f7914009fdd42b8bc3de3bff73c8f006cd
Reviewed-on: https://go-review.googlesource.com/124388
Reviewed-by: Russ Cox <rsc@golang.org>
2018-07-19 17:37:31 +00:00
Michael Matloob d74aaa1f57 go/packages: Options.{Dir,Env} pass-through
This change adds optional Dir string and Env []string options
that are passed through to the build system's metadata query.
As with exec.Cmd, the defaults are inherited from the parent
process.

Options.GOPATH is gone. If the client needs to override
GOPATH, they must use Env, but typically the inherited environment
is correct.

The tests not longer use os.Chdir.

We now guarantee that Package.Srcs are absolute file names.

Added test for Options.Dir and relative patterns.

This is a copy of golang.org/cl/123777, which had a merge conflict.

Change-Id: I301724581f3d8c712ea78fa5ab5cabd909940dca
Reviewed-on: https://go-review.googlesource.com/123777
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
2018-07-17 15:06:01 +00:00
Brad Fitzpatrick fd2d2c45eb go/packages: fix/skip some tests making build.golang.org red
Updates golang/go#26387

Change-Id: I5d91f3747b4f17186813d830f24aa510f5cf0060
Reviewed-on: https://go-review.googlesource.com/123957
Reviewed-by: Alan Donovan <adonovan@google.com>
2018-07-14 20:55:45 +00:00
Alan Donovan 18e9dfbf20 go/packages: add Option.Tests bool, which affects pattern expansion
In the go build system, test packages and executables do not have a
name distinct from the package under test; they are implied, so
"go test fmt" means build those packages but "go build fmt" does not.

This change adds a Tests boolean option to indicate that implied
tests are desired during pattern expansion.
It has no effect on build systems that have explicit names
for tests, such as Blaze/Bazel.

The gopackages diagnostic tool now has a -test flag.

Change-Id: I424f343958c4286539e518d5f30067da19a57f3b
Reviewed-on: https://go-review.googlesource.com/123775
Reviewed-by: Michael Matloob <matloob@golang.org>
2018-07-13 17:38:36 +00:00
Alan Donovan 9d3ae49c73 go/packages: report a distinguished ErrGoTooOld error for older go commands
We should add support for older go commands using the multiple-calls
approach of earlier drafts of go/packages.

Also, tag tests for go1.11 to make 1.10 builder happy.

Change-Id: Ia04979528af25cbcd4b4fa5b21cb91d014d530c1
Reviewed-on: https://go-review.googlesource.com/123756
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-07-13 17:38:21 +00:00
Alan Donovan 2087f8c107 go/packages: remove POSIX filename assumption from test
Change-Id: If1aac9f109b05897b21a2f27a4050fbee2cc2d2e
Reviewed-on: https://go-review.googlesource.com/123357
Run-TryBot: Alan Donovan <adonovan@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
2018-07-11 20:34:38 +00:00
Alan Donovan 9622293277 go/packages: a new Go package loader for go, vgo and other build systems
This package defines a new API for applications that need information
about Go packages, such as their source files, tests, dependencies,
and (optionally) typed syntax trees. It is intended to replace both
go/build and golang.org/x/tools/go/loader with an API that is simpler
yet supports a range of build systems including 'go build', vgo,
Bazel, and Blaze.

This CL contains the API, the "go list"-based implementation, and some
basic tests. More tests, more features as described in doc.go, and
implementations for bazel and blaze will follow.

Read doc.go for orientation and a list of open questions.

Change-Id: Ib39f15b5e4e2f854553e7185fec5cf135641ffb0
Reviewed-on: https://go-review.googlesource.com/116359
Run-TryBot: Alan Donovan <adonovan@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
2018-07-11 20:11:18 +00:00
LE Manh Cuong 8cb83b71b4 imports: fix lost line between package and import statement
Fixes golang/go#26290

Change-Id: Ide797a46bf1d0d6070940fb5b9db3e76502bc528
Reviewed-on: https://go-review.googlesource.com/122736
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-07-10 02:38:27 +00:00
Alan Donovan 16699b2d33 go/gcexportdata: add -package flag to diagnostic tool
...to show information about indirectly mentioned packages.

Change-Id: Ib74b56493861bf41d9720760e76ace186efae2ea
Reviewed-on: https://go-review.googlesource.com/121195
Reviewed-by: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-06-27 17:17:06 +00:00
Robert Griesemer 56e9b8e653 go/internal/gcimporter,gccgoimporter: use types.NewInterfaceType
https://go-review.googlesource.com/c/go/+/120875 changed the name
of types.NewInterface2 to NewInterfaceType. Adjust x/tools code to
match new API.

For golang/go#25301.

Change-Id: I21e13566f7c88591a16ce461cb4cce8901980b05
Reviewed-on: https://go-review.googlesource.com/120895
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-06-26 17:42:40 +00:00
Austin Clements 25b95b4822 go/ssa: fix some incorrect comments
Change-Id: I8aa4780e0fa4a182678f1d34b247ab203e906144
Reviewed-on: https://go-review.googlesource.com/119915
Reviewed-by: Alan Donovan <adonovan@google.com>
2018-06-20 14:00:53 +00:00
David Symonds fcb3cb6c24 go/vcs: match go-import package prefixes by slash
This is related to golang/go#15947.

This ports https://golang.org/cl/23732 (June 2016)
from cmd/go to this repository.

Change-Id: I9960556bd19775b433d4eecc0ecca3f09ce1368b
Reviewed-on: https://go-review.googlesource.com/119935
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-06-20 03:09:55 +00:00
Robert Griesemer c995a08888 go/internal/gcimporter: move 1.11 specific tests out of non-1.11 builds (fix build)
TBR=adonovan

The tests TestImportedTypes and TestIssue25301 are dependent on many
1.11-specific bug fixes that went into go/types. Just move them out
of non-1.11 builds.

While doing so, also extended the set of test cases run by
TestImportedTypes (now matching the corresponding tests cases
in the std lib).

This also makes it again unnecessary to factor out the embeddedType
function into build-specific versions. Removed again.

For https://github.com/golang/lint/issues/402.

Change-Id: I45eb8c3d1dcca7b392f14a7660bc1599a44a0d41
Reviewed-on: https://go-review.googlesource.com/118567
Reviewed-by: Robert Griesemer <gri@golang.org>
2018-06-13 19:12:07 +00:00
Robert Griesemer e580e344d4 go/internal/gcimporter: don't use Interface.EmbeddedType for builds before go1.11
For https://github.com/golang/lint/issues/402.

Change-Id: I3f4eab123e52460980e76f5ffaca3a77a3af7374
Reviewed-on: https://go-review.googlesource.com/118565
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2018-06-13 18:37:28 +00:00
Robert Griesemer 6f857df7d4 go/internal/gccgoimporter: use types.NewInterface (not NewInterface2) for builds before Go 1.11
For https://github.com/golang/lint/issues/402.

Change-Id: I06d944aaa168fb595ff96eb27a7d6e7da344ebd6
Reviewed-on: https://go-review.googlesource.com/118564
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Andrew Bonventre <andybons@golang.org>
2018-06-13 18:13:43 +00:00
Robert Griesemer 9d855108b0 go/internal/gcimporter: missed a NewInterface2 call in prior CL
For https://github.com/golang/lint/issues/402.

Change-Id: Ideaac18b4f0be1674bb07010840b3d10e6ebe9d6
Reviewed-on: https://go-review.googlesource.com/118639
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Andrew Bonventre <andybons@golang.org>
2018-06-13 18:12:16 +00:00
Robert Griesemer 58c6d92c35 go/internal/gcimporter: use types.NewInterface (not NewInterface2) for builds before Go 1.11
For https://github.com/golang/lint/issues/402.

Change-Id: If8802c93679af57bcb50c43f386f37458813d910
Reviewed-on: https://go-review.googlesource.com/118563
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-06-13 17:48:59 +00:00
Robert Griesemer 9a70f1fcbf go/internal/gcimporter, gccgoimporter: updated to match latest version in std lib
This CL brings over the changes from:

https://go-review.googlesource.com/118496 (better error message when importer is out of date)
https://go-review.googlesource.com/114317 (permit embedding of non-defined interfaces via alias type names)
https://go-review.googlesource.com/85318  (use named receiver types for methods of named interfaces)
https://go-review.googlesource.com/42870  (report import path if package is not found)
https://go-review.googlesource.com/41710  (version tests for 1.8, v4 and v5)

Also updated go/gcexportdata to select between binary and new indexed export format.

For golang/go#25856.
For golang/go#25301.
For golang/go#20230.
For golang/go#13829.

Change-Id: Ibf77c50f86e767cef411bd1d3809e12397678958
Reviewed-on: https://go-review.googlesource.com/118555
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
2018-06-13 15:25:57 +00:00
Ian Lance Taylor c65208ee29 go/...: make most tests pass with gccgo
There is one non-test change: have FakeContext change the compiler to
"gc", as callers expect to be accessing a gc-style GOROOT.

The go/pointer, go/ssa, and go/ssa/interp tests still fail with gccgo.

Change-Id: I850c9618401f6b9e63d7ca7196f91931b03f1524
Reviewed-on: https://go-review.googlesource.com/117395
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-06-08 16:58:49 +00:00
Andrew Gerrand 28aef64757 go/internal/gcimporter: return error from BExportData
This change adds an error return value to BExportData and replaces the
various calls to log.Fatal within that library with panics that
propagate the internal error up the call stack to BExportData which
recovers and returns the error.

Fixes golang/go#25431

Change-Id: Id628c63a04145bb469bd6fbc7fbab1b0fa291b2c
Reviewed-on: https://go-review.googlesource.com/113457
Reviewed-by: David Symonds <dsymonds@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-05-17 02:09:35 +00:00
Rebecca Stambler 6e0e2181b9 go/internal/gcimporter: support indexed export data
Support indexed export data in the x/tools gcimporter. Fixes tests with
tip.

This is just a copy of the bimport.go and iimport.go files in the
standard library gcimporter package, including some minor fixes to the
existing bimport.go. The iexport logic in x/tools still needs to be
updated.

Fixes golang/go#25052

Change-Id: I2858e5c0853735c904f32b7b27c1c288a9e62e88
Reviewed-on: https://go-review.googlesource.com/109595
Reviewed-by: Alan Donovan <adonovan@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2018-04-26 19:07:32 +00:00
Tobias Klauser ccd319aab1 go/ssa/interp: add internal/syscall/unix.syscall_fcntl to fix tests
CL 100077 added the syscall_fcntl function in the internal/syscall/unix
package to refer to syscall.fcntl outside of the syscall package in a
unified way.

Add a replacement that simulates a successful fcntl call to fix the
interp tests.

Change-Id: I05847d222f18a19cb30f1395497e708a027a002e
Reviewed-on: https://go-review.googlesource.com/106415
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-04-11 19:48:31 +00:00
Matthew Dempsky 5dfd8930f2 go/internal/gcimporter: rename from go/gcimporter15
Follow through on promise to remove the old API.

Change-Id: If1f5addfeb1b82acc5a1730474e2f06102dbb615
Reviewed-on: https://go-review.googlesource.com/105977
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
2018-04-10 13:03:03 +00:00
Matthew Dempsky 14d5b80f95 go/gcimporter15: support bimport format v6
Format change introduced by golang.org/cl/105038.

Change-Id: I76eefe9ce7f52743cb5cdcfe77e5ee0b5eb8743f
Reviewed-on: https://go-review.googlesource.com/105976
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-04-09 23:44:46 +00:00
Dmitri Shuralyov 9f6d4ad827 go/buildutil: use build.Import to find GOPATH containing x/tools
Previously, the test assumed that golang.org/x/tools was always in the
first GOPATH workspace. It may not be. Find it dynamically instead.

Fixes golang/go#19400.

Change-Id: I9c75d5ff1409aebd403d7ad4314b496fe1a04140
Reviewed-on: https://go-review.googlesource.com/94900
Run-TryBot: Dmitri Shuralyov <dmitri@shuralyov.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
2018-03-05 17:28:52 +00:00
Dmitri Shuralyov e8fdd2090a go/vcs: fix command injection in VCS path
Apply same change as CL 94656 did for cmd/go/internal/get, but for
golang.org/x/tools/go/vcs, to help keep them in sync.

It indirectly includes changes from CL 94603, since CL 94656 was
rebased on top of CL 94603.

Updates golang/go#23867.
Helps golang/go#11490.

Change-Id: I33eca1aba19f47bbe3e83d4ef9f9cc9a9c9ae975
Reviewed-on: https://go-review.googlesource.com/94899
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-02-21 04:00:24 +00:00
Alan Donovan 2c62430689 go/callgraph/cha: fix bug computing correspondence of abstract/concrete methods
In a dynamic interface method call x.f() where x has type I, it is not sound
to assume that the receiver of the types.Signature for types.Func f has type I, as
Func objects for abstract methods may be shared by multiple interfaces.

Fixes golang/go#23925

Change-Id: I755e3010d1310480c46855e072946346626b3e59
Reviewed-on: https://go-review.googlesource.com/95697
Reviewed-by: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-02-21 01:23:17 +00:00
Dmitri Shuralyov a4ae709237 go/vcs: add package comment
According to https://golang.org/doc/effective_go.html#commentary,
"Every package should have a package comment."

Updates golang/go#11490.

GitHub-Last-Rev: 8dd80d0f1cbd94ab14dbfdbf0199ca199f33e1fd
GitHub-Pull-Request: golang/tools#22
Change-Id: Ia3af83cc68bcde12c37492ad240031aecf6934a3
Reviewed-on: https://go-review.googlesource.com/93081
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-02-14 20:11:16 +00:00
Daniel Martí 90b807ada4 all: fix a few issues found by unparam
In cmd/present, a mode was being passed to the function parse, but it
wasn't actually being used. Use it.

In go/ssa, checkFinalInstr received an idx integer but it doesn't
actually need it. Get rid of it.

Lastly, in imports, findImportStdlib always returned rename==false. Get
rid of that result parameter.

Change-Id: I719006b69ee80a3ef4b0ea24c1c206016a7e304b
Reviewed-on: https://go-review.googlesource.com/93596
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-02-13 22:52:51 +00:00
Alan Donovan a5d79d28aa go/...: fix/disable broken tests
gp/ssa: add {Start,Stop}TestLog methods to synthesized test main package.

go/ssa/interp: add (not thread-safe) intrinsics for atomic.Value,
which are now used by Getenv.

go/pointer: disable test of callbacks from runtime timers
as the analysis's intrinsics are out of date.  Also fix 3 typos.

Change-Id: I25f95ba18986727275a730b465e7fd23c08b2af2
Reviewed-on: https://go-review.googlesource.com/88055
Reviewed-by: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-01-17 18:00:52 +00:00
Robert Griesemer fbec762f83 go/internal/gccgoimporter: parse optional escape info in export data
This is a copy of https://go-review.googlesource.com/c/go/+/86977
and brings those changes into the x/tools repo.

It also includes a minor change to parser.go that was done via
https://go-review.googlesource.com/37839 but that wasn't brought
over.

For golang/go#23324.

Change-Id: I84b7cf134fec250ac340e404802158860cb3c630
Reviewed-on: https://go-review.googlesource.com/87295
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2018-01-11 04:04:09 +00:00
Brad Fitzpatrick ef037a11d2 go/ssa/interp: skip tests on darwin until crashes are fixed
Updates golang/go#23166

Change-Id: Ie9db70d6f2f8d90817ec3de35e6ca51ec476f949
Reviewed-on: https://go-review.googlesource.com/85995
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-01-03 17:43:40 +00:00
Michael Hudson-Doyle 894cde2672 go/ssa/interp: add intrinsic for math.hasVectorFaciliy to fix tests on s390x
Change-Id: I482924585d2d74a25bf88169900a8788b5333738
Reviewed-on: https://go-review.googlesource.com/85235
Reviewed-by: Michael Munday <mike.munday@ibm.com>
Run-TryBot: Michael Munday <mike.munday@ibm.com>
2018-01-02 20:34:48 +00:00
Kashav Madan f271d7a0f8 go/pointer: fix typo ("distiction" -> "distinction")
Change-Id: I88334b30b08e110b837c255220385c9c4cd4a823
Reviewed-on: https://go-review.googlesource.com/85576
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
2017-12-28 08:16:41 +00:00
Robert Griesemer 04447353bc go/ssa: complete interface types for correct string form (fix build)
Fixes golang/go#22933.

Change-Id: I0cf0aab8b77114ee7eb1e181aee2c5b75087aa83
Reviewed-on: https://go-review.googlesource.com/80897
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
2017-11-30 18:55:14 +00:00
Alan Donovan 2c687adedb go/ssa/interp: drop interpretation of "testing" package
The "testing" package depends on low-level details that change too often.

Change-Id: I59101e16588296cb40c851d4a34ddf199f4d176c
Reviewed-on: https://go-review.googlesource.com/80376
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-11-28 21:57:06 +00:00
Alan Donovan 0e42b0fe40 go/ssa/interp: add fake runtime.callerName to fix broken tests
We are inching towards the point at which I blow away this entire
package, or at least all tests that interpret the standard "testing"
package.

Change-Id: I06d99aac6d7baab14ee6c6a61afe0af34b814767
Reviewed-on: https://go-review.googlesource.com/80356
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-11-28 20:52:38 +00:00
Robert Griesemer 6d70fb2e85 go/ast/astutil: add Apply, for rewriting Go ASTs
This change implements an AST walker, Apply, with the capability
to perform various actions (including rewrites) during the AST
walk, in pre- and post-iteration order.

Ideally we would like to have this functionality in the std lib
(go/ast), but as this change contains significant new API, it
is better to first gain some experience with it in x/tools.

Credits: This is joint work of Josh Bleecher Snyder, Roger
Peppe, and myself (author of this CL). The code is based on
proposal golang/go#17108 which I had started, together with an
initial implementation. It was then reworked significantly by
Josh in golang.org/cl/55790, further refined by suggestions
from Roger (allocation reduction), and finally cleaned up a bit
by me (AST simplifications).

Fixes golang/go#17108.

Change-Id: I56d56b7f2bc5be2acfeb927f76aea7f264bb7b94
Reviewed-on: https://go-review.googlesource.com/77811
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
2017-11-16 01:30:56 +00:00
Dmitri Shuralyov ebae2dcdba go/vcs: reject update of VCS inside VCS
Manually apply same change as CL 68110 did for cmd/go/internal/get,
but for golang.org/x/tools/go/vcs, to help keep them in sync.

Updates golang/go#22125.
Helps golang/go#11490.

Change-Id: I255f7a494d9572389fc8dc8ce96891b6fcc214a0
Reviewed-on: https://go-review.googlesource.com/68352
Reviewed-by: Russ Cox <rsc@golang.org>
2017-10-05 08:21:07 +00:00
haya14busa 84a35ef54d go/ast/astutil: new third-party imports shouldn't go in the std group
Before this change, astutil would only do a prefix match of a new import
with all the existing ones, to try to place it in the correct group. If
none was found, the new import would be placed at the beginning of the
first import group.

This works well for new std imports, but it doesn't work well for new
third-party packages that don't share any prefix with any of the
existing imports.

Example:

	import (
		"time"

		"github.com/golang/snappy"
	)

When adding "golang.org/x/sys/unix" with astutil.AddImport, the import
is inserted as follows:

	import (
		"golang.org/x/sys/unix"
		"time"

		"github.com/golang/snappy"
	)

And goimports reorganizes the imports to separate std and third-party
packages:

	import (
		"time"

		"golang.org/x/sys/unix"

		"github.com/golang/snappy"
	)

We usually don't want to introduce a new import group; in most cases,
the desired behavior is separating std from third-party packages.

With this CL, new imports that don't share prefix with any existing ones
will be placed with the first group of third-party imports, if any
exist. If no third-party import group exists, a new one will be added.
In the case of our example above, this will be the new outcome:

	import (
		"time"

		"github.com/golang/snappy"
		"golang.org/x/sys/unix"
	)

Fixes golang/go#19190.

Change-Id: Id4630015c029bd815234a6c8726cb97f4af16f1c
Reviewed-on: https://go-review.googlesource.com/37552
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2017-08-15 00:39:00 +00:00
Kirill Smelkov c2d03f470b go/loader: Fix thinko in FindPackage hook signature
(*build.Context).Import has signature of

	(ctx, importPath, fromDir, mode)

not

	(ctx, fromDir, importPath, mode)

and the loader actually uses the first version.

The thinko was introduced in d6e83e53 (go/loader: changes for vendor
support; CL 18053) and was possible because importPath and fromDir both
have the same type string.

Fix it.

Change-Id: I52deaec6d141846b8a495835b121c1bdc2864215
Reviewed-on: https://go-review.googlesource.com/47343
Reviewed-by: Alan Donovan <adonovan@google.com>
2017-07-05 16:38:48 +00:00
Alan Donovan 63c6481f3b go/loader: fix a data race
The loader was calling (*types.Checker).Files on the "unsafe" package,
a global variable.  Even with zero files, this operation is not a no-op
because it sets the package's "complete" flag, leading to a data race.
(Because Unsafe.complete is already set at construction, the
race is benign, but is reported by -race nonetheless.)

Fixes golang/go#20718

Change-Id: I5a4f95be5ab4c60ea3b6c2a7fb6f1b67acbf42bc
Reviewed-on: https://go-review.googlesource.com/46071
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-06-19 17:45:44 +00:00
Alan Donovan 34f7837286 go/ssa: remove statement with no effect
Change-Id: I1c7958ab16f19fbdc71d2305da3d4afb6e150f73
Reviewed-on: https://go-review.googlesource.com/45934
Reviewed-by: Dmitri Shuralyov <shurcool@gmail.com>
2017-06-15 21:28:45 +00:00
Alan Donovan 6d30ceaab7 go/ssa: fix regression in φ-elimination
https://go-review.googlesource.com/37157 introduced a bug that caused
some live φ-nodes to be removed from the CFG.  The cause was that
reachability traversal considered edges only among "new" φ-nodes
(those introduced during SSA renaming) but not existing φ-nodes from
&& and || expressions.  The fix is to mark existing phis, and thus
other phis reachable from them, as live.  We also clear the Phi.block
field when eliminating a φ-node.

Also, during reachability, we treat DebugRef instructions as roots
like any other non-Phi instruction.  This eliminates a related known
bug whereby the operand of a DebugRef may be a dead φ.

This change also adds a sanity check that all operands of an SSA value
that are themselves instructions must belong to a block.  The sanity
check would fail 7 times on the standard library without the fix.

Fixes golang/go#19622

Change-Id: If3a897a6a593a17bc3f0f8228d1edf483be7a3d0
Reviewed-on: https://go-review.googlesource.com/45832
Run-TryBot: Dominik Honnef <dominik@honnef.co>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dominik Honnef <dominik@honnef.co>
2017-06-15 18:36:17 +00:00
Alan Donovan 365911de24 go/ssa: opt: avoid an allocation
In the dom tree traversal, the final child of each node now
inherits the parent's renaming map, reducing garbage.

This reduces allocations by 1.4% and bytes allocated by 2.0% when
building SSA for the entire standard library.

Change-Id: Id19b6d6766b3e0bf32d1db1238eff8a42d11b242
Reviewed-on: https://go-review.googlesource.com/45833
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-06-15 16:36:43 +00:00
Robert Griesemer b9ad13c5e8 go/gcexportdata: fix test again (fix older builds)
This time, chose a package that's not changed across several builds.
Follow-up on https://go-review.googlesource.com/45151.

Change-Id: I0b487a45f8b12179b3aa495d852c0b7caa44c921
Reviewed-on: https://go-review.googlesource.com/45154
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-06-08 21:12:18 +00:00
Robert Griesemer add5a52034 go/gcexportdata: fix test output (fix build)
Change-Id: Ib9a92c7b7ac09e739177b8c4c16f893dfb5e4420
Reviewed-on: https://go-review.googlesource.com/45151
Reviewed-by: Alan Donovan <adonovan@google.com>
2017-06-08 18:19:49 +00:00
Alan Donovan b62b8c72b8 go/gcexportdata: a command for inspecting gc export data in archive files
Change-Id: I2428b201c49dc441a0023053798f3287902fc370
Reviewed-on: https://go-review.googlesource.com/44861
Reviewed-by: Robert Griesemer <gri@golang.org>
2017-06-05 19:49:53 +00:00
Spencer Nelson 2a5864fcfb x/tools/go/ssa: Accept struct conversions that ignore tags
This is now allowed in go1.8.

Fixes golang/go#19646.

Change-Id: Iece4fd2a881144bdbe841e0a26ba4348d6b8828e
Reviewed-on: https://go-review.googlesource.com/38452
Reviewed-by: Alan Donovan <adonovan@google.com>
Run-TryBot: Alan Donovan <adonovan@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-06-02 20:57:42 +00:00
Fatih Arslan bc6db94186 go/ast/astutil: do not merge if import path is last line
DeleteNamedImport assumes the import declaration is in the form of:

    import (
      "foo"
    )

If an import path is deleted there might be a blank line-sized hole:

    import (

    )

It'll merge the black hole with the last line to change it to:

    import (
    )

However the import declaration might be in the following form as well:

    import (
      "foo")

Whic means after deleting the import path, it changes to:

    import (
    )

In this case it still tries to merge the line with a non existing line,
causing token.File.MergeLine to panic.

We fix the issue by checking that the import path line is not the last
line to avoid panicing.

Fixes golang/go#20229

Change-Id: I37537a4eaa83d14db59a2926d7bb14c27167a2e4
Reviewed-on: https://go-review.googlesource.com/44372
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-05-29 01:35:25 +00:00
Brad Fitzpatrick 15c7897560 go/ssa/interp: fix tests on Go 1.7 and Go 1.8
This mostly reverts commit 1c59bc354d
(CL 43350) which had fixed Go tip but broken Go 1.7 and Go 1.8
builders.

Change-Id: I4e7bdfafde74c9e730bb870b9db05b663b4f56a3
Reviewed-on: https://go-review.googlesource.com/43391
Reviewed-by: Alan Donovan <adonovan@google.com>
2017-05-12 16:33:29 +00:00
Martin Möhrmann 1c59bc354d go/ssa/interp: add internal/cpu.cpuid to fix short tests
http://golang.org/cl/41476 added the internal/cpu package
to unify cpu feature flag detection in the standard library.

Add a replacement for the assembler function internal/cpu.cpuid
that simulates a x86 cpu with no feature detection capabilities.

Remove bytes.init and strings.init from the external function list
because they do not depend on assembler functions anymore.

Remove hash/crc32.haveSSE42 and math.hasSSE4 because they
have been removed from the go standard library.

Change-Id: Icab6ed3cb13eb14b28d23f2b9c5ae94688f2dc95
Reviewed-on: https://go-review.googlesource.com/43350
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-05-12 13:04:21 +00:00
Koichi Shiraishi 9862c35773 go/gcexportdata: fix unnecessary plural type definitions of arg
importPath and srcDir are both of string type.

Change-Id: Ia5230bd19ea83bc210cb0b1a50046e4e0ef2accb
Reviewed-on: https://go-review.googlesource.com/42890
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-05-06 16:03:34 +00:00
Dmitri Shuralyov 2382e3994d go/vcs: allow go get on github.com/ import paths with Unicode letters
Manually apply same change as CL 41822 did for cmd/go/internal/get,
but for golang.org/x/tools/go/vcs, to help keep them in sync.

Updates golang/go#18660.
Helps golang/go#11490.

Change-Id: I6c7759c073583dea771bc438b70f8c2eb7b5ebfb
Reviewed-on: https://go-review.googlesource.com/42017
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-04-28 05:47:26 +00:00
Josh Bleecher Snyder 4bb9a6d30b go/gcimporter: update to latest copy from master
Backport of CL 41619.
Generated by copying bimport.go and reverting
the chunk containing the "This file is a copy"
comment near the top.

Fixes golang/go#20121

Change-Id: If24c97d01a550318ab919c37cd0c4a8f34d776c7
Reviewed-on: https://go-review.googlesource.com/41756
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-04-25 22:48:49 +00:00
Robert Griesemer c853fd5769 go/gcimporter: fix importing of anonymous interfaces
This is a backport of https://go-review.googlesource.com/#/c/41198/.

For golang/go#20046.

Change-Id: I58448c7dcc5e835d5c774e253cb56fec6e154f12
Reviewed-on: https://go-review.googlesource.com/41204
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2017-04-20 22:13:23 +00:00
Ross Light a17c85b5d7 go/vcs: fix doc for Cmd.TagSync
Change-Id: I6037372d7390faad23e12d85a0f1189648e80f8f
Reviewed-on: https://go-review.googlesource.com/41199
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-04-20 21:08:16 +00:00
Alan Donovan fc77adfcad go/ssa/interp: add two intrinsics to fix tests
(specifically: strings.Count, testing.callerEntry)

The interpreter tests were very useful for finding bugs during
development of go/ssa but now seem to be all cost and no benefit.
It may be time to delete this package.

Change-Id: I22348be9fb37bb0fd0c572c3e6f57e70fc069e02
Reviewed-on: https://go-review.googlesource.com/40871
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-04-15 13:02:17 +00:00
Robert Griesemer c21bc47f89 go/gcimporter: exclude failing test from gcimporter tests (fix build)
This is already tested in the std library. Ok to take the easy way
out here.

Change-Id: Ie17e16fddba827bfe279e1f790006b3874f830ad
Reviewed-on: https://go-review.googlesource.com/38455
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2017-03-22 23:20:07 +00:00
Matthew Dempsky b08393ce6d go/gcimporter15: backport interface embedding support
Backports golang.org/cl/38392 from go/internal/gcimporter.

Updates golang/go#16369.

Change-Id: Ic805f96e6565590987a5dae9f0f76c206fceab05
Reviewed-on: https://go-review.googlesource.com/38429
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
2017-03-21 22:26:56 +00:00
Alan Donovan 767744efe2 go/ssa/interp: add more intrinsics for sync/atomic and runtime
Change-Id: I4743fa32be5549b2d141595d236c653e53cc9ff4
Reviewed-on: https://go-review.googlesource.com/37712
Reviewed-by: Robert Griesemer <gri@golang.org>
2017-03-06 18:20:00 +00:00
Dominik Honnef a99f4ece36 go/pointer: implement extended queries
The existing API for querying values only allows directly querying
pointer-like values, or pointers to such values. The new, extended
queries make it possible to destructure values and access arbitrarily
nested pointers, such as fields in structs, or specific values in
tuples.

We use single Go expressions as the queries, which we further restrict
to a subset of the language (indexing, field access, pointer
dereferences and channel receives).

Instead of adding another map to Result, we return a *Pointer and
populate it during analysis. This does mean that a Config cannot be
reused for multiple analyses, as it now holds analysis-specific state.
That is, however, not a big problem as reusing one Config had little
use.

Since the new API can do everything the old could, it deprecates
AddQuery and AddIndirectQuery.

Change-Id: I4b2ae7d85c462bc7faa6bab76456106e76be5a65
Reviewed-on: https://go-review.googlesource.com/37635
Reviewed-by: Alan Donovan <adonovan@google.com>
2017-03-06 04:11:41 +00:00
Alan Donovan 181cdfd456 go/ssa: create an 'init' function even if len(files)==0
Package "unsafe" has no files, and is treated like a regular package since
https://go-review.googlesource.com/37710, and the interpreter needs an
init function with a body for every package.

Change-Id: I27bd7cdb1ecaf01d0b5ed91db57145d1b4f551e1
Reviewed-on: https://go-review.googlesource.com/37711
Reviewed-by: Robert Griesemer <gri@golang.org>
2017-03-03 14:03:29 +00:00
Alan Donovan 7a49e427c8 go/loader: don't create types.Package for "unsafe"
https://golang.org/cl/37694 is a backwards-incompatible change to the
go/types API that causes "unsafe" to be included among the results of
(*types.Package).Imports().  Client packages such as go/loader and
go/ssa now need to recognize the special unsafe package and its
unusual *Bultin members and not create a types.Package for it.

Change-Id: I902725d3053cb887246978efdb5ec5dcdc0e4818
Reviewed-on: https://go-review.googlesource.com/37710
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-03-02 21:55:26 +00:00
David R. Jenni b20a216efb x/tools/go/internal/gccgoimporter: remove unused method
Found with honnef.co/go/tools/cmd/unused.

Change-Id: Ib8acac744a171b70f3f842f8f5f8c34064869383
Reviewed-on: https://go-review.googlesource.com/37604
Reviewed-by: Alan Donovan <adonovan@google.com>
2017-03-01 14:54:10 +00:00
David R. Jenni 76c38d6bce x/tools/go/buildutil: remove unused function
Found with honnef.co/go/tools/cmd/unused.

Change-Id: I1dc8e4dbfd784bb22b2f0dabb7c1a08cf1ef44ee
Reviewed-on: https://go-review.googlesource.com/37603
Reviewed-by: Alan Donovan <adonovan@google.com>
2017-03-01 14:53:57 +00:00
David R. Jenni 36a48c93a6 x/tools/go/ssa: remove unused field from NamedConst
Found with honnef.co/go/tools/cmd/unused.

Change-Id: I68b4af07cc64a46f5794a0e339859f4d6bc9dad1
Reviewed-on: https://go-review.googlesource.com/37605
Reviewed-by: Alan Donovan <adonovan@google.com>
2017-03-01 14:40:01 +00:00
David R. Jenni 718875e4f9 x/tools: simplify and format code
Semi-mechanical changes using gofmt -s
and honnef.co/go/tools/cmd/gosimple.

Change-Id: I41bcf4bea5b16c4776b7cf6534b76aa59b3c022d
Reviewed-on: https://go-review.googlesource.com/37447
Reviewed-by: Alan Donovan <adonovan@google.com>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-02-28 14:15:42 +00:00
Alan Donovan 219e654bb7 go/ssa: eliminate dead φ-nodes in cycles
The previous "dead φ" check was simple and naive but left cycles of
dead φ-nodes.  This confused some downstream static analysis tools.
This change makes the φ-nodes liveness check transitive.

+ Test.

Also, number phi nodes so they're not all called t0 during debugging.

Reduces memory consumption by  1%.
Increases execution time   by <1%.

Change-Id: I2908662c1478d455fdf4a179f4a12d6184a456c0
Reviewed-on: https://go-review.googlesource.com/37157
Reviewed-by: Robert Griesemer <gri@golang.org>
2017-02-22 01:23:56 +00:00
Ian Lance Taylor f84eaba4be go/loader: only run examples on 1.8
Tip introduces a new internal/poll package that breaks the expected
output.

Fixes golang/go#19150
Updates golang/go#19152

Change-Id: I5ff7e8a92afe4d25feb6365933062e931c9b435f
Reviewed-on: https://go-review.googlesource.com/37148
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
2017-02-17 19:31:53 +00:00
David R. Jenni be0fcc31ae x/tools/go: gofmt -s -w
Change-Id: I978b981d95909f2590c1e1db05e8a95e232a67d5
Reviewed-on: https://go-review.googlesource.com/32794
Reviewed-by: Alan Donovan <adonovan@google.com>
2017-02-15 21:43:35 +00:00
Alan Donovan 6e7ee5a9ec x/tools: support Go 1.9 type aliases
For #18130.

Change-Id: Ice695602619dbbf851af970e790f07ff2ac2c141
Reviewed-on: https://go-review.googlesource.com/36623
Reviewed-by: Robert Griesemer <gri@golang.org>
2017-02-13 21:46:59 +00:00
haya14busa 8524ce5143 imports, go/ast/astutil: do not make grouped imports non-grouped when removing
import (
		"fmt"
		"strings"
	)

When deleting "fmt" import statement, code should be converted to the
following code.

	import (
		"strings"
	)

Instead of

	import "strings"

Diff becomes nicer by this change and it avoids that rewriting grouped
imports non-grouped may result in confusion comments.

Example:

	// comment 1
	import (
		"fmt"
	        // comment 2
		"strings"
	)

should be

	// comment 1
	import (
	        // comment 2
		"strings"
	)

instead of

	// comment 1
        // comment 2
	import "strings"

Fixes golang/go#18051

Change-Id: I3c07b70b657191eacf83c3197a965e587286c950
Reviewed-on: https://go-review.googlesource.com/36853
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
2017-02-13 18:56:44 +00:00
Alan Donovan b56ef30191 tools: updates for minimum Go version 1.6
Details:
- remove go1.5 "default version" labels on most files
- remove go1.6 labels on a few files
- go/loader: use conf.Cwd not "." in a couple places; update faulty
  test expectations.  (Not sure why this wasn't caught sooner.)
- go/ssa/interp: add 'mono' result to time.now intrinsic
- go/gcimporter15/bimport.go: make consistent with the version in gc
- go/ssa/interp: update test error message
- go/ssa: update a comment

The go/gcimporter15/bexport.go logic is stale and needs to be brought
up to date.  Needs a separate CL since it's tricky.

Tested on go1.6, go1.7, go1.8.

Change-Id: I841189d30e131b7c49a4e8690ea7c40b55041bae
Reviewed-on: https://go-review.googlesource.com/36540
Reviewed-by: Robert Griesemer <gri@golang.org>
2017-02-07 21:06:19 +00:00
Alan Donovan 1977f1cf7d go/ssa/interp: remove old TODO
Change-Id: Ia518721769048a5f7413eb90265cc27128cc9c10
Reviewed-on: https://go-review.googlesource.com/36537
Reviewed-by: Robert Griesemer <gri@golang.org>
2017-02-07 19:36:57 +00:00
Robert Griesemer b55a2aaa40 go/internal/gccgoimporter: add missing testfile (fix 1.9 build)
Change-Id: Icba8d6917dcac4b8f541fc11305981539a12924a
Reviewed-on: https://go-review.googlesource.com/36116
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-02-01 22:16:26 +00:00
Robert Griesemer fcfba28e23 go/internal/gccgoimporter: support for type aliases
This is essentially a copy of the changes in https://golang.org/cl/35268/
but with Go1.9 specific tests factored out into a separate file with build
tag.

For golang/go#18130.

Change-Id: I235693e1bc6145bb53bfd3b343647704c8e82e61
Reviewed-on: https://go-review.googlesource.com/35269
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
2017-01-20 05:57:59 +00:00
Robert Griesemer de557280a1 go/gcimporter15: update import/export to handle type aliases
- bimport.go is a 1:1 copy of the respective version in the std
  library: $GOROOT/src/go/internal/gcimporter/bimport.go .

- bexport.go is mimicking the respective code in the cmd/compile.

- isAlias18/19.go are needed because types.TypeName.IsAlias does
  not exist before Go 1.9.

Tested against Go 1.6, 1.7, 1.8, 1.9 (dev.typealias branch).

For golang/go#18130.

Change-Id: Ic46c5850923fab2a35d4dc33850f2b0667c30398
Reviewed-on: https://go-review.googlesource.com/35104
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
2017-01-11 20:35:34 +00:00
Samuel Tan dd79664177 go/internal/gccgoimporter: accept missed portions of v2 format
Same as https://go-review.googlesource.com/c/34371/ in the standard library.

Fixes #18301.

Change-Id: I132585e0f98c53437fdef44ac36af8f21d141a83
Reviewed-on: https://go-review.googlesource.com/34387
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-12-15 00:32:54 +00:00
Brad Fitzpatrick a888bfdffa go/loader: fix broken tests after context removal from testing package
Updates golang/go#11811
Updates golang/go#18199

Change-Id: I2ce4615653034563a64b9c126651d2a6ce2aef50
Reviewed-on: https://go-review.googlesource.com/34274
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
2016-12-10 02:42:22 +00:00
Alan Donovan 3d92dd6003 go/internal/gccgoimporter: handle conversions in exported const values
Same as https://go-review.googlesource.com/c/33412/ in the standard library.

Fixes #17981.

Change-Id: Iaf47872840a4456d824ed5d7b3eda205c043e4cf
Reviewed-on: https://go-review.googlesource.com/34110
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-12-07 20:12:13 +00:00
Rebecca Stambler 99be5a0b85 go/buildutil, cmd/guru: resolve symlinks in filenames through build.Context
Resolve symlinks in source directories (GOPATH, GOROOT, etc.) and source
files in order to find correct package. All I/O performed through
build.Context. Also add minor fix to guru unit tests in order to pass on
Windows.

Change-Id: Ie6134b9cd74eb7386e1d93603eb37c8e44b083b8
Reviewed-on: https://go-review.googlesource.com/33924
Reviewed-by: Alan Donovan <adonovan@google.com>
2016-12-06 21:45:43 +00:00
Rebecca Stambler ae1141fc8b Revert "go/buildutil: handle symlinks in filenames"
Reason: ContainingPackage should do all I/O through build.Context.

This reverts commit 3a9a2cbbc4.

Change-Id: I3897d8da5026ddc470989e3f239540286e89df4d
Reviewed-on: https://go-review.googlesource.com/33922
Reviewed-by: Alan Donovan <adonovan@google.com>
2016-12-05 22:44:39 +00:00
Rebecca Stambler 07e766bf81 Revert "go/buildutil, cmd/guru: fix tests for symlinks in guru and gorename to account for windows."
Reason: ContainingPackage must do all I/O through build.Context.

This reverts commit c945ee3be4.

Change-Id: I625410bc754ea2d150be097bf424de2be42acde4
Reviewed-on: https://go-review.googlesource.com/33921
Reviewed-by: Alan Donovan <adonovan@google.com>
2016-12-05 22:43:53 +00:00
Rebecca Stambler c945ee3be4 go/buildutil, cmd/guru: fix tests for symlinks in guru and gorename to account for windows
Restructure tests to account for possibility of being run on Windows
(which doesn't handle symlinks).

Change-Id: I428db26c9a1aad337d8972baa2b71468be3a2e58
Reviewed-on: https://go-review.googlesource.com/33920
Reviewed-by: Alan Donovan <adonovan@google.com>
2016-12-05 21:18:37 +00:00
Rebecca Stambler 3a9a2cbbc4 go/buildutil: handle symlinks in filenames
Resolve symlinks in source directories (GOPATH, GOROOT, etc.) and source
files in order to find correct package.

Fixes golang/go#16219

Change-Id: I6fae14908827d5ebac55dfe455eaf616f71f8767
Reviewed-on: https://go-review.googlesource.com/33919
Reviewed-by: Alan Donovan <adonovan@google.com>
2016-12-05 20:02:40 +00:00
Zac Bergquist 8462b1669f go/buildutil: fix doc reference
Fix reference to OverlayContext in the doc for
ParseOverlayArchive.

Change-Id: I0b1db478489764fa309cb2e2f788865ac7ff71bb
Reviewed-on: https://go-review.googlesource.com/33916
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-12-05 17:11:22 +00:00
Alan Donovan 34fe8ce027 go/gcexportdata: better error when reading exportdata directly from archive
Change-Id: Iaa6fe8a33bee852be4e2414c6db7ca5df17006b6
Reviewed-on: https://go-review.googlesource.com/33715
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-11-30 19:52:27 +00:00
Alan Donovan 6c803ab014 go/loader: resolve imports in "created" packages w.r.t. parent dir not cwd
Fixes golang/go#16580

Change-Id: Id891f40659257eac9dbb0d70dae17f725e911f9b
Reviewed-on: https://go-review.googlesource.com/33589
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-11-28 22:26:25 +00:00
Alan Donovan 89662b06bc go/ssa/interp: add several intrinsics for Darwin
Also: drop all pretense of support for platforms other than darwin and linux.
This package is just a test of go/ssa, not a portable interpreter, and these
are the only platforms to which I have easy access.

Builds on: freebsd darwin plan9 linux windows

Change-Id: I965abc67b1280d33e933b83607a4372d65e070cf
Reviewed-on: https://go-review.googlesource.com/33163
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-11-28 17:49:04 +00:00
Alan Donovan 167995c67f go/ssa: avoid no-arg println(), for gccgo compatibility
Change-Id: I5f789ae492ff0f0ad62d89e3ae762ece6c867d20
Reviewed-on: https://go-review.googlesource.com/33573
Reviewed-by: Alan Donovan <adonovan@google.com>
2016-11-23 22:44:20 +00:00
Alan Donovan 5e2ae75eb7 go/ssa/interp: add syscall.Readlink intrinsic, needed by os package
Change-Id: Ie408fd5ffb2be2d60773eb3fda91912887df0a7e
Reviewed-on: https://go-review.googlesource.com/33147
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-11-11 21:41:07 +00:00
Alan Donovan 22ba3f367c go/gcimporter15: pretend blank fields have same owner
The export data formats (text and binary) emitted by gc in Go 1.7 did
not record the package that "owns" each blank field, even though blank
is an unexported identifier.  Before, gcimporter would assume the
package of the export data file owns blank fields within it, even
blank fields reexported from another package.  As a result, identical
types would become nonidentical during reexporting.

For bug compatibility with gc, gcimporter now treats blank fields as
if they all belong to the same dummy package, avoiding spurious "can't
assign A to B" errors in tools based on go/types.

Change-Id: I0dbf71491a0ec0f376e9dc8a91efe0376c855a28
Reviewed-on: https://go-review.googlesource.com/33146
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-11-11 21:27:08 +00:00