1
0
mirror of https://github.com/golang/go synced 2024-11-19 01:24:39 -07:00
Commit Graph

816 Commits

Author SHA1 Message Date
Rob Pike
6bd3206b1f go.tools/cmd/vet: allow checks to be disabled explicitly as well as set explicitly
Now we can say
        vet -printf=false
to disable the printf test but run all others.
Implemented by creating a tri-state boolean flag that records whether it has been
set explicitly; before this, -printf=false was not distinguishable from not having
mentioned the printf flag at all.

Fixes golang/go#7422.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/72330043
2014-03-07 16:02:49 +11:00
Rob Pike
95c9b7bad1 go.tools/cmd/vet: replace warnings by errors
Over time, a number of modules were added that used Warn instead of Bad
to report problems with the code, but the documentation states that
if there is a problem, the exit code must be 1, not 0. Warn does not set the
exit code and should be used only for internal errors and messages
triggered by the -v flag.

There's nothing substantive here except calling the other function in a few
places.

Fixes golang/go#7017.

LGTM=crawshaw
R=golang-codereviews, crawshaw
CC=golang-codereviews
https://golang.org/cl/71860044
2014-03-07 15:31:28 +11:00
Robert Griesemer
4f1c486d35 go.tools/go/types: towards permitting adding additional package files incrementally
Another small step towards resolving issue 7114.

LGTM=adonovan
R=adonovan
CC=golang-codereviews
https://golang.org/cl/72230043
2014-03-06 15:53:37 -08:00
Robert Griesemer
d14a9d31e6 go.tools/go/types: support for "soft" errors
Provide an extra field, "Soft" in types.Error.
A client may want to filter out soft errors and
only abort if there are "hard" errors.

Qualified a first set of errors as "soft".

Fixes golang/go#7360.

LGTM=adonovan
R=adonovan
CC=golang-codereviews
https://golang.org/cl/71800043
2014-03-05 15:19:38 -08:00
Robert Griesemer
5d3ec72759 go.tools/go/types: implement shadowed return parameter restriction
Also:
- slightly better error messages for return statements
- more AST validity checking of parameter lists
- use secondary error message for clarifying message in type switch errors

Fixes golang/go#7469.

LGTM=adonovan
R=adonovan
CC=golang-codereviews
https://golang.org/cl/71780044
2014-03-05 15:05:34 -08:00
Robert Griesemer
e3ab342481 go.tools/go/types: report correctly rounded constant values
Also:
- better documentation of exact.Float64Val
- minor rearrangement in go/importer (unrelated)

LGTM=adonovan
R=adonovan
CC=golang-codereviews
https://golang.org/cl/70200047
2014-03-05 10:23:33 -08:00
Robert Griesemer
fccaf8c467 go.tools/go/types: adjust tests for better parser error positions
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
2014-03-04 14:32:55 -08:00
Alan Donovan
5536d2ae3e go/loader: convert directory separators to slash when enumerating packages.
(On Windows the two are not the same.)

Fixes golang/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
2014-03-04 13:48:09 -05:00
Alan Donovan
53324e8992 go/ssa/interp: add syscall.Sysctl to Darwin.
This fixes a recent test breakge now that os.init calls it
(on Darwin).

LGTM=gri
R=gri
CC=golang-codereviews
https://golang.org/cl/68000048
2014-03-04 13:34:45 -05:00
Robert Griesemer
ddcdb3637a go.tools/go/types: built-in calls returning constants don't count as function calls
Fixes golang/go#7457.

LGTM=adonovan
R=adonovan
CC=golang-codereviews
https://golang.org/cl/69890052
2014-03-04 09:26:21 -08:00
Rob Pike
31c219bef7 go.tools/cmd/vet: change reporting of incorrect error count in Printf
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).
Fixes golang/go#6248.

LGTM=dsymonds
R=golang-codereviews, dsymonds
CC=golang-codereviews
https://golang.org/cl/69120044
2014-03-04 15:41:49 +11:00
Andrew Gerrand
744443b9dc go.tools/dashboard/app: silence solaris11 and dragonfly builders
LGTM=aram, minux.ma
R=minux.ma, jsing, ality, aram, 0intro
CC=golang-codereviews
https://golang.org/cl/69980045
2014-03-04 11:53:58 +11:00
David du Colombier
ec0de5a8bc go.tools/cmd/godoc: fix test on Plan 9
LGTM=bradfitz
R=minux.ma, bradfitz
CC=golang-codereviews
https://golang.org/cl/70610044
2014-03-02 19:34:05 +01:00
Alan Donovan
d503a640d7 go.tools/go/ssa: name anon funcs by their enclosing func.
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
2014-02-28 10:18:55 -05:00
Alan Donovan
c509cf123c go.tools/go/pointer: recover from panic in Analyse and return an error.
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
2014-02-27 14:13:52 -05:00
Robert Griesemer
d15a452238 go.tools/go/types: move new switch test case in the right place (cleanup)
LGTM=adonovan
R=adonovan
CC=golang-codereviews
https://golang.org/cl/69000047
2014-02-27 10:46:04 -08:00
Alan Donovan
ced954c167 go.tools/go/types: split Info.Objects map into Defs and Uses.
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.

Fixes golang/go#7276

LGTM=gri
R=gri
CC=golang-codereviews
https://golang.org/cl/68270044
2014-02-27 13:21:59 -05:00
Brad Garcia
aaca3a4f95 godoc: Remove bogus messages referring to "/target".
Fix package text display spacing.
Fixes golang/go#7395.

R=bradfitz, sameer
CC=golang-codereviews
https://golang.org/cl/68210043
2014-02-26 13:21:44 -05:00
Francesc Campoy
246da56072 go.tools/present: Remove formatting comments (HL, OMIT) from raw code.
LGTM=adg
R=adg
CC=golang-codereviews
https://golang.org/cl/68870043
2014-02-25 17:53:00 -08:00
Rob Pike
ee3eeefaa3 cmd/vet: check for nil result set in isStringer
Fixes golang/go#7149.

LGTM=gri
R=golang-codereviews, gri
CC=golang-codereviews
https://golang.org/cl/68260044
2014-02-24 11:39:42 -08:00
Rob Pike
cde4d316d2 go.tools/cmd/vet: docs: explain the command line interface better
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
2014-02-24 10:44:02 -08:00
Robert Griesemer
3ff8e6554d go/types: simplify tracking of side effects for len/cap
LGTM=adonovan
R=adonovan
CC=golang-codereviews
https://golang.org/cl/67190043
2014-02-24 10:14:33 -08:00
Dave Cheney
1c1af4be5d go.tools/dashboard/builder: fix imported by not used error
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
2014-02-22 13:24:39 +11:00
Brad Garcia
61bd98e5b3 godoc: Fix m=src URLs.
For source code links, prepend /src/pkg if not already prefixed.
Fixes golang/go#7383.

R=bradfitz, sameer
CC=golang-codereviews
https://golang.org/cl/67110043
2014-02-21 19:51:51 -05:00
Brad Garcia
0cf8ab65b2 godoc: identifiers can contain underscores, not spaces.
Fixes golang/go#7382.

R=bradfitz, sameer
CC=golang-codereviews
https://golang.org/cl/67090043
2014-02-21 19:51:15 -05:00
David du Colombier
29d0463c1c go.tools/oracle: fix TestOracle on Plan 9
LGTM=minux.ma
R=golang-codereviews, lucio.dere, gobot, minux.ma
CC=golang-codereviews
https://golang.org/cl/64400043
2014-02-21 21:53:57 +01:00
Alan Donovan
99b2441d95 go.tools/oracle: optionally restrict 'callgraph' query to a single package.
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
2014-02-21 10:46:02 -05:00
Alan Donovan
49eaa56ed1 go.tools/go/*: fix breakage caused by removal of types.NewPackage parameter.
(This fixes the build, but one test is failing.)

TBR=gri
R=gri
CC=golang-codereviews
https://golang.org/cl/66730043
2014-02-20 20:11:00 -05:00
Alan Donovan
01263f0a00 go.tools/go/ssa: fix breakage caused by removal of types.NewPackage parameter.
TBR=gri
R=gri
CC=golang-codereviews
https://golang.org/cl/66600045
2014-02-20 19:49:38 -05:00
Robert Griesemer
9111cead20 go.tools/go/types: internal cleanups
- 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
2014-02-20 14:52:21 -08:00
David du Colombier
374c600cae go.tools/cmd/vet: disable TestVet on Plan 9
LGTM=minux.ma
R=golang-codereviews, minux.ma
CC=golang-codereviews
https://golang.org/cl/64410043
2014-02-20 21:43:24 +01:00
Alan Donovan
829d52f2e8 go.tools/go/callgraph: simplifications to API.
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
2014-02-20 11:57:48 -05:00
Alan Donovan
28104d2c91 go.tools/go/pointer: remove context-sensitivity from API.
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
2014-02-20 11:35:09 -05:00
Brad Garcia
804b9654fe godoc: Fix dereference of nil *SearchResult.
Fixes golang/go#7364.

R=bradfitz
CC=golang-codereviews, sameer
https://golang.org/cl/66470044
2014-02-20 11:26:05 -05:00
Chris Manghane
fcad4a15d8 go.tools/dashboard/builder: Use git for gccgo builds instead of svn.
LGTM=adg
R=adg
CC=golang-codereviews
https://golang.org/cl/66090046
2014-02-19 16:32:41 -08:00
Alan Donovan
0eac03b836 go.tools/go/types: include import path in (*Package).String()
LGTM=gri
R=gri
CC=golang-codereviews
https://golang.org/cl/66120045
2014-02-19 17:55:30 -05:00
Robert Griesemer
9d6717b260 go.tools/go/importer: handle predeclared types consistently
- 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
2014-02-19 13:27:11 -08:00
Alan Donovan
aaa5866ea1 go.tools/go/loader: rename backdoor so only tests can use it.
Also: add copyright message.

LGTM=gri
R=gri
CC=golang-codereviews
https://golang.org/cl/64040044
2014-02-19 13:52:19 -05:00
Alan Donovan
03ca00ddd4 go.tools/go/types/typeutil: new package for type utilities.
Contains the members formerly known as:
- ssa.IntuitiveMethodSet
- typemap.M (now: Map)

LGTM=gri
R=gri
CC=golang-codereviews
https://golang.org/cl/65670043
2014-02-19 13:32:36 -05:00
Alan Donovan
42022f89d4 go.tools/go/loader: add file missing from rev ebef51b726fc
(CL https://golang.org/cl/62540043)

TBR=gri
R=gri
CC=golang-codereviews
https://golang.org/cl/65530046
2014-02-19 13:28:12 -05:00
Alan Donovan
0c9517ddba go.tools/go/pointer: assert that input program is complete.
Fixes golang/go#7257

LGTM=crawshaw
R=daniel.morsing, crawshaw
CC=golang-codereviews
https://golang.org/cl/65730045
2014-02-19 13:08:06 -05:00
Josh Bleecher Snyder
e8c291b808 go.tools/cmd/benchcmp: sort by original benchmark order by default
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.

Fixes golang/go#7259.

LGTM=dave
R=dave, mtj
CC=bradfitz, dvyukov, golang-codereviews
https://golang.org/cl/60840045
2014-02-19 07:44:49 -08:00
Alan Donovan
ed45af74ff go.tools/go/loader: add AllowTypeErrors flag.
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
2014-02-18 19:43:14 -05:00
Alan Donovan
5f96644dbf go.tools/pointer: opt: type-based label tracking reduces solver time by up to 75%.
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
2014-02-18 12:40:44 -08:00
Alan Donovan
675033b4f3 go.tools/go/ssa: fix nondeterministic computation of necessary method sets.
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
2014-02-18 12:39:29 -08:00
Alan Donovan
a75195d091 go.tools/go/ssa/interp: fix tests broken by recent runtime changes.
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
2014-02-18 15:37:24 -05:00
Francesc Campoy
ca8198c132 go.tools/playground: parse shebang correctly
Fixes golang/go#7321.

LGTM=adg
R=adg
CC=golang-codereviews
https://golang.org/cl/63560043
2014-02-18 09:44:12 -08:00
David du Colombier
0b0cd8b22c go.tools/dashboard/builder: use $home on Plan 9
LGTM=alex.brainman
R=golang-codereviews, lucio.dere, alex.brainman
CC=golang-codereviews
https://golang.org/cl/64520043
2014-02-16 17:40:50 +01:00
Dave Cheney
a565a4ff67 go.tools/dashboard/builder: respect CGO_ENABLED value from the environment
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
2014-02-16 20:43:00 +11:00
Shenghou Ma
ddb496edf3 go.tools/dashboard/builder: use "hg archive -t files -r REV dest" instead of "hg clone" for the work directory.
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
2014-02-13 20:50:29 -05:00