1
0
mirror of https://github.com/golang/go synced 2024-11-05 22:56:11 -07:00
Commit Graph

958 Commits

Author SHA1 Message Date
Robert Griesemer
1faba6e3b8 go.tools/cmd/godex: replicate path logic for gccgo-new importer
LGTM=adonovan
R=adonovan
CC=golang-codereviews
https://golang.org/cl/81990043
2014-03-28 14:50:14 -07:00
Robert Griesemer
250eb11b9b go.tools/go/gccgoimporter: backported some changes from godex implementation
LGTM=adonovan
R=adonovan
CC=golang-codereviews
https://golang.org/cl/82000043
2014-03-28 14:24:35 -07:00
Robert Griesemer
700390eaed go.tools/cmd/godex: fix prefix generation, filtering, formatting
Details:
- auto-generate prefixes for std lib (e.g., "godex big" works now)
- apply filtering to package-level objects only
- nicer formatting of single-entry const, var, or type declaration

TBR=adonovan
R=adonovan
CC=golang-codereviews
https://golang.org/cl/81360046
2014-03-28 12:21:51 -07:00
Robert Griesemer
069e8474de go.tools/go/types: print meaningful panic for unknown expressions
LGTM=iant
R=iant
CC=golang-codereviews
https://golang.org/cl/81310045
2014-03-27 15:47:04 -07:00
Alan Donovan
f35b5691f3 go.tools/godoc: fix two regressions caused by -analysis CL.
- Add missing methodset.html template file.
- Suppress initial display of package callgraph.
  Client-side JS will make it visible if there is data.

LGTM=bgarcia
R=crawshaw, bgarcia
CC=golang-codereviews
https://golang.org/cl/81550043
2014-03-27 15:30:14 -04:00
Robert Griesemer
f293460f67 go/tools/cmd/godex: don't print unexported methods
and print exported methods of unexported types

LGTM=adonovan
R=adonovan
CC=golang-codereviews
https://golang.org/cl/80920046
2014-03-27 10:49:59 -07:00
Robert Griesemer
33f2a1701b go.tools/go/types: minor internal cleanup
LGTM=adonovan
R=adonovan
CC=golang-codereviews
https://golang.org/cl/80960046
2014-03-27 10:03:51 -07:00
Alan Donovan
2414677bb9 go.tools/go/loader: add Config.ParserMode configuration parameter.
Existing tools use the default value of zero; their behaviour is unchanged.
(*Config).ParseFile is used only from tests.

LGTM=crawshaw, rsc, gri
R=crawshaw, gri, rsc
CC=golang-codereviews
https://golang.org/cl/79290044
2014-03-27 12:50:26 -04:00
Robert Griesemer
8b161c33a9 go.tools/cmd/godex: support for common path prefixes
All of these work now as expected:

        godex code.google.com/p/go.tools/go/types
        godex go.tools/go/types
        godex go/types
        godex types

Also improved logging/verbose mode.

LGTM=adonovan
R=adonovan
CC=golang-codereviews
https://golang.org/cl/80930043
2014-03-26 14:47:52 -07:00
Robert Griesemer
03478d3d3e go.tools/cmd/godex: better argument handling
1) Split a path.name argument at the last '.' that
   is not part of the path.

2) Try various importers always in the same order
   for consistent results (use lists instead of maps).

LGTM=adonovan
R=adonovan
CC=golang-codereviews
https://golang.org/cl/80790043
2014-03-26 09:54:20 -07:00
Robert Griesemer
8648e1a481 go.tools/cmd/godex: nicer formatting
- handle indentation
- write non-empty tuples and signatures in multiple lines
- don't crash for package unsafe

LGTM=adonovan
R=adonovan
CC=golang-codereviews
https://golang.org/cl/79920044
2014-03-26 08:38:40 -07:00
Robert Griesemer
4a27ee3a1b go.tools/cmd/godex: a tool to dump export information
Initial implementation. Lots of missing pieces.

Example use:
        godex math
        godex math.Sin
        godex math.Sin math.Cos

LGTM=adonovan
R=adonovan
CC=golang-codereviews
https://golang.org/cl/76890044
2014-03-25 15:26:38 -07:00
Sameer Ajmani
a1c1cf19ba imports: extend findImports to return a boolean, rename, that tells
goimports to use the package name as a local qualifier in an import.
For example, if findImports("pkg", "X") returns ("foo/bar",
rename=true), then goimports adds the import line:
  import pkg "foo/bar"
to satisfy uses of pkg.X in the file.

This change doesn't add any implementations of rename=true, though one
is sketched in a TODO.

LGTM=crawshaw
R=crawshaw, rsc
CC=bradfitz, golang-codereviews
https://golang.org/cl/76400050
2014-03-25 09:37:10 -04:00
Robert Griesemer
a781b00b0d go.tools/go/types: avoid spurious "declared but not used" errors in case of other errors
LGTM=adonovan
R=adonovan
CC=golang-codereviews
https://golang.org/cl/76810044
2014-03-20 11:28:26 -07:00
Alan Donovan
a4491f08bf go.tools/oracle: fix bug in reduceScope on ad-hoc main packages.
LGTM=crawshaw
R=crawshaw
CC=golang-codereviews
https://golang.org/cl/77450048
2014-03-19 14:00:35 -04:00
Robert Griesemer
6256e2d81b go.tools/go/types: use package-local type names in errors referring to operands
LGTM=adonovan
R=adonovan
CC=golang-codereviews
https://golang.org/cl/77670043
2014-03-19 09:36:06 -07:00
Robert Griesemer
62216e60bb go.tools/go/types: use unqualified names for local objects in error messages
LGTM=adonovan
R=adonovan
CC=golang-codereviews
https://golang.org/cl/77590043
2014-03-18 13:37:09 -07:00
Andrew Gerrand
5893c271ff go.tools/dashboard: include builder in "invalid key" error message
LGTM=bradfitz
R=bradfitz
CC=golang-codereviews
https://golang.org/cl/77250043
2014-03-18 16:02:54 +11:00
Robert Daniel Kortschak
84fae1b215 go.tools/playground: provide script-safe option for playground
This change allows code to be sent safely to a partially sandboxed playground using the Native Client environment.

Execution of non-Go code is blocked when the RunScripts is false to prevent inclusion of code that might escape by virtue of being under a different runtime environment.

Two options for communicating whether to prevent non-Go code were considered: as has been done here and alternatively, using a message field. The latter was not chosen to close that as an attack option.

Another will be follow that adds a -nacl flag to the present command to allow sandboxing of playground code in presentations.

See discussion here: https://groups.google.com/d/topic/golang-dev/Hy-7PBP-T4Q/

LGTM=adg
R=adg, dave
CC=golang-codereviews
https://golang.org/cl/74740045
2014-03-17 16:57:36 +11:00
Alan Donovan
7877131709 cmd/godoc: fix careless crash introduced by recent analysis CL
+ basic integration test

LGTM=bgarcia
R=bgarcia, bradfitz
CC=golang-codereviews
https://golang.org/cl/76410045
2014-03-16 16:17:13 -04:00
Alan Donovan
80c4f06c0f go.tools/godoc: server mode: add support for type and pointer analysis.
See analysis.go for overview of new features.
See README for known bugs and issues.

Much UI polish, testing and optimization work remains, but
this is a starting point.

Flag: we add a new flag -analysis=type,pointer, default "",
for adventurous users only at this stage.
Type analysis takes ~10s for stdlib + go.tools;
Pointer analysis (currently) takes several minutes.

Dependencies: we now include jquery.treeview.js and its GIF
images among the resources.  (bake.go now handles binary.)

LGTM=crawshaw, bgarcia
R=crawshaw, bgarcia
CC=bradfitz, golang-codereviews
https://golang.org/cl/60540044
2014-03-14 18:58:22 -04:00
Alan Donovan
e3dc58c6e0 go.tools/go/loader: use the build.Context's I/O hooks, if any.
Also, add loader.Config.DisplayPath hook, which allows the
filename returned by build.Context.Import() to be transformed
prior to attaching to the AST.  This allows a virtual file
system to be used without leaking into the user interface.

Eliminate parsePackageFiles hook; I don't think we need it any
more.  The test that was using it has been rewritten to use
the build.Context hooks.

LGTM=gri
R=gri, crawshaw
CC=daniel.morsing, golang-codereviews, rsc
https://golang.org/cl/75520046
2014-03-14 16:17:53 -04:00
Robert Griesemer
71b6dfeb19 go.tools/go/types: correct a comment (was pointing at wrong issue)
LGTM=adonovan
R=adonovan
CC=golang-codereviews
https://golang.org/cl/76160044
2014-03-14 10:34:06 -07:00
Brad Garcia
a81074af88 godoc: Output "No match found" only if there is no ast or docs included in info.
Fixes golang/go#7499.

R=minux.ma
CC=golang-codereviews
https://golang.org/cl/75400043
2014-03-14 10:00:10 -04:00
David Symonds
7c69950f7f vet: Don't consider %T for recursive stringers.
Unlike the other anyType verbs, %T never calls String.

Fixes golang/go#7540.

LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/75580045
2014-03-14 16:08:04 +11:00
Andrew Gerrand
ccd43c1d95 go.tools/dashboard/app: send log hash to gobot on build failure
Fixes golang/go#7322.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/75630043
2014-03-14 09:51:13 +11:00
Robert Griesemer
c4ca0e2489 go.tools/go/types: don't change dot-imported object's parents
With this CL, an Object.Parent() Scope is always the scope in
which the object was originally declared. For dot-imported
objects, that is the package scope of the package from which
the objects are imported (not the file scope into which they
are imported).

Also:

- Changed Scope.Insert to be agnostic regarding blank
identifiers - blank identifiers must be handled outside.

- Fixed handling of blank labels: they are never declared.

Fixes golang/go#7537.

LGTM=adonovan
R=adonovan
CC=golang-codereviews
https://golang.org/cl/75570043
2014-03-13 13:22:44 -07:00
David Symonds
d4c8d5dae3 vet: Broaden suppression of recursive stringer warning.
Updates golang/go#6212.

LGTM=r, gri
R=r, gri
CC=golang-codereviews
https://golang.org/cl/75130043
2014-03-13 11:19:34 +11:00
Andrew Gerrand
1a2b7a26cc godoc/static: update site policies link
Fixes golang/go#7520.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/74900047
2014-03-13 10:50:06 +11:00
Rob Pike
e239f1b3f2 go.tools/cmd/vet: don't check for shadowing of blank identifier
It's pointless.
Also this fixes a crash, because the blank identifier no longer appears as a
defined object after CL 74190043 so we were getting nil pointer violations.
Even better, we get to re-enable a disabled test.

LGTM=gri
R=gri
CC=golang-codereviews
https://golang.org/cl/75140043
2014-03-13 10:27:55 +11:00
Robert Griesemer
ea79d922e6 go.tools/go/vet: temporarily disable some tests to fix build
Revert this CL once a proper fix is in place.

LGTM=adonovan
R=r, adonovan
CC=golang-codereviews
https://golang.org/cl/74930043
2014-03-12 11:56:25 -07:00
Alan Donovan
4f7b2f8882 go.tools/go/types: add Scope.comment as a debugging aid.
e.g. file foo.go scope {...}
     package math scope {...}
     function f scope {...}
     if scope {...}

LGTM=gri
R=gri
CC=golang-codereviews
https://golang.org/cl/74320043
2014-03-12 14:12:09 -04:00
Brad Fitzpatrick
305a363bdd dashboard/builder: fix bugs
1) Killing proceses on timeout was wrong: the os/exec
package will never return our package's error type
from its Wait.

2) fix a goroutine leak on timeout.

3) unexported an undocumented and elsewhere-unused type.

4) rename timeout type to end in "Error", per convention,
not Err.

LGTM=adg
R=adg
CC=golang-codereviews
https://golang.org/cl/74290043
2014-03-11 18:13:26 -07:00
Dave Cheney
dc0772a41e go.tools/dashboard/builder: always cross compile for nacl builds
If we are building, for example, linux/386 on a linux/amd64 machine we want to make sure that the whole build is done as a if this were compiled on a real linux/386 machine. In other words, we want to not do a cross compilation build.

The exception to this rule is when we are doing nacl builds. These are by definition always cross compilation, and we have support built into cmd/go to be able to handle this case.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/74230043
2014-03-12 09:52:02 +11:00
Alan Donovan
98ed3d3c76 go.tools/go/pointer: node renumbering
This change renumbers nodes so that addressable ones
  (that may appear in a points-to set) all have lower
  numbers than non-addressable ones----initially at least:
  reflection, SetFinalizer, etc add new nodes during
  solving.

  This improves the efficiency of sparse PTS
  representations (to be added later).  The largest int in
  a PTS is now about 20% of the previous max.

  Overview:
  - move constraint stuff into constraint.go.
  - add two methods to constraint:
    (1) renumber(): renumbers all nodeids.  The
        implementations are very repetitive but simple.  I
        thought hard about other ways (mixins, reflection)
        but decided this one was fine.
	(2) indirect(): report the set of nodeids whose
        points-to relations depend on the solver, not just
        the initial constraint graph.
        (This method is currently unused and is logically
        part of a forthcoming change to implement PE/LE
        presolver optimizations. (Perhaps I should comment
        it out/remove it for now.)
  - split up the population of the intrinsics map by file.
  - delete analysis.probes (unused field)
  - remove state="..." from panic message; unnecessary.

LGTM=crawshaw
R=crawshaw
CC=golang-codereviews
https://golang.org/cl/73320043
2014-03-11 18:37:19 -04:00
Robert Griesemer
52c6f24392 go.tools/go/types: short var decls require new variables
This appears to be a regression. Added fix and test case.

LGTM=adonovan
R=adonovan
CC=golang-codereviews
https://golang.org/cl/74190043
2014-03-11 15:31:12 -07:00
Alan Donovan
ba9c801433 go.tools: various comments + doc tweaks.
No functional changes.

LGTM=gri
R=gri
CC=golang-codereviews
https://golang.org/cl/74270043
2014-03-11 18:24:39 -04:00
Alan Donovan
be96a2037f go.tools/go/loader: fix broken test.
(The previous figure was based on an unclean workspace.)

LGTM=gri
R=gri
CC=golang-codereviews
https://golang.org/cl/74210043
2014-03-11 17:04:45 -04:00
Alan Donovan
cd987a3c83 go.tools/go/loader: allow loading of multiple test packages.
Now that go/types permits files to be added to a package
      incrementally (fixing bug 7114), this CL extends the loader
      to load and augment multiple test packages at once.

      TESTED:
      - go/loader/stdlib_test runs the type-checker on the entire
        standard library loaded from source in a single gulp, with
        each package augmented by tests.
      - Manually tested on:
        % ssadump -test -run unicode encoding/ascii85
            Both sets of tests are run (and pass).

LGTM=gri
R=gri
CC=golang-codereviews
https://golang.org/cl/61060043
2014-03-11 15:41:57 -04:00
Robert Griesemer
2b8dd19c64 go.tools/go/types: enable incremental adding of package files
With this CL, it is now possible to type-check additional
package files to an already type-checked package through
repeated calls to Checker.Files.

Fixes golang/go#7114.

LGTM=adonovan
R=adonovan
CC=golang-codereviews
https://golang.org/cl/72730043
2014-03-10 15:25:56 -07:00
Robert Griesemer
c5d02e0e94 go.tools/go/types: factor resolveFiles
Another step towards resolvinng issue 7114.

LGTM=adonovan
R=adonovan
CC=golang-codereviews
https://golang.org/cl/72550044
2014-03-07 14:40:14 -08:00
Robert Griesemer
f06b7e1853 go.tools/go/types: remove need for global initializer map
Another step towards resolving issue 7114.

LGTM=adonovan
R=adonovan
CC=golang-codereviews
https://golang.org/cl/72260043
2014-03-07 11:03:08 -08:00
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