1
0
mirror of https://github.com/golang/go synced 2024-10-01 12:28:37 -06:00
Commit Graph

1767 Commits

Author SHA1 Message Date
Robert Griesemer
3c2fc37aec go/gccgoimporter: remove incorrect scope passed to NewSignature
Change-Id: I4b9670dc72ef85b852361aa5524a55b82d88e8f2
Reviewed-on: https://go-review.googlesource.com/10993
Reviewed-by: Alan Donovan <adonovan@google.com>
2015-06-12 23:06:12 +00:00
Robert Griesemer
568df9f49c go/types: remove global vars in test
Change-Id: I5fb61a38362a40c706ba5cb8968c387c8dc4aef2
Reviewed-on: https://go-review.googlesource.com/10992
Reviewed-by: Alan Donovan <adonovan@google.com>
2015-06-12 23:05:41 +00:00
Robert Griesemer
665374f1c8 go/types: add pos parameter to Eval; remove New, EvalNode
Scopes now have "extent" information; that is they provide a
range [scope.Pos(), scope.End()) which describes the source
text range covered by the scope. It requires that the incoming
AST has correct position information; also the extent for the
Universe and for package scopes is not set (positions are invalid).

Objects have a new (currently unexported) scopePos position,
which is the position at which the object becomes visible inside
its *Scope.

Scope.LookupParent takes an addition parameter pos. If valid, an
identifier is looked up as if found at position pos. This can be
used to find the object corresponding to an identifier at position
pos after scopes have been completely populated (and thus may
contain the same identifier which may be defined only later in the
source text).

Fixes #9980.

Change-Id: Icb49c44c5c3d4b93c0718ce2a769ec468877709d
Reviewed-on: https://go-review.googlesource.com/10800
Reviewed-by: Alan Donovan <adonovan@google.com>
2015-06-12 23:04:54 +00:00
Robert Griesemer
a6d2a4254e cmd/vet: backport of https://go-review.googlesource.com/#/c/10777/3
Change-Id: I8d63575f2053eda2d7f0a63f3ff862bf0de88d31
Reviewed-on: https://go-review.googlesource.com/10807
Reviewed-by: Alan Donovan <adonovan@google.com>
2015-06-09 16:33:12 +00:00
Alan Donovan
ac303766f5 go/ssa/interp: don't run encoding/pem tests in interpreter
since they use quick.Check, which requires the unimplemented
(reflect.Value).SetString.

Also:
- Add reflect.Type.{In,NumIn} methods, whose absence
  was only the proximate cause of the failed test.
- Delete bodies of reflect.Value methods so that it's obvious a
  function that should be intrinsic is missing.

Change-Id: Ib64b8f4953a913f4ead90e376bda70419adb87cb
Reviewed-on: https://go-review.googlesource.com/10796
Reviewed-by: Robert Griesemer <gri@golang.org>
2015-06-06 15:50:50 +00:00
Robert Griesemer
f0b0213b21 cmd/vet: remove dependency on types.New
In preparation for removal of types.New.

Change-Id: Ieff0c41cf03351124cea32e9b96075a4801c051f
Reviewed-on: https://go-review.googlesource.com/10775
Reviewed-by: Rob Pike <r@golang.org>
2015-06-05 20:06:37 +00:00
Robert Griesemer
de24c4870a go/types: remove unused return value (minor cleanup)
Change-Id: I37dd83100b7e977e1d5a06ae84a93a40bbd651c3
Reviewed-on: https://go-review.googlesource.com/10773
Reviewed-by: Alan Donovan <adonovan@google.com>
2015-06-05 18:41:51 +00:00
Robert Griesemer
e262ee18f0 go/types/typeutil: add missing copyright notices
Change-Id: I101c033ffc20fde38b0f0b075f559aa10a6e43d0
Reviewed-on: https://go-review.googlesource.com/10772
Reviewed-by: Alan Donovan <adonovan@google.com>
2015-06-05 18:11:17 +00:00
Robert Griesemer
3f8eecd15b go/types: move MethodSetCache into package go/types/typeutil
Change-Id: Iba5d7c2df533948a5b28373b077cc0476a6745ad
Reviewed-on: https://go-review.googlesource.com/10770
Reviewed-by: Alan Donovan <adonovan@google.com>
2015-06-05 17:34:01 +00:00
Rob Pike
cc54cd6553 cmd/vet: don't use filepath.Join to build binary name in test
It cleans the string and removes the initial ./, which will cause the
test to fail if . is not in $PATH

Change-Id: Icc216f7ab4887c39ccda93d1c4093ccd03de44bc
Reviewed-on: https://go-review.googlesource.com/10696
Reviewed-by: Robert Griesemer <gri@golang.org>
2015-06-04 21:29:42 +00:00
Rob Pike
3caa6cfbd2 cmd/vet: add -tags flag
This is needed to control which files to test in the usual manner.
A followup CL on the main repo will add the flag to the go vet command.

Updates golang/go#10228

Change-Id: I820d3c74657b58de5e92276627368dedf4e2096c
Reviewed-on: https://go-review.googlesource.com/10692
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-06-04 19:20:34 +00:00
Nick Craig-Wood
578c521fc2 cmd/stringer: fix panic caused by integer overflow
When String() was called on the maximum value of an integer type (eg
255 for uint8) this would cause an integer overflow, which would cause
an index error later in the code.

Fixed by re-arranging the code slightly.

Fixes golang/go#10563

Change-Id: I9fd016afc5eea22adbc3843f6081091fd50deccf
Reviewed-on: https://go-review.googlesource.com/9255
Reviewed-by: Rob Pike <r@golang.org>
2015-06-02 19:44:20 +00:00
Rob Pike
27e692e6ec cmd/cover: check error
The variable was assigned but not used, as caught by a tool
written by gorden.klaus@gmail.com.

Change-Id: I84ca3d00896287a35561bd122a0cf64212854a86
Reviewed-on: https://go-review.googlesource.com/10610
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-06-02 04:29:08 +00:00
Gustav Paul
68353d2750 godoc/vfs: close file on error
When Stat() or IsDir() return errors, close the file to avoid a leak.

Change-Id: I46d5e34c3443413ca674f2a703d033d945c21efa
Reviewed-on: https://go-review.googlesource.com/10557
Reviewed-by: Minux Ma <minux@golang.org>
2015-06-01 03:28:17 +00:00
Alan Donovan
8ccf558e8a cmd/callgraph: update flag docstring
And add a TODO.

Change-Id: I51c63b32e9ac4309cdfb8228348a5d528f36a919
Reviewed-on: https://go-review.googlesource.com/10489
Reviewed-by: Robert Griesemer <gri@golang.org>
2015-05-29 17:21:31 +00:00
Dominik Honnef
9c7ccd869c refactor/rename: emacs: kill go-rename buffer correctly
Match gofmt's behaviour of closing the status buffer. Don't display the
buffer in case of success as we were going to hide it instantly again,
anyway. Also, instead of using delete-window, use
gofmt--kill-error-buffer. gofmt--kill-error-buffer uses quit-window if
there's a window for the buffer, kill-buffer otherwise.

quit-window only deletes the window if it was created explicitly for the
status buffer and if it is still displaying it. This way, we won't close
windows that the user created or repurposed himself.

Additionally, this change ensures that we don't leave a *go-rename*
buffer lying around when gorename succeeded.

Fixes golang/go#10972.

Change-Id: Id1efb60d399f0062d870e925138aa827e12f3e58
Reviewed-on: https://go-review.googlesource.com/10453
Reviewed-by: Alan Donovan <adonovan@google.com>
2015-05-29 16:50:48 +00:00
Alan Donovan
9333b8f458 refactor/eg: fix crash while unifying wildcard with KeyValueExpr, which has no type
+ tests.

Fixes issue golang/go#10923

Change-Id: I0813cdfbb447bbd9f579bb1998b355a3179a7e79
Reviewed-on: https://go-review.googlesource.com/10332
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2015-05-29 16:42:57 +00:00
Robert Griesemer
5e9beacd77 go/types: fix error message for embedded non-interface types in interfaces
Backport of https://go-review.googlesource.com/#/c/10466/ .

Change-Id: Ib88a9707ea8ad6e2dbfaeb2edeb586a968abd508
Reviewed-on: https://go-review.googlesource.com/10468
Reviewed-by: Alan Donovan <adonovan@google.com>
2015-05-28 20:04:54 +00:00
Robert Griesemer
8c8390201d go/types: exclude test/fixedbugs/issue7746.go from tests
This backports an anlogous change made to std repo go/types and
enables running the tests again in a reasonable amount of time.

Change-Id: Ied59f6788b7b180f34c918a3c94d50c892b15f32
Reviewed-on: https://go-review.googlesource.com/10467
Reviewed-by: Alan Donovan <adonovan@google.com>
2015-05-28 19:10:56 +00:00
Shenghou Ma
cd3ef3b6f0 godoc/static: set explicit page background color
Fixes golang/go#10961.

Change-Id: I3fc947bb18535853b278bad5fa449cf259eba59c
Reviewed-on: https://go-review.googlesource.com/10451
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-05-28 01:09:23 +00:00
Alan Donovan
3d1847243e oracle: disable parser bailout
This change sets ParserMode=AllErrors so that the parser is never
allowed to discard the AST and use a dummy one just because it saw too
many errors.

Also, change (*loader.Program).PathEnclosingInterval so that other
clients that forget to set this flag don't panic while calling
fset.File(f.Pos()).Base() on an ast.File f with no position info.

Change-Id: Ie544f169d367d2aa85426212b27063dc72e36fb1
Reviewed-on: https://go-review.googlesource.com/10290
Reviewed-by: Robert Griesemer <gri@golang.org>
2015-05-20 20:27:48 +00:00
Daniel Morsing
500e956000 oracle: attempt to deduce callees statically before building SSA
When querying for callees against a static call, the entire SSA
form for the program was built. Since we can tell if a callee is
statically dispatched after typechecking, try to do that before
building the SSA form.

This cuts 3.5 seconds off queries against static calls.

Change-Id: I22291381d3bec490e3b1d6f9c6b5a0092fd9f635
Reviewed-on: https://go-review.googlesource.com/10230
Reviewed-by: Alan Donovan <adonovan@google.com>
2015-05-20 12:10:52 +00:00
Josh Bleecher Snyder
3f8aef80c8 go/ast/astutil: set Pos for import name
Failing to set this when adding a named import
to an existing block at the 0th position
caused the Lparen position to be set to zero.
As a result, the specs were printed as if
they were a single spec, not a group.
This made it appear as if imports had
been swallowed.

See CL 8663 for more context
and the original bug report.

CL 2050 fixed most similar cases
but missed this one.

Change-Id: Ic578fbb8040fa3d3d41db5bde2b839e394801608
Reviewed-on: https://go-review.googlesource.com/10252
Reviewed-by: Robert Griesemer <gri@golang.org>
2015-05-19 23:10:16 +00:00
Austin Clements
45716cd4c6 cmd/stress: print number of failed runs
Currently at the end of a long stress run you may not know from the
end of the output whether there were any failures. Add a failure count
to the periodic status message to make this obvious.

Change-Id: I5ad19b9e6f462369fb32be6efbfb6f21568e98e4
Reviewed-on: https://go-review.googlesource.com/10187
Reviewed-by: Rick Hudson <rlh@golang.org>
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
2015-05-19 12:13:22 +00:00
Alan Donovan
7d75e8b219 cmd/fiximports: a tool to rewrite import paths to match import comments.
fiximports enumerates the set of packages identified by the
command-line arguments, using "go list" notation.  Within each
package, it replaces all imports of non-canonical packages by their
canonical name, introducing an import renaming if (heuristically)
necessary.

If a package comes from one of the -baddomains, and it has no import
comment, fiximports reports an error.  The error message includes the
list of packages that import the errant package, directly or
indirectly.  This flag is used to indicate "sinking ship" package
hosting domains like code.google.com.

Caveat: this process is not trivially reversible.  Consider a package A
to which we add an import comment "B", and run the tool.  Package C,
which imported A, now imports B.  ('go get -u' would fetch package B).
But changing the import comment in directory A and re-running the tool
will not cause C to be changed because it no longer imports A; it
imports B.

+ Tests.

Change-Id: I3d3d9663d3c084356fffc7e55407709ebc6d9a39
Reviewed-on: https://go-review.googlesource.com/8562
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-05-13 15:07:09 +00:00
Alan Donovan
d1b42377f9 cmd/oracle: improve error messages
Also, in Emacs, make 'referrers' query not prompt for a scope.

Change-Id: I5c0f034d4fa8b653311f1b7d8ff58b699d168b79
Reviewed-on: https://go-review.googlesource.com/9927
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-05-13 15:02:11 +00:00
Alan Donovan
5df6d9290d go/ssa/interp: remove hash/crc32 from test suite, since it uses Examples
Change-Id: Ia87b7f6d589cd22028b437a94355f499fbedd18a
Reviewed-on: https://go-review.googlesource.com/9928
Reviewed-by: Alan Donovan <adonovan@google.com>
2015-05-12 17:41:59 +00:00
Alan Donovan
d00f0cb57d cmd/oracle: emacs: look for oracle on $PATH and nowhere else
Change-Id: Ifbc8e3ff6fe22a56e29fe7ba8004510cb0cee343
Reviewed-on: https://go-review.googlesource.com/9687
Reviewed-by: Dominik Honnef <dominik@honnef.co>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-05-08 16:30:11 +00:00
Alan Donovan
fb47c16287 go/buildutil: fix usage message for -tags flag
Now:

% gorename -h
Usage of ./gorename:
...
  -tags build tags
        a list of build tags to consider...

Change-Id: I46d6906f683407bad6f3dee25c63b139f47e4588
Reviewed-on: https://go-review.googlesource.com/9655
Reviewed-by: Dominik Honnef <dominik@honnef.co>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-05-08 14:48:23 +00:00
Rob Pike
96f6cfbb92 cmd/cover: document that it is moving to the standard repository
Change-Id: I876afaa2c468f0f6f5d30bff8bc884e3beb33c7f
Reviewed-on: https://go-review.googlesource.com/9539
Reviewed-by: Minux Ma <minux@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-05-01 00:38:25 +00:00
Alan Donovan
8ff1f51a5b cmd/oracle: expect oracle binary beneath $GOBIN, $GOPATH/bin, or $GOROOT/bin
in that order, so that "go get golang.org/x/tools/cmd/oracle" installs
it and no copy is needed.  We keep the old location for compatibility.

Why is if/else control flow so hard in basic Lisp?  Sometimes you just need 'return'.

Change-Id: Iae231a761d707daaa1316161cfad0365111eff0e
Reviewed-on: https://go-review.googlesource.com/9547
Reviewed-by: David Chase <drchase@google.com>
2015-04-30 19:31:40 +00:00
Alan Donovan
6a8dc4ed40 oracle: report a better error if query is outside GOROOT/GOPATH
Change-Id: I2f724b5015021be8bf1fccb518f17cc011d687e8
Reviewed-on: https://go-review.googlesource.com/9546
Reviewed-by: David Chase <drchase@google.com>
2015-04-30 18:55:42 +00:00
David Symonds
863c9c67a8 go/pointer: Remove a mention of the deleted ImportFromBinary option.
Change-Id: I9ca8a5b37afc6ae9603849d233ee6b4976e2b973
Reviewed-on: https://go-review.googlesource.com/9462
Reviewed-by: Alan Donovan <adonovan@google.com>
2015-04-29 01:29:12 +00:00
Dmitry Vyukov
7534f4943d x/tools/cmd/stress: add utility for stress testing
The stress utility is intended for catching of episodic failures.
It runs a given process in parallel in a loop and collects any failures.
Usage:
 	$ stress ./fmt.test -test.run=TestSometing -test.cpu=10
You can also specify a number of parallel processes with -p flag;
instruct the utility to not kill hanged processes for gdb attach;
or specify the failure output you are looking for (if you want to
ignore some other episodic failures).

Do you find it useful?
I use it for several years for all kinds of episodic failures (not just Go btw).

Change-Id: I06553345b76768a819412acb45f9bdfb3bababf7
Reviewed-on: https://go-review.googlesource.com/9373
Reviewed-by: Keith Randall <khr@golang.org>
2015-04-28 09:34:05 +00:00
Alan Donovan
a9f55c4fa4 oracle: support "referrers" query on package declaration
Added test.

Change-Id: Id7d061b0f74959166b5631a3fde8da4000ffb8d2
Reviewed-on: https://go-review.googlesource.com/9326
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-04-27 13:27:00 +00:00
chai2010
fb59b33999 godoc: add missing copyright
Change-Id: Ic0256b511b4d4346702aeac18298614b1e8d5438
Reviewed-on: https://go-review.googlesource.com/9384
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-04-27 04:29:37 +00:00
Alan Donovan
837a81a1b2 oracle: referrers: display the selected object relative to the current package
Added test.  (Its previous output was "references to type
referrers.s", with s package-qualified.)

Change-Id: Ifd70246bf5976d5f59ed85e7bbded618286ec6bc
Reviewed-on: https://go-review.googlesource.com/9294
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-04-23 20:44:32 +00:00
Alan Donovan
ee9a07d373 go/buildutil: TagsFlag provides a flag.Value for setting build.Context.BuildTags from -tags flag.
Add -tags flag to oracle, ssadump, callgraph, gomvpkg, gorename, eg.

Change-Id: I4a818501b2331c4ea589caca37a3ad9d381dc8af
Reviewed-on: https://go-review.googlesource.com/9172
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-04-23 14:10:21 +00:00
Josh Bleecher Snyder
b1aed1a596 cmd/vet: add arm64 asmdecl support
Change-Id: I5ab54616488bc9bc41aefb27b45d72c36fc4fbde
Reviewed-on: https://go-review.googlesource.com/9211
Reviewed-by: Rob Pike <r@golang.org>
2015-04-22 01:25:24 +00:00
Alan Donovan
bc61fa75b3 go/ssa: acquire TestEnclosingFunction from go/loader package.
Not sure how it ended up there...

Change-Id: I0d48025fd6595714b0c52cadf305b3e06e2b9b84
Reviewed-on: https://go-review.googlesource.com/9171
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-04-21 16:27:33 +00:00
Alan Donovan
41d9a0e7b2 go/loader: rename Example functions to appease godoc
And other minor cosmetic tweaks.

Change-Id: Ic75d405e6eca8f29b7e97de66fb86f1f39bcae1e
Reviewed-on: https://go-review.googlesource.com/9035
Reviewed-by: Robert Griesemer <gri@golang.org>
2015-04-17 19:40:02 +00:00
Alan Donovan
9c57c19a58 go/loader: eliminate ImportFromBinary option and PackageCreated hook
The loader package now loads, parses, and type-checks a whole program
from source, and that is all.

Also:
- simplified loader logic
- ssa.Create is gone; use ssautil.CreateProgram.
- ssautil.LoadPackage renamed to BuildPackage.
  It is now independent of go/types' Import hook and the Packages map.
- ssadump: -importbin flag removed.
  The value of this flag was that it caused the tool to print IR
  for only a single package; this is now the normal behaviour.

Fixes #9955

Change-Id: I4571118258ab1a46dccece3241b7dc51401a3acc
Reviewed-on: https://go-review.googlesource.com/8953
Reviewed-by: Robert Griesemer <gri@golang.org>
2015-04-17 18:58:17 +00:00
Alan Donovan
1b6275a2ec go/loader: API examples
Also: make it easier to find packages.  Hide the importMap field
(never used) and expose a (*Program).Package method which searches
importMap and then Created.

Also: move huge comments into doc.go.

Change-Id: Iad96a12524b7c41ad9acd1e806af23171e71fa7c
Reviewed-on: https://go-review.googlesource.com/9030
Reviewed-by: Robert Griesemer <gri@golang.org>
2015-04-17 18:50:18 +00:00
Alan Donovan
77d380c9e6 go/gcimporter: populate (*types.Package).Imports
All importers should populate the set of imported packages.  In Go 1.5
importer API, there will be no package map from which to compute the
transitive closure of dependencies, and SSA package creation needs
this information.

+ test.

Change-Id: I1c2823b07bf7316aa62c80e2ef2a0755cf6f5384
Reviewed-on: https://go-review.googlesource.com/8924
Reviewed-by: Robert Griesemer <gri@golang.org>
2015-04-15 18:12:10 +00:00
Alan Donovan
20186168d5 go/ssa/ssautil: break ssa->loader dependency
Remove all dependencies from non-test code in go/ssa to go/loader,
except the deprecated Create function which will be eliminated in
favor of ssautil.CreateProgram in a mechnanical followup.

Add Examples of two main use cases of SSA construction:
loading a complete program from source; and
building a single package, loading its dependencies from import data.

Add tests to ssautil of the two load functions.
Suggestions welcome for better names.

Planned follow-ups:
- replace all references to ssa.Create with ssautil.CreateProgram and eliminate it.
- eliminate support in go/loader for the ImportBinary flag, and the
  PackageCreated hook which is no longer needed since clients can
  create the package themselves (see Example).

Step 1 to fixing issue 9955.

Change-Id: I4e64df67fcd5b7f0c0388047e06cea247fddfec5
Reviewed-on: https://go-review.googlesource.com/8669
Reviewed-by: Robert Griesemer <gri@golang.org>
2015-04-14 18:01:36 +00:00
Robert Griesemer
14c815ee28 cmd/vet: remove (another) dependency on go/astutil
Missed this in a prior change.

Change-Id: I7358c17b73a1221cb8f9dff6b808fdea8b13ec06
Reviewed-on: https://go-review.googlesource.com/8916
Reviewed-by: Rob Pike <r@golang.org>
2015-04-14 16:22:22 +00:00
Robert Griesemer
850ba653f7 Revert "cmd/vet: switch to go/types from std repo"
This reverts commit 5b72e8e9bb.

Change-Id: I75270045022d69444b7812f290cdd5861af13feb
Reviewed-on: https://go-review.googlesource.com/8915
Reviewed-by: Robert Griesemer <gri@golang.org>
2015-04-14 03:54:48 +00:00
Robert Griesemer
5b72e8e9bb cmd/vet: switch to go/types from std repo
Depends on https://golang.org/cl/8767/.

With this change, cmd/vet does not depend on x/tools anymore
and could be moved into the std repo if so desired.

Change-Id: Ia205c6e1a6a63eebb27776064e5c24491043b683
Reviewed-on: https://go-review.googlesource.com/8791
Reviewed-by: Rob Pike <r@golang.org>
2015-04-14 00:30:21 +00:00
Robert Griesemer
069d2f3bcb go/types, go/gcimporter: backport changes from std repo
This is a 1:1 backport of the following changes:

https://go-review.googlesource.com/8611
https://go-review.googlesource.com/8621

Change-Id: I4a75d73cb99a7d104d32553f5530408c2b6d81b8
Reviewed-on: https://go-review.googlesource.com/8629
Reviewed-by: Alan Donovan <adonovan@google.com>
2015-04-08 18:15:25 +00:00
Robert Griesemer
bf8b6a5c4c go/types: reenable disabled test (backport from std repo go/types)
Change-Id: I93a914dcfc5bd2cfa8078cec683a46225b665e44
Reviewed-on: https://go-review.googlesource.com/8626
Reviewed-by: Alan Donovan <adonovan@google.com>
2015-04-08 16:31:48 +00:00