1
0
mirror of https://github.com/golang/go synced 2024-10-01 03:18:33 -06:00
go/ssa
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
..
interp go.tools/importer: generalize command-line syntax. 2013-09-06 18:13:57 -04:00
testdata go.tools/ssa: fix bug in Program.VarValue. 2013-08-27 17:57:55 -04:00
blockopt.go go.tools: add copyright messages to source files. 2013-08-27 18:49:13 -04:00
builder_test.go go.tools/importer: generalize command-line syntax. 2013-09-06 18:13:57 -04:00
builder.go go.tools/importer: generalize command-line syntax. 2013-09-06 18:13:57 -04:00
const.go go.tools: add copyright messages to source files. 2013-08-27 18:49:13 -04:00
create.go go.tools/importer: generalize command-line syntax. 2013-09-06 18:13:57 -04:00
doc.go go.tools: add copyright messages to source files. 2013-08-27 18:49:13 -04:00
dom.go go.tools: add copyright messages to source files. 2013-08-27 18:49:13 -04:00
emit.go go.tools: add copyright messages to source files. 2013-08-27 18:49:13 -04:00
example_test.go go.tools/importer: generalize command-line syntax. 2013-09-06 18:13:57 -04:00
func.go go.tools/ssa: use correct names for Captures. 2013-09-06 09:19:34 -04:00
lift.go go.tools: add copyright messages to source files. 2013-08-27 18:49:13 -04:00
lvalue.go go.tools: add copyright messages to source files. 2013-08-27 18:49:13 -04:00
print.go go.tools: add copyright messages to source files. 2013-08-27 18:49:13 -04:00
promote.go go.tools: add copyright messages to source files. 2013-08-27 18:49:13 -04:00
sanity.go go.tools: add copyright messages to source files. 2013-08-27 18:49:13 -04:00
source_test.go go.tools/importer: generalize command-line syntax. 2013-09-06 18:13:57 -04:00
source.go go.tools: add copyright messages to source files. 2013-08-27 18:49:13 -04:00
ssa.go go.tools/importer: generalize command-line syntax. 2013-09-06 18:13:57 -04:00
stdlib_test.go go.tools/importer: generalize command-line syntax. 2013-09-06 18:13:57 -04:00
testmain.go go.tools/importer: generalize command-line syntax. 2013-09-06 18:13:57 -04:00
util.go go.tools: add copyright messages to source files. 2013-08-27 18:49:13 -04:00
visit.go go.tools/importer: generalize command-line syntax. 2013-09-06 18:13:57 -04:00