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>
And add a TODO.
Change-Id: I51c63b32e9ac4309cdfb8228348a5d528f36a919
Reviewed-on: https://go-review.googlesource.com/10489
Reviewed-by: Robert Griesemer <gri@golang.org>
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.
Fixesgolang/go#10972.
Change-Id: Id1efb60d399f0062d870e925138aa827e12f3e58
Reviewed-on: https://go-review.googlesource.com/10453
Reviewed-by: Alan Donovan <adonovan@google.com>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
And other minor cosmetic tweaks.
Change-Id: Ic75d405e6eca8f29b7e97de66fb86f1f39bcae1e
Reviewed-on: https://go-review.googlesource.com/9035
Reviewed-by: Robert Griesemer <gri@golang.org>
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>
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>
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>
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>
Missed this in a prior change.
Change-Id: I7358c17b73a1221cb8f9dff6b808fdea8b13ec06
Reviewed-on: https://go-review.googlesource.com/8916
Reviewed-by: Rob Pike <r@golang.org>
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>
This package was only imported for the trivial Unparen function.
Change-Id: I0ead916a7fdb469a26b4fe99c6964a8ed1438c49
Reviewed-on: https://go-review.googlesource.com/8566
Reviewed-by: Rob Pike <r@golang.org>
Currently, if for some reason http.ListenAndServe fails, any running
running godoc processes don't get killed. I don't think this would ever
actually happen because, with godoc being set up in a separate go
routine, http.ListenAndServe would always(?) fail before the godoc
server started.
This change ensures that, if a Proxy has a cmd, it is closed when
http.ListenAndServe fails.
Change-Id: I0d3bfae0c16bc583248c2052a4d7a84c95127e76
Reviewed-on: https://go-review.googlesource.com/8570
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
...otherwise the interpreted program can make the whole test suite
slow. Just ignore the argument and return the current GOMAXPROCS
value.
Change-Id: Ife2ad6c53e6fdf9feea1d1b231d8d796b3db3a24
Also: add missing intrinsic for os.runtime_beforeExit.
Reviewed-on: https://go-review.googlesource.com/8591
Reviewed-by: Robert Griesemer <gri@golang.org>
Such errors include files without package decl, or conflicting package
decls. We ignore type errors, so we should ignore import errors too.
Fixes#10347
Change-Id: I9011a9099a2804281ea2d989d7263a9ce691be16
Reviewed-on: https://go-review.googlesource.com/8498
Reviewed-by: David Crawshaw <crawshaw@golang.org>
This package was only imported for the trivial Unparen function.
Change-Id: I14f8d91bc0afaa6ab3aa797a53e42e56b59ffcbe
Reviewed-on: https://go-review.googlesource.com/8499
Reviewed-by: Alan Donovan <adonovan@google.com>
This makes type-based queries faster and more robust because they
needn't invoke a C compiler, at the cost of worse results in/near .go
files that import "C". It's particularly important for "referrers"
since a refererrs query on a name from the standard library can load
every package in the workspace.
Fixes issue 10347
Change-Id: I2f65474ce963de5c0897ba67eeb26290dd449cf1
Reviewed-on: https://go-review.googlesource.com/8493
Reviewed-by: David Crawshaw <crawshaw@golang.org>
This is a putative fix for the file descriptor exhaustion problem
described in https://github.com/golang/go/issues/10306.
Change-Id: If603fb9bbaec1b53f6b44d15b2c202e4670035ce
Reviewed-on: https://go-review.googlesource.com/8421
Reviewed-by: Matt Joiner <anacrolix@gmail.com>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
This peculiar case arose in range statements but there are other contexts
and one turned up in the auto-generated translation of the compiler.
Take care of it always.
for i := 0; i < 0; func() {i++; q=q.Link}() { ... }
That code has been given the obvious rewrite but we should still handle it.
Odd but easy to fix (tricky to test).
Fixes#10269.
Change-Id: I66e1404eb24da15a24be7f67403e19ed66fba0a7
Reviewed-on: https://go-review.googlesource.com/8284
Reviewed-by: Robert Griesemer <gri@golang.org>
Added test case. This required making the result sort order
deterministic when the results are spread across several packages.
Also: implements: print type names relative to query package.
Updated tests.
Change-Id: I9f882cd358a612585a4aac9a117b89d9131a294e
Reviewed-on: https://go-review.googlesource.com/8283
Reviewed-by: David Crawshaw <crawshaw@golang.org>