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

124 Commits

Author SHA1 Message Date
Alan Donovan
f1e5b03c6e go.tools/ssa: populate Function.Referrers(), for anon functions.
Added sanity check to ensure Operands/Referrers are complete and dual.

Also: unexport Instruction.setBlock (=> no longer user-implementable).

R=gri
CC=golang-dev
https://golang.org/cl/22150043
2013-11-07 10:08:51 -05:00
Alan Donovan
2e7d5a8b6b go.tools/ssa: dump types in "pkg."-unqualified form where appropriate.
Also: types.Typ[types.UnsafePointer].String() now always prints as "unsafe.Pointer".

R=gri
CC=golang-dev
https://golang.org/cl/21820044
2013-11-05 17:32:45 -05:00
Alan Donovan
d84d338a42 go.tools/ssa/interp: improve print() on interfaces, and log message for panic.
R=gri
CC=golang-dev
https://golang.org/cl/21960043
2013-11-05 13:03:14 -05:00
Alan Donovan
ce321e34d0 go.tools/ssa: simplify initialization of globals using go/types.Info.InitOrder.
R=gri
CC=golang-dev
https://golang.org/cl/21950043
2013-11-05 13:02:46 -05:00
Alan Donovan
0faac9ebe6 go.tools/ssa: include line count in stdlib_test.
R=gri
CC=golang-dev
https://golang.org/cl/20860043
2013-11-01 14:32:44 -04:00
Alan Donovan
74b761d099 go.tools/ssa: clarify spec of (*builder).complit().
Added test for []*map composite literals containing nested
literal subelements.  This required implementing
(reflect.Value).Map{Keys,Index} in ssa/interp.

Plus two minor fixes in ssa/interp.

R=gri
CC=golang-dev
https://golang.org/cl/20470043
2013-10-31 17:59:52 -04:00
Alan Donovan
bac7098173 go.tools/ssa: fix crash on (new)(T) due to missing unparen() call.
Audited codebase for other occurrences, found two more.
Added test coverage for all of them.

R=gri
CC=golang-dev
https://golang.org/cl/14698043
2013-10-29 11:07:09 -04:00
Alan Donovan
e29626539b go.tools/ssa: clarify that DebugRef relation is a function from ast.Expr to (ssa.Value, IsAddr bool), in docs and printed form.
R=gri
CC=golang-dev
https://golang.org/cl/18410043
2013-10-28 12:05:29 -04:00
Alan Donovan
aa2386290b go.tools/ssa: new Function.Syntax() returns the declaring AST (debug mode) or just the Pos/End of the function's extent (otherwise).
R=gri
CC=golang-dev
https://golang.org/cl/16980043
2013-10-27 10:55:21 -04:00
Alan Donovan
d644aa1fcd go.tools/ssa/interp: enable $GOROOT/test/switch.go test
(now that go/types can handle it)

R=gri
TBR=gri
CC=golang-dev
https://golang.org/cl/16970043
2013-10-24 22:38:10 -04:00
Alan Donovan
9f640c2abb go.tools/ssa: record lvalue/rvalue distinction precisely in DebugRef.
A DebugRef associates a source expression E with an ssa.Value
V, but until now did not record whether V was the value or the
address of E.  So, we would guess from the "pointerness" of
the Value, leading to confusion in some cases, e.g.

   type N *N
   var n N
   n = &n  // lvalue and rvalue are both pointers

Now we explicitly record 'IsAddress bool' in DebugRef, and
plumb this everywhere: through (*Function).ValueForExpr and
(*Program).VarValue, all the way to forming the pointer
analysis query.

Also:
- VarValue now treats each reference to a global distinctly,
  just like it does for other vars.  So:
    var g int
    func f() {
   	g = 1     // VarValue(g) == Const(1:int), !isAddress
        print(g)  // VarValue(g) == Global(g), isAddress
    }
- DebugRefs are not emitted for references to predeclared
  identifiers (nil, built-in).
- DebugRefs no longer prevent lifting of an Alloc var into a
  register; now we update or discard the debug info.
- TestValueForExpr: improve coverage of ssa.EnclosingFunction
  by putting expectations in methods and init funcs, not just
  normal funcs.
- oracle: fix golden file broken by recent
  (*types.Var).IsField change.

R=gri
CC=golang-dev
https://golang.org/cl/16610045
2013-10-24 18:31:50 -04:00
Alan Donovan
8636f40baf go.tools/ssa: CreateTestMainPackage: synthesize test driver as a package ("testmain") not 'main' function.
This allows us to run/analyze multiple tests.
Also it causes the production code packages to be properly initialized.

Also:
- cmd/ssadump: improved usage message (add example;
  incorporate LoadInitialPackages usage; explain how -run
  finds main).
- pointer, oracle, ssa/interp: use CreateTestMainPackage.
- ssa/builder.go: remove 'rundefers' instruction from package init,
  which no longer uses 'defer'.

R=gri
CC=golang-dev
https://golang.org/cl/15920047
2013-10-23 18:07:53 -04:00
Alan Donovan
87ced824bd go.tools/ssa: fix computation of set of types requiring method sets.
Motivation:

Previously, we assumed that the set of types for which a
complete method set (containing all synthesized wrapper
functions) is required at runtime was the set of types
used as operands to some *ssa.MakeInterface instruction.

In fact, this is an underapproximation because types can
be derived from other ones via reflection, and some of
these may need methods.  The reflect.Type API allows *T to
be derived from T, and these may have different method
sets.  Reflection also allows almost any subcomponent of a
type to be accessed (with one exception: given T, defined
'type T struct{S}', you can reach S but not struct{S}).

As a result, the pointer analysis was unable to generate
all necessary constraints before running the solver,
causing a crash when reflection derives types whose
methods are unavailable.  (A similar problem would afflict
an ahead-of-time compiler based on ssa.  The ssa/interp
interpreter was immune only because it does not require
all wrapper methods to be created before execution
begins.)

Description:

This change causes the SSA builder to record, for each
package, the set of all types with non-empty method sets that
are referenced within that package.  This set is accessed via
Packages.TypesWithMethodSets().  Program.TypesWithMethodSets()
returns its union across all packages.

The set of references that matter are:
- types of operands to some MakeInterface instruction (as before)
- types of all exported package members
- all subcomponents of the above, recursively.
This is a conservative approximation to the set of types
whose methods may be called dynamically.

We define the owning package of a type as follows:
- the owner of a named type is the package in which it is defined;
- the owner of a pointer-to-named type is the owner of that named type;
- the owner of all other types is nil.

A package must include the method sets for all types that it
owns, and all subcomponents of that type that are not owned by
another package, recursively.  Types with an owner appear in
exactly one package; types with no owner (such as struct{T})
may appear within multiple packages.
(A typical Go compiler would emit multiple copies of these
methods as weak symbols; a typical linker would eliminate
duplicates.)

Also:
- go/types/typemap: implement hash function for *Tuple.
- pointer: generate nodes/constraints for all of
  ssa.Program.TypesWithMethodSets().
  Add rtti.go regression test.
- Add API test of Package.TypesWithMethodSets().
- Set Function.Pkg to nil (again) for wrapper functions,
  since these may be shared by many packages.
- Remove a redundant logging statement.
- Document that ssa CREATE phase is in fact sequential.

Fixes golang/go#6605

R=gri
CC=golang-dev
https://golang.org/cl/14920056
2013-10-23 17:07:52 -04:00
Robert Griesemer
c8f4d650c8 go.tools/ssa/interp: make typeAssert robust against nil types
R=adonovan
CC=golang-dev
https://golang.org/cl/16180043
2013-10-23 13:45:49 -07:00
Robert Griesemer
a1886cc6ef go/tools/ssa/interp: make iface.eq robust against nil types
A future version of go/types.IsIdentical does not accept
nil types anymore.

R=adonovan
CC=golang-dev
https://golang.org/cl/16150043
2013-10-23 13:26:23 -07:00
Robert Griesemer
d8391b87d1 go.tools/ssa/interp: use new Sizes interface (fix build)
R=adonovan
TBR=adonovan
CC=golang-dev
https://golang.org/cl/14722043
2013-10-15 15:30:03 -07:00
Alan Donovan
2accef29d7 go.tools/ssa: implement correct control flow for recovered panic.
A function such as this:
        func one() (x int) {
                defer func() { recover() }()
                x = 1
                panic("return")
        }
that combines named return parameters (NRPs) with deferred calls
that call recover, may return non-zero values despite the
fact it doesn't even contain a return statement. (!)

This requires a change to the SSA API: all functions'
control-flow graphs now have a second entry point, called
Recover, which is the block at which control flow resumes
after a recovered panic.  The Recover block simply loads the
NRPs and returns them.

As an optimization, most functions don't need a Recover block,
so it is omitted.  In fact it is only needed for functions that
have NRPs and defer a call to another function that _may_ call
recover.

Dataflow analysis of SSA now requires extra work, since every
may-panic instruction has an implicit control-flow edge to
the Recover block.  The only dataflow analysis so far implemented
is SSA renaming, for which we make the following simplifying
assumption: the Recover block only loads the NRPs and returns.
This means we don't really need to analyze it, we can just
skip the "lifting" of such NRPs.  We also special-case the Recover
block in the dominance computation.

Rejected alternative approaches:
- Specifying a Recover block for every defer instruction (like a
   traditional exception handler).
   This seemed like excessive generality, since Go programs
   only need the same degenerate form of Recover block.
- Adding an instruction to set the Recover block immediately
   after the named return values are set up, so that dominance
   can be computed without special-casing.
   This didn't seem worth the effort.

Interpreter:
- This CL completely reimplements the panic/recover/
  defer logic in the interpreter.  It's clearer and simpler
  and closer to the model in the spec.
- Some runtime panic messages have been changed to be closer
  to gc's, since tests depend on it.
- The interpreter now requires that the runtime.runtimeError
  type be part of the SSA program.  This requires that clients
  import this package prior to invoking the interpreter.
  This in turn requires (Importer).ImportPackage(path string),
  which this CL adds.
- All $GOROOT/test/recover{,1,2,3}.go tests are now passing.

NB, the bug described in coverage.go (defer/recover in a concatenated
init function) remains.  Will be fixed in a follow-up.

Fixes golang/go#6381

R=gri
CC=crawshaw, golang-dev
https://golang.org/cl/13844043
2013-10-14 15:38:56 -04:00
Alan Donovan
7aabe2e113 go.tools/ssa: build a separate Function for each init() func.
Before, we would concatenate all the init() blocks together,
resulting in incorrect treatment of a recovered panic in one
init block: the implicit return would cause the subsequent ones
to be skipped.

The result is simpler, and closer to what gc does.

The additional functions are visible in the call graph,
so some tests required updating.

R=gri
CC=crawshaw, golang-dev
https://golang.org/cl/14671044
2013-10-14 14:08:23 -04:00
Alan Donovan
1ff3452afa go.tools/ssa: unexport Register.
R=gri
CC=golang-dev
https://golang.org/cl/14672043
2013-10-14 13:48:34 -04:00
Robert Griesemer
271af2c149 go.tools/importer: delete BuiltinCallSignature
This functionality is now provided by go/types.

R=adonovan
CC=golang-dev
https://golang.org/cl/14489045
2013-10-11 12:26:31 -07:00
Alan Donovan
e1e9089196 go.tools/importer: change type of print{,ln} built-ins.
Before: func(any, ...interface{}).
After:  func(any, ...any)

They are no longer variadic, so you can't write print(x, y...).

(Recall that print(1) and print(interface{}(1)) behave
differently and that this is useful.)

Fixes bug 6560

R=gri
CC=golang-dev
https://golang.org/cl/14455054
2013-10-10 13:33:29 -04:00
Alan Donovan
9cce4759bb go.tools/importer: expose CreatePackage method.
The new method is functionally identical to typeCheck, and
obviates the LoadMainPackage method.

Updated all clients.

Fixes bug 6561.

R=gri
CC=golang-dev
https://golang.org/cl/14494051
2013-10-10 12:37:49 -04:00
Robert Griesemer
f50f6c858a go.tools/go/types: nil is not a constant + misc. cleanups
- removed support for nil constants from go/exact
- instead define a singleton Nil Object (the nil _value_)
- in assignments, follow more closely spec wording
  (pending spec CL 14415043)
- removed use of goto in checker.unary
- cleanup around handling of isRepresentable for
  constants, with better error messages
- fix missing checks in checker.convertUntyped
- added isTyped (== !isUntyped) and isInterface predicates
- fixed hasNil predicate: unsafe.Pointer also has nil
- adjusted ssa per adonovan
- implememted types.Implements (wrapper arounfd types.MissingMethod)
- use types.Implements in vet (and fix a bug)

R=adonovan, r
CC=golang-dev
https://golang.org/cl/14438052
2013-10-09 14:17:25 -07:00
Alan Donovan
e590cdbdf8 go.tools/ssa: doc tweaks + a sanity check.
R=gri
CC=golang-dev
https://golang.org/cl/14454053
2013-10-09 12:47:30 -04:00
Alan Donovan
cd908f1108 go.tools/ssa/interp: capture stdout/err of target programs and check for "BUG".
The $GOROOT/tests may print "BUG" on failure but do not
necessarily exit zero, so we must capture their output too.

Details:
- make plan9 use unix's valueToBytes function (now in externals.go)
- direct the target's syscall.Write and print/println built-ins to a new utility, write().  This may capture the output into a global variable.

R=gri, r
CC=golang-dev
https://golang.org/cl/14550044
2013-10-08 14:35:39 -04:00
Alan Donovan
068f017092 go.tools/ssa: s/Ret/Return/g
R=gri
CC=golang-dev
https://golang.org/cl/14526044
2013-10-08 12:31:39 -04:00
Alan Donovan
8ae5d36d2a go.tools: clear DeclarationErrors flag; it's redundant w.r.t go/types checking.
R=gri
CC=golang-dev
https://golang.org/cl/14147043
2013-10-08 10:34:36 -04:00
Alan Donovan
eb632ebaca go.tools/ssa/interp: enable tests of builtin(f()) where f has multiple results.
R=gri
CC=golang-dev
https://golang.org/cl/14408043
2013-10-04 16:52:12 -04: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
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
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
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
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
Alan Donovan
7e7d99b4c9 go.tools/ssa/interp: fixes to enable running tests of package "encoding".
Running the interpreter on (most of) the tests package in
"encoding" unearthed a couple of ssa.builder bugs, already
fixed.  This CL contains the interpreter fixes that were
required.  (The "encoding" tests aren't added to the suite
since they're slow.)

Added intrinsics for:
        math.Exp
        math.Min
        hash/crc32.haveSSE42
        (reflect.Type).Field
        (reflect.Type).NumField
        (reflect.Type).NumMethod
        reflect.New
        (reflect.Value).NumMethod
        syscall.RawSyscall (returns ENOSYS)
        reflect.Set (a no-op)

Treat unsafe.Pointer -> *T conversions by returning new(T).
This is incorrect but at least preserves type-safety,
which is sufficient for these tests.

hashmap: treat nil *hashmap as an empty map.

R=gri
CC=golang-dev
https://golang.org/cl/12901046
2013-09-12 11:00:31 -04:00
Alan Donovan
6bc6da88ec go.tools/ssa/interp: implement unary negation of complex numbers.
Fixes golang/go#6291.

Also: call go/types.DefaultSizeof instead of hard-coding the
initial value of runtime.sizeof_C_MStats.

R=gri
CC=golang-dev
https://golang.org/cl/13648043
2013-09-10 12:08:55 -04:00
Alan Donovan
3f2f9a7e70 go.tools/importer: generalize command-line syntax.
Motivation: pointer analysis tools (like the oracle) want the
user to specify a set of initial packages, like 'go test'.
This change enables the user to specify a set of packages on
the command line using importer.LoadInitialPackages(args).

Each argument is interpreted as either:
- a comma-separated list of *.go source files together
  comprising one non-importable ad-hoc package.
  e.g. "src/pkg/net/http/triv.go" gives us [main].
- an import path, denoting both the imported package
  and its non-importable external test package, if any.
  e.g. "fmt" gives us [fmt, fmt_test].

Current type-checker limitations mean that only the first
import path may contribute tests: multiple packages augmented
by *_test.go files could create import cycles, which 'go test'
avoids by building a separate executable for each one.
That approach is less attractive for static analysis.

Details:  (many files touched, but importer.go is the crux)

importer:
- PackageInfo.Importable boolean indicates whether
  package is importable.
- un-expose Importer.Packages; expose AllPackages() instead.
- CreatePackageFromArgs has become LoadInitialPackages.
- imports() moved to util.go, renamed importsOf().
- InitialPackagesUsage usage message exported to clients.
- the package name for ad-hoc packages now comes from the
  'package' decl, not "main".

ssa.Program:
- added CreatePackages() method
- PackagesByPath un-exposed, renamed 'imported'.
- expose AllPackages and ImportedPackage accessors.

oracle:
- describe: explain and workaround a go/types bug.

Misc:
- Removed various unnecessary error.Error() calls in Printf args.

R=crawshaw
CC=golang-dev
https://golang.org/cl/13579043
2013-09-06 18:13:57 -04:00
Alan Donovan
33f988691e go.tools/ssa: use correct names for Captures.
Until now, the name of the captured ssa.Value, not
types.Var was used, leading to confusing disassembly
when it was a numbered register.  See:
https://code.google.com/p/go/issues/detail?id=6337

Now the output is:

# Free variables:
#   0:	a *int
#   1:	b *int
func func@6.9() int:
.0.entry:
        t0 = *b
        t1 = *a
        t2 = *b
        etc...

BUG=6337

R=crawshaw
CC=golang-dev
https://golang.org/cl/13249049
2013-09-06 09:19:34 -04:00
Alan Donovan
b21b4e8c88 go.tools/importer: negate "cgo" build tag to avoid native code in "net".
This removes the need for the caller to specify CGO_ENABLED=0
in the environment.

R=crawshaw
CC=golang-dev
https://golang.org/cl/13464045
2013-09-04 15:20:38 -04:00
Alan Donovan
e2921e188a go.tools/importer: make loading/parsing concurrent.
1. ParseFiles (in util.go) parses each file in its own goroutine.

2. (*Importer).LoadPackage asynchronously prefetches the
   import graph by scanning the imports of each loaded package
   and calling LoadPackage on each one.

   LoadPackage is now thread-safe and idempotent: it uses a
   condition variable per package; the first goroutine to
   request a package becomes responsible for loading it and
   broadcasts to the others (waiting) when it becomes ready.

ssadump runs 34% faster when loading the oracle.

Also, refactorings:
- delete SourceLoader mechanism; just expose go/build.Context directly.
- CreateSourcePackage now also returns an error directly,
  rather than via PackageInfo.Err, since every client wants that.

R=crawshaw
CC=golang-dev
https://golang.org/cl/13509045
2013-09-04 13:15:49 -04:00
Alan Donovan
b43fa6fbda go.tools/cmd/ssadump: move ssa/ssadump.go command to its own package.
(Its former location was based on a misunderstanding of 'go build'.)

Also: set GOMAXPROCS to NumCPU by default.

R=crawshaw
CC=golang-dev
https://golang.org/cl/13354043
2013-08-29 21:34:36 -04:00
Alan Donovan
713699d8ad go.tools: add copyright messages to source files.
R=r
CC=golang-dev
https://golang.org/cl/13305043
2013-08-27 18:49:13 -04:00
Alan Donovan
be2647ec01 go.tools/ssa: fix bug in Program.VarValue.
Before, VarValue looked for the ssa.Value for the 'var' object
in the same package as the object was defined, but this is
(obviously) wrong for a cross-package FieldVal selection,
expr.f.  The caller must provide the package containing the
reference.

+ test.

Also:
- add 2 TODOs.
- split builder.expr into two functions so we don't need
  defer, which makes panic dumps harder to read.

R=golang-dev, crawshaw
CC=golang-dev
https://golang.org/cl/13257045
2013-08-27 17:57:55 -04:00
Alan Donovan
de47ebac4b go.tools/ssa: fix bad type info in 'for _ = range channel'.
Previously, if the result was not wanted, the received
(value, ok) tuple had no type for 'value'.
Now it is always set to the channel's element type.

Also: set the position on such receive instructions to that of
the = or := token, and document it.

+ (indirect) test via pointer analysis.

R=crawshaw, gri
CC=golang-dev
https://golang.org/cl/12956052
2013-08-27 11:18:31 -04:00
Alan Donovan
c8a6890a12 go.tools/ssa: fix a bug building SSA code for ast.CompositeLit.
Map literals should use the same recursion logic as
struct/array/slice literals to apply an implicit &-operator to
the nested literals when a pointer is wanted.

+ test.

Also:
- ensure we set the source location for all Lookup and
  MapUpdate instructions.
- remove obsolete address.object field.

R=gri, crawshaw
CC=golang-dev
https://golang.org/cl/12787048
2013-08-22 10:13:51 -04:00
Alan Donovan
99ac9493e1 go.types/ssa: add back Signature.Recv to interface method wrappers.
It is needed after all, as I discovered in the pointer analysis.
(ssa needs more API test coverage.)

Also:
- sanity: remove debugging cruft
- promote: don't redundantly include the function's
  own name in its Synthetic string.
- print: IntuitiveMethodSet utility fixes a bug in the
  printing logic (for interface types, mset(*T) is empty).
  The function is also used by the Oracle.

R=crawshaw
CC=golang-dev
https://golang.org/cl/13116043
2013-08-20 14:50:13 -04:00
Alan Donovan
5cbf2abd36 go.tools/ssa: ensure address-deriving operations panic on nil inputs.
&x.f, &x[0], x[i:j], &*x all must panic if x==nil.

The first three are already addressed by the semantics of
FieldAddr, IndexAddr, Slice; updated docs to reflect this.
The final case requires generation of an additional dynamic check.

See golang.org/s/go12nil for details.

Tested on $GOROOT/test/nilptr2.go (with patch from CL 13108043)

Also: remove a TODO where a no-op will do.

R=gri, crawshaw
CC=golang-dev, rsc
https://golang.org/cl/13064044
2013-08-19 17:51:33 -04:00
Alan Donovan
7072253af5 go.tools/ssa: fixes, cleanups, cosmetic tweaks.
Fix bug: the Signature for an interface method wrapper
erroneously had a non-nil receiver.

Function:
- Set Pkg field non-nil even for wrappers.
  It is equal to that of the wrapped function.
  Only wrappers of error.Error
  (and its embeddings in other interfaces) may have nil.
  Sanity checker now asserts this.
- FullName() now uses .Synthetic field to discriminate
  synthetic methods, not Pkg==nil.
- Fullname() uses new relType() utility to print receiver type
  name unqualified if it belongs to the same package.
  (Alloc.String also uses relType utility.)

CallCommon:
- Description(): fix switch logic broken when we
  eliminated the Recv field.
- better docs.

R=david.crawshaw, crawshaw, gri
CC=golang-dev
https://golang.org/cl/13057043
2013-08-19 15:38:30 -04:00
Alan Donovan
50bd0e3288 go.tools/ssa: synthesize main functions for test packages.
Package.CreateTestMainFunction() creates a function called
main and adds it to the package.  This function calls
testing.Main in the Go library with the appropriate arguments:
slices of test, benchmark and example functions from the
package.

Tested by running the interpreter on the following tests:
- unicode/script_test.go
- unicode/digit_test.go
- hash/crc32/crc32_test.go
- path/path_test.go

It's also covered indirectly via the pointer analysis.

R=crawshaw, gri
CC=golang-dev
https://golang.org/cl/12814046
2013-08-19 15:00:25 -04:00
Alan Donovan
3b53279d8f go.tools/ssa: preserve type of &&/|| operands in result.
+ test.

With this change, the Go Oracle is now self-aware. :)

R=gri, rsc
CC=golang-dev
https://golang.org/cl/12381043
2013-08-19 12:50:40 -04:00
Robert Griesemer
ae874abc7a go.tools/go/types: *interface types have no methods
Fixes golang/go#5918.

R=adonovan
CC=golang-dev
https://golang.org/cl/12909043
2013-08-14 11:02:10 -07:00