The parser may return error positions referring to positions
immediately after rather than at a token position. Provide
mechanism to identify those positions in test cases.
Also: Don't compute position strings for each token in test
cases. Should speed up Check test.
Pending CL 70190046 in main repo.
LGTM=adonovan
R=adonovan
CC=golang-codereviews
https://golang.org/cl/71330043
(On Windows the two are not the same.)
Fixesgolang/go#7189.
Also: remove exception for code.google.com subtree; this was
an artifact of my unusual setup.
LGTM=gri
R=alex.brainman, gri
CC=golang-codereviews
https://golang.org/cl/70060048
The old code was misleading in saying how many args were present.
Change the wording of the message to be unambiguous and change
the presentation of the format to include the full directive, making
it easier to correlate with the input (and fixing a silent bug).
Fixesgolang/go#6248.
LGTM=dsymonds
R=golang-codereviews, dsymonds
CC=golang-codereviews
https://golang.org/cl/69120044
Before, they were named func@line:col which made them easy to find in the source if you know the file, but hard if you don't, and it made tests fragile.
Now, they are named outer$1, outer$2, etc, which makes them
more informative in a UI since "outer" has meaning.
LGTM=crawshaw
R=crawshaw
CC=golang-codereviews
https://golang.org/cl/65630048
This is to avoid an internal error in pointer analysis from
bringing down a long-lived application such as godoc.
LGTM=crawshaw
R=crawshaw
CC=golang-codereviews
https://golang.org/cl/68930046
An identifier X in anonymous struct field struct{X} is both a
definition of a field (*Var) and reference to a type
(*TypeName). Now that we have split the map, we can capture
both of these aspects.
Interestingly, every client but one was going to extra effort
to iterate over just the uses or just the defs; this
simplifies them.
Also, fix two bug related to tagless switches:
- An entry was being recorded in the Object map for a piece of
synthetic syntax.
- The "true" identifier was being looked up in the current scope,
which allowed perverse users to locally redefine it. Now
we use the bool (not untyped boolean) constant true, per the
consequent clarification of the spec (issue 7404).
+ tests.
Fixesgolang/go#7276
LGTM=gri
R=gri
CC=golang-codereviews
https://golang.org/cl/68270044
How it handles packages vs. directories vs. files was not explained.
LGTM=rsc
R=golang-codereviews, gobot, rsc
CC=golang-codereviews
https://golang.org/cl/67150043
Update golang/go#7372
This slipped into the build in revision 4b4229fc616b.
Thanks to @pierredurand87 for noticing the break.
LGTM=bgarcia
R=golang-codereviews, bgarcia
CC=golang-codereviews
https://golang.org/cl/66670043
If a -pos argument is specified, a 'callgraph' query reports only the
functions within the query package. This produces a far more manageable
amount of information, and because we don't need to package-qualify the
names, the result is easier to read.
Added tests:
- callgraph query with/without -pos
(The test driver was extended to allow "nopos" queries.)
- callers and callees queries don't return wrappers
Also, in go/callgraph:
- (*Node).String, (*Edge).String
- (*Graph).DeleteSyntheticNodes eliminates synthetic wrapper functions,
preserving topology. Used in all four oracle "call*" queries.
- (*Graph).DeleteNode
LGTM=crawshaw
R=crawshaw
CC=golang-codereviews
https://golang.org/cl/66240044
- clearer separation between package-level and object-level state
- lazy allocation of various package-level maps
- NewPackage automatically allocates a package scope
- steps towards enabling incremental checking of extra (test) files
after the (non-test) package is type-checked (not yet exposed)
LGTM=adonovan
R=adonovan
CC=golang-codereviews
https://golang.org/cl/66230044
1) We remove context sensitivity from API. The pointer analysis is
not sufficiently context-sensitive for the context information to
be worth exposing. (The actual analysis precision still benefits
from being context-sensitive, though.) Since all clients would
discard the context info, we now do that for them.
2) Make the graph doubly-linked. Edges are now shared by the Nodes
at both ends of the edge so it's possible to navigate more easily
(e.g. to the callers).
3) Graph and Node are now concrete, not interfaces.
Less code in every file!
LGTM=crawshaw
R=crawshaw
CC=golang-codereviews
https://golang.org/cl/66460043
Previously, each {Indirect,}Query would return a set of Pointers, one per context; now it returns (at most) one Pointer combining information from all contexts.
The old API was more faithful to the implementation concepts, but the analysis is not sufficiently context-sensitive that it makes sense: all existing clients simply throw away the context information---so now we do that for them.
(I may remove the context-sensitivity from the callgraph too, but I'll benchmark that first to see if it reduces precision.)
LGTM=crawshaw
R=crawshaw
CC=golang-codereviews
https://golang.org/cl/66130044
- pre-poluate typIndex and typList using a predefined list of types
- no need to handle basic types explicitly anymore
- removed basicTag
- go/types: exported UniverseByte and UniverseRune for now
LGTM=adonovan
R=adonovan
CC=cmang, golang-codereviews
https://golang.org/cl/65920044
benchcmp now preserves benchmark order. This restores the original
misc/benchcmp behavior. This also makes the output of benchcmp stable,
and groups together multiple -cpu results.
Magnitude-based sorting is still available via the -mag flag.
It is useful for surfacing items of note (particularly changes
in allocs) when making compiler changes and running broad
benchmarks.
Fixesgolang/go#7259.
LGTM=dave
R=dave, mtj
CC=bradfitz, dvyukov, golang-codereviews
https://golang.org/cl/60840045
If this flag is set, (*Config).Load will not return an
error even if some packages had type errors. Each individual
PackageInfo can be queried for its error state, now exposed as
TypeError.
In addition, each PackageInfo exposes whether it is
"transitively error-free". ssa.Create skips packages without
this flag since it is required for SSA construction.
+ Test.
LGTM=gri
R=gri
CC=golang-codereviews
https://golang.org/cl/62000045
Observation: not all alias facts are interesting.
- A channel-peers query also cares about pointers of kind chan.
- An oracle "points-to" query on an expression of kind map
only cares about maps.
- We always care about func, interface and reflect.Value,
since they're needed for sound analysis of dynamic dispatch.
We needn't bother collecting alias information for
uninteresting pointers, and this massively reduces the number
of labels flowing in to the constraint system.
The only constraints that create new labels are addressOf
and offsetAddr; both are now selectively emitted by type.
We compute the set of type kinds to track, based on the
{Indirect,}Query types. (We could enable tracking at an
even finer grain if we want.)
This requires that we can see all the {Indirect,}Query
value types a priori, which is not the case for the PrintCalls
mechanism used in the tests, so I have rewritten the latter
to use {Indirect,}Query instead.
This reduces the solver-phase time for the entire standard
library and tests from >8m to <2m. Similar speedups are
obtained on small and medium-sized programs.
Details:
- shouldTrack inspects the flattened form of a type to see if
it contains fields we must track. It memoizes the result.
- added precondition checks to (*Config).Add{,Indirect}Query.
- added (*ssa.Program).LookupMethod convenience method.
- added Example of how to use the Query mechanism.
- removed code made dead by a recent invariant:
the only pointerlike Const value is nil.
- don't generate constraints for any functions in "reflect".
(we had forgotten to skip synthetic wrappers too).
- write PTA warnings to the log.
- add annotations for more intrinsics.
LGTM=gri, crawshaw
R=crawshaw, gri
CC=golang-codereviews
https://golang.org/cl/62540043
Method Signatures (types.Signatures with a non-nil receiver) behave
like ordinary func Signatures in the hash function/equivalence relation
used by typemap.M, which leads to surprising incomplete traversal
over the type graph if an M is used to remember types already
visited.
This change avoids ever putting method Signatures in a typemap.
% go test -v code.google.com/p/go.tools/go/ssa
now repeatedly shows the exact same number of functions and
instructions.
(We should discuss how to avoid this problem more generally.)
Also:
- recur over the params/results of all the methods of
each type when computing necessary method sets.
- there's no longer any need to treat declarations of unexported
methods as a root for traversal. Added test case.
- enable SourceImports flag in stdlib_test, which was dropped
during a recent refactoring (d'oh).
- doc tweaks
LGTM=gri
R=gri
CC=golang-codereviews
https://golang.org/cl/65450043
This CL adds no-op stubs for intrinsics now required by tests:
runtime.Goexit
sync.runtime_Sem{acquire,release}
sync/atomic.AddUint{32,64}
Goexit needs more thought; for now I've disabled the interpreted
tests of the "testing" package to make the build green again.
TBR=gri
R=gri
CC=golang-codereviews
https://golang.org/cl/65480044
Allow builder owners to set CGO_ENABLED to override the logic in cmd/go
LGTM=minux.ma, adg
R=golang-codereviews, minux.ma, adg
CC=golang-codereviews
https://golang.org/cl/63570046
It will save a lot of time for slow builders running on slow SD cards.
LGTM=dave, adg
R=golang-codereviews, dave, adg
CC=golang-codereviews
https://golang.org/cl/63550043
These are the simplest possible descriptions of each command.
They may be fleshed out later.
Fixesgolang/go#7298.
LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/61480044
Don't say the word "fork" (not accurate), and remove the
tab/comment flags that were removed from gofmt.
LGTM=adg
R=golang-codereviews, adg
CC=golang-codereviews
https://golang.org/cl/61410052
- Add math.{Log,Ldexp} to externals
- Test now uses FromArgs
- Scan all initial packages for tests, don't assume Created[0] exists.
(It doesn't if we import a package that has only in-package tests.)
LGTM=gri
R=gri
CC=golang-codereviews
https://golang.org/cl/62010044