1
0
mirror of https://github.com/golang/go synced 2024-11-07 08:36:28 -07:00
Commit Graph

965 Commits

Author SHA1 Message Date
Alan Donovan
39779f52c3 go.tools/call: a callgraph API.
This package provides a simple abstraction of a call graph,
capable of representing context sensitive and insensitive
graphs.  It also provides some basic utilities and algorithms.

This simplifies clients such as the oracle, and makes similar
clients (e.g. an offline version of the oracle) easier to write.

R=crawshaw, gri
CC=golang-dev
https://golang.org/cl/13901044
2013-09-25 14:16:35 -04:00
Robert Griesemer
a6c151c04d go.tools/go/types: (panic(0)) (parenthesized) is a terminating statement
R=adonovan
CC=golang-dev
https://golang.org/cl/13913043
2013-09-25 10:19:24 -07:00
Robert Griesemer
9d1c551b43 go.tools/go/types: check 3-index slice expressions
R=adonovan
CC=golang-dev
https://golang.org/cl/13881043
2013-09-25 10:15:40 -07:00
Chris Manghane
b25f3012f3 go.tools/dashboard/builder: only download gcc once for gccgo buildTool.
Downloading the GCC repo takes a lot of time and everything works fine if we just store it in the buildRoot and reuse it.

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/13583045
2013-09-24 16:08:25 -07:00
Robert Griesemer
dfaa5cc0c1 go.tools/go/types: test case for issue 6413
Fixes golang/go#6413.

R=adonovan
CC=golang-dev
https://golang.org/cl/13840047
2013-09-24 12:51:45 -07:00
Robert Griesemer
bce88d26ea go.tools/go/types: improved operand printing in error messages
Also:
- removed operand.val hack for built-in encoding; added id field
- minor cleanups

R=adonovan
CC=golang-dev
https://golang.org/cl/13840046
2013-09-24 12:22:04 -07:00
Alan Donovan
37f76edde8 go.tools/oracle: support -format=xml (for Eclipse)
This CL is mostly a renaming s/json/serial/, abstracting the
oracle package away from any particular data syntax.  (The
encoding/* machinery is very clean; clearly I should have
structured it this way from the outset.)

Supporting XML then becomes a one-liner in cmd/oracle/main.go.

Also: call MarshalIndent(), not Marshall() then Indent().

R=crawshaw
CC=golang-dev
https://golang.org/cl/13858046
2013-09-24 15:08:14 -04:00
Nathan John Youngman
84cae5a52d go.tools/cover: clean up usage information
R=golang-dev, r, minux.ma
CC=golang-dev
https://golang.org/cl/13532052
2013-09-24 17:27:26 +10:00
Chris Manghane
1d41279086 go.tools/dashboard: fix Repo creation in buildSubRepo to have valid Master repo.
R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/13568047
2013-09-23 17:18:31 -07:00
Chris Manghane
7bcc81e644 go.tools/dashboard: add gccgo build dashboard.
This change adds a new build dashboard url to the existing appengine app: $dashurl/gccgo/ which will show the build status of gccgo.
* Added Dashboard struct with exported Name, Rel(ative)Path, and Packages fields.
* Added Dashboard Context method that returns an appengine context with a namespace corresponding to the dashboard's name.
* Modified HandlerFuncs to use Dashboard's Context method for all appengine requests.
* Modified ui template to show different title/header for separate dashboard and added dashboard tab.

R=adg
CC=golang-dev
https://golang.org/cl/13753043
2013-09-23 17:06:49 -07:00
Robert Griesemer
0e6d095d11 go.tools/go/types: better error messages for invald expression statements
Also: removed some dynamic print formats.

R=adonovan
CC=golang-dev
https://golang.org/cl/13849043
2013-09-23 15:39:11 -07:00
Alan Donovan
318b83e376 go.tools/ssa: SSA fixes for *types.Builtin becoming an object (CL 13813043)
R=gri
CC=golang-dev
https://golang.org/cl/13848043
2013-09-23 18:18:35 -04:00
Robert Griesemer
a05da76c7b go.tools/go/types: represent built-ins as Objects (rather than types)
This change affects the API: Func objects now always have a *Signature
as type (never a *Builtin). Instead, built-ins now appear as *Builtin
objects. Only the built-in name is exposed, other fields are now private
to go/types.

Several bugs are fixed:
- correctly checking for built-ins permitted in statement context
- expression statements that are calls are not type-checked twice anymore
- go/defer statements report call types and provide good error messages now

This CL will briefly break the build until CL 13848043 is submitted.

R=adonovan
CC=golang-dev
https://golang.org/cl/13813043
2013-09-23 15:14:17 -07:00
Alan Donovan
3371b79a96 go.tools/pointer: reflect, part 2: channels.
(reflect.Value).Send
        (reflect.Value).TrySend
        (reflect.Value).Recv
        (reflect.Value).TryRecv
        (reflect.Type).ChanOf
        (reflect.Type).In
        (reflect.Type).Out
        reflect.Indirect
        reflect.MakeChan

Also:
- specialize genInvoke when the receiver is a reflect.Type under the
  assumption that there's only one possible concrete type.  This
  makes all reflect.Type operations context-sensitive since the calls
  are no longer dynamic.
- Rename all variables to match the actual parameter names used in
  the reflect API.
- Add pointer.Config.Reflection flag
  (exposed in oracle as --reflect, default false) to enable reflection.
  It currently adds about 20% running time.  I'll make it true after
  the presolver is implemented.
- Simplified worklist datatype and solver main loop slightly
  (~10% speed improvement).
- Use addLabel() utility to add a label to a PTS.

(Working on my 3 yr old 2x2GHz+4GB Mac vs 8x4GHz+24GB workstation,
one really notices the cost of pointer analysis.
Note to self: time to implement presolver.)

R=crawshaw
CC=golang-dev
https://golang.org/cl/13242062
2013-09-23 16:13:01 -04:00
Alan Donovan
25a0cc4bfd go.tools/oracle: refactor Oracle API to allow repeated queries on same scope.
The existing standalone Query function builds an importer, ssa.Program, oracle,
and query position, executes the query and returns the result.
For clients (such as Frederik Zipp's web-based github.com/fzipp/pythia tool)
that wish to load the program once and make several queries, we now expose
these as separate operations too.  Here's a client, in pseudocode:

        o := oracle.New(...)
        for ... {
                qpos := o.ParseQueryPos(...)
                res := o.Query(mode, qpos)
                print result
        }

NB: this is a slight deoptimisation in the one-shot case since we have to
build the entire SSA program with debug info, not just the query package,
since we now don't know the query package at that time.

The 'exact' param to ParseQueryPos needs more thought since its
ideal value is a function of the query mode.  This will do for now.

Details:
- expose Oracle type, New() func and Query() method.
- expose QueryPos type and ParseQueryPos func.
- improved package doc comment.
- un-exposed the "needs" bits.
- added test.

R=crawshaw
CC=frederik.zipp, golang-dev
https://golang.org/cl/13810043
2013-09-23 15:02:18 -04:00
Andrew Gerrand
eb130cb481 go.tools/cmd/cover: add content-type meta tag to HTML output
Fixes golang/go#6435.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/13822045
2013-09-23 13:57:03 +10:00
Robert Griesemer
26a4f47422 go.tools/go/types: enable more std lib tests
R=adonovan
CC=golang-dev
https://golang.org/cl/13798043
2013-09-20 10:09:40 -07:00
Robert Griesemer
c2d7895b1e go.tools/go/types: "imported but not used" errors for dot-imports
R=adonovan, josharian
CC=golang-dev
https://golang.org/cl/13795043
2013-09-20 10:09:16 -07:00
Alan Donovan
0c4a02a8c4 go.tools/oracle: improve usage messages.
Full help is only displayed when -help is requested;
CLI usage errors just remind the the user of this flag.

R=r, crawshaw
CC=golang-dev
https://golang.org/cl/13523048
2013-09-20 11:35:00 -04:00
Yasuhiro Matsumoto
7959c09b86 go.tools/cmd/oracle: Encoding issue, Possible to describe modified file
line2byte doesn't handle non utf-8 fileencoding. So added s:getpos().
        And also, changing errorformat is not right way on go filetype.
        Added range operations.

R=golang-dev, kamil.kisiel, dsymonds, dominik.honnef
CC=golang-dev
https://golang.org/cl/13656045
2013-09-20 11:09:27 +10:00
Robert Griesemer
86e41f819a go.tools/go/types: "imported but not used" checks for packages
also:
- initial code for unused label errors
- some cleanups, better names
- additional tests

TODO: Dot-imported packages are not handled yet; i.e., they
      are always considered used for now.

R=adonovan
CC=golang-dev
https://golang.org/cl/13768043
2013-09-19 10:05:34 -07:00
Rob Pike
34fbb29ae0 go.tools/gotype: move to go.tools/cmd/gotype
Commands in the go.tools repo should be under the cmd subdirectory.

R=gri, adg
CC=golang-dev
https://golang.org/cl/13768044
2013-09-19 11:38:07 +10:00
Andrew Gerrand
f54bd1aebf go.tools/cmd/godoc: update import paths
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/13770043
2013-09-19 10:59:21 +10:00
Andrew Gerrand
b605e38d5d go.tools/playground/socket: move package from go.talks
R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/13244049
2013-09-19 10:59:00 +10:00
Andrew Gerrand
cc069b6297 go.tools/blog: use atom and present packages from go.tools
R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/13244050
2013-09-19 10:58:36 +10:00
Andrew Gerrand
2cac03d805 go.tools/blog/atom: move package from go.blog
R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/13368058
2013-09-19 10:58:11 +10:00
Andrew Gerrand
9fc516408c go.tools/godoc/present: move present package from go.talks
Godoc depends on go.talks/pkg/present by way of go.tools/pkg/blog.
Better to keep all godoc dependencies in one place.

R=golang-dev, dsymonds, r
CC=golang-dev
https://golang.org/cl/13656047
2013-09-19 10:55:46 +10:00
Andrew Gerrand
a76da35c40 go.tools: move playground to repo root
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/13451046
2013-09-19 10:45:22 +10:00
Robert Griesemer
2695d311b9 go.tools/ssa: fix ssa tests (fix build partly)
R=adonovan
CC=golang-dev
https://golang.org/cl/13668048
2013-09-18 11:39:55 -07:00
Robert Griesemer
a24d794bb1 go.tools/pointer: fix pointer tests (fix build partly)
R=adonovan
CC=golang-dev
https://golang.org/cl/13246052
2013-09-18 11:37:26 -07:00
Robert Griesemer
0e06e5845b go.tools/oracle: fix oracle tests (fix build partly)
R=adonovan
CC=golang-dev
https://golang.org/cl/13722049
2013-09-18 11:32:18 -07:00
Robert Griesemer
a68deb25ff go.tools/go/types: "declared but not used" error for type switches
Also:
- added more tests
- removed Var.Used accessor: it's not meaningful for clients since
  it does not reflect actual use/def information
- fixed position for short variable declaration errors

R=adonovan
CC=golang-dev
https://golang.org/cl/13240051
2013-09-18 11:31:46 -07:00
Robert Griesemer
f1051f2025 go.tools/go/types: 'declared but not used' checks for variables
- updated all tests to conform to stricter rules
- TODO: check for implicitly declared variables in type switches

R=adonovan
CC=golang-dev
https://golang.org/cl/13695046
2013-09-18 08:39:02 -07:00
Andrew Gerrand
072133c61b go.tools/cmd/godoc: include the blog server
Defer parsing of blog content until accessed for faster startup.
Fall back on redirect if blog content unavailable locally.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/13335052
2013-09-18 15:20:41 +10:00
Andrew Gerrand
371fdaacb9 go.tools/godoc: add 'Blog' heading and playground scripts and styles
This is part of altering the blog to be styled like the rest of golang.org.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/13641045
2013-09-18 15:12:51 +10:00
Andrew Gerrand
03c8be29db go.tools/godoc/blog: add PlayEnabled and GodocURL options
Also make NewServer take a Config, not *Config.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/13755044
2013-09-18 14:59:34 +10:00
Andrew Gerrand
72d39cf585 go.tools/godoc/blog: copy package from go.blog
R=golang-dev, r, dsymonds
CC=golang-dev
https://golang.org/cl/13755043
2013-09-18 14:56:44 +10:00
Rob Pike
6ad0d283e1 go.tools/cmd/vet: handle recursive structs and slices.
Fixes golang/go#6309

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/13386046
2013-09-18 12:57:59 +10:00
Andrew Gerrand
dceff279d0 go.tools/cmd/godoc: add redirects for godoc, vet, and gotest
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/13709046
2013-09-18 11:15:12 +10:00
Robert Griesemer
4acd602bea go.tools/go/types: fix a couple of std lib test failures
1. handle return statements with zero (but expected) return values
2. indices provided for array or slice composite literals must be integer constants

Added additional test cases.

R=adonovan
CC=golang-dev
https://golang.org/cl/13734043
2013-09-17 10:26:06 -07:00
Robert Griesemer
cf1e27bbda go.tools/go/types: add test case for resolution of blank methods
(was bug on go/types wishlist; probably fixed a while ago)

R=adonovan
CC=golang-dev
https://golang.org/cl/13633047
2013-09-16 13:18:56 -07:00
Alan Donovan
5db6491e90 go.tools/ssa/interp: fixes to equivalence relations.
- This change implements the correct type-based equivalence
  relation for aggregate types. e.g. comparison of struct
  types no longer compares the anonymous fields.  We do
  analogous things for hash().

- equals() and eqnil() have been separated: the former panics
  for uncomparable types, the latter permits comparisons of
  slice/map/func types against a literal nil and is intended
  for use only by "static" ssa.BinOp(EQL), not "dynamic" slice
  comparisons encountered during (e.g.) interface comparisons,
  which should panic regardless of operand nilness.

- we use a (global) typemap.Hasher to compute type hashes;
  hashing the Type.String() value was not sound.

+ tests.

NB, this change unearthed a bug in defer/recover within
init(); it will be fixed in a followup change.

R=gri, crawshaw
CC=golang-dev
https://golang.org/cl/13719043
2013-09-16 15:22:19 -04:00
Alan Donovan
3b5de067a1 go.tools/pointer: reflection, part 1: maps, and some core features.
Core:
        reflect.TypeOf
        reflect.ValueOf
        reflect.Zero
        reflect.Value.Interface
Maps:
        (reflect.Value).MapIndex
        (reflect.Value).MapKeys
        (reflect.Value).SetMapIndex
        (*reflect.rtype).Elem
        (*reflect.rtype).Key

+ tests:
  pointer/testdata/mapreflect.go.
  oracle/testdata/src/main/reflection.go.

Interface objects (T, V...) have been renamed "tagged objects".

Abstraction: we model reflect.Value similar to
interface{}---as a pointer that points only to tagged
objects---but a reflect.Value may also point to an "indirect
tagged object", one in which the payload V is of type *T not T.
These are required because reflect.Values can hold lvalues,
e.g. when derived via Field() or Elem(), though we won't use
them till we get to structs and pointers.

Solving: each reflection intrinsic defines a new constraint
and resolution rule.  Because of the nature of reflection,
generalizing across types, the resolution rules dynamically
create additional complex constraints during solving, where
previously only simple (copy) constraints were created.
This requires some solver changes:

  The work done before the main solver loop (to attach new
  constraints to the graph) is now done before each iteration,
  in processNewConstraints.

  Its loop over constraints is broken into two passes:
  the first handles base (addr-of) constraints,
  the second handles simple and complex constraints.

  constraint.init() has been inlined.  The only behaviour that
  varies across constraints is ptr()

Sadly this will pessimize presolver optimisations, when we get
there; such is the price of reflection.

Objects: reflection intrinsics create objects (i.e. cause
memory allocations) with no SSA operation.  We will represent
them as the cgnode of the instrinsic (e.g. reflect.New), so we
extend Labels and node.data to represent objects as a product
(not sum) of ssa.Value and cgnode and pull this out into its
own type, struct object.  This simplifies a number of
invariants and saves space.  The ntObject flag is now
represented by obj!=nil; the other flags are moved into
object.

cgnodes are now always recorded in objects/Labels for which it
is appropriate (all but those for globals, constants and the
shared contours for functions).

Also:
- Prepopulate the flattenMemo cache to consider reflect.Value
  a fake pointer, not a struct.
- Improve accessors and documentation on type Label.
- @conctypes assertions renamed @types (since dyn. types needn't be concrete).
- add oracle 'describe' test on an interface (missing, an oversight).

R=crawshaw
CC=golang-dev
https://golang.org/cl/13418048
2013-09-16 09:49:10 -04:00
Alan Donovan
4c5148c4cd go.tools/ssa/interp: set GOARCH to runtime.GOARCH in target program.
Causes $GOROOT/test/env.go to pass if GOARCH is unset in parent's env.

R=gri
CC=golang-dev
https://golang.org/cl/13709043
2013-09-16 09:27:59 -04:00
Andrew Gerrand
b9b578154e go.tools/godoc: some content re-organization
Remove References section heading.
Add redirects from old paths to new content.
Add a link to the SubRepositories wiki page from package list.
Add styles for "pop-out" link.

R=r
CC=golang-dev
https://golang.org/cl/13356047
2013-09-16 15:46:38 +10:00
Andrew Gerrand
4709d08a36 go.toos/cmd/cover: "add" package comment
R=r
CC=golang-dev
https://golang.org/cl/13463046
2013-09-16 14:39:12 +10:00
Andrew Gerrand
334d56a124 go.tools/cmd/godoc: permit dash and capitals in redirect paths
This was causing some /blog/foo-bar-baz paths to 404.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/13640044
2013-09-16 13:02:15 +10:00
Andrew Gerrand
1564988897 go.tools/cmd/godoc: add redirect helpers
Previously these helpers were added by a private deployment script.
There's no reason why they shouldn't be part of godoc proper now
that it's in the go.tools repository.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/13722043
2013-09-16 11:41:03 +10:00
Rob Pike
ece05f910e go.tools/cmd/vet: update for fmt handling %b for complex numbers
R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/13490048
2013-09-16 08:18:27 +10:00
Robert Griesemer
1928c01286 go.tools/go/types: separate package descriptor from package object
Includes changes by adonovan to make oracle work again
(former CL 13395050).

R=adonovan
CC=golang-dev
https://golang.org/cl/13672044
2013-09-13 09:52:57 -07:00