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

3965 Commits

Author SHA1 Message Date
Chris Manghane
a705311956 go.tools: add dashboard
Moving misc/dashboard to its new home. It will be deleted
(except for misc/dashboard/codereview) from its current home
if this is approved.

R=golang-dev, bradfitz, cmang, adg
CC=golang-dev
https://golang.org/cl/12180043
2013-08-01 13:23:51 +10:00
Robert Griesemer
caf3fc90ed go.tools/go/types: test against test/fixedbugs
Fixed several bugs:
- lhs blank identifier may be parenthesized: (_) = 0 is ok
- constant shift counts in non-constant shifts must be >= 0
- init functions must have a body

Classified currently failing tests:
- 10 classes of errors not checked at the moment

R=adonovan, r
CC=golang-dev
https://golang.org/cl/11952046
2013-07-31 20:08:18 -07:00
Folke Behrens
976d735966 go.tools/godoc: Fix jump-to-line in source view.
Remove the empty anchor element and add the line ID (Lnnn)
to the span element that contains the line number.
Fixes golang/go#5903.
Fixes golang/go#5977.

R=adg
CC=bradfitz, golang-dev
https://golang.org/cl/12189043
2013-08-01 11:52:25 +10:00
Alan Donovan
e7016436a6 go.tools/ssa: accommodate go/types changes to value,ok-mode inferred types.
The required changes were surprisingly minimal (I was hoping for a net
code deletion) because ssa is essentially doing its own type inference
for the three value,ok operators---and it continues to have to do so.
To see why, consider:

  var i interface{}; var ok bool
  i, ok := (map[string]string)(nil)[""]

Before, go/types inferred interface{} for the RHS of the assignment,
and now it infers (interface{}, bool), yet neither of these is what
ssa needs: it needs to know that the map values were strings so
that it can emit a lookup of the right type followed by a conversion
from string to interface{}.

TBR=gri
CC=golang-dev
https://golang.org/cl/11988044
2013-07-31 21:31:46 -04:00
Andrew Gerrand
508186a765 go.tools/cmd/godoc: copy templates from $GOROOT/lib/godoc
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/12209043
2013-08-01 11:01:10 +10:00
Robert Griesemer
ae07aa6055 go.tools/go/types: return typed bool for comma-ok expressions
Also: determine default types for assignments of the form: _ = x .

R=adonovan
CC=golang-dev
https://golang.org/cl/12186043
2013-07-31 12:49:34 -07:00
Alan Donovan
323b856f4d go.tools/ssa: oops, missing file from CL 12147043.
(Should fix build; ssa tests remain broken from CL 12024046)

R=gri
TBR=gri
CC=golang-dev
https://golang.org/cl/12002046
2013-07-31 13:30:59 -04:00
Alan Donovan
c28bf6e069 go.tools/ssa: extend debug information to arbitrary ast.Exprs.
CanonicalPos was inadequate since many pairs of instruction share the same pos (e.g. Allocs and Phis).  Instead, we generalize the DebugRef instruction to associate not just Idents but Exprs with ssa.Values.

We no longer store any DebugRefs for constant expressions, to save space.  (The type and value of such expressions can be obtained by other means, at a cost in complexity.)

Function.ValueForExpr queries the DebugRef info to return the ssa.Value of a given Expr.

Added tests.

Also:
- the DebugInfo flag is now per package, not global.
   It must be set between Create and Build phases if desired.
- {Value,Instruction}.Pos() documentation updated: we still maintain
  this information in the instruction stream even in non-debug mode,
  but we make fewer claims about its invariants.
- Go and Defer instructions can now use their respective go/defer
   token positions (not the call's lparen), so they do.
- SelectState:
     Posn token.Pos indicates the <- position
     DebugNode ast.Expr is the send stmt or receive expr.
- In building SelectStmt, we introduce extra temporaries in debug
   mode to hold the result of the receive in 'case <-ch' even though
   this value isn't ordinarily needed.
- Use *SelectState (indirectly) since the struct is getting bigger.
- Document some missing instructions in doc.go.

R=gri
CC=golang-dev
https://golang.org/cl/12147043
2013-07-31 13:13:05 -04:00
Robert Griesemer
e5cfd92deb go.tools/go/types: record comma-ok results as tuples
- added corresponding api tests
- support tuple comparison with IsIdentical

This CL will require some adjustments to SSA.

R=adonovan
CC=golang-dev
https://golang.org/cl/12024046
2013-07-31 09:33:46 -07:00
Robert Griesemer
eae0511b70 go.tools/ssa/interp: fix build
fallthrough's are now checked - adjust
now illegal test.

TBR: adonovan

R=adonovan
CC=golang-dev
https://golang.org/cl/12041052
2013-07-30 20:28:18 -07:00
Robert Griesemer
1e79a68ff5 go.tools/go/types: check fallthrough statements
R=adonovan
CC=golang-dev
https://golang.org/cl/12041049
2013-07-30 16:00:57 -07:00
Brad Fitzpatrick
143d18d6c5 cmd/godoc: fix build
R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/12127043
2013-07-30 13:42:50 -07:00
Alan Donovan
2f6855ad75 go.tools/ssa: avoid calling go/types.NewSelection, and eliminate it.
Also: s/LookupMethod/Method/

R=gri
CC=golang-dev
https://golang.org/cl/12058052
2013-07-30 16:36:58 -04:00
Robert Griesemer
4ae33302a4 go.tools/go/types: map keys must be comparable
R=adonovan
CC=golang-dev
https://golang.org/cl/12102044
2013-07-30 13:15:28 -07:00
Robert Griesemer
33d57bf48f go.tools/go/types: report identifier for methods with blank names
R=adonovan
CC=golang-dev
https://golang.org/cl/12123045
2013-07-30 12:47:40 -07:00
Alan Donovan
2a3a12930b go.tools/ssa: add test of SSA construction on $GOROOT/src/pkg/...
stdlib_test runs the builder (in sanity-checking mode) over
the Go standard library.  It also prints some stats about
the time and memory usage.

Also:
- importer.LoadPackage too (not just doImport) must consult
  the cache to avoid creating duplicate Package instances for
  the same import path when called serially from a test.
- importer: skip empty directories without an error.
- importer: print all errors, not just the first.
- visit.go: added AllFunctions utility for enumerating all
  Functions in a Program.
- ssa.MethodSet is not safe to expose from the package since
  it must be accessed under an (inaccessible) lock.  (!!!)
  This CL makes it unexported and restricts its use to the
  single function Program.LookupMethod().
- Program.MethodSet() has gone.
  Clients should instead iterate over the types.MethodSet
  and call LookupMethod.
- Package.DumpTo(): improved efficiency of methodset printing
  (by not creating wrappers) and accuracy (by showing * on
  receiver type only when necessary).
- Program.CreatePackage: documented precondition and added
  assertion.

R=gri
CC=golang-dev
https://golang.org/cl/12058048
2013-07-30 14:28:14 -04:00
Robert Griesemer
e7c7afbb1a go.tools/go/types: enable (previously broken) shift tests
R=adonovan
CC=golang-dev
https://golang.org/cl/12109044
2013-07-30 11:10:28 -07:00
Robert Griesemer
7a1a18283b go.tools/go/types: constant shifts always produce integers (bug fix)
R=adonovan
CC=golang-dev
https://golang.org/cl/12025044
2013-07-30 10:28:57 -07:00
Robert Griesemer
30c6d6350d go.tools/go/types: check type-checker against $GOROOT/test
R=adonovan
CC=golang-dev
https://golang.org/cl/12070044
2013-07-30 09:00:25 -07:00
Rob Pike
2a8b9debdd go.tools/cmd/vet: don't complain about empty interface values in printf
R=dsymonds
CC=golang-dev
https://golang.org/cl/12005047
2013-07-30 15:51:35 +10:00
Andrew Gerrand
253974207b go.tools/cmd/godoc: update appinit.go to use new godoc packages
Also move some common code from main.go to handlers.go, and
exclude remotesearch.go from the appengine build (it is only
relevant to the command line interface).

R=bradfitz, dsymonds
CC=golang-dev
https://golang.org/cl/12001049
2013-07-30 14:23:23 +10:00
Rob Pike
5ba51116ee go.tools/cmd/vet: treat arrays like slices in the printf checks.
The analysis for types.Array was just missing. It's the same as a slice,
but we can't share code easily because the types differ, so we just dup it.

R=dsymonds
CC=golang-dev
https://golang.org/cl/12041045
2013-07-30 14:00:52 +10:00
David Symonds
40baf75587 cmd/vet: Avoid warning on pointer to invalid types.
TBR=r
CC=golang-dev
https://golang.org/cl/12038051
2013-07-30 13:41:07 +10:00
David Symonds
573374c476 cmd/vet: Fix handling of non-Stringer arguments.
First, %v and %T accept any arguments, so they should never warn.
Second, pointer types were not handled in matchArgType.
Third, the default response for matchArgType should be false.

R=r
CC=adonovan, golang-dev
https://golang.org/cl/12038050
2013-07-30 13:15:31 +10:00
Alan Donovan
0ba53b54bd go.tools/ssa: add debug info for x.f where Selection.Kind()==FieldVal.
Also:
- Implement Program.FuncValue for interface methods (+ test).
- go/types.Object.String(): don't package-qualify names unless
  they are package level objects---otherwise you see "main.x" for
  locals, struct fields, etc.
- go/types.Func.String(): don't assume Type() is *Signature;
  it could be *Builtin.

R=gri
CC=golang-dev
https://golang.org/cl/12058045
2013-07-29 17:10:11 -04:00
Robert Griesemer
90aa993096 go.tools/go/types: provide package for imported methods
Fixes golang/go#5815.

R=adonovan
CC=golang-dev
https://golang.org/cl/12048043
2013-07-29 13:22:46 -07:00
Robert Griesemer
bb34185432 go.tools/go/types: more implicit conversion tests
Also: Fixed grammar in selection.go comment.

R=adonovan
CC=golang-dev
https://golang.org/cl/11962043
2013-07-29 13:07:46 -07:00
Alan Donovan
fb0642f5fb go.tools/ssa: fix a package-level var initialization order bug.
buildDecl was visiting all decls in source order, but the spec
calls for visiting all vars and init() funcs in order, then
all remaining functions.  These two passes are now called
buildInit(), buildFuncDecl().

+ Test.

Also:
- Added workaround to gcimporter for Func with pkg==nil.
- Prog.concreteMethods has been merged into Pkg.values.
- Prog.concreteMethod() renamed declaredFunc().
- s/mfunc/obj/ (name cleanup from recent gri CL)

R=gri
CC=golang-dev
https://golang.org/cl/12030044
2013-07-29 14:24:09 -04:00
Robert Griesemer
64ea46e0bc go.tools/go/types: replace Method w/ Selection
A Method corresponds to a MethodVal Selection;
so the explicit Method object is not needed anymore.

- moved Selection code into separate file
- implemented Selection.String()
- improved and more consistent documentation

R=adonovan
CC=golang-dev
https://golang.org/cl/11950043
2013-07-26 22:27:48 -07:00
Alan Donovan
ba2241824d go.tools/ssa: use new Selections to simplify builder case discrimination.
Delete importer.PkgInfo.{ClassifySelector,IsPackageRef}.

R=gri
CC=golang-dev
https://golang.org/cl/11937045
2013-07-26 22:29:44 -04:00
Alan Donovan
ae8016313d go.tools/ssa: tests of method promotion and of interface conversion + bugfixes.
methprom.go covers method promotion.
Found bug: receiver() requires a following load under some
circumstances.

ifaceconv.go covers interface conversion.
Found bug: confusion about infallible and fallible conversions
led to use of TypeAssert in emitConv, which should never fail.
Changed semantics of ChangeInterface to make it infallible
and made some simplifications.

Also in this CL:
- SelectState.Pos now records the position of the
  the '<-' operator for sends/receives done by a Select.

R=gri
CC=golang-dev
https://golang.org/cl/11931044
2013-07-26 21:49:27 -04:00
Robert Griesemer
4ea4ce9e03 go.tools/go/types: added missing implicit conversion checks
R=adonovan, r
CC=golang-dev
https://golang.org/cl/11934047
2013-07-26 18:21:14 -07:00
Robert Griesemer
41fb587948 go.tools/go/types: implement Info.Selections
Should make it easier for clients to deal with
selector expressions.

Removed Field type: The respective information
is now reported in Info.Selections.

R=adonovan
CC=golang-dev
https://golang.org/cl/11942043
2013-07-26 13:55:14 -07:00
Alan Donovan
118786e3d6 go.tools/ssa: combine CallCommon.{Recv,Func} as Value.
Also:
- add types.Func.FullName() (e.g. "fmt.Println", "(main.S).f")
- remove rogue print stmt.
- fix bad docstrings.

R=gri
CC=golang-dev
https://golang.org/cl/11936044
2013-07-26 14:06:26 -04:00
Robert Griesemer
bf6a1e674e go.tools/go/types: unsafe.Offsetof must deref named pointers to structs
R=adonovan
CC=golang-dev
https://golang.org/cl/11889043
2013-07-26 09:53:47 -07:00
Alan Donovan
4da31df1c8 go.tools/ssa: (another) major refactoring of method-set logic.
We now use LookupFieldOrMethod for all SelectorExprs, and
simplify the logic to discriminate the various cases.

We inline static calls to promoted/indirected functions,
dramatically reducing the number of functions created.

More tests are needed, but I'd like to submit this as-is.

In this CL, we:
- rely less on Id strings.  Internally we now use
  *types.Method (and its components) almost everywhere.
- stop thinking of types.Methods as objects. They don't
  have stable identities. (Hopefully they will become
  plain-old structs soon.)
- eliminate receiver indirection wrappers:
  indirection and promotion are handled together by makeWrapper.
- Handle the interactions of promotion, indirection and
  abstract methods much more cleanly.
- support receiver-bound interface method closures.
- break up builder.selectField so we can re-use parts
  (emitFieldSelection).
- add importer.PackageInfo.classifySelector utility.
- delete interfaceMethodIndex()
- delete namedTypeMethodIndex()
- delete isSuperInterface() (replaced by types.IsAssignable)
- call memberFromObject on each declared concrete method's
  *types.Func, not on every Method frem each method set, in the
  CREATE phase for packages loaded by gcimporter.

go/types:
- document Func, Signature.Recv() better.
- use fmt in {Package,Label}.String
- reimplement Func.String to be prettier and to include method
  receivers.

API changes:
- Function.method now holds the types.Method (soon to be
  not-an-object) for synthetic wrappers.
- CallCommon.Method now contains an abstract (interface)
  method object; was an abstract method index.
- CallCommon.MethodId() gone.
- Program.LookupMethod now takes a *Method not an Id string.

R=gri
CC=golang-dev
https://golang.org/cl/11674043
2013-07-26 11:22:34 -04:00
Robert Griesemer
c98ff05fdd go.tools/go/types: faster scopes, cleanups around method lookups
R=adonovan
CC=golang-dev
https://golang.org/cl/11787043
2013-07-24 20:02:54 -07:00
Robert Griesemer
6dbbc59ae0 go.tools/go/types: simplify handling of blank _ identifiers
Also: Fixes a couple of places where scopes instead
      of objsets were used (missed in previous CL).

R=adonovan
CC=golang-dev
https://golang.org/cl/11419047
2013-07-24 12:39:11 -07:00
Robert Griesemer
d0657ebb0d go.tools/go/types: record lhs identifier in switch lhs := rhs.(type)
Added testcase.

R=adonovan
CC=golang-dev
https://golang.org/cl/11742043
2013-07-24 12:38:51 -07:00
Alan Donovan
d4f2f2d7fa go.tools/ssa: repair treatment of typeswitch after recent go/types changes.
Now, in a "switch y := x.(type)", there is no object for the
outer y, only implicit objects, one per case (including
default).

Also: don't set obj=nil for blank idents (workaround suggested by gri).

R=gri
CC=golang-dev
https://golang.org/cl/11564046
2013-07-24 14:03:53 -04:00
Robert Griesemer
c5b1cc4227 go.tool/go/types: ignore invalid anonymous fields
Fixes go tool vet breakage when applied to files
with incomplete type information for anonymous
fields.

R=adonovan
CC=golang-dev
https://golang.org/cl/11773043
2013-07-24 10:49:44 -07:00
Robert Griesemer
407e159412 go.tools/go/types: fix typo in self test
R=adonovan
CC=golang-dev
https://golang.org/cl/11749044
2013-07-24 09:26:39 -07:00
Andrew Gerrand
7375911b0e go.tools/cmd/godoc: use playground package from go.tools
R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/11507044
2013-07-24 17:25:24 +10:00
Andrew Gerrand
8cc9c49348 go.tools/godoc/playground: copy playground package from go.talks
After this change is submitted the dependants on go.talks/pkg/playground
talks will be updated to use this one and the old package will be deleted.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/11759043
2013-07-24 17:25:00 +10:00
Robert Griesemer
66e7552830 go.tools/go/types: simplified and faster Scope
- implemented objset for tracking duplicates of fields and methods
  which permitted a simpler and faster scope implementation in turn
- related cleanups and internal renames
- fixed a couple of identifier reporting bugs

Speed of type-checking itself increased by almost 10%
(from ~71Kloc/s to ~78Kloc/s on one machine, measured
via go test -run=Self).

R=adonovan
CC=golang-dev
https://golang.org/cl/11750043
2013-07-23 21:21:37 -07:00
Robert Griesemer
2f54663e0e go.tools/go/types: fix build: ignore self-test if it fails
R=adonovan
CC=golang-dev
https://golang.org/cl/11398045
2013-07-23 20:52:41 -07:00
Robert Griesemer
cc55bd9129 go.tools/go/types: add self test
R=adonovan
CC=golang-dev
https://golang.org/cl/11739043
2013-07-23 18:30:06 -07:00
Robert Griesemer
09d04edfcf go.tools/go/types: declare typeswitch local variable in correct scope
R=adonovan
CC=golang-dev
https://golang.org/cl/11534044
2013-07-23 14:18:38 -07:00
Robert Griesemer
7bc647b29a go.tools/go/types: internal cleanups
- more consistent naming of some internal data types and methods
- better factoring of some error reporting code
- cleanup around association of methods with receiver base types
- more tests

R=adonovan
CC=golang-dev
https://golang.org/cl/11726043
2013-07-23 13:42:04 -07:00
Alan Donovan
7eafcedc87 go.tools/ssa: opt: create elements of method sets lazily.
Reduces by 94% the number of wrappers created during the tests.
(No appreciable difference in running time, sadly.)

R=gri
CC=golang-dev
https://golang.org/cl/11619043
2013-07-23 13:38:52 -04:00