]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: simplify exportsym flags and logic
authorMatthew Dempsky <mdempsky@google.com>
Mon, 2 Apr 2018 22:38:57 +0000 (15:38 -0700)
committerMatthew Dempsky <mdempsky@google.com>
Mon, 2 Apr 2018 23:12:53 +0000 (23:12 +0000)
commitce1252a6109ad81840ba7c0c69138175b093d107
tree8dbbe36edcfcc7b68c2d90933e8d2bd472d051ea
parent096d96779aca3baaa14644f64313abf03ff3d49f
cmd/compile: simplify exportsym flags and logic

We used to have three Sym flags for dealing with export/reexport:
Export, Package, and Exported.

Export and Package were used to distinguish whether a symbol is
exported or package-scope (i.e., mutually exclusive), except that for
local declarations Export served double-duty as tracking whether the
symbol had been added to exportlist.

Meanwhile, imported declarations that needed reexporting could be
added to exportlist multiple times, necessitating a flag to track
whether they'd already been written out by exporter.

Simplify all of these into a single OnExportList flag so that we can
ensure symbols on exportlist are present exactly once. Merge
reexportsym into exportsym so there's a single place where we append
to exportlist.

Code that used to set Exported to prevent a symbol from being exported
can now just set OnExportList before calling declare to prevent it
from even appearing on exportlist.

Lastly, drop the IsAlias check in exportsym: we call exportsym too
early for local symbols to detect if they're an alias, and we never
reexport aliases.

Passes toolstash-check.

Change-Id: Icdea3719105dc169fcd7651606589cd08b0a80ff
Reviewed-on: https://go-review.googlesource.com/103865
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/cmd/compile/internal/gc/bexport.go
src/cmd/compile/internal/gc/closure.go
src/cmd/compile/internal/gc/export.go
src/cmd/compile/internal/gc/inl.go
src/cmd/compile/internal/gc/subr.go
src/cmd/compile/internal/types/sym.go