1
0
mirror of https://github.com/golang/go synced 2024-11-18 14:54:40 -07:00
Commit Graph

3752 Commits

Author SHA1 Message Date
Alan Donovan
06a43b8a0c go.tools/ssa: fix regression in x<<y logic from CL 11011043
Details:
- reintroduce interp.asUint64: it's not sound to use only the
  low 32 bits of y, which is what asInt gives us, when GOARCH=386.
- instead, emit a uint64 conversion when y is not unsigned
  (i.e. a signed var, or an untyped constant).

Tested on 386 & x86-64.

R=gri
CC=golang-dev
https://golang.org/cl/11023043
2013-07-09 10:21:25 -04:00
Andrew Gerrand
2b6515094c go.talks/cmd/cover: better color scheme and fonts
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/11032043
2013-07-09 16:58:15 +10:00
Alan Donovan
5da7e5a1a8 go.tools/ssa: give consistent positions for CanonicalPos(Literal).
(There are only seven ast.Expr types that can be constant.)

R=gri
CC=golang-dev
https://golang.org/cl/10766044
2013-07-08 18:02:50 -04:00
Alan Donovan
8846992823 go.tools/ssa: avoid redundant uint64 conversion of right operand of <<, >>.
Also: add sanity check that no Instruction yields a Value of 'untyped' type.

R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/11011043
2013-07-08 17:33:51 -04:00
Robert Griesemer
1aa0484f4b go.tools/go/types: report correct type for untyped conversion arguments
Fixes golang/go#5849.

R=adonovan
CC=golang-dev
https://golang.org/cl/11007043
2013-07-08 13:51:20 -07:00
Robert Griesemer
cc52b8b7f8 go.tools/go/types: clean up assignment checks (round 1)
Various bug fixes:
- don't allow := to redeclare non-variables
- don't permit a comma-ok expression as a two-value function return

Lots of dead code removed.

Fixes golang/go#5500.

R=adonovan
CC=golang-dev
https://golang.org/cl/10792044
2013-07-08 09:40:30 -07:00
Andrew Gerrand
a82eaff6b7 go.tools/cmd/cover: change color scheme and add legend
R=r, dsymonds
CC=golang-dev
https://golang.org/cl/10991043
2013-07-08 15:24:34 +10:00
Andrew Gerrand
00268482c0 go.tools/cmd/cover: use html/template for html generation
Also includes simple JavaScript dropdown picker.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/10838045
2013-07-06 16:58:50 +10:00
Andrew Gerrand
d9e6cbb135 go.tools/cmd/cover: use a gradient to colorize "count" profiles
R=r
CC=golang-dev
https://golang.org/cl/10858047
2013-07-05 13:53:09 +10:00
Robert Griesemer
4ca3d7e9da go.tools/go/types: remove defers from critical paths
Various minor cleanups.

R=adonovan
CC=golang-dev
https://golang.org/cl/10925043
2013-07-03 20:51:39 -07:00
Alan Donovan
1fa3f78146 go.tools/ssa: Function.Synthetic documents provenance of synthetic functions.
We use the new field to determine whether or not a function is
synthetic, not Pos() == 0, so synthetic functions can have
positions too.

R=gri
CC=golang-dev
https://golang.org/cl/10916044
2013-07-03 17:57:20 -04:00
Alan Donovan
3b6580d5b4 go.tools/ssa: remove workaround for missing go/types check, now fixed.
R=gri
CC=golang-dev
https://golang.org/cl/10921043
2013-07-03 17:54:55 -04:00
Alan Donovan
ea8ba6f45b go.tools/ssa: fix crash on 'select { case x, ok = <-ch: }' (= not :=).
Added test.

Also:
- abstracted Function.addLocalForIdent (9 calls).
- remove vestige of old typeswitch hack.
- specify and fix CallCommon.Signature() for calls to built-ins.

R=gri
CC=golang-dev
https://golang.org/cl/10884044
2013-07-03 15:10:49 -04:00
Alan Donovan
997111ba7d go.tools/importer: update comment (and absolve gri of blame) for non-bug.
R=gri
CC=golang-dev
https://golang.org/cl/10911044
2013-07-03 14:41:26 -04:00
Robert Griesemer
f052654314 go.tools/go/types: remove iota from all parameter lists (cleanup)
Instead of passing around iota everywhere, keep track of the
current value in the checker, and update it when entering
different declarations. This is less explicit, but the improvement
over all code is so significant that it is worth it.

R=adonovan
CC=golang-dev
https://golang.org/cl/10814044
2013-07-03 10:06:09 -07:00
Robert Griesemer
b58f98e9c2 go.tools/go/types: fix more cycle errors, lots of refactoring
- moved ident and typ expr checking into typexpr.go
- as a result, fewer parameters are needed for expr checking
- forward-chain type decls of the form type ( A B; B C; C *A) etc.
  so that cycles are getting the right types in all cases
- fixed several corner case bugs, added more test cases

R=adonovan
CC=golang-dev
https://golang.org/cl/10773043
2013-07-02 16:39:30 -07:00
Alan Donovan
6ae930a01c go.tools/ssa: some renamings.
- Prog.Files -> Fset
- Prog.Packages -> PackagesByPath
- Prog.Builtins -> builtins
- Package.Types -> Object

R=gri
CC=golang-dev
https://golang.org/cl/10748043
2013-07-01 15:24:50 -04:00
Alan Donovan
c24b2413c0 go.tools/ssa: use go/types.LookupFieldOrMethod, and simplify.
Added tests.

R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/10830043
2013-07-01 15:17:36 -04:00
Andrew Gerrand
98e8131132 go.tools/cmd/vet: add image.Uniform to untagged literal white list
R=nigeltao
CC=golang-dev
https://golang.org/cl/10817043
2013-07-01 12:42:08 +10:00
Rob Pike
78efac5f33 go.tools/cmd/cover: yet another attempt at a usage message (YAAAAUM) for go tool cover
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/10710044
2013-06-27 14:48:27 -07:00
Robert Griesemer
69c297407f go.tools/go/types: fix nil assignment
Fixes golang/go#5800.

R=adonovan
CC=golang-dev
https://golang.org/cl/10709044
2013-06-27 13:26:13 -07:00
Robert Griesemer
a0160af20b go.tools/go/types: tests for cycles in type decls
Fixed one aspect of issue 5090. Fixing it completely
requires a bit more work around the representation of
interface types.

R=adonovan
CC=golang-dev
https://golang.org/cl/10678045
2013-06-27 12:43:20 -07:00
Rob Pike
b52f745c3a go.tools/cmd/cover: delete TODO that is NOWDONE
R=adg
CC=golang-dev
https://golang.org/cl/10505044
2013-06-27 09:20:34 -07:00
Robert Griesemer
feb0ab2b10 go.tools/go/types: -files flag for testing one-off packages
Removed special case for testdata/test.go file in favor of
a simpler, more flexible, and explicit flag for one-off test
packages.

R=adonovan
CC=golang-dev
https://golang.org/cl/10618044
2013-06-26 13:01:16 -07:00
Alan Donovan
86b0a65b65 go.tools/ssa: emit ChangeType when using method as function in f := T.meth.
Previously: typeOf(f).Signature.Recv == T
       Now: typeOf(f).Signature.Params.At(0) == T

Added test.

BUG=5781

R=gri
CC=golang-dev
https://golang.org/cl/10622043
2013-06-26 13:18:31 -04:00
Alan Donovan
b68a029040 go.tools/ssa: un-export Function.FullName. Use String.
R=gri
CC=golang-dev
https://golang.org/cl/10604044
2013-06-26 12:38:08 -04:00
Robert Griesemer
22b7915ff5 go.tools/go/types: factored out code for calls and selectors
No other changes.

R=adonovan
CC=golang-dev
https://golang.org/cl/10573043
2013-06-25 15:40:28 -07:00
Robert Griesemer
25da72adcd go.tools/go/types: initialize local x early in case of bailout panic
- added respective test case

Fixes golang/go#5770.

R=adonovan
CC=golang-dev
https://golang.org/cl/10531043
2013-06-24 21:29:47 -07:00
Robert Griesemer
124e603d87 go.tools/go/types: imported structs may contain _ fields
Don't report import errors due to (multiple) _ fields
in imported structs.

Fixes golang/go#5758.

R=adonovan
CC=golang-dev
https://golang.org/cl/10529043
2013-06-24 17:38:41 -07:00
Rob Pike
6740bb0838 go.tools/cmd/vet: delete the word "only" from a warning
No semantic change.

R=dsymonds, rsc
CC=golang-dev
https://golang.org/cl/10516043
2013-06-24 12:56:35 -07:00
Rob Pike
40caf1ff72 go.tools/cmd/cover: better usage message
R=adg, rsc
CC=golang-dev
https://golang.org/cl/10453044
2013-06-24 12:56:25 -07:00
Robert Griesemer
c13bb422de go.tools/go/types: fix nil-ptr deref in gcimporter
Also: Make error handling more explicit.

Possibly a fix for issue 5758.

R=adonovan
CC=golang-dev
https://golang.org/cl/10520043
2013-06-24 11:49:02 -07:00
Alan Donovan
8097dad724 go.tools/ssa: Select now returns received values by tuple, not interface.
Before, all values received on some channel by Select would
flow to an empty interface, creating a spurious confluence for
flow analyses.  Now, the tuple returned by Select has one
component for each 'receive' case.

Also, fixes:
- Removed workarounds for now-fixed typechecker bug in FuncLit+TypeAssert.
- sanity check that all Value Instructions have non-nil Type().
- Convert: document and sanity-check that at least one of the types is basic.

Also, other things to help clients:
- Define CallInstruction interface: common parts of Call, Go, Defer.
- Add CallCommon.Signature() method.
- Literal.Pos() is now populated.

R=gri
CC=golang-dev
https://golang.org/cl/10505043
2013-06-24 14:15:13 -04:00
Robert Griesemer
bd55eef6ec go.tools/go/types: handle p.x with p of type P *S
R=adonovan
CC=golang-dev
https://golang.org/cl/10459044
2013-06-24 09:58:27 -07:00
Robert Griesemer
cf8ec1591f go.tools/go/exact: more consistent handling of unknown values
R=adonovan
CC=golang-dev
https://golang.org/cl/10431046
2013-06-21 19:56:40 -07:00
Rob Pike
78d364c43e go.tools/cmd/cover: fix build
Need the ./ for the path. Quick fix to get the build green, but what really is the right answer for Windows?

R=golang-dev
CC=golang-dev
https://golang.org/cl/10359044
2013-06-21 14:47:04 -07:00
Rob Pike
c28528d489 go.tools/cmd/cover: add a test
Test the statistics work as expected for a simple program, which can be extended as needed. This is all a bit meta.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/10392050
2013-06-21 14:35:09 -07:00
Robert Griesemer
628104465d go.tools/go/types: fix logic error in MissingMethod and type assert code
R=adonovan
CC=golang-dev
https://golang.org/cl/10448046
2013-06-21 14:30:47 -07:00
Rob Pike
decfd079c5 go.tools/cmd/cover: skip mode line (first line of profile)
Still to do: use the mode to affect how to present the data.

R=adg, rsc
CC=golang-dev
https://golang.org/cl/10364050
2013-06-21 14:19:57 -07:00
Robert Griesemer
0325defab0 go.tools/go/types: factor method set and lookup better
No functional change, just symmetric cleanup.

R=adonovan
CC=golang-dev
https://golang.org/cl/10417045
2013-06-21 13:19:41 -07:00
Rob Pike
331c428e76 go.tools/cmd/vet: add check for shadowed variables
Experimental feature. It's too noisy yet to be enabled by default,
so it must be enabled explicitly by
        go tool vet -shadow *.go
or
        go tool vet -shadow directory
(The go command does not know about the -shadow flag.)

Fixes golang/go#5634.

R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/10409047
2013-06-21 11:27:53 -07:00
Robert Griesemer
2d345c1dd7 go.tools/go/types: improved LookupFieldOrMethod, ast.Nodes for Scopes
- LookupFieldOrMethod now computes if any indirection was found on the
  way to an embedded field/method: this is the only information required
  to determine if a result method is in the method set.

- Scopes now provide a link to the ast.Node responsible for them.

Also:
- don't permit unsafe.Offsetof on method values
- report ambiguities in field/method lookup errors
- added some missing checks for anonymous fields
- lots of new tests

Fixes golang/go#5499.

R=adonovan
CC=golang-dev
https://golang.org/cl/10411045
2013-06-21 08:57:26 -07:00
Robert Griesemer
9ff248b00d go.tools/go/types: simplified lookup
- much simpler lookup
- more result information
- will make tracking of pointer-ness easier

TODO: apply the same changes to method set computation

R=adonovan
CC=golang-dev
https://golang.org/cl/10379049
2013-06-19 12:29:17 -07:00
Rob Pike
33ae2b030f go.tools.cmd/cover: define a block to end at the closing brace rather than last statement
Makes for prettier output in many cases.

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/10360049
2013-06-19 09:11:32 -07:00
Robert Griesemer
d338982a64 go.tools/go/types: use qualified names when printing types in errors
Also: Require that clean package paths are not ".".

R=adonovan, r
CC=golang-dev
https://golang.org/cl/10368047
2013-06-18 16:41:11 -07:00
Robert Griesemer
9a50e157b4 go.tools/go/types: first cut at sorted method sets
- moved single field and method lookup functionality
  from operand.go to new file lookup.go and cleaned
  up the lookup implementation

- implemented method set computation using the same
  basic structure as for field/method lookup, in new
  file methodset.go

- minor related changes

- the method set computation ignores pointer-ness of
  the receiver type at the moment (next CL)

- fixed a couple of bugs (missing pkg info for imported
  embedded types, wrong test for method expressions)

The method set computation is currently verified by
comparing a regular method lookup with a method-set
based method lookup.

R=adonovan
CC=golang-dev
https://golang.org/cl/10235049
2013-06-18 15:59:16 -07:00
Robert Griesemer
7517d8bae3 go.tools/go/types: catch cycles in function declarations
Fixes golang/go#5217.

R=adonovan
CC=golang-dev
https://golang.org/cl/10402044
2013-06-18 15:34:12 -07:00
Rob Pike
86c0ff156c go.tools/cmd/vet: set the package name unconditionally
A better fix than the one in CL 10400044

R=gri
CC=golang-dev
https://golang.org/cl/10376044
2013-06-18 14:12:51 -07:00
Rob Pike
ce82fb0e23 go.tools/cmd/vet: use directory for pkg.path if path is "."
Before:
        math/big/nat_test.go:688: arg r for printf verb %s of wrong type: ..Word
After:
        math/big/nat_test.go:688: arg r for printf verb %s of wrong type: big.Word

R=gri
CC=golang-dev
https://golang.org/cl/10400044
2013-06-18 14:02:01 -07:00
Rob Pike
df787c2073 go.tools/cmd/vet: check for missing printf verb
A trailing % resulted in a bad error message.
Also clean up a couple of dregs left over from the
refactoring to add indexed formats.

R=dsymonds
CC=golang-dev
https://golang.org/cl/10336044
2013-06-18 08:21:06 -07:00