(from importing golang.org/x/tools/go/types to std lib go/types)
The cmd/vet package should never have been included in this change.
Tested with 1.4.1, 1.5 and ~1.6 (tip).
Change-Id: I6d915619cbfa0297dbb9aa9ba033c1320a08c367
Reviewed-on: https://go-review.googlesource.com/18385
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Because the std go/importer's Lookup functionality is incomplete,
clients have no way to create a Go 1.5 types.Package from an io.Reader
reading from gc export data. This package provides a stopgap until
the standard library is complete.
The go/gcimporter package remains unchanged, and uses only the
golang.org/x/tools/go/types package.
Change-Id: I47a817f4b6a52ddab26c6b01de6e28099301faf5
Reviewed-on: https://go-review.googlesource.com/18382
Reviewed-by: Robert Griesemer <gri@golang.org>
A few files have been forked and tagged "go1.5,!go1.6" to work around
minor API changes between the two types packages:
- constant.Value.String() in oracle/describe.go and its tests;
- constant.ToInt must now be called before constant.Int64Val.
- types.Config{Importer: importer.Default()} in a number of places
- go/types/typeutil/import_test.go uses lowercase names to avoid 'import "C"'.
Files in go/types/typesutil, missing from my previous CL, have been
tagged !go1.5; these files will be deleted in February.
All affected packages were tested using 1.4.1, 1.5, and ~1.6 (tip).
Change-Id: Iec7fd370e1434508149b378438fb37f65b8d2ba8
Reviewed-on: https://go-review.googlesource.com/18207
Reviewed-by: Robert Griesemer <gri@golang.org>
This change will ensure that the tree continues to work with go1.4.1.
All files continue to depend on golang.org/x/tools/go/types, but in a
follow-up change, I will switch the primary files to depend on the
standard go/types package. Another (smaller) set of files will be
forked and tagged, this time !1.6, due to API differences between the
two packages.
All tests pass using 1.4.1, 1.5, and ~1.6 (tip).
Change-Id: Ifd75a6330e120957d646be91693daaba1ce0e8c9
Reviewed-on: https://go-review.googlesource.com/18333
Reviewed-by: Robert Griesemer <gri@golang.org>
Packages specified on the command line should be interpreted relative to
cwd iff they are local (e.g. ./http within $GOROOT/src/net), otherwise a
request for, say, "golang.org/x/net/http2/hpack" might return the vendored
package depending on the working directory.
The FindPackage hook function now takes a build.ImportMode parameter, so
it matches the signature of (*build.Context).Import. The AllowVendor
flag is enabled only for imports within source files, but not for the
initial packages.
+ test.
Change-Id: I756dc46b70928d2fd9f824e6670092d8169e0d64
Reviewed-on: https://go-review.googlesource.com/18318
Reviewed-by: Robert Griesemer <gri@golang.org>
Files with //line directives may not exist.
Print a helpful error instead of panicking when a file fails to load.
+ Test.
Fixes issue #13459
Change-Id: I305d1380e66e64d20ea84a27c284f53c019fe5e6
Reviewed-on: https://go-review.googlesource.com/18209
Reviewed-by: Michael Matloob <matloob@golang.org>
Use an concurrency-limiting semaphore to reduce I/O parallelism in Import.
Also, start the producer in a new goroutine so that it runs in parallel
with the consumer. Paradoxically, this reduces the peak number of
goroutines.
Also, in buildutil.ForEachPackage, make the concurrency limiting
semaphore global, since I/O parallelism is a process-wide resource.
Change-Id: I282b717c50603361826e5675077c9f464c874132
Reviewed-on: https://go-review.googlesource.com/18215
Reviewed-by: Michael Matloob <matloob@golang.org>
The user may specify the diff tool using the -diffcmd flag.
+ test.
Also:
- eliminate redundant DryRun flag
- simplify Verbose messages using log.SetPrefix
Fixes issue #13355
Change-Id: I917edc73e31ddf0f5d5b9b30c43f826465529da1
Reviewed-on: https://go-review.googlesource.com/18208
Reviewed-by: Michael Matloob <matloob@golang.org>
...using same logic as in $GOROOT/go/src/cmd/go/discovery.go
See issue #13757
Change-Id: I2ace0abed0743f4a8675fa8780e190d640b57e6c
Reviewed-on: https://go-review.googlesource.com/18196
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
We need a better approach for tests such as these.
Change-Id: I6fb608acc096088fe377f6f2c40ff6124cf3d09c
Reviewed-on: https://go-review.googlesource.com/18194
Reviewed-by: Alan Donovan <adonovan@google.com>
1. Added intrinsic for os.Pipe to avoid use of "unsafe". This makes
Example tests work in the interpreter, fixing the broken "unicode"
package (which recently sprouted some Examples) and allowing us to
enable tests for:
encoding/csv
flag
path
text/scanner
unicode/utf8
The implementation of os.Pipe may require tweaking for non-Linux platforms.
2. Added intrinsic for strings.Index to avoid assembly dependency.
3. Added dumb intrinsic for testing۰runExample to work around a bug in
go/ssa/testmain.go that requires an invasive fix
(Until then, the output of Example functions will not be checked.)
Change-Id: I6374c9c47aa802275b7cdc98525e057f5db0615a
Reviewed-on: https://go-review.googlesource.com/18191
Reviewed-by: Alan Donovan <adonovan@google.com>
(gcimporter does not support vendoring---see issue #13756)
Change-Id: Ief4101e4f33007d497ed1519845febfcffdded38
Reviewed-on: https://go-review.googlesource.com/18193
Reviewed-by: Alan Donovan <adonovan@google.com>
Prior to this change, the loader made the simplifying assumption
that an import path is equal to a package path, that is, a
subdirectory of src/. (This assumption was already false because
relative imports "../foo" are possible, though discouraged.)
Now, an import "foo" may denote "a/vendor/foo" or "b/vendor/foo"
depending on whether it appears beneath a/ or b/. Thus import
paths and package paths are no longer the same, and the directory
containing an import declaration is a necessary input to the
import resolution function.
This change makes the loader hygienic w.r.t. the directory of
each import declaration, and cleans up the terminology.
The only API change is to the FindPackage hook, which most
clients never use.
Details:
- Add a 'fromDir string' parameter to the FindPackage hook function.
- Add a dir field to each PackageInfo.
- doImport (called by go/types) now consists of two steps:
use FindPackage(dir, importPath) to locate the package,
then consult the import map using the canonical package path.
Only the first step can fail.
- Memoize FindPackage.
- Simplify importInfo now that it no longer has to deal with errors.
Replace a condition variable with a channel.
- Use a separate type to report importErrors.
- Rename loadAll to importAll
- Delete the importMode constant.
- Test.
Change-Id: I3defab51bfa12b48b1511a2172fb48dc8e9150e6
Reviewed-on: https://go-review.googlesource.com/18053
Reviewed-by: Robert Griesemer <gri@golang.org>
Each string in build.Package.{,Test,XTest}Imports must now be
interpreted relative to the Package.Dir. This adds a ton of
redundant I/O.
Also:
- use a counting semaphore to limit concurrent I/O calls
(Fixesgolang/go#10306)
- remove obsolete call to runtime.GOMAXPROCS from the test.
Change-Id: Ic556c4cf41cce7a88c0158800c992e66f354c484
Reviewed-on: https://go-review.googlesource.com/18050
Reviewed-by: Russ Cox <rsc@golang.org>
so that the bundled package doesn't clobber the package declaration
of the host package.
Also: minor comment tweaks.
Change-Id: I28ab3aca2b02213edc95c6b12c0d1a2514453cfe
Reviewed-on: https://go-review.googlesource.com/18040
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Makes programs like ssadump work on packages using vendored code,
for example net/http.
For golang/go#12278.
Depends on CL 17726 in main repository.
Change-Id: Ibabf564e397044a0f449087124dd96161081baaf
Reviewed-on: https://go-review.googlesource.com/17727
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
Since this tool is a handy way to run the pointer analysis during debugging.
Change-Id: If9a62f71dd8651ad6c782ead85bb84f09c703cba
Reviewed-on: https://go-review.googlesource.com/17382
Reviewed-by: Robert Griesemer <gri@golang.org>
godoc still runs on App Engine (not Managed VMs). The metadata server is only
available from Compute Engine and Managed VMs, but not App Engine.
Change-Id: I0e5e9ef3f169f6d24ca7562df744c8f1556b825f
Reviewed-on: https://go-review.googlesource.com/17391
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
If the analysis scope is not set, inspect all packages that depend on
the query package.
Fixes issue 13457
Change-Id: I08791d8a0a752470891ee93e65e664d0408525c5
Reviewed-on: https://go-review.googlesource.com/17342
Reviewed-by: Robert Griesemer <gri@golang.org>
Since Go 1.5, if a key expression in a map literal is itself a composite
literal, the type may be omitted. An & operation may be implied,
but was not generated, resulting in a type mismatch crash.
Added regression test.
Also, added missing intrinsic math.hasSSE4 to interpreter.
Fixes issue 13341
Change-Id: I6a5e560460cdcac295a500a3fc3738cbe8aa5853
Reviewed-on: https://go-review.googlesource.com/17123
Reviewed-by: Robert Griesemer <gri@golang.org>
- add tests for Open, ReadDir, and Stat funcs
- add tests for Seek of Open()
- simplify internal handling of absolute vs. "zip" paths
- fix handling of "/"
The fix special cases this scenario, leaving the codepath for all
other file paths the same. Specifically,
- Exported funcs call stat(), so stat("/") is handled by simply
returning 0 to indicate all entries are (effectively) prefixed
by "/" and zipFI{"", nil} because "/" has no name and nil
indicates it is a directory.
- ReadDir("/") is further handled by seeding the existing lookup
logic with "" instead of what would have been "/". This is
necessary because, per the zipfs spec, the zip file entries MUST
NOT start with "/", so using "/" would incorrectly match nothing.
This works because seeding lookup with "" (correctly) matches
all files and then the following, existing logic (correctly) pares
things down to just the files in the root directory; not in any
subdirectories.
Verified that godoc -zip still works.
Fixesgolang/go#12743
Change-Id: Icb5f01b8a29cefa4e2820135f318894042970301
Reviewed-on: https://go-review.googlesource.com/16925
Reviewed-by: Andrew Gerrand <adg@golang.org>
Use the compiler intrinsic __builtin_popcount.
Change-Id: I58286fbcf66d1068390ea9caff2f98b8fe244c2d
Reviewed-on: https://go-review.googlesource.com/16831
Reviewed-by: Andrew Gerrand <adg@golang.org>
Change-Id: I6f3b351d42f5534dd5a5ff161f1e5680b4dbfd58
Reviewed-on: https://go-review.googlesource.com/16793
Reviewed-by: Andrew Gerrand <adg@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
The example incorrectly used buildutil.TagsDoc identifier which does not
exist. It should be buildutil.TagsFlagDoc instead.
The issue was introduced in https://golang.org/cl/9172 when this code was
first written.
Also use more idiomatic style for Go comments, '//' followed by a space,
then tab (instead of skipping the space). Although both render correctly
in godoc, this form is more correct and consistent.
Change-Id: I3b3c9767fe313106a8ff81e7887f3241c5806b59
Reviewed-on: https://go-review.googlesource.com/16743
Reviewed-by: Alan Donovan <adonovan@google.com>