The 'fmtImportEl' option lets the called specify a checkbox element
that determines whether to send the 'imports=true' key/value pair when
calling '/fmt'.
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/43240043
Ensure that we do not split UTF-8 rune in half.
Otherwise appengine python scripts will break badly.
R=adg, r
CC=golang-dev
https://golang.org/cl/42530043
This fixes a case where adding an import when there are is no
existing import declaration can corrupt the position of
comments attached to types. This was the last known
goimports/astutil corruption case.
See golang.org/issue/6884 for more details.
Unfortunately this requires changing the API to add a
*token.FileSet, which we should've had before. I will update
goimports (the only user of this API?) immediately after
submitting this.
This CL also contains a hack (used only in this case of no
imports): rather than fix the comment positions by hand
(something that only Robert might know how to do), it instead
just prints the AST, manipulates the source, and re-parses
the AST. We can fix up later.
Fixesgolang/go#6884
R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/38270043
By using a simple (graph-based) serialization algorithm
and binary encoding, a significantly more compact export
data format is achieved than what the current compilers
use. Furthermore, the exporter and importer are completely
symmetric algorithms that are compact, and much easier to
change/expand.
R=adonovan
CC=golang-dev
https://golang.org/cl/42960043
Not for Go 1.2. Still needs a flag.
Linux at least (and likely other OSes) don't like you doing
a few hundred readdirs at once and spawing as many threads.
R=golang-dev, adg, jeremyjackins
CC=golang-dev
https://golang.org/cl/30620043
Command set:
- what: an extremely fast query that parses a single
file and returns the AST stack, package name and the
set of query modes that apply to the current selection.
Intended for GUI tools that need to grey out UI elements.
- definition: shows the definition of an identifier.
- pointsto: the PTA features of 'describe' have been split
out into their own command.
- describe: with PTA stripped out, the cost is now bounded by
type checking.
Performance:
- The importer.Config.TypeCheckFuncBodies predicate supports
setting the 'IgnoreFuncBodies' typechecker flag on a
per-package basis. This means we can load dependencies from
source more quickly if we only need exported types.
(We avoid gcimport data because it may be absent or stale.)
This also means we can run type-based queries on packages
that aren't part of the pointer analysis scope. (Yay.)
- Modes that require only type analysis of the query package
run a "what" query first, and restrict their analysis scope
to just that package and its dependencies (sans func
bodies), making them much faster.
- We call newOracle not oracle.New in Query, so that the
'needs' bitset isn't ignored (oops!). This makes the
non-PTA queries faster.
Also:
- removed vestigial timers junk.
- pos.go: existing position utilties split out into own file.
Added parsePosFlag utility.
- numerous cosmetic tweaks.
+ very basic tests.
To do in follow-ups:
- sophisticated editor integration of "what".
- better tests.
- refactoring of control flow as described in comment.
- changes to "implements", "describe" commands.
- update design doc + user manual.
R=crawshaw, dominik.honnef
CC=golang-dev, gri
https://golang.org/cl/40630043
Obviously in that mode, we can't correctly diagnose such
errors, so we shouldn't attempt it (and emit false positives).
R=gri
CC=golang-dev
https://golang.org/cl/41080043
When fetching repos it is not uncommon for a 500 or 503 to be returned
from code.google.com. When this happens, log the error and continue so
that we try again later, rather than treating this as fatal.
R=adg, dvyukov
CC=golang-dev
https://golang.org/cl/38720044
This improves both performance (most calls are static) and
precision (e.g. for static calls in dead code).
Also, break callees() function into smaller ones.
R=crawshaw
CC=golang-dev
https://golang.org/cl/38740045
This avoids leaking nodeids into client code before the
analysis has had a chance to run the (forthcoming) constraint
optimizer, which renumbers them.
R=crawshaw
CC=golang-dev
https://golang.org/cl/39410043
This change is a really nasty hack to preserve the magic header
across requests. The nasty hack will go away once we refactor these
tests to use the new "appengine/aetest" package instead.
R=golang-dev, dvyukov
CC=golang-dev
https://golang.org/cl/39230043
Using a type containing a sync type directly
in a function call (whether as a receiver,
a param, or a return value) is an easy way
to accidentally copy a lock or other sync primitive.
Check for it.
The test as implemented does not provide 100%
coverage; see the discussion near the bottom of
testdata/copylock.go for shortcomings.
Fixesgolang/go#6729.
R=adg, r, dsymonds
CC=golang-dev
https://golang.org/cl/23420043
(Elminate premature abstraction.)
The test probes used Pointer!=nil for the "is pointerlike"
predicate. Now that Pointer is a struct, they check the type
of the expression, which is more accurate. Two probes on
non-pointerlike values have beem removed.
R=crawshaw
CC=golang-dev
https://golang.org/cl/38420043
New APIs:
(*BasicBlock).{Idom,Dominees,Dominates}
(*Function).DomPreorder
Messy but systematic refactoring of domNode:
- renamed "domInfo".
- embedded directly in BasicBlock, not as pointer. Block field removed.
- Level field removed; was unused.
- Working state of LT algorithm now in its own type.
{semi,parent,ancestor} fields moved into it.
- remaining fields made private; accessors added.
- use 32-bit ints for pre/postorder numbers.
- allocate LT working space (5 copies of fn.Blocks) contiguously.
dom.go is simpler but somewhat more verbose.
Also:
- we always build the domtree now---yet memory usage is down 5%.
- number the Recover block too.
- add sanity check for DomPreorder.
R=gri
CC=golang-dev
https://golang.org/cl/37230043
This allows the creation of URLs to lines of source code with a query
term highlighted without assuming godoc source code URL parameters.
Needed for interfacing with other source code viewing servers.
R=bradfitz
CC=golang-dev
https://golang.org/cl/34200043
Split the profile parsing code out of cmd/cover into
a reusable package, to support third-party coverage
tools.
R=golang-dev, r, adg
CC=golang-dev
https://golang.org/cl/36050045
This test generates a program that declares the constant
elements of an n*n Hilbert matrix, its inverse, and the
constant elements of the explicit product of the two.
The product should be the identity matrix; that check is
also expressed as a constant expression. Type-checking
verifies that the product is indeed the identity matrix
by asserting the result of the identity check (using the
assert built-in which is available for type-check tests).
The test is run for n = 5. Other values can be tested via
the -H flag, say: go test -run=Hilbert -H=100
The generated program can be written to a file for testing
the constant arithmetic of a compiler: go test -out=test.go
Because of the mathematically precise constant arithmetic
of go/types, this test should always succeed and is only
limited by the size of the matrix. It does run successfully
from n = 0 to values larger than 100.
The Hilbert matrix is famous for being ill-conditioned and
thus exposes arithmetic imprecision very quickly. The gc
compiler only produces a correct result for n = 0 (trivially),
and n = 1 at the moment.
R=adonovan, rsc
CC=golang-dev
https://golang.org/cl/35840043