1
0
mirror of https://github.com/golang/go synced 2024-10-01 06:08:32 -06:00
Commit Graph

578 Commits

Author SHA1 Message Date
Josh Bleecher Snyder
866b24e166 cmd/vet: check for sync types being copied during function calls
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.

Fixes golang/go#6729.

R=adg, r, dsymonds
CC=golang-dev
https://golang.org/cl/23420043
2013-12-09 20:14:28 -08:00
Robert Griesemer
d6902b2ad5 go/tools/go/gcimporter: avoid possible endless loops in case of errors
R=adonovan
CC=golang-dev
https://golang.org/cl/39630045
2013-12-09 15:43:31 -08:00
Peter Collingbourne
7dcd8ded7c go.tools/go/types: handle embedded interfaces in NewInterface
R=gri
CC=golang-dev
https://golang.org/cl/39040043
2013-12-09 13:37:24 -08:00
Alan Donovan
fb3d862cae go.tools/importer: move PathEnclosingInterval to package astutil.
R=crawshaw
CC=golang-dev
https://golang.org/cl/38650044
2013-12-09 09:36:29 -05:00
Andrew Gerrand
55fb2e8e28 go.tools/dashboard/app: only accept commits when given master key
R=dvyukov, rsc
CC=golang-dev
https://golang.org/cl/37790044
2013-12-09 14:33:08 +11:00
Alan Donovan
6b75c15eec go.tools/pointer: replace Pointer, PointsToSet interfaces with their sole implementations.
(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
2013-12-06 12:52:04 -05:00
Brad Fitzpatrick
2d324f247c astutil: in test, dump AST before and after on failure
R=golang-dev, crawshaw
CC=golang-dev
https://golang.org/cl/37740043
2013-12-06 10:11:13 +04:00
Alan Donovan
7f8168b1d4 go.tools/pointer: allow clients to request both pts(v) and pts(*v) in the same analysis.
Also: add (ptset).String().

R=crawshaw
CC=golang-dev
https://golang.org/cl/36800044
2013-12-05 22:30:42 -05:00
Alan Donovan
100638985b go.tools/ssa/interp: fix bug: recovered panic without NRPs should return zero values.
+ test.

R=gri
CC=golang-dev
https://golang.org/cl/38040043
2013-12-05 21:22:57 -05:00
Alan Donovan
d063887ea0 go.tools/ssa: move AllFunctions to ssautil subpackage
R=gri
CC=golang-dev
https://golang.org/cl/37970043
2013-12-05 17:16:00 -05:00
Alan Donovan
d6490fa510 go.tools/ssa/ssautil: Switches() utility infers multiway branches.
(Note new subpackage ssa/ssautil.)

R=gri, axwalk, gri
CC=golang-dev
https://golang.org/cl/36710043
2013-12-05 17:00:17 -05:00
Alan Donovan
b5016cbbbd go.tools/ssa: expose dominator tree of control-flow graph in API.
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
2013-12-05 09:50:18 -05:00
Alan Donovan
c846ececde go.tools/ssa: eliminate remaining uses of operands of "untyped" type.
Added sanity check.

R=gri
CC=golang-dev
https://golang.org/cl/37270043
2013-12-04 13:59:55 -05:00
Brad Garcia
ff7cfafc58 godoc: Add URLForSrcQuery option to godoc.Presentation.
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
2013-12-04 10:37:01 -05:00
Andrew Wilkins
df34f98521 go.tools/cover: split parsing code out from cmd/cover
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
2013-12-03 20:55:21 -08:00
Robert Griesemer
ff84d756df go.tools/go/types: avoid spurious error in a common case
R=adonovan
CC=golang-dev
https://golang.org/cl/36900043
2013-12-03 17:51:54 -08:00
Shenghou Ma
5d386107a0 go.tools/cmd/oracle: output help messages to stderr for consistency
Fixes golang/go#6838.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/36820043
2013-12-03 17:37:59 -05:00
Robert Griesemer
14cf5b0a28 go.tools/go/types: fun with Hilbert: a const arithmetic test
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
2013-12-03 13:36:57 -08:00
Robert Griesemer
62a3fc7538 go.tools/go/types: clean up internal iota in all cases
R=dsymonds
CC=golang-dev
https://golang.org/cl/33570043
2013-11-26 17:48:47 -08:00
Robert Griesemer
3d343e42d1 go.tools/go/types: constants must have constant types
R=adonovan
CC=golang-dev
https://golang.org/cl/33210043
2013-11-26 12:42:52 -08:00
Brad Garcia
f2a9326f67 godoc: fix cmdline_test under Windows. Make sure the absolute path
testcase starts with a volume name for windows platforms.

R=bradfitz
CC=alex.brainman, golang-dev
https://golang.org/cl/32800043
2013-11-26 13:28:43 -05:00
Robert Griesemer
bbf45e5e0c go.tools/go/types: missing assignment checks when assigning to _
R=adonovan, gri
CC=golang-dev
https://golang.org/cl/31340044
2013-11-26 09:34:12 -08:00
Robert Griesemer
b9c2c88573 go.tools/go/types: add Package.SetImports
R=adonovan, neelance
CC=golang-dev
https://golang.org/cl/32500043
2013-11-26 09:19:17 -08:00
Francesc Campoy
6cb29d8d47 go.tools/present: add Raw content to Code for new go-tour.
R=adg
CC=golang-dev
https://golang.org/cl/26390044
2013-11-26 10:04:08 +01:00
Brad Garcia
8880e2e9d7 godoc: Add tests for corpus indexing options.
R=bradfitz
CC=golang-dev
https://golang.org/cl/31370043
2013-11-25 14:23:36 -05:00
Dmitriy Vyukov
23d25a2ed7 dashboard/app: do not send unnecessary data in todo response
R=adg
CC=golang-dev
https://golang.org/cl/30350043
2013-11-25 10:15:56 +04:00
Richard Musiol
397114a391 go.tools/go/gcimporter: ImportData has no need for *bufio.Reader, can get just io.Reader.
R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/31620043
2013-11-24 12:48:45 -08:00
Robert Griesemer
8c9bb9c1e3 go.tools/go/types: various cleanups
- use unpack also for assignments
- run benchmarks only requested (-b flag)

R=adonovan
CC=golang-dev
https://golang.org/cl/31190044
2013-11-22 20:34:07 -08:00
Brad Garcia
60954257d5 godoc: Update cmdline_test to no longer rely on having GOROOT set
to a valid Go environment.

R=bradfitz
CC=golang-dev
https://golang.org/cl/30960043
2013-11-22 13:58:59 -05:00
Dmitriy Vyukov
1dd13c2478 dashboard/builder: minor fixes and enhancements
- do not print secret key
- log app responses
- allow to customize go repo

R=adg, bradfitz
CC=golang-dev
https://golang.org/cl/29990046
2013-11-22 10:12:51 +04:00
Robert Griesemer
007f41d43e go.tools/go/types: more benchmarks, clearer results
The benchmarks don't permit clear-cut apples-to-apples
comparisons since they depend on the very source code
they are testing. But they do give an indication of
the approximate performance - as a sanity test.

Using 3 different code bases makes it apparent that
there's some difference in performance per code base;
i.e., the lines/s speed varies pretty strongly. This
may be due to setup costs, or other issues. We should
investigate eventually.

R=adonovan
CC=golang-dev
https://golang.org/cl/30650043
2013-11-21 21:08:29 -08:00
Alan Donovan
cf7368c879 go.tools/ssa: fix builder crash in select { case n, _ := <-c: ... }.
Cause: emitExtract requires a type for each component of the
receive tuple; blank supplies no such type.

Solution: remove type parameter for emitExtract as it is no
longer needed: since rev b75cc03b4a56 it is always identical
to the tuple.Type().At(index).

+ tests.

Fixes golang/go#6806.

R=gri, gri
CC=axwalk, golang-dev
https://golang.org/cl/30410043
2013-11-21 15:38:58 -05:00
Alan Donovan
8f1fdf33de go.tools/ssa: opt: improve the "unused φ-node" check to eliminate self-refs, debug-refs.
This removes about 5% of φ-nodes in one large program
and eliminates many zero-value constants.

(This does cause some Idents to no longer map to an ssa.Value.
This is observable in the oracle, whose tests are here updated.)

R=gri, gri
CC=golang-dev
https://golang.org/cl/26980043
2013-11-21 14:19:38 -05:00
Robert Griesemer
ef434a14da go.tools/go/types: record correct type for parenthesized x.(T) in comma-ok expressions
Fixes golang/go#6796.

R=adonovan
CC=golang-dev
https://golang.org/cl/30070044
2013-11-21 09:11:57 -08:00
Brad Garcia
f3faf8b6e0 godoc: add search results that point to documentation instead of source.
Add explicit options to Corpus to control search indexing of documentation, Go source code, and full-text.

R=bradfitz, r
CC=golang-dev
https://golang.org/cl/24190043
2013-11-21 11:55:42 -05:00
Richard Musiol
88e2928490 go.tools/go/types: Do not throw error on division of complex variables by zero.
See http://play.golang.org/p/DrgLKnHaUW
Seems like division of a variable by zero should only throw an error if the variable is an integer.

R=golang-dev, mtj, gri
CC=golang-dev, gri
https://golang.org/cl/29500047
2013-11-20 13:42:30 -08:00
Alan Donovan
2e33158b60 go.tools/oracle: show size and alignment for structs and named types.
Users should be familiar with the sizes of all other types.

Currently we assume amd64 (as do other parts of the oracle,
e.g. go/build tags).  Will parameterize later.

R=crawshaw
CC=golang-dev, gri
https://golang.org/cl/29710043
2013-11-20 16:00:23 -05:00
Brad Garcia
b844907f9f godoc: refactor command-line mode handling.
R=bradfitz
CC=golang-dev
https://golang.org/cl/29230044
2013-11-20 09:56:10 -05:00
Robert Griesemer
b4286c4c1b go.tools/go/types: missing checks for select statements
Also: Use defer to make sure scopes are always closed
even in case of early exits via bailout (and don't cause
an imbalanced scope error in debug mode).

R=adonovan, gri
CC=golang-dev
https://golang.org/cl/29300043
2013-11-19 13:58:01 -08:00
Robert Griesemer
849643aaaf go.tools: cleanups (added copyrights to astutil, clearer logic in go/types)
R=adonovan
CC=golang-dev
https://golang.org/cl/29110043
2013-11-19 09:07:02 -08:00
Robert Griesemer
df6f0829a2 go.tools/go/types: complete expr and type string functions
- consolidate them in (expr|type)string[_test].go
- support for printing all ast.Expr
- fix printing of type: chan (<-chan int) (parentheses)
- more consistent names, comments, and exports

R=adonovan
CC=golang-dev
https://golang.org/cl/28680043
2013-11-18 22:38:48 -08:00
Robert Griesemer
65aa1a4fbe go.tools/go/types: String method for Initializers
Plus a couple of minor fixes.

R=adonovan
CC=golang-dev
https://golang.org/cl/28540043
2013-11-18 11:26:49 -08:00
Brad Fitzpatrick
a284a61701 astutil: add new broken test
Tests will still pass because it's marked as known broken,
but it will log the unexpected for now.

R=golang-dev, crawshaw
CC=golang-dev
https://golang.org/cl/27330043
2013-11-16 14:53:18 -08:00
Robert Griesemer
e785f050b6 go.tools/go/types: add missing checks for short variable declarations
Fixes golang/go#6766.

R=adonovan
CC=golang-dev
https://golang.org/cl/24330044
2013-11-15 14:26:29 -08:00
Robert Griesemer
01f122e48b go.tools/go/gcimporter: fix build by adjusting test to new print output
R=adonovan, bradfitz
CC=golang-dev
https://golang.org/cl/26430049
2013-11-15 11:58:23 -08:00
Marko Mikulicic
ae3dd78063 godoc: Index const and vars in godoc.
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/26990043
2013-11-15 11:03:25 -08:00
Alan Donovan
9c112540f6 go.tools/oracle: use SelectionString when printing methods.
R=gri, crawshaw, gri
CC=golang-dev
https://golang.org/cl/26900043
2013-11-15 12:35:11 -05:00
Alan Donovan
45992044b5 go.tools/go/types: SelectionString: print method with selective package-qualification.
R=gri, gri
CC=golang-dev
https://golang.org/cl/26570048
2013-11-15 12:35:03 -05:00
Alan Donovan
f488a2c4f5 go.tools/oracle: use TypeString, ObjectString to print relative (unqualified) names when a package is implied by the context.
+ a couple more tests.

R=gri, crawshaw
CC=golang-dev
https://golang.org/cl/26370046
2013-11-15 09:22:16 -05:00
Alan Donovan
9fcd20e680 go.tools/ssa: display named types package-qualified using types.TypeString.
Details:
- use relative (non-qualified) names in more places
- Member interface now has Package(), RelString() methods.
- (*Function).DumpTo: add "# Package: " header.
- Added sanity checks for String functions.

R=gri, gri
CC=golang-dev
https://golang.org/cl/26380043
2013-11-15 09:21:48 -05:00