aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/noder
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2021-02-17 16:30:12 -0500
committerRuss Cox <rsc@golang.org>2021-02-17 16:43:48 -0500
commit0f210b75f9d8707f4e8a34ce23b778df33e9b501 (patch)
treeb6a63bf7b4983779b5f36169ae766afe14bbac02 /src/cmd/compile/internal/noder
parent1aea1b199f261c95a769ef3a2722a1e6a64a6939 (diff)
parent2f0da6d9e29d9b9d5a4d10427ca9f71d12bbacc8 (diff)
downloadgo-0f210b75f9d8707f4e8a34ce23b778df33e9b501.tar.xz
[dev.boringcrypto] all: merge master (2f0da6d) into dev.boringcrypto
Manual edits in src/cmd/compile/internal/reflectdata/reflect.go to keep build working. Merge List: + 2021-02-17 2f0da6d9e2 go/types: revert "no 'declared but not used' errors for invalid var decls" + 2021-02-17 70c37ee7d0 cmd/compile/internal/test: gofmt abiutils_test.go + 2021-02-16 84825599dc all: merge branch dev.regabi (d3cd4830ad) into master + 2021-02-16 d3cd4830ad [dev.regabi] test: run abi/regabipragma test with -c=1 + 2021-02-16 03cea563d1 [dev.regabi] all: merge master (5faf941) into dev.regabi + 2021-02-16 b8fb049c7a [dev.regabi] cmd/go: copy internal/abi in TestNewReleaseRebuildsStalePackagesInGOPATH + 2021-02-16 5faf941df0 internal/goversion: update Version to 1.17 + 2021-02-16 ed55da46ab [dev.regabi] go/types: overlapping embedded interfaces requires go1.14 + 2021-02-16 7696c94334 [dev.regabi] go/types: type alias decl requires go1.9 + 2021-02-16 c2358a1ae7 [dev.regabi] runtime: stub out spillArgs and unspillArgs + 2021-02-16 8cfbf34dd9 internal/abi: set register count constants to zero for regabi experiment + 2021-02-16 6f3da9d2f6 README: pull gopher image from website + 2021-02-16 d28aae26b0 [dev.regabi] cmd/link: recognize internal/abi as runtime package + 2021-02-16 098504c73f cmd/link: generate trampoline for inter-dependent packages + 2021-02-16 1004a7cb31 runtime/metrics: update documentation to current interface + 2021-02-16 6530f2617f doc/go1.16: remove draft notice + 2021-02-16 353e111455 doc/go1.16: fix mismatched id attribute + 2021-02-16 e0215315f5 [dev.regabi] reflect: support for register ABI on amd64 for reflect.(Value).Call + 2021-02-16 f0d23c9dbb internal/poll: netpollcheckerr before sendfile + 2021-02-16 0cb3415154 doc: remove all docs not tied to distribution + 2021-02-16 626ef08127 doc: remove install.html and install-source.html + 2021-02-16 30641e36aa internal/poll: if copy_file_range returns 0, assume it failed + 2021-02-15 33d72fd412 doc/faq: update generics entry to reflect accepted proposal + 2021-02-15 852ce7c212 cmd/go: provide a more helpful suggestion for "go vet -?" + 2021-02-13 66c27093d0 cmd/link: fix typo in link_test.go + 2021-02-13 b81efb7ec4 [dev.regabi] go/types: add support for language version checking + 2021-02-13 a7e9b4b948 [dev.regabi] go/types: untyped shift counts must fit into uint + 2021-02-13 060fa49bd2 [dev.regabi] go/types: refuse excessively long constants + 2021-02-12 baa6c75dce [dev.regabi] internal/abi: add new internal/abi package for ABI constants + 2021-02-12 d1fd9a8863 [dev.regabi] all: merge master (ff0e93e) into dev.regabi + 2021-02-12 ff0e93ea31 doc/go1.16: note that package path elements beginning with '.' are disallowed + 2021-02-11 249da7ec02 CONTRIBUTORS: update for the Go 1.16 release + 2021-02-11 864d4f1c6b cmd/go: multiple small 'go help' fixes + 2021-02-11 26ceae85a8 spec: More precise wording in section on function calls. + 2021-02-11 930c2c9a68 cmd/go: reject embedded files that can't be packed into modules + 2021-02-11 e5b08e6d5c io/fs: allow backslash in ValidPath, reject in os.DirFS.Open + 2021-02-10 ed8079096f cmd/compile: mark concrete call of reflect.(*rtype).Method as REFLECTMETHOD + 2021-02-10 59703d53e2 [dev.regabi] cmd/link: stop using ABI aliases if wrapper is enabled + 2021-02-09 e9c9683597 cmd/go: suppress errors from 'go get -d' for packages that only conditionally exist + 2021-02-09 168d6a49a5 [dev.regabi] go/types: use 512 bits as max. integer precision + 2021-02-09 0a62067708 [dev.regabi] go/types: adjust importer to match compiler importer + 2021-02-09 1c58fcf7ed [dev.regabi] go/types: handle untyped constant arithmetic overflow + 2021-02-09 493363ccff [dev.regabi] go/types: must not import a package called "init" + 2021-02-09 e0ac989cf3 archive/tar: detect out of bounds accesses in PAX records resulting from padded lengths + 2021-02-09 c48d1503ba [dev.regabi] go/types: report unused packages in source order + 2021-02-09 813958f13c [dev.regabi] go/types: factor out sorting of methods + 2021-02-09 11d15c171b [dev.regabi] go/types: convert untyped arguments to delete + 2021-02-09 c9d6f45fec runtime/metrics: fix a couple of documentation typpos + 2021-02-09 cea4e21b52 io/fs: backslash is always a glob meta character + 2021-02-08 dc725bfb3c doc/go1.16: mention new vet check for asn1.Unmarshal + 2021-02-08 618e3c15bd [dev.regabi] go/types: consistently report nil type as "untyped nil" + 2021-02-08 50449de66a [dev.regabi] all: merge master (1901853) into dev.regabi + 2021-02-08 7b0dfb177f [dev.regabi] runtime: use g register in some assembly functions on AMD64 + 2021-02-08 2e60c00f56 [dev.regabi] cmd/internal/obj/x86: use g register in stack bounds check + 2021-02-08 22f9e1ccbc [dev.regabi] runtime: initialize special registers before sigpanic + 2021-02-08 5d7dc53888 [dev.regabi] cmd/compile, runtime: reserve R14 as g registers on AMD64 + 2021-02-08 1901853098 runtime/metrics: fix panic in readingAllMetric example + 2021-02-08 ed3e4afa12 syscall/plan9: remove spooky fd action at a distance + 2021-02-08 a21de9ec73 [dev.regabi] cmd/link: resolve symbol ABI in shared linkage + 2021-02-05 724d0720b3 doc/go1.16: add missed heading tag in vet section + 2021-02-05 b54cd94d47 embed, io/fs: clarify that leading and trailing slashes are disallowed + 2021-02-05 4516afebed testing/fstest: avoid symlink-induced failures in tester + 2021-02-05 8fa84772ba [dev.regabi] runtime: delete gosave function + 2021-02-05 946351d5a2 [dev.regabi] runtime: zero X15 in racecall + 2021-02-05 397a46a10a [dev.regabi] cmd/asm: define g register on AMD64 + 2021-02-05 e79c2fd428 [dev.regabi] runtime: mark racecallbackthunk as ABIInternal + 2021-02-05 7cc6de59f2 [dev.regabi] runtime: don't mark rt0_go ABIInternal + 2021-02-05 63de211014 [dev.regabi] runtime/cgo: call setg_gcc in crosscall_amd64 + 2021-02-04 120b819f45 [dev.regabi] go/types: report error for invalid main function signature + 2021-02-04 52d5cb2822 [dev.regabi] cmd/internal/obj: access Attribute atomically + 2021-02-04 bc451b5770 [dev.regabi] go/types: port check_test.go ergonomics from dev.typeparams + 2021-02-04 afd67f3334 [dev.regabi] go/types: no "declared but not used" errors for invalid var decls + 2021-02-04 8869086d8f runtime: fix typo in histogram.go + 2021-02-03 401d7e5a24 [dev.regabi] cmd/compile: reserve X15 as zero register on AMD64 + 2021-02-03 bfc7418e6d [dev.regabi] runtime, syscall, etc.: mark Darwin syscall wrappers as ABIInternal + 2021-02-03 e491c6eea9 math/big: fix comment in divRecursiveStep + 2021-02-02 23b0c1f76e [dev.regabi] all: merge master (fca94ab) into dev.regabi + 2021-02-02 fca94ab3ab spec: improve the example in Type assertions section + 2021-02-02 98f8454a73 cmd/link: don't decode type symbol in shared library in deadcode + 2021-02-02 1426a571b7 cmd/link: fix off-by-1 error in findShlibSection + 2021-02-01 32e789f4fb test: fix incorrectly laid out instructions in issue11656.go + 2021-02-01 ca6999e27c [dev.regabi] test: add a test for inlining closures + 2021-02-01 0b6cfea634 doc/go1.16: document that on OpenBSD syscalls are now made through libc + 2021-02-01 26e29aa15a cmd/link: disable TestPIESize if CGO isn't enabled + 2021-02-01 6ac91e460c doc/go1.16: minor markup fixes + 2021-01-29 44361140c0 embed: update docs for proposal tweaks + 2021-01-29 68058edc39 runtime: document pointer write atomicity for memclrNoHeapPointers + 2021-01-28 c8bd8010ff syscall: generate readlen/writelen for openbsd libc + 2021-01-28 41bb49b878 cmd/go: revert TestScript/build_trimpath to use ioutil.ReadFile + 2021-01-28 725a642c2d runtime: correct syscall10/syscall10X on openbsd/amd64 + 2021-01-28 4b068cafb5 doc/go1.16: document go/build/constraint package + 2021-01-28 376518d77f runtime,syscall: convert syscall on openbsd/arm64 to libc + 2021-01-27 aca22bddf2 [dev.regabi] cmd/compile: remove nested functions from expands_calls.go + 2021-01-27 667e08ba8c [dev.regabi] cmd/go: Use GOMAXPROCS to limit default build, compile parallelism + 2021-01-27 00f2ff5c94 api/go1.16: add go/build/constraint APIs + 2021-01-27 35334caf18 crypto/x509: remove leftover CertificateRequest field + 2021-01-27 a5a5e2c968 runtime: make sure to remove open-coded defer entries in all cases after a recover + 2021-01-27 8cfa01943a runtime: block console ctrlhandler when the signal is handled + 2021-01-27 ff9e8364c6 cmd/go: skip issue33139 when the 'cc' script command is unavailable + 2021-01-27 cd176b3615 runtime: switch runtime to libc for openbsd/arm64 + 2021-01-27 6c8fbfbdcf runtime: convert openbsd/arm64 locking to libc + 2021-01-27 5cdf0da1bf syscall: clean up mkasm related changes + 2021-01-27 210f70e298 doc/go1.16: fix closing brace in .Export format + 2021-01-27 0f797f168d math: fix typo in sqrt.go code comment + 2021-01-26 9b636feafe [dev.regabi] cmd/compile: missing last patch set for cl286013 + 2021-01-26 f7dad5eae4 [dev.regabi] cmd/compile: remove leftover code form late call lowering work + 2021-01-26 8634a234df runtime,syscall: convert syscall on openbsd/amd64 to libc + 2021-01-26 1d5e14632e os: further document limitations around naked file descriptors + 2021-01-25 5e4a0cdde3 [dev.regabi] all: merge master (bf0f7c9) into dev.regabi + 2021-01-26 cf263e9f77 os: correct names in CreateTemp and MkdirTemp doc comments + 2021-01-26 ce8b318624 net/http/fcgi: remove locking added to prevent a test-only race + 2021-01-25 bf0f7c9d78 doc/go1.16: mention os.DirFS in os section + 2021-01-25 deaf29a8a8 cmd/compile: fix order-of-assignment issue w/ defers + 2021-01-25 ad2ca26a52 doc/go1.16: mention os.DirEntry and types moved from os to io/fs + 2021-01-25 a51921fa5b doc/go1.16: mention new testing/iotest functions + 2021-01-25 e6b6d107f7 doc/go1.16: mention deprecation of io/ioutil + 2021-01-25 7eaaf28cae [dev.regabi] cmd/compile: disallow taking address of SSA'd values + 2021-01-25 96a276363b doc/go1.16: mention go/build changes + 2021-01-25 3d85c69a0b html/template: revert "avoid race when escaping updates template" + 2021-01-25 54514c6b28 cmd/go: fix TestScript/cgo_path, cgo_path_space when CC set + 2021-01-25 6f5e79f470 [dev.regabi] cmd/compile/internal: specify memory layout + 2021-01-25 cabffc199d [dev.regabi] cmd/compile/internal: add internal ABI specification + 2021-01-25 6de8443f3b doc/asm: add a section on go_asm.h, clean up go_tls.h section + 2021-01-25 6a4739ccc5 [dev.regabi] cmd/compile: enable rational constant arithmetic + 2021-01-25 be9612a832 [dev.regabi] os: disable TestDirFS until #42637 is fixed + 2021-01-25 8ee3d39838 [dev.regabi] cmd/go: workaround -race issue on ppc64le + 2021-01-25 54b251f542 lib/time, time/tzdata: update tzdata to 2021a + 2021-01-25 5a76c3d548 [dev.regabi] cmd/compile: modify abiutils for recently updated ABI + 2021-01-25 ff82cc971a os: force consistent mtime before running fstest on directory on Windows + 2021-01-25 044f937a73 doc/go1.16: fix WalkDir and Walk links + 2021-01-25 063c72f06d [dev.regabi] cmd/compile: backport changes from dev.typeparams (9456804) + 2021-01-23 b634f5d97a doc/go1.16: add crypto/x509 memory optimization + 2021-01-23 9897655c61 doc/go1.16: reword ambiguously parsable sentence + 2021-01-23 cd99385ff4 cmd/internal/obj/arm64: fix VMOVQ instruction encoding error + 2021-01-23 d05d6fab32 [dev.regabi] cmd/compile: replace ir.Name map with ir.NameSet for SSA 2 + 2021-01-23 66ee8b158f runtime: restore cgo_import_dynamic for libc.so on openbsd + 2021-01-23 48badc5fa8 [dev.regabi] cmd/compile: fix escape analysis problem with closures + 2021-01-23 51e1819a8d [dev.regabi] cmd/compile: scan body of closure in tooHairy to check for disallowed nodes + 2021-01-22 25c39e4fb5 io/ioutil: fix example test for WriteFile to allow it to run in the playground + 2021-01-22 eb21b31e48 runtime: define dummy msanmove + 2021-01-22 3a778ff50f runtime: check for g0 stack last in signal handler + 2021-01-22 a2cef9b544 cmd/go: don't lookup the path for CC when invoking cgo + 2021-01-22 7e0a81d280 [dev.regabi] all: merge master (dab3e5a) into dev.regabi + 2021-01-22 dab3e5affe runtime: switch runtime to libc for openbsd/amd64 + 2021-01-22 a1b53d85da cmd/go: add documentation for test and xtest fields output by go list + 2021-01-22 b268b60774 runtime: remove pthread_kill/pthread_self for openbsd + 2021-01-22 ec4051763d runtime: fix typo in mgcscavenge.go + 2021-01-22 7ece3a7b17 net/http: fix flaky TestDisableKeepAliveUpgrade + 2021-01-22 50cba0506f time: clarify Timer.Reset behavior on AfterFunc Timers + 2021-01-22 cf10e69f17 doc/go1.16: mention net/http.Transport.GetProxyConnectHeader + 2021-01-22 ec1b945265 doc/go1.16: mention path/filepath.WalkDir + 2021-01-22 11def3d40b doc/go1.16: mention syscall.AllThreadsSyscall + 2021-01-21 07b0235609 doc/go1.16: add notes about package-specific fs.FS changes + 2021-01-21 e2b4f1fea5 doc/go1.16: minor formatting fix + 2021-01-21 9f43a9e07b doc/go1.16: mention new debug/elf constants + 2021-01-21 3c2f11ba5b cmd/go: overwrite program name with full path + 2021-01-21 953d1feca9 all: introduce and use internal/execabs + 2021-01-21 b186e4d70d cmd/go: add test case for cgo CC setting + 2021-01-21 5a8a2265fb cmd/cgo: report exec errors a bit more clearly + 2021-01-21 46e2e2e9d9 cmd/go: pass resolved CC, GCCGO to cgo + 2021-01-21 3d40895e36 runtime: switch openbsd/arm64 to pthreads + 2021-01-21 d95ca91380 crypto/elliptic: fix P-224 field reduction + 2021-01-21 d7e71c01ad [dev.regabi] cmd/compile: replace ir.Name map with ir.NameSet for dwarf + 2021-01-21 5248f59a22 [dev.regabi] cmd/compile: replace ir.Name map with ir.NameSet for SSA + 2021-01-21 970d8b6cb2 [dev.regabi] cmd/compile: replace ir.Name map with ir.NameSet in inlining + 2021-01-21 68a4664475 [dev.regabi] cmd/compile: remove tempAssigns in walkCall1 + 2021-01-21 fd9a391cdd [dev.regabi] cmd/compile: remove CallExpr.Rargs + 2021-01-21 19a6db6b63 [dev.regabi] cmd/compile: make sure mkcall* passed non-nil init + 2021-01-21 9f036844db [dev.regabi] cmd/compile: use ir.DoChildren directly in inlining + 2021-01-21 213c3905e9 [dev.regabi] cmd/compile: use node walked flag to prevent double walk for walkSelect + 2021-01-20 1760d736f6 [dev.regabi] cmd/compile: exporting, importing, and inlining functions with OCLOSURE + 2021-01-20 ecf4ebf100 cmd/internal/moddeps: check content of all modules in GOROOT + 2021-01-20 92cb157cf3 [dev.regabi] cmd/compile: late expansion of return values + 2021-01-20 d2d155d1ae runtime: don't adjust timer pp field in timerWaiting status + 2021-01-20 803d18fc6c cmd/go: set Incomplete field on go list output if no files match embed + 2021-01-20 6e243ce71d cmd/go: have go mod vendor copy embedded files in subdirs + 2021-01-20 be28e5abc5 cmd/go: fix mod_get_fallback test + 2021-01-20 928bda4f4a runtime: convert openbsd/amd64 locking to libc + 2021-01-19 824f2d635c cmd/go: allow go fmt to complete when embedded file is missing + 2021-01-19 0575e35e50 cmd/compile: require 'go 1.16' go.mod line for //go:embed + 2021-01-19 9423d50d53 [dev.regabi] cmd/compile: use '%q' for printing rune values less than 128 + 2021-01-19 ccb2e90688 cmd/link: exit before Asmb2 if error + 2021-01-19 ca5774a5a5 embed: treat uninitialized FS as empty + 2021-01-19 d047c91a6c cmd/link,runtime: switch openbsd/amd64 to pthreads + 2021-01-19 61debffd97 runtime: factor out usesLibcall + 2021-01-19 9fed39d281 runtime: factor out mStackIsSystemAllocated + 2021-01-19 a2f825c542 [dev.regabi] cmd/compile: directly create go.map and go.track symbols + 2021-01-19 4a4212c0e5 [dev.regabi] cmd/compile: refactor Linksym creation + 2021-01-19 4f5c603c0f [dev.regabi] cmd/compile: cleanup callTargetLSym + 2021-01-18 dbab079835 runtime: free Windows event handles after last lock is dropped + 2021-01-18 5a8fbb0d2d os: do not close syscall.Stdin in TestReadStdin + 2021-01-18 422f38fb6c [dev.regabi] cmd/compile: move stack objects to liveness + 2021-01-18 6113db0bb4 [dev.regabi] cmd/compile: convert OPANIC argument to interface{} during typecheck + 2021-01-18 4c835f9169 [dev.regabi] cmd/compile: use LinksymOffsetExpr in TypePtr/ItabAddr + 2021-01-18 0ffa1ead6e [dev.regabi] cmd/compile: use *obj.LSym instead of *ir.Name for staticdata functions + 2021-01-17 7e0fa38aad [dev.regabi] cmd/compile: remove unneeded packages from ir.Pkgs + 2021-01-17 99a5db11ac [dev.regabi] cmd/compile: use LinksymOffsetExpr in walkConvInterface + 2021-01-17 87845d14f9 [dev.regabi] cmd/compile: add ir.TailCallStmt + 2021-01-17 e3027c6828 [dev.regabi] cmd/compile: fix linux-amd64-noopt builder + 2021-01-17 59ff93fe64 [dev.regabi] cmd/compile: rename NameOffsetExpr to LinksymOffsetExpr + 2021-01-17 82b9cae700 [dev.regabi] cmd/compile: change ir.NameOffsetExpr to use *obj.LSym instead of *Name + 2021-01-17 88956fc4b1 [dev.regabi] cmd/compile: stop analyze NameOffsetExpr.Name_ in escape analysis + 2021-01-17 7ce2a8383d [dev.regabi] cmd/compile: simplify stack temp initialization + 2021-01-17 ba0e8a92fa [dev.regabi] cmd/compile: refactor temp construction in walk + 2021-01-17 78e5aabcdb [dev.regabi] cmd/compile: replace Node.HasCall with walk.mayCall + 2021-01-16 6de9423445 [dev.regabi] cmd/compile: cleanup OAS2FUNC ordering + 2021-01-16 a956a0e909 [dev.regabi] cmd/compile, runtime: fix up comments/error messages from recent renames + 2021-01-16 ab3b67abfd [dev.regabi] cmd/compile: remove ONEWOBJ + 2021-01-16 c9b1445ac8 [dev.regabi] cmd/compile: remove TypeAssertExpr {Src,Dst}Type fields + 2021-01-15 682a1d2176 runtime: detect errors in DuplicateHandle + 2021-01-15 9f83418b83 cmd/link: remove GOROOT write in TestBuildForTvOS + 2021-01-15 ec9470162f cmd/compile: allow embed into any string or byte slice type + 2021-01-15 54198b04db cmd/compile: disallow embed of var inside func + 2021-01-15 b386c735e7 cmd/go: fix go generate docs + 2021-01-15 bb5075a525 syscall: remove RtlGenRandom and move it into internal/syscall + 2021-01-15 1deae0b597 os: invoke processKiller synchronously in testKillProcess + 2021-01-15 03a875137f [dev.regabi] cmd/compile: unexport reflectdata.WriteType + 2021-01-15 14537e6e54 [dev.regabi] cmd/compile: move stkobj symbol generation to SSA + 2021-01-15 ab523fc510 [dev.regabi] cmd/compile: don't promote Byval CaptureVars if Addrtaken + 2021-01-15 ff196c3e84 crypto/x509: update iOS bundled roots to version 55188.40.9 + 2021-01-15 b7a698c73f [dev.regabi] test: disable test on windows because expected contains path separators. + 2021-01-15 4be7af23f9 [dev.regabi] cmd/compile: fix ICE during ir.Dump + 2021-01-14 e125ccd10e cmd/go: in 'go mod edit', validate versions given to -retract and -exclude + 2021-01-14 eb330020dc cmd/dist, cmd/go: pass -arch for C compilation on Darwin + 2021-01-14 84e8a06f62 cmd/cgo: remove unnecessary space in cgo export header + 2021-01-14 0c86b999c3 cmd/test2json: document passing -test.paniconexit0 + 2021-01-14 9135795891 cmd/go/internal/load: report positions for embed errors + 2021-01-14 35b9c66601 [dev.regabi] cmd/compile,cmd/link: additional code review suggestions for CL 270863 + 2021-01-14 d9b79e53bb cmd/compile: fix wrong complement for arm64 floating-point comparisons + 2021-01-14 c73232d08f cmd/go/internal/load: refactor setErrorPos to PackageError.setPos + 2021-01-14 6aa28d3e06 go/build: report positions for go:embed directives + 2021-01-14 9734fd482d [dev.regabi] cmd/compile: use node walked flag to prevent double walk for walkSwitch + 2021-01-14 f97983249a [dev.regabi] cmd/compile: move more PAUTOHEAP to SSA construction + 2021-01-14 4476300425 [dev.regabi] cmd/compile: use byte for CallExpr.Use + 2021-01-14 5a5ab24689 [dev.regabi] cmd/compile: do not rely on CallExpr.Rargs for detect already walked calls + 2021-01-14 983ac4b086 [dev.regabi] cmd/compile: fix ICE when initializing blank vars + 2021-01-13 7eb31d999c cmd/go: add hints to more missing sum error messages + 2021-01-13 d6d4673728 [dev.regabi] cmd/compile: fix GOEXPERIMENT=regabi builder + 2021-01-13 c41b999ad4 [dev.regabi] cmd/compile: refactor abiutils from "gc" into new "abi" + 2021-01-13 861707a8c8 [dev.regabi] cmd/compile: added limited //go:registerparams pragma for new ABI dev + 2021-01-13 c1370e918f [dev.regabi] cmd/compile: add code to support register ABI spills around morestack calls + 2021-01-13 2abd24f3b7 [dev.regabi] test: make run.go error messages slightly more informative + 2021-01-13 9a19481acb [dev.regabi] cmd/compile: make ordering for InvertFlags more stable + 2021-01-12 d9acf6f3a3 [dev.regabi] cmd/compile: remove Func.ClosureType + 2021-01-12 41352fd401 [dev.regabi] cmd/compile: transform closures during walk + 2021-01-12 d6ad88b4db [dev.regabi] cmd/compile: compile functions before closures + 2021-01-12 432f9ffb11 [dev.regabi] cmd/compile: unindent compileFunctions + 2021-01-12 cc90e7a51e [dev.regabi] cmd/compile: always use the compile queue + 2021-01-12 cd5b74d2df [dev.regabi] cmd/compile: call NeedFuncSym in InitLSym + 2021-01-12 ba76567bc2 cmd/go/internal/modload: delete unused *mvsReqs.next method + 2021-01-12 665def2c11 encoding/asn1: document unmarshaling behavior for IMPLICIT string fields + 2021-01-12 95acd8121b [dev.regabi] cmd/compile: remove Name.Typegen + 2021-01-12 12ee55ba7b [dev.regabi] cmd/compile: stop using Vargen for import/export + 2021-01-12 b4d2a0445b [dev.regabi] cmd/compile: refactor closure var setup/teardown + 2021-01-12 f57f484053 [dev.regabi] cmd/compile: decouple escape analysis from Name.Vargen + 2021-01-11 81ea89adf3 cmd/go: fix non-script staleness checks interacting badly with GOFLAGS + 2021-01-11 759309029f doc: update editors.html for Go 1.16 + 2021-01-11 c3b4c7093a cmd/internal/objfile: don't require runtime.symtab symbol for XCOFF + 2021-01-10 7fd84c6e46 [dev.regabi] cmd/compile: remove OCLOSUREREAD + 2021-01-10 c9c26d7ffb [dev.regabi] cmd/compile: use ClosureVars for method value wrappers + 2021-01-10 950cf4d46c [dev.regabi] cmd/compile: bind closure vars during SSA constructions + 2021-01-10 8b2efa990b [dev.regabi] cmd/compile: deref PAUTOHEAPs during SSA construction + 2021-01-08 59bfc18e34 cmd/go: add hint to read 'go help vcs' to GOVCS errors + 2021-01-08 6ee9b118a2 [dev.regabi] cmd/compile: remove fmt_test code; it has outlived its usefulness + 2021-01-08 cd6f3a54e4 cmd/go: revise 'go help' documentation for modules + 2021-01-08 6192b98751 cmd/go: make hints in error messages more consistent + 2021-01-08 25886cf4bd cmd/go: preserve sums for indirect deps fetched by 'go mod download' + 2021-01-08 6250833911 runtime/metrics: mark histogram metrics as cumulative + 2021-01-08 8f6a9acbb3 runtime/metrics: remove unused StopTheWorld Description field + 2021-01-08 6598c65646 cmd/compile: fix exponential-time init-cycle reporting + 2021-01-08 fefad1dc85 test: fix timeout code for invoking compiler + 2021-01-08 6728118e0a cmd/go: pass signals forward during "go tool" + 2021-01-08 e65c543f3c go/build/constraint: add parser for build tag constraint expressions + 2021-01-08 0c5afc4fb7 testing/fstest,os: clarify racy behavior of TestFS + 2021-01-08 32afcc9436 runtime/metrics: change unit on *-by-size metrics to match bucket unit + 2021-01-08 c6513bca5a io/fs: minor corrections to Glob doc + 2021-01-08 b241938e04 [dev.regabi] cmd/compile: fix some methods error text + 2021-01-08 304f769ffc cmd/compile: don't short-circuit copies whose source is volatile + 2021-01-08 ae97717133 runtime,runtime/metrics: use explicit histogram boundaries + 2021-01-08 a9ccd2d795 go/build: skip string literal while findEmbed + 2021-01-08 d92f8add32 archive/tar: fix typo in comment + 2021-01-08 cab1202183 cmd/link: accept extra blocks in TestFallocate + 2021-01-08 ee4d32249b io/fs: minor corrections to Glob release date + 2021-01-08 54bd1ccce2 cmd: update to latest golang.org/x/tools + 2021-01-07 9ec21a8f34 Revert "reflect: support multiple keys in struct tags" + 2021-01-07 091414b5b7 io/fs: correct WalkDirFunc documentation + 2021-01-07 9b55088d6b doc/go1.16: add release note for disallowing non-ASCII import paths + 2021-01-07 fa90aaca7d cmd/compile: fix late expand_calls leaf type for OpStructSelect/OpArraySelect + 2021-01-07 7cee66d4cb cmd/go: add documentation for Embed fields in go list output + 2021-01-07 e60cffa4ca html/template: attach functions to namespace + 2021-01-07 6da2d3b7d7 cmd/link: fix typo in asm.go + 2021-01-07 df81a15819 runtime: check mips64 VDSO clock_gettime return code + 2021-01-06 4787e906cf crypto/x509: rollback new CertificateRequest fields + 2021-01-06 c9658bee93 cmd/go: make module suggestion more friendly + 2021-01-06 4c668b25c6 runtime/metrics: fix panic message for Float64Histogram + 2021-01-06 d2131704a6 net/http/httputil: fix deadlock in DumpRequestOut + 2021-01-05 3e1e13ce6d cmd/go: set cfg.BuildMod to "readonly" by default with no module root + 2021-01-05 0b0d004983 cmd/go: pass embedcfg to gccgo if supported + 2021-01-05 cb05a0aa6a [dev.regabi] cmd/compile: remove toolstash scaffolding + 2021-01-05 9821838832 [dev.regabi] cmd/compile: remove CaptureVars + 2021-01-05 fd43831f44 [dev.regabi] cmd/compile: reimplement capture analysis + 2021-01-05 fb69c67cad [dev.regabi] test: enable finalizer tests on !amd64 + 2021-01-05 1b85e7c057 cmd/go: don't scan gccgo standard library packages for imports + 2021-01-05 81f4f0e912 [dev.regabi] cmd/compile: remove race-y check in Name.Canonical + 2021-01-05 6b37b15d95 runtime: don't take allglock in tracebackothers + 2021-01-05 4a9d9adea4 [dev.regabi] cmd/compile: remove initname function + 2021-01-05 77365c5ed7 [dev.regabi] cmd/compile: add Name.Canonical and move Byval + 2021-01-05 e09783cbc0 [dev.regabi] cmd/compile: make ir.StaticValue safer + 2021-01-05 9aa950c407 [dev.regabi] cmd/compile: make ir.OuterValue safer + 2021-01-05 eb626409d1 [dev.regabi] cmd/compile: simplify CaptureVars + 2021-01-05 c28ca67a96 [dev.regabi] cmd/compile: fix ir.Dump for []*CaseClause, etc + 2021-01-04 9eef49cfa6 math/rand: fix typo in comment + 2021-01-04 b01fb2af9e testing/fstest: fix typo in error message + 2021-01-04 f24e40c14a [dev.regabi] cmd/compile: remove Name.Class_ accessors + 2021-01-04 d89705e087 [dev.regabi] cmd/compile: fix re-export of parameters + 2021-01-04 290b4154b7 [dev.regabi] cmd/compile: fix ICE due to large uint64 constants + 2021-01-04 a30fd52884 [dev.regabi] cmd/compile: use ir.NewNameAt in SubstArgTypes + 2021-01-03 8fc44cf0fa [dev.regabi] cmd/compile: remove a couple CloneName calls + 2021-01-03 907a4bfdc7 [dev.regabi] cmd/compile: fix map assignment order + 2021-01-03 f2e6dab048 [dev.regabi] cmd/compile: remove walkReturn "common case" path + 2021-01-03 d36a6bf44d [dev.regabi] cmd/compile: improve walkReturn common case + 2021-01-03 a317067d65 [dev.regabi] cmd/compile: improve ascompatee + 2021-01-03 5d80a590a2 [dev.regabi] cmd/compile: simplify walkReturn + 2021-01-03 bb1b6c95c2 [dev.regabi] cmd/compile: remove Node.{,Set}Walkdef + 2021-01-03 57c426c9a5 [dev.regabi] cmd/compile: tighten typecheckdef to *ir.Name + 2021-01-03 b1747756e3 [dev.regabi] cmd/compile: reorganize escape analysis somewhat + 2021-01-02 f2538033c0 [dev.regabi] cmd/compile: remove Nodes.Set [generated] + 2021-01-02 2f2d4b4e68 [dev.regabi] cmd/compile: remove {Ptr,Set}Init from Node interface + 2021-01-01 3dd5867605 doc: 2021 is the Year of the Gopher + 2021-01-01 1544a03198 [dev.regabi] cmd/compile: refactor redundant type conversion [generated] + 2021-01-01 7958a23ea3 [dev.regabi] cmd/compile: use *ir.Name where possible in inl.go + 2021-01-01 bfa97ba48f [dev.regabi] test: add another closure test case + 2021-01-01 67ad695416 [dev.regabi] cmd/compile: split escape analysis state + 2021-01-01 fad9a8b528 [dev.regabi] cmd/compile: simplify inlining of closures + 2021-01-01 7d55669847 [dev.regabi] cmd/compile: simplify dwarfgen.declPos + 2021-01-01 9ed1577779 [dev.regabi] cmd/compile: remove Func.ClosureEnter + 2021-01-01 ece345aa69 [dev.regabi] cmd/compile: expand documentation for Func.Closure{Vars,Enter} + 2021-01-01 6ddbc75efd [dev.regabi] cmd/compile: earlier deadcode removal + 2021-01-01 68e6fa4f68 [dev.regabi] cmd/compile: fix package-initialization order + 2021-01-01 3a4474cdfd [dev.regabi] cmd/compile: some more manual shuffling + 2021-01-01 0f1d2129c4 [dev.regabi] cmd/compile: reshuffle type-checking code [generated] + 2021-01-01 b8fd3440cd [dev.regabi] cmd/compile: report unused variables during typecheck + 2021-01-01 fd22df9905 [dev.regabi] cmd/compile: remove idempotent Name() calls [generated] + 2020-12-31 dfbcff80c6 [dev.regabi] cmd/compile: make copyExpr return *ir.Name directly + 2020-12-31 77fd81a3e6 [dev.regabi] cmd/compile: use names for keep alive variables in function call + 2020-12-31 8fe1197654 [dev.regabi] cmd/compile: remove Name.orig + 2020-12-31 477b049060 [dev.regabi] cmd/compile: fix printing of method expressions + 2020-12-31 95ce805d14 io/fs: remove darwin/arm64 special condition + 2020-12-30 20d0991b86 lib/time, time/tzdata: update tzdata to 2020f + 2020-12-30 ed301733bb misc/cgo/testcarchive: remove special flags for Darwin/ARM + 2020-12-30 0ae2e032f2 misc/cgo/test: enable TestCrossPackageTests on darwin/arm64 + 2020-12-30 178c667db2 [dev.regabi] cmd/compile: fix OSLICEARR comments + 2020-12-30 f0d99def5b [dev.regabi] cmd/compile: add newline to ir.Dump + 2020-12-30 451693af71 [dev.regabi] cmd/compile: simplify typecheckdef + 2020-12-30 0c1a899a6c [dev.regabi] cmd/compile: fix defined-pointer method call check + 2020-12-30 f9b67f76a5 [dev.regabi] cmd/compile: change ir.DoChildren to use bool result type + 2020-12-30 499851bac8 [dev.regabi] cmd/compile: generalize ir/mknode.go + 2020-12-30 82ab3d1448 [dev.regabi] cmd/compile: use *ir.Name for Decl.X + 2020-12-30 9958b7ed3e [dev.regabi] cmd/compile: unexport ir.FmtNode + 2020-12-29 780b4de16b misc/ios: fix wording for command line instructions + 2020-12-29 b4a71c95d2 doc/go1.16: reference misc/ios/README for how to build iOS programs + 2020-12-29 f83e0f6616 misc/ios: add to README how to build ios executables + 2020-12-29 f5816624cd [dev.regabi] cmd/compile: change AddrExpr.Alloc to AddrExpr.Prealloc + 2020-12-29 850aa7c60c [dev.regabi] cmd/compile: use *ir.Name instead of ir.Node for CaseClause.Var + 2020-12-29 37babc97bb [dev.regabi] cmd/compile: allow visitor visits *ir.Name + 2020-12-29 5cf3c87fa6 [dev.regabi] cmd/compile: generate case/comm clause functions in mknode.go + 2020-12-29 b3e1ec97fd [dev.regabi] cmd/compile: move new addrtaken bit back to the old name + 2020-12-29 0620c674dd [dev.regabi] cmd/compile: remove original addrtaken bit + 2020-12-29 0523d525ae [dev.regabi] cmd/compile: separate out address taken computation from typechecker + 2020-12-29 9ea272e5ec [dev.regabi] cmd/compile: simplify ir.Func somewhat + 2020-12-29 e40cb4d4ae [dev.regabi] cmd/compile: remove more unused code + 2020-12-29 6f30c95048 [dev.regabi] cmd/compile: remove unneeded indirection + 2020-12-29 171fc6f223 [dev.regabi] cmd/compile: remove workarounds for go/constant issues + 2020-12-29 33801cdc62 [dev.regabi] cmd/compile: use Ntype where possible + 2020-12-29 82ad3083f8 [dev.regabi] cmd/compile: remove typ from AssignOpStmt + 2020-12-29 e34c44a7c4 [dev.regabi] cmd/compile: refactoring typecheck arith + 2020-12-29 a5ec920160 [dev.regabi] cmd/compile: more Linksym cleanup + 2020-12-29 ec59b197d5 [dev.regabi] cmd/compile: rewrite to use linksym helpers [generated] + 2020-12-29 25c613c02d [dev.regabi] cmd/compile: add Linksym helpers + 2020-12-29 289da2b33e [dev.regabi] cmd/compile: move Node.Opt to Name + 2020-12-29 6acbae4fcc [dev.regabi] cmd/compile: address some ir TODOs + 2020-12-29 4629f6a51d [dev.regabi] cmd/compile: merge {Selector,CallPart,Method}Expr + 2020-12-29 e563715b30 [dev.regabi] cmd/compile: remove Sym.Importdef + 2020-12-29 3f370b75fb [dev.regabi] cmd/compile: cleanup //go:generate directives + 2020-12-28 4fd9455882 io/fs: fix typo in comment + 2020-12-28 07569dac4e [dev.regabi] all: merge master (1d78139) into dev.regabi + 2020-12-28 76136be027 [dev.regabi] cmd/compile: check for recursive import in ImportBody + 2020-12-28 fda7ec3a3f [dev.regabi] cmd/compile: remove Name.IsDDD, etc + 2020-12-28 098a6490b9 [dev.regabi] cmd/compile: remove Declare in makepartialcall + 2020-12-28 137f0d2e06 [dev.regabi] cmd/compile: remove unnecessary Name.Sym call + 2020-12-28 3383b5c74a [dev.regabi] cmd/compile: flatten dependency graph [generated] + 2020-12-28 f8afb8216a [dev.regabi] cmd/compile: rename CommStmt and CaseStmt [generated] + 2020-12-28 5f3bd59a0d [dev.regabi] cmd/compile: remove some unneeded code in package ir + 2020-12-28 3bdafb0d82 [dev.regabi] cmd/compile: remove CommStmt.List + 2020-12-28 2ecf52b841 [dev.regabi] cmd/compile: separate CommStmt from CaseStmt + 2020-12-28 ed9772e130 [dev.regabi] cmd/compile: add explicit file name in types generation + 2020-12-28 a59d26603f [dev.regabi] cmd/compile: use []*CaseStmt in {Select,Switch}Stmt + 2020-12-28 fbc4458c06 [dev.regabi] cmd/compile: simplify some tree traversal code + 2020-12-28 6c67677541 [dev.regabi] cmd/compile: simplify FuncName and PkgFuncName + 2020-12-28 676d794b81 [dev.regabi] cmd/compile: remove refersToCommonName + 2020-12-28 c98548e110 [dev.regabi] cmd/compile: merge ascompatee, ascompatee1, and reorder3 + 2020-12-28 4c215c4fa9 [dev.regabi] cmd/compile: simplify and optimize reorder3 + 2020-12-28 e6c973198d [dev.regabi] cmd/compile: stop mangling SelectorExpr.Sel for ODOTMETH + 2020-12-28 135ce1c485 [dev.regabi] cmd/compile: desugar OMETHEXPR into ONAME during walk + 2020-12-28 0f732f8c91 [dev.regabi] cmd/compile: minor walkExpr cleanups + 2020-12-28 0de8eafd98 [dev.regabi] cmd/compile: remove SelectorExpr.Offset field + 2020-12-28 a4f335f420 [dev.regabi] cmd/compile: always use a Field for ODOTPTR expressions + 2020-12-26 1d78139128 runtime/cgo: fix Android build with NDK 22 + 2020-12-25 2018b68a65 net/mail: don't use MDT in test + 2020-12-25 e4f293d853 [dev.regabi] cmd/compile: fix OCALLMETH desugaring + 2020-12-25 1d9a1f67d5 [dev.regabi] cmd/compile: don't emit reflect data for method types + 2020-12-25 396b6c2e7c [dev.regabi] cmd/compile: cleanup assignment typechecking + 2020-12-25 e24d2f3d05 [dev.regabi] cmd/compile: remove typ from RangeStmt + 2020-12-25 2785c691c2 [dev.regabi] cmd/compile: cleanup devirtualization docs + 2020-12-25 4b1d0fe66f [dev.regabi] cmd/compile: new devirtualization pkg [generated] + 2020-12-24 082cc8b7d9 [dev.regabi] cmd/compile: change ir.IsAssignable -> ir.IsAddressable + 2020-12-24 27b248b307 [dev.regabi] cmd/compile: separate range stmt Vars to Key, Value nodes + 2020-12-23 40818038bf [dev.regabi] cmd/compile: change CaseStmt.Vars to Var + 2020-12-23 b116404444 runtime: shift timeHistogram buckets and allow negative durations + 2020-12-23 8db7e2fecd runtime: fix allocs-by-size and frees-by-size buckets + 2020-12-23 fb96f07e1a runtime: fix nStackRoots comment about stack roots + 2020-12-23 d1502b3c72 lib/time, time/tzdata: update tzdata to 2020e + 2020-12-23 30c99cbb7a cmd/go: add the Retract field to 'go help mod edit' definition of the GoMod struct + 2020-12-23 49d0b239cb doc: fix a typo in contribute.html + 2020-12-23 9eeed291bc [dev.regabi] cmd/compile: eliminate usage of ir.Node in liveness + 2020-12-23 d1d64e4cea [dev.regabi] cmd/compile: split SliceExpr.List into separate fields + 2020-12-23 98a73030b0 cmd/go: in 'go get', promote named implicit dependencies to explicit + 2020-12-23 d19018e8f1 [dev.regabi] cmd/compile: split SliceHeaderExpr.LenCap into separate fields + 2020-12-23 53f082b0ee [dev.regabi] cmd/compile: cleanup export code further + 2020-12-23 31267f82e1 [dev.regabi] cmd/compile: simplify function/interface/struct typechecking + 2020-12-23 addade2cce [dev.regabi] cmd/compile: prefer types constructors over typecheck + 2020-12-23 18ebfb49e9 [dev.regabi] cmd/compile: cleanup noder + 2020-12-23 87a592b356 [dev.regabi] cmd/compile: cleanup import/export code + 2020-12-23 5898025026 [dev.regabi] cmd/compile: update mkbuiltin.go to use new type constructors + 2020-12-23 63c96c2ee7 [dev.regabi] cmd/compile: update mkbuiltin.go and re-enable TestBuiltin + 2020-12-23 37f138df6b [dev.regabi] cmd/compile: split out package test [generated] + 2020-12-23 3d8a3cb06b [dev.regabi] cmd/compile: split out package pkginit [generated] + 2020-12-23 3f04d964ab [dev.regabi] cmd/compile: split up walkexpr1, walkstmt [generated] + 2020-12-23 e4895ab4c0 [dev.regabi] cmd/compile: split out package walk [generated] + 2020-12-23 01fd2d05c8 [dev.regabi] cmd/compile: split out package dwarfgen [generated] + 2020-12-23 6c34d2f420 [dev.regabi] cmd/compile: split out package ssagen [generated] + 2020-12-23 de65151e50 [dev.regabi] cmd/compile: split out package reflectdata [generated] + 2020-12-23 4dfb5d91a8 [dev.regabi] cmd/compile: split out package staticdata [generated] + 2020-12-23 fbc82f03b1 [dev.regabi] cmd/compile: split out package noder [generated] + 2020-12-23 de454eef5f [dev.regabi] cmd/compile: split out package escape [generated] + 2020-12-23 071ab0a14c [dev.regabi] cmd/compile: split out package liveness [generated] + 2020-12-23 0ced54062e [dev.regabi] cmd/compile: split out package objw [generated] + 2020-12-23 575fd6ff0a [dev.regabi] cmd/compile: split out package inline [generated] + 2020-12-23 0256ba99a8 [dev.regabi] cmd/compile: split up typecheck1 [generated] + 2020-12-23 b9693d7627 [dev.regabi] cmd/compile: split out package typecheck [generated] + 2020-12-23 dac0de3748 [dev.regabi] cmd/compile: move type size calculations into package types [generated] + 2020-12-23 527a1895d6 [dev.regabi] cmd/compile: move helpers into package ir [generated] + 2020-12-23 65c4c6dfb2 [dev.regabi] cmd/compile: group known symbols, packages, names [generated] + 2020-12-23 9ee309255a [dev.regabi] cmd/compile: move helpers into package types [generated] + 2020-12-23 ead4957892 [dev.regabi] cmd/compile: move helpers into package base [generated] + 2020-12-23 440308ffd7 [dev.regabi] cmd/compile: simplify Nodes usage [generated] + 2020-12-23 f9d373720e [dev.regabi] cmd/compile: remove Left, Right etc methods [generated] + 2020-12-23 14d667341f [dev.regabi] cmd/compile: remove Node.Left etc [generated] + 2020-12-23 6f27d29be0 [dev.regabi] cmd/compile: remove ir.Nod [generated] + 2020-12-23 fd6ba1c8a2 os/signal: fix a deadlock with syscall.AllThreadsSyscall() use + 2020-12-23 69cf39089f [dev.regabi] cmd/compile: do not die in early base.FlushErrors + 2020-12-23 6d03cde88a [dev.regabi] cmd/dist: automatically bootstrap cmd subdirs + 2020-12-23 b0b0d98283 runtime: linux iscgo support for not blocking nptl signals + 2020-12-23 d1d1099c91 [dev.regabi] cmd/compile: fixes for big rewrite + 2020-12-22 223331fc0c cmd/go/internal/modload: add hint for missing implicit dependency + 2020-12-22 ec741b0447 [dev.regabi] all: merge master (c9fb4eb) into dev.regabi + 2020-12-22 acc32ea124 [dev.regabi] codereview.cfg: add config for dev.regabi + 2020-12-22 c9fb4eb0a2 cmd/link: handle grouped resource sections + 2020-12-22 c40934b33d [dev.regabi] cmd/compile: adjust one case in walkexpr + 2020-12-22 280e7fd1ee [dev.regabi] cmd/compile: only access Func method on concrete types + 2020-12-22 51ba53f5c2 [dev.regabi] cmd/compile: separate misc for gc split + 2020-12-22 572f168ed2 [dev.regabi] cmd/compile: separate various from Main + 2020-12-22 3b12c6dc08 [dev.regabi] cmd/compile: separate typecheck more cleanly + 2020-12-22 7c8f5356ab [dev.regabi] cmd/compile: separate dowidth better + 2020-12-22 c06a354bcc test: trigger SIGSEGV instead of SIGTRAP in issue11656.go + 2020-12-22 0aa9b4709a cmd/pack: r command create output file if not exist + 2020-12-22 cb28c96be8 [dev.regabi] cmd/compile,cmd/link: initial support for ABI wrappers + 2020-12-22 c8610e4700 [dev.regabi] cmd/compile: add ir.BasicLit to represent literals + 2020-12-22 3512cde10a [dev.regabi] cmd/compile: stop reusing Ntype for OSLICELIT length + 2020-12-22 2755361e6a [dev.regabi] cmd/compile: change noder.declNames to returns ir.Names + 2020-12-22 301af2cb71 [dev.regabi] runtime/race: adjust test pattern match for ABI wrapper + 2020-12-22 4d27c4c223 runtime: correct error handling in several FreeBSD syscall wrappers + 2020-12-22 9b6147120a cmd/pack: treat compiler's -linkobj output as "compiler object" + 2020-12-22 306b2451c8 [dev.regabi] runtime: fix ABI targets in runtime.panic{Index,Slice} shims + 2020-12-21 bc7e4d9257 syscall: don't generate ptrace on iOS + 2020-12-21 94cfeca0a5 [dev.regabi] cmd/compile: stop using ONONAME with Name + 2020-12-21 cb4898a77d [dev.regabi] cmd/compile: simplify declaration importing + 2020-12-21 06915ac14d [dev.regabi] cmd/compile: move itabname call out of implements + 2020-12-21 6cff874c47 runtime/metrics: add Read examples + 2020-12-21 4e8f681eff Merge "[dev.regabi] all: merge master into dev.regabi" into dev.regabi + 2020-12-21 1a523c8ab0 [dev.regabi] cmd/compile: separate nowritebarrierrec from main + 2020-12-21 e999c17022 [dev.regabi] cmd/compile: separate ssa from other phases + 2020-12-21 4836e28ac0 [dev.regabi] cmd/compile: separate noder more cleanly + 2020-12-21 85ce6ecfe3 [dev.regabi] cmd/compile: separate exportsym more cleanly + 2020-12-21 1a3b036b83 [dev.regabi] cmd/compile: collect global compilation state + 2020-12-21 2153a99914 [dev.regabi] cmd/compile: setup to move Addrconst, Patch into cmd/internal/obj + 2020-12-21 0bb0baf683 [dev.regabi] cmd/compile: cleanup for concrete types - more + 2020-12-21 ca8e17164e [dev.regabi] all: merge master into dev.regabi + 2020-12-21 8438a5779b runtime: use _exit on darwin + 2020-12-21 cb95819cf6 runtime: detect netbsd netpoll overrun in sysmon + 2020-12-21 53c984d976 runtime: skip wakep call in wakeNetPoller on Plan 9 + 2020-12-21 9abbe27710 test: skip issue11656.go on mips/mips64/ppc64 + 2020-12-20 89b44b4e2b cmd/compile: recognize reassignments involving receives + 2020-12-19 55b58018f4 test: for issue11656 try to execute trap, not call it + 2020-12-18 626cc7c02d test: permit "exponent too large" error + 2020-12-18 139cd0e12f go/build: make TestDependencies work again + 2020-12-18 2de7866470 os: remove dependency on strings package + 2020-12-18 c45313bf45 [dev.regabi] cmd/compile: remove prealloc map + 2020-12-18 ffb0cb7044 [dev.regabi] cmd/compile: remove uses of Name.Offset, Name.copy + 2020-12-18 c76be2a24e [dev.regabi] cmd/compile: add ONAMEOFFSET, delete to-be-deleted fields + 2020-12-18 4e8f1e139f [dev.regabi] cmd/compile: cleanup for concrete types - sinit + 2020-12-18 27aba22651 [dev.regabi] cmd/compile: cleanup for concrete types - walk + 2020-12-18 0b9cb63b8d [dev.regabi] cmd/compile: rename ir.Find to ir.Any and update uses + 2020-12-18 ae652a4ac9 os/signal: fix flaky tests for NotifyContext. + 2020-12-18 740851baca cmd/link: avoid use of -T when linking with lld + 2020-12-18 f1778c28a9 test: recognize and use gc build tag + 2020-12-17 8fcf318123 api/go1.16: remove crypto/tls APIs that are moved to Go 1.17 + 2020-12-17 520f3b72db crypto/tls: revert "add HandshakeContext method to Conn" + 2020-12-17 2ff33f5e44 api: promote next to go1.16 + 2020-12-17 aeedc9f804 [dev.regabi] cmd/compile: remove OSELRECV + 2020-12-17 0328c3b660 [dev.regabi] cmd/compile: use OSELRECV2 for all <-c variants + 2020-12-17 88e1415d08 [dev.regabi] cmd/compile: add type assertion in regabi test + 2020-12-17 9c384e881e [dev.regabi] cmd/compile: cleanup for concrete types - mop-up + 2020-12-17 be64c8bece [dev.regabi] cmd/compile: cleanup for concrete types - noder + 2020-12-17 5024396563 [dev.regabi] cmd/compile: cleanup for concrete types - subr + 2020-12-17 dd67b13d07 [dev.regabi] cmd/compile: cleanup for concrete types - range, select, swt + 2020-12-17 42fec2ded4 [dev.regabi] cmd/compile: cleanup for concrete types - const + 2020-12-17 389ae3d5ba [dev.regabi] cmd/compile: cleanup for concrete types - inl + 2020-12-17 5fe64298a4 [dev.regabi] cmd/compile: cleanup for concrete types - import/export + 2020-12-17 aa55d4e54b [dev.regabi] cmd/compile: cleanup for concrete types - escape + 2020-12-17 846740c17f [dev.regabi] cmd/compile: cleanup for concrete types - ssa + 2020-12-17 bf9bbbd6ed [dev.regabi] cmd/compile: cleanup for concrete types - order + 2020-12-17 4ac6a6317b [dev.regabi] cmd/compile: cleanup for concrete types - typecheck + 2020-12-17 f6efa3d4a4 [dev.regabi] cmd/compile: simplify ir.Find, replace ir.Inspect with ir.Visit + 2020-12-17 f6d2834f8f [dev.regabi] cmd/compile: limit Implicit method to nodes where it is defined + 2020-12-17 7fde0d2b50 [dev.regabi] cmd/compile: remove use of Initorder, Offset Node fields for initorder + 2020-12-17 114af2a044 [dev.regabi] cmd/compile: change Nodes to be a slice + 2020-12-17 4dfc7333f4 [dev.regabi] cmd/compile: update ir/fmt for concrete types + 2020-12-17 a997543292 [dev.regabi] cmd/compile: fix potential closure waste in Order + 2020-12-17 578fbbe3aa [dev.regabi] cmd/compile: rewrite some generic ir.Nod calls + 2020-12-17 5ae70b85c6 [dev.regabi] cmd/compile: cleanup preparing for concrete types, 2 + 2020-12-17 fa06894b36 [dev.regabi] cmd/compile: cleanup preparing for concrete types + 2020-12-17 5a4db102b2 html/template: avoid race when escaping updates template + 2020-12-16 b0f01e17f8 go/types: report error for invalid (but empty) expr switch + 2020-12-16 5abda2618b cmd/link: handle large relocation addend on darwin/arm64 + 2020-12-16 a318d56c1e cmd/link: pass arch-specific flags to external linker when testing supported flag + 2020-12-16 f4e7a6b905 cmd/internal/goobj: fix buglet in object file reader + 2020-12-16 75e16f5127 doc/go1.16: add link to reflect.StructTag + 2020-12-16 08b5091d03 net: close connection in localServer teardown + 2020-12-16 8981092d71 cmd/link: ignore SEH marking on PE objects + 2020-12-15 731bb54038 test: update for gofrontend error message changes + 2020-12-15 129bb1917b doc/go1.15: mention 1.15.3 cgo restriction on empty structs + 2020-12-15 685a322fe4 test: match gofrontend error messages + 2020-12-15 3d6467824c test: only require issue11674 errors with gc compiler + 2020-12-15 7cdc84a15b test: remove bug429 (duplicates runtime.TestSimpleDeadlock) + 2020-12-15 412dc2f4d3 test: adjust issue11371 to fit in required precision + 2020-12-15 8e2d74b705 test: only check for issue11362 error with gc + 2020-12-15 f8ac237032 test: import file name for issue19028 + 2020-12-15 a508840c67 doc/go1.16: fix path, path/filepath release notes + 2020-12-15 5046cb8a6e doc/go1.16: fix formatting in net, net/http and net/http/httputil sections + 2020-12-15 3298300ddf text/template: error on range over send channel + 2020-12-15 4c2d66f642 [dev.regabi] cmd/compile: use ir.Ident for imported identifiers + 2020-12-15 305d93ef84 [dev.regabi] cmd/compile: type check externdcl earlier + 2020-12-15 9f16620f46 [dev.regabi] cmd/compile: fix latent Sym.SetPkgDef issue + 2020-12-15 5a25a3fd1d test: recognize gofrontend error messages + 2020-12-14 fea898a4b0 [dev.regabi] cmd/compile: intercept the making of OADDR nodes + 2020-12-14 663cd862ed cmd/link: do not mark resource section as writable + 2020-12-14 48dfa2b2dc cmd/link: deal with ADDR32NB relocations the same way as ADDR32 on arm + 2020-12-14 033390d9ad cmd/link: recognize arm header of PE objects + 2020-12-14 48906a6d57 net/http/pprof: don't treat os.Args as format string in Cmdline handler + 2020-12-14 6e3cc5c56f go/types: report invalid ... in conversions + 2020-12-14 278b9a8a4a io/fs: fix package reference in FS godoc + 2020-12-14 617383377f [dev.regabi] cmd/compile: reorg generated array hash loop + 2020-12-14 d06794da4a doc/go1.16: add missing <code> tag + 2020-12-14 dea6d94a44 math/big: add test for recursive division panic + 2020-12-14 2f5b1a3974 test: make a race detector test robust to timing variations + 2020-12-14 c81343ce3a net/http: attempt deadlock fix in TestDisableKeepAliveUpgrade + 2020-12-14 828746ec57 debug/dwarf: don't try to parse addr/rnglists header + 2020-12-14 be10af7c4e test: match gofrontend error messages + 2020-12-14 89f38323fa [dev.regabi] cmd/compile: add register ABI analysis utilities + 2020-12-14 ce61ccca8f test: match gofrontend error messages + 2020-12-14 a58be734ea cmd/compile: fix incorrect shift count type with s390x rules + 2020-12-14 8ce37e4110 [dev.regabi] cmd/compile: fix noopt builder + 2020-12-14 7e17b46c58 [dev.regabi] cmd/compile/internal/types: add IsScalar query method + 2020-12-14 2b76429eb0 [dev.regabi] cmd/compile: refactor type initialization code into helper + 2020-12-14 9c5241e520 [dev.regabi] cmd/compile: remove unnecessary String methods + 2020-12-14 267975dc47 Merge branch 'master' into dev.regabi + 2020-12-14 64d8846aae cmd/go: print hint when 'go install' run without version outside module + 2020-12-14 451b6b38fd cmd/go: refactor error reporting in internal/load + 2020-12-14 0a02371b05 cmd/compile: set correct type for OpIData + 2020-12-11 41d8e61a6b doc: make clear that Go 1.4 is not required for bootstrap + 2020-12-11 14305527f6 cmd/compile: fix select statement evaluation order corner case + 2020-12-11 1341a3decd cmd/go: add documentation for the -overlay flag + 2020-12-11 e508c1c67b cmd/link/internal/loadelf: support additional ELF relocations on mips64 + 2020-12-11 58e381b0b2 cmd/vet: vendor in x/tools, update structtag vet check + 2020-12-10 e012d0dc34 syscall: drop references to Unix epoch in Timeval/Timespec docs + 2020-12-10 1fe891a937 doc/go1.16: add vet release note for CL 235677 + 2020-12-10 6d3d3fb37f doc/go1.16: address some remaining high-level TODOs + 2020-12-10 6a64f6dc31 cmd/go: encode backslash and newline in response files + 2020-12-10 985d91666c runtime/metrics: add a note about floating-point values to package docs + 2020-12-10 e0d20e52ee runtime/metrics: expand Read documention with caveats + 2020-12-10 d0f40d2922 runtime/metrics: add ordering line to supported metrics docs + 2020-12-10 6d2b3351f6 test: match gofrontend error messages + 2020-12-10 e5522c882d std: update golang.org/x/net to 20201209123823-ac852fbbde11 + 2020-12-10 422dc83baa database/sql: fix typo in comment + 2020-12-10 56b783ad94 cmd/go, cmd/asm: pass -linkshared to assembler for shared linkage builds + 2020-12-10 b110733327 cmd/link: reject too-large relocation addend on darwin/arm64 + 2020-12-10 0aba8f24cb cmd/link: truncate file after code signature + 2020-12-10 6c64b6db68 cmd/compile: don't constant fold divide by zero + 2020-12-09 89f465c2b5 go/types: avoid endless recursion in the Comparable predicate + 2020-12-09 f1980efb92 all: update to use os.ReadDir where appropriate + 2020-12-09 4f1b0a44cb all: update to use os.ReadFile, os.WriteFile, os.CreateTemp, os.MkdirTemp + 2020-12-09 63bc23b545 [dev.regabi] cmd/compile: first start towards using Ident + 2020-12-09 eae8fd519b [dev.regabi] cmd/compile: iexport debug crumbs for toolstash + 2020-12-09 837b35cc55 [dev.regabi] cmd/compile: adjust IR representations + 2020-12-09 0c49440664 [dev.regabi] cmd/compile: arrange for walkstmt, walkexpr, to return from switch cases + 2020-12-09 4090af83c5 [dev.regabi] cmd/compile: use reflection in ir.Dump + 2020-12-09 e2d278bfeb [dev.regabi] cmd/compile: two small fixes + 2020-12-09 5627a4dc30 runtime/metrics: simplify test to support more environments + 2020-12-09 db6032dd0c cmd/compile: fix message typo + 2020-12-09 854a2f8e01 net/http: add connections back that haven't been canceled + 2020-12-09 6fa06d960b runtime: prevent stack growth after fork in runtime.sigfillset + 2020-12-09 ae9b442df2 doc: add description of new framepointer vet check + 2020-12-08 31496cfde5 cmd/vet: vendor in x/tools, enable framepointer vet check + 2020-12-08 01b76d5fbc go/types: correct error position for inherited const init expressions + 2020-12-08 48d6275952 doc/go1.16: improve channel race detector changes description + 2020-12-08 dbf2fc8cff [dev.regabi] cmd/compile: replace many uses of ir.Node with *ir.Name + 2020-12-08 bb31c75343 [dev.regabi] cmd/compile: ir.Node is no longer an ssa.Aux + 2020-12-08 6db970e20a [dev.regabi] cmd/compile: rewrite Aux uses of ir.Node to *ir.Name [generated] + 2020-12-08 1c8943a6ad [dev.regabi] cmd/compile: introduce FwdRefAux for wrapping ir.Node as ssa.Aux + 2020-12-08 9c91cab0da runtime: correct sigfwd on openbsd/mips64 + 2020-12-08 dcec658f6c [dev.regabi] cmd/compile: change LocalSlot.N to *ir.Name + 2020-12-08 1a98ab0e2d [dev.regabi] cmd/compile: add ssa.Aux tag interface for Value.Aux + 2020-12-07 6362d01c15 doc/go1.16: update linker stats + 2020-12-07 9b8c272558 reflect: document multiple keys in struct tags + 2020-12-07 63722da46b [dev.regabi] cmd/compile: fix comment + 2020-12-07 7ad6596c47 io/fs: fix Sub method error text + 2020-12-07 6d783e7440 [dev.regabi] cmd/compile: export all Node fields [generated] + 2020-12-07 2de0af3b1b [dev.regabi] cmd/compile: prepare mknode for rename of Func.body + 2020-12-07 724374f859 [dev.regabi] cmd/compile: rewrite stale format strings + 2020-12-07 61889ba680 [dev.regabi] cmd/compile: simplify fmtmap + 2020-12-07 6ea2b8c54c [dev.regabi] cmd/compile: clean up and document formatting + 2020-12-07 bb4a37bd93 [dev.regabi] cmd/compile: move Type, Sym printing to package types [generated] + 2020-12-07 70155cca81 [dev.regabi] cmd/compile: untangle FmtFlag, FmtMode + 2020-12-07 3904a62829 [dev.regabi] cmd/compile: remove mode.Sprintf etc in printer + 2020-12-07 fb17dfa43d [dev.regabi] cmd/compile: narrow interface between ir and types + 2020-12-07 3b25f3c150 [dev.regabi] cmd/compile: simplify Op, Node, Nodes printing + 2020-12-07 8ce2605c5b [dev.regabi] cmd/compile: untangle ir.Dump printing + 2020-12-07 158c9dd131 [dev.regabi] cmd/compile: reorganize ir/fmt.go + 2020-12-07 a79742f39a [dev.regabi] cmd/compile: remove "short" node header mode + 2020-12-07 ef5964dd6b [dev.regabi] cmd/compile: arrange for typecheck1 to end in switch + 2020-12-07 dcc640e839 [dev.regabi] test: add exhaustive test of evaluated but not used + 2020-12-07 2cec6c4a8c [dev.regabi] cmd/compile: generate Node methods using program + 2020-12-07 50cdb2d8e9 runtime/cgo: fix building on musl + 2020-12-07 8d34585171 doc/go1.16: announce openbsd/mips64 port + 2020-12-07 9c0e2db051 test: add new test that gofrontend failed to handle + 2020-12-07 7f9a2bc2bc doc/go1.16: fix typo + 2020-12-07 ac0ba6707c doc/go1.16: add missing </a> tag + 2020-12-07 c155931974 internal/cpu: add darwin/arm64 CPU feature detection support + 2020-12-07 d90b199e9c [dev.regabi] cmd/compile: silence errors about missing blank methods + 2020-12-07 e10c94af26 doc/go1.16: document riscv64 port changes + 2020-12-06 e885df2731 [dev.regabi] cmd/compile: change iexport to avoid map[ir.Node] + 2020-12-06 2d4c95565a [dev.regabi] cmd/compile: change nowritebarrierrec to use map[*ir.Func] + 2020-12-06 1b5eed8982 [dev.regabi] cmd/compile: replace NodeQueue with NameQueue + 2020-12-06 6c5967e528 [dev.regabi] cmd/compile: change NodeSet to NameSet + 2020-12-05 3b2a578166 internal/cpu: fix typo in cpu_arm64.go + 2020-12-05 be9379f8a8 syscall: correct CertOpenStore to expect a 0 return value on failure + 2020-12-04 4de4480dc3 doc/go1.16: cleanup crypto release notes + 2020-12-04 0b99ea3b16 cmd/vendor: sync pprof@v0.0.0-20201203190320-1bf35d6f28c2 + 2020-12-04 46b6e70e3b [dev.regabi] cmd/compile: replace ir.Node with *ir.Name in Order + 2020-12-04 b75f51c645 [dev.regabi] cmd/compile: replace ir.Node with *ir.Name in Liveness + 2020-12-04 133b03e1c3 [dev.regabi] cmd/compile: rewrite code to use DeclaredBy + 2020-12-04 d9cb84c84b [dev.regabi] cmd/compile: add SameSource, Uses, and DeclaredBy helpers + 2020-12-04 edf60be151 doc/go1.16: document no language changes + 2020-12-04 5dbd2e8e44 [dev.regabi] cmd/compile: remove DeepCopyNode interface + 2020-12-04 9ab3d854ad [dev.regabi] cmd/compile: avoid general traversal in deadcode + 2020-12-04 bb5aa2b664 [dev.regabi] cmd/compile: implement editChildren for nodes + 2020-12-04 4725c3ffd1 [dev.regabi] cmd/compile: implement doChildren for nodes + 2020-12-04 18f2df7e81 [dev.regabi] cmd/compile: implement copy for nodes + 2020-12-04 d855b30fe4 [dev.regabi] cmd/compile: use ir.EditChildren for inline rewriting + 2020-12-04 b9df26d7a8 [dev.regabi] cmd/compile: use ir.Find for "search" traversals + 2020-12-04 0d1b44c645 [dev.regabi] cmd/compile: introduce IR visitors + 2020-12-04 7fcf5b994c [dev.regabi] cmd/compile: replace inlcopy with ir.DeepCopy + 2020-12-04 989a3f5041 [dev.regabi] cmd/compile: adjustments to Copy and DeepCopy + 2020-12-04 99ecfcae31 [dev.regabi] cmd/compile: swap inlining order of if then vs else blocks + 2020-12-04 478bde3a43 io/fs: add Sub + 2020-12-04 5d4569197e cmd/go/internal/modload: fix minor errors in comments + 2020-12-04 21cfadf0dc runtime: avoid receiving preemotion signal while exec'ing + 2020-12-04 7358064508 doc/go1.16: preannounce dropping macOS 10.12 support + 2020-12-04 37588ffcb2 cmd/go, embed: exclude .* and _* from embedded directory trees + 2020-12-04 b67b7ddabc doc/go1.16: add reflect changes to release notes + 2020-12-04 cc386bd05a doc/go1.16: fix broken <code> tag + 2020-12-04 84cb51d7d7 [dev.regabi] cmd/compile: eliminate more SetOrig + 2020-12-04 2c2980aa0c doc/go1.16: pre-announce GODEBUG=x509ignoreCN=0 removal in Go 1.17 + 2020-12-03 37a32a1833 cmd/compile: make sure address of offset(SP) is rematerializeable + 2020-12-03 b78b427be5 runtime, time: strictly enforce when, period constraints + 2020-12-03 b635e4b808 time, runtime: don't set timer when = 0 + 2020-12-03 4eb7ceba06 doc/go1.16: update runtime and compiler sections + 2020-12-03 bacb307b80 test: match gofrontend error messages + 2020-12-03 7f5a3196c9 cmd/go/internal/modload: rename constants to reflect that lazy loading is not yet implemented + 2020-12-03 351bc2f38c [dev.regabi] cmd/compile: store types.Field on {Selector,CallPart}Expr + 2020-12-03 bdc9a837e9 doc/go1.16: add path, path/filepath changes to release notes + 2020-12-03 9b0e8a2c95 doc/go1.16: tidy darwin/arm64 port section + 2020-12-03 b1369d5862 math/big: remove the s390x assembly for shlVU and shrVU + 2020-12-03 a2058bac21 [dev.regabi] cmd/compile: add ConstExpr + 2020-12-03 beb5e05404 [dev.regabi] cmd/compile: refactoring prep for ConstExpr + 2020-12-03 7e81135be7 [dev.regabi] cmd/compile: rename addinit(n, init) to initExpr(init, n) + 2020-12-03 6e30fc10fc [dev.regabi] all: merge master (d0c0dc682c1f) into dev.regabi + 2020-12-03 dda2991c2e internal/cpu: disable FMA when OSXSAVE is not enabled on x86 + 2020-12-03 58768ae15b test: match gccgo error messages + 2020-12-03 59b8916d48 [dev.regabi] cmd/compile: handle OCONVNOP better in ssa + 2020-12-03 932733d421 doc/go1.16: document embed, io/fs, runtime/metrics + 2020-12-03 c519b156fc doc/go1.16: more release notes + 2020-12-03 5246fa5e75 mime/multipart: handle ReadForm(math.MaxInt64) better + 2020-12-03 07cba70d57 cmd/compile, runtime: use __msan_memmove for moving data, split msanread to fields + 2020-12-03 d0c0dc682c doc/go1.16: document os package changes + 2020-12-03 00e5727790 [dev.regabi] cmd/compile: remove okAs + 2020-12-03 5a3b6796cd [dev.regabi] cmd/compile: remove extra typ field in Name struct + 2020-12-03 da54dfb6a1 doc/go1.16: document new behavior of asn1.Unmarshal on invalid argument + 2020-12-03 78e442ea79 doc/go1.16: add encoding/json note for tag change + 2020-12-02 f26f227f66 doc/go1.16: add crypto/tls Config.Clone note + 2020-12-02 64bc656aed [dev.regabi] cmd/compile: use explicit block statements for init + 2020-12-02 48838c35dc go/parser: ignore subdirectories in ParseDir + 2020-12-02 2d0258d495 crypto/ed25519/internal/edwards25519: fix typo in comments + 2020-12-02 ecc8d15bc5 [dev.regabi] cmd/compile: delete OEMPTY + 2020-12-02 ec5f349b22 [dev.regabi] cmd/compile: merge OBLOCK and OEMPTY + 2020-12-02 05ddb879c7 cmd/go: fix TestNewReleaseRebuildsStalePackagesInGOPATH + 2020-12-02 ac38af2f3d cmd/go: stop tests from using network during -short + 2020-12-02 3d913a9266 os: add ReadFile, WriteFile, CreateTemp (was TempFile), MkdirTemp (was TempDir) from io/ioutil + 2020-12-02 5984ea7197 doc: update signal.Notify example to use buffered channel + 2020-12-02 10240b9d6b cmd/go: fix unbuffered channel passed to signal.Notify + 2020-12-02 c32140fa94 all: update to use filepath.WalkDir instead of filepath.Walk + 2020-12-02 0433845ad1 cmd/asm, cmd/internal/obj/riscv: fix branch pseudo-instructions + 2020-12-02 c769d393de [dev.regabi] cmd/compile: add ir.NewDeclNameAt + 2020-12-02 c10b0ad628 [dev.regabi] cmd/compile: add Pkg parameter to type constructors + 2020-12-02 42e46f4ae0 [dev.regabi] cmd/compile: comment out //go:linkname warning + 2020-12-02 77a71e0057 [dev.regabi] cmd/compile: add Interface, Signature, and Struct constructors + 2020-12-02 15085f8974 [dev.regabi] cmd/compile: tweak hash bucket type descriptor + 2020-12-02 73e796cb00 test: match gofrontend error messages + 2020-12-01 cf7aa585ac cmd/link: invalidate kernel cache on darwin + 2020-12-01 8cd35e00bd cmd/internal/buildid: update Mach-O code signature when rewriting buildid + 2020-12-01 6f84993e90 cmd/link: code-sign on darwin/arm64 + 2020-12-01 4826abb6c2 cmd/compile: do not assume TST and TEQ set V on arm + 2020-12-01 283d65413d encoding/json: revert "add "json: " prefix to SyntaxError messages" + 2020-12-01 1408d26ccc [dev.regabi] cmd/compile: cleanup some leftover cruft + 2020-12-01 7fca39aa05 cmd/internal/buildid: exclude Mach-O code signature in hash calculation + 2020-12-01 7430266af4 cmd/internal/codesign: new package + 2020-12-01 20e251864b cmd: update golang.org/x/mod to v0.4.0 + 2020-12-01 933ce97bba cmd/go: don't print deprecation notice for 'go get exe' + 2020-12-01 50b16f9de5 net/http: allow upgrading non keepalive connections + 2020-12-01 212d385a2f net/http: ignore connection closes once done with the connection + 2020-12-01 4ef78b09c9 doc/go1.16: add runtime/debug changes to release notes + 2020-12-01 ae3bfba626 doc/go1.16: add text/template changes to release notes + 2020-12-01 5ffa275f3c [dev.regabi] cmd/compile: first pass at abstracting Type + 2020-12-01 dd4a52c2a5 doc/go1.16: add multiple release notes for the go command + 2020-12-01 6ca23a45fe [dev.regabi] cmd/compile: only save ONAMEs on Curfn.Dcl + 2020-12-01 a17c5e2fce [dev.regabi] cmd/compile: add NewBasic and cleanup universe + 2020-12-01 f37aa5e4e2 [dev.regabi] cmd/compile: add NewNamed + 2020-12-01 63a6f08b39 [dev.regabi] cmd/compile: move setUnderlying to package types + 2020-12-01 f2311462ab [dev.regabi] cmd/compile: cleanup type-checking of defined types + 2020-12-01 2d6ff998ed [dev.regabi] cmd/compile: process //go:linknames after declarations + 2020-12-01 ecff7628ea [dev.regabi] cmd/compile: unexport Node.RawCopy + 2020-12-01 4da41fb3f8 [dev.regabi] cmd/compile: use ir.Copy instead of direct use of RawCopy + 2020-12-01 dadfc80bc1 [dev.regabi] cmd/compile: improve findTypeLoop + 2020-12-01 f5978a0958 cmd/internal/obj/riscv: add tests for BGE/BGEU/BLT/BLTU + 2020-12-01 a36ba090fd cmd/link/internal/amd64: always generate R_X86_64_PLT32 for SDYNIMPORT calls + 2020-12-01 f3741bdf7c doc/go1.16: add crypto/x509 note about Verify on Windows + 2020-12-01 45f3b646d4 [dev.regabi] cmd/compile: add OSTMTEXPR Op + 2020-12-01 9a5a11adfa [dev.regabi] cmd/compile: add custom expression Node implementations + 2020-12-01 0ecf769633 cmd/compile: do not mark OpSP, OpSB pos for debugging + 2020-12-01 0f9f27287b [dev.regabi] cmd/compile: remove types.InitSyms + 2020-11-30 41ad4dec99 [dev.regabi] cmd/compile: fix -h + 2020-11-30 ffa68716a0 [dev.regabi] cmd/compile: add custom statement Node implementations + 2020-11-30 2bc814cd18 [dev.regabi] cmd/compile: clean up ONEW node + 2020-11-30 b7f67b75d2 [dev.regabi] cmd/compile: clean up in preparation for expression Nodes + 2020-11-30 5fc192af56 [dev.regabi] cmd/compile: clean up Order.copyExpr TODO + 2020-11-30 7c9b6b1ca2 [dev.regabi] cmd/compile: clean up in preparation for statement Nodes + 2020-11-30 7f688d18c0 runtime: mlock signal stack on macOS/ARM64 + 2020-11-30 c6de5d8d1f [dev.regabi] cmd/compile: simplify export data representation of nil + 2020-11-30 d2b436d95d cmd/go: fix infinite loop in modload.keepSums + 2020-11-30 4f42a9b76b net: add note about disabling loopback in ListenMulticastUDP() + 2020-11-30 7b192f33cf cmd/go: remove trailing whitespace from test script + 2020-11-30 848dff6dda test: update gofrontend expected errors + 2020-11-30 a45e12fd4b test: recognize gofrontend error messages + 2020-11-30 d6abf298cf test: recognize new gofrontend error message + 2020-11-30 ae1a337809 [dev.regabi] cmd/compile: remove ODCLFIELD and ODDD ops + 2020-11-30 4e7685ef1a [dev.regabi] cmd/compile: add custom type syntax Node implementations + 2020-11-30 d40869fced [dev.regabi] cmd/compile: move gc.treecopy to ir.DeepCopy + 2020-11-30 f0001e8867 [dev.regabi] cmd/compile: add OTSLICE Op + 2020-11-30 1b84aabb01 [dev.regabi] cmd/compile: move typenod, typenodl to ir.TypeNode, ir.TypeNodeAt [generated] + 2020-11-30 e5c6463e20 [dev.regabi] cmd/compile: add ir.CallPartExpr + 2020-11-30 4eaef981b5 [dev.regabi] cmd/compile: add ir.Closure, ir.ClosureRead + 2020-11-30 e84b27bec5 [dev.regabi] cmd/compile: clean up Name and Func uses + 2020-11-30 c4bd0b7474 [dev.regabi] cmd/compile: make ir.Func the ODCLFUNC Node implementation + 2020-11-30 65ae15ac5d [dev.regabi] cmd/compile: move func code from node.go to func.go + 2020-11-30 862f638a89 [dev.regabi] cmd/compile: make ir.Name the ONAME Node implementation + 2020-11-30 f6106d195d [dev.regabi] cmd/compile: add ir.PkgName + 2020-11-30 420809ab08 [dev.regabi] cmd/compile: move name code from node.go to name.go + 2020-11-30 be3d8b40b5 [dev.regabi] cmd/compile: ir.BranchStmt, add ir.EmptyStmt, ir.LabelStmt + 2020-11-30 b09dbc6913 [dev.regabi] cmd/compile: remove SetOp(OEMPTY) calls + 2020-11-30 171787efcd [dev.regabi] cmd/compile: remove Orig, SetOrig from Node interface + 2020-11-30 79a3d5ce15 [dev.regabi] cmd/compile: setup for new Node implementations + 2020-11-30 0c65a2f317 [dev.regabi] cmd/compile: drop Node.HasOpt method + 2020-11-30 65f4ec2fae [dev.regabi] cmd/compile: cleanup label handling + 2020-11-30 c193279e2c os: return proper user directories on iOS + 2020-11-30 294c214cca runtime: gofmt + 2020-11-30 e5da18df52 os/exec: constrain thread usage in leaked descriptor test on illumos + 2020-11-28 4ce0a7cea6 runtime/pprof: ignore test failures on windows/arm + 2020-11-28 358d35455d bufio: make string(int) conversion safer + 2020-11-28 b94346e69b test: match gofrontend error messages + 2020-11-27 cb84d831c9 cmd/link: mark windows/arm as all PIE + 2020-11-27 0252cfd84d runtime: adjust address calculation in identifying abort on windows/arm + 2020-11-27 91f77ca2f8 runtime: return 0 from C function in test + 2020-11-26 926994fd7c log: make Default doc comment consistent with package doc + 2020-11-26 f0ff6d4a67 reflect: fix Value.Convert for int-to-string conversions (regression) + 2020-11-25 88e33f6ecb [dev.regabi] cmd/compile: fix latent import/export issue with break/continue + 2020-11-25 40f5bc4d55 [dev.regabi] merge master 4481ad6eb6 into dev.regabi + 2020-11-25 4481ad6eb6 doc/go1.16: consolidate stdlib changes in "Minor changes" section + 2020-11-25 ef603bead5 cmd/dist: restore GOARM=7 default for android/arm + 2020-11-25 41f3af9d04 [dev.regabi] cmd/compile: replace *Node type with an interface Node [generated] + 2020-11-25 4d0d9c2c5c [dev.regabi] cmd/compile: introduce ir.INode interface for *ir.Node + 2020-11-25 c26aead50c [dev.regabi] cmd/compile: convert types.Node (a pointer) to types.IRNode (an interface) + 2020-11-25 acb4d1cef1 [dev.regabi] cmd/compile: use Node getters and setters [generated] + 2020-11-25 41ab6689ed [dev.regabi] cmd/compile: rewrite a few ++/--/+=/-= to prep for getters/setters [generated] + 2020-11-25 048debb224 [dev.regabi] cmd/compile: remove gc ↔ ssa cycle hacks + 2020-11-25 84e2bd611f [dev.regabi] cmd/compile: introduce cmd/compile/internal/ir [generated] + 2020-11-25 331b8b4797 [dev.regabi] cmd/compile: move okforconst into its own declaration + 2020-11-25 26b66fd60b [dev.regabi] cmd/compile: introduce cmd/compile/internal/base [generated] + 2020-11-25 eb3086e5a8 [dev.regabi] cmd/compile: finish cleanup of Debug parsing + 2020-11-25 3c240f5d17 [dev.regabi] cmd/compile: clean up debug flag (-d) handling [generated] + 2020-11-25 9dc2350d8c doc/go1.16: add time/tzdata release note for CL 261877 + 2020-11-25 756661c82a [dev.regabi] cmd/compile: finish cleanup of Flag initialization + 2020-11-25 b9365488f0 cmd/internal/objabi: assume GOARM=7 on Android + 2020-11-25 df68e01b68 runtime: check channel's elemsize before calling race detector + 2020-11-25 259fd8adbb [dev.regabi] cmd/compile: fix reporting of overflow + 2020-11-25 1d3baf20dc regexp/syntax: add note about Unicode character classes + 2020-11-25 18573aea3c [dev.regabi] cmd/compile: clean up flag handling [generated] + 2020-11-25 6e583d65ab [dev.regabi] cmd/compile: simplify fmt handling of Nodes + 2020-11-25 d166ef6876 [dev.regabi] cmd/compile: add Node field getters and setters + 2020-11-25 750b3729dc go/constant: MakeFloat64(0) must return a value of Float kind + 2020-11-25 9262909764 [dev.regabi] cmd/compile: rewrite problematic use of Node fields + 2020-11-25 9e0e43d84d [dev.regabi] cmd/compile: remove uses of dummy + 2020-11-25 4a6b4fd139 [dev.regabi] add FatalfAt and fix Fatalf docs + 2020-11-25 484449c641 [dev.regabi] cmd/compile: remove file mistakenly added by CL 272248 + 2020-11-25 1308f11897 cmd/link: add relocation type R_AARCH64_LDST16_ABS_LO12_NC for arm64 + 2020-11-25 f6dcc975f7 go/constant: make constant.Make produce "smallest" const representation + 2020-11-25 7d72951229 [dev.regabi] cmd/compile: replace Val with go/constant.Value + 2020-11-24 e8de596f04 runtime: use inlined function name for traceback elision + 2020-11-24 ba2adc21e8 runtime/testdata/testprogcgo: refactor CrashTraceback + 2020-11-24 6826287c6b [dev.regabi] cmd/compile: replace evconst with non-mutating version + 2020-11-24 c22bc745c3 [dev.regabi] cmd/compile: delete n.List after collapsing OADDSTR to OLITERAL + 2020-11-24 ee6132a698 [dev.regabi] cmd/compile: introduce OMETHEXPR instead of overloading ONAME + 2020-11-24 4f9d54e41d [dev.regabi] cmd/compile: add OMETHEXPR + 2020-11-24 fd11a32c92 [dev.regabi] cmd/compile: clean up Node.Func + 2020-11-24 8e2106327c [dev.regabi] cmd/compile: clean up tests to know less about Node + 2020-11-24 65dcd15c72 doc/go1.16: fill in Go 1.16 release note TODOs using relnote + 2020-11-24 742c05e3bc [dev.regabi] cmd/compile: prep refactoring for switching to go/constant + 2020-11-24 015423a15b [dev.regabi] strconv: add to bootstrap packages + 2020-11-24 c767d73227 [dev.regabi] cmd/compile: remove CTRUNE + 2020-11-24 6dae48fb0b [dev.regabi] cmd/compile: refactor type/value assertions + 2020-11-24 88a9e2f9ad [dev.regabi] cmd/compile: replace CTNIL with ONIL + 2020-11-24 4af2decf30 [dev.regabi] cmd/compile: add (unused) ONIL constant + 2020-11-24 668e3a598f [dev.regabi] cmd/compile: cleanup type switch typechecking + 2020-11-24 96f3fb7244 [dev.regabi] go/constant: avoid heap allocations in match + 2020-11-24 1abb12fc97 [dev.regabi] go/constant: optimize BitLen + 2020-11-24 228b732ad9 [dev.regabi] cmd/compile: prepare for package ir + 2020-11-24 e37597f7f0 [dev.regabi] cmd/compile: rename a few 'base' identifiers + 2020-11-24 357c576878 [dev.regabi] cmd/compile: clean up error API + 2020-11-24 5fd949e4bd [dev.regabi] cmd/compile: initialize importMap lazily + 2020-11-24 7b144ed4f7 [dev.regabi] cmd/compile: rewrite concurrentFlagOk to be clearer + 2020-11-24 6965b01ea2 runtime: allow for usleep2HighRes to run without TLS setup + 2020-11-24 7dc5d909fb cmd/compile: set OpLoad argument type interface{} correctly + 2020-11-24 c754f25241 [dev.regabi] cmd/compile/internal/types: remove Func.Nname + 2020-11-24 c50c7a8c06 [dev.regabi] cmd/compile/internal/gc: refactor to use stop using Func.Nname + 2020-11-24 d5928847de [dev.regabi] cmd/compile/internal/gc: prep for Func.Nname removal refactoring + 2020-11-24 b30c7a8044 [dev.regabi] cmd/compile/internal/gc: add MethodName for getting referenced method + 2020-11-24 e1047302bd [dev.regabi] cmd/compile/internal/types: add pos/sym/typ params to NewField + 2020-11-24 762eda346a go/types: fix incorrect string(int) conversion (regression) + 2020-11-23 48a1a51898 runtime/metrics: tweak wording of stack and unused memory metrics + 2020-11-23 d902791b50 sync: use 386 instead of x86-32 to refer to the 32 bit x86 architecture + 2020-11-21 9ea6364a5e cmd/compile: add test for 42753 + 2020-11-21 f7342596da syscall: add DLLError.Unwrap function + 2020-11-21 f93ef07b11 cmd/go/internal/modload: remove the Reqs function + 2020-11-21 3f5a97514b cmd/go/internal/modload: remove a stale comment for EditBuildList + 2020-11-20 78e59bb1f7 cmd/go: support the -overlay flag for go mod commands + 2020-11-20 c47eac7db0 cmd/cgo, cmd/internal/pkgpath: support gofrontend mangler v3 + 2020-11-20 3fd4917472 doc: fix misspelling of “initialization” in diagnostics.html + 2020-11-20 676f0a45ed cmd/go: support overlaying go.mod files + 2020-11-20 a19c925eda cmd/go: recommend 'go get' command to switch from retracted versions + 2020-11-20 c306fd6d0b cmd/compile: allow loading single field of typed-interface{} OpIData + 2020-11-20 5e58ae43be cmd/go: report changes and resolved versions in 'go get' + 2020-11-20 012efc67f2 cmd/go/internal/modload: ignore selected version in checkRetractions + 2020-11-20 9264067a41 cmd/go: remove ListModules call in runGet + 2020-11-20 cb3f84ad25 cmd/go/internal/modload: eliminate LoadedModules + 2020-11-20 8bbd8294d0 cmd/go/internal/work: remove a redundant call to modload.LoadedModules + 2020-11-20 66c0264506 net, internal/poll: reset value before adding in minor kernel version + 2020-11-20 0dcc7d6ea8 go/types: use correct error position + 2020-11-20 c72a448881 go/types: fix error message for consistency + 2020-11-20 7eed73f36f go/types, go/constant: handle infinities as unknown values + 2020-11-19 f3ce010b33 io/fs: make WalkDirFunc parameter name consistent with doc comment + 2020-11-19 59f5fdac5d runtime/metrics: clarify Read's documentation + 2020-11-19 add45938b5 runtime/metrics: clarify memory and GC metrics documentation + 2020-11-19 498d8d5371 cmd/go/internal/work: avoid modload.Selected in 'go install pkg@version' + 2020-11-19 e73697b710 cmd/go: fix failing gccgo cases in TestScript/build_overlay + 2020-11-19 cb674b5c13 cmd/compile,cmd/asm: fix function pointer call perf regression on ppc64 + 2020-11-19 c31540364c cmd/compile: flag "-d=dumpptrs" to print Node ptrs in Dump output + 2020-11-19 4d048194cd runtime: support new callbackasm1 calling convention on windows/arm + 2020-11-19 5ba1c3f290 cmd/go/internal/modload: remove SetBuildList + 2020-11-19 ff2824d4b3 cmd/go/internal/modcmd: eliminate a call to modload.LoadedModules + 2020-11-19 0bb6115dd6 internal/fmtsort: sort the unsafe pointers in map + 2020-11-19 96b943a483 go/types: report an error for invalid constant values + 2020-11-18 35693d037f cmd/compile: fix miscompilation during inlining + 2020-11-18 5b0ec1a6ac cmd/compile: fix panic in field tracking logic + 2020-11-18 b4f3d52f6a sync: document RWMutex race semantics + 2020-11-18 b63db7f724 runtime: give test child time to block + 2020-11-18 ae76f6e962 runtime: use clock_gettime instead of gettimeofday on darwin + 2020-11-18 ee1b51294a runtime: use pipe2 syscall for Pipe in tests + 2020-11-18 d3072b8383 cmd/go: in 'go get', only load retractions for resolved versions + 2020-11-18 b194b5151f cmd/link: recompute heapPos after copyHeap + 2020-11-18 64ef84881f cmd/go: fix retract interval syntax in 'go help mod edit' + 2020-11-18 399b5d14d4 cmd/compile: stop MOVW-ing -1 as SRA shift amount in mips + 2020-11-18 a14e7bf6d4 go/ast: document invalid comment end positions with CRLF line endings + 2020-11-18 bcfaeca58c time: in NewTicker, document that the 1st tick comes after d + 2020-11-17 041a4e4c34 go/types: add test case for incorrect map index expression + 2020-11-17 05082c90d5 cmd/compile: clean up buggy DWARF inlined info PC ranges + 2020-11-17 01df2febf5 cmd/go: allow querying other versions of the main module + 2020-11-17 0968d2d599 cmd/go/internal/modget: clarify error for 'go get' without arguments + 2020-11-17 3e56bad13b cmd/go: revert "in 'go get', only load retractions for resolved versions" + 2020-11-17 0ae3b7cb74 cmd/compile: fix rules regression with shifts on PPC64 + 2020-11-16 869e2957b9 cmd/go: update 'go help mod init' + 2020-11-16 97700baf8b cmd/go: in 'go get', only load retractions for resolved versions + 2020-11-16 38367d098e cmd/link/internal/ld: dedup shared libraries on openbsd + 2020-11-16 d834ecec86 runtime/race: reject runtime fatal error in tests + 2020-11-16 0932dc2118 runtime: declare arg size/map for race version of sync/atomic functions + 2020-11-16 d70a33a40b cmd/go/internal/work: add missing newline to go version note + 2020-11-16 c7233dd063 cmd/go: permit wrongly rejected -Wl,-O... linker flags + 2020-11-16 f2eea4c1dc cmd/compile: mask SLL,SRL,SRAconst shift amount + 2020-11-14 92c732e901 cmd/compile: fix load of interface{}-typed OpIData in expand_calls + 2020-11-14 782cf560db cmd/go: permit CGO_LDFLAGS to appear in //go:ldflag + 2020-11-13 4f63e0a1f8 cmd/compile: update comments only for Node types and some functions + 2020-11-13 86954d5246 cmd/compile: mark plugin-exported types as used in interface + 2020-11-13 f423d616b1 cmd/cgo: fix initialization of empty argument types + 2020-11-13 35455fff0e runtime: swap the order of raceacquire() and racerelease() + 2020-11-13 31f71506d7 syscall: use correct type for TIOCSPGRP/TIOCGPGRP + 2020-11-12 30ba798093 cmd/go: use overlaid path contents in build cache + 2020-11-12 f016172dbe cmd/go: pass in overlaid paths for .s files + 2020-11-12 60b1253293 cmd/go: pass in overlaid file paths to C compiler + 2020-11-12 062e0e5ce6 cmd/go, cmd/cgo: don't let bogus symbol set cgo_ldflag + 2020-11-12 1e1fa5903b math/big: fix shift for recursive division + 2020-11-12 b34b0aaf69 cmd/go: skip TestScript/build_plugin_non_main on platforms that do not support -buildmode=plugin + 2020-11-12 c167635a6e cmd/compile: gofmt + 2020-11-12 e75aef80ca cmd/go: migrate away from semver.Max + 2020-11-12 9ef65ff137 cmd/compile: do not emit an extra debug_line entry for the end of seq addr + 2020-11-12 4bc5f6f45f cmd/link: put DYLD_INFO at beginning of LINKEDIT segment on darwin + 2020-11-12 d7974c31d0 os: gofmt + 2020-11-11 141fa337ad bytes: add example for (*Buffer).Bytes + 2020-11-11 f2e58c6d42 syscall: improve TestSetuidEtc() /proc/ parsing against races + 2020-11-11 4c174a7ba6 testing: reduce memory allocation in Helper + 2020-11-11 b641f0dcf4 os: clarify that IsExist and friends do not use errors.Is + 2020-11-11 26a860706a doc/go1.16: add crypto/x509 CSR release note + 2020-11-11 28437546f4 cmd/go: don't copy cgo files to objdir when overlay is present + 2020-11-11 c906608406 io/fs: fix reference to WalkFunc + 2020-11-11 f2e186b877 all: update vendored dependencies for Go 1.16 release + 2020-11-10 8f2db14cd3 cmd/go: release note for -mod=readonly by default + 2020-11-10 b2ef159db2 cmd/go: introduce the GOVERSION env variable + 2020-11-10 1948c00b6e doc/go1.16: add release notes for darwin ports + 2020-11-10 da3957ad0d Revert "cmd/go: don't copy cgo files to objdir when overlay is present" + 2020-11-10 0e0a872a76 runtime: add lock rank partial order edge pollDesc -> spanSetSpine + 2020-11-10 c68745b130 runtime: add lock rank partial order edge sweep -> mspanSpecial + 2020-11-10 e3de852f3e cmd/go: don't copy cgo files to objdir when overlay is present + 2020-11-10 189931296f cmd/internal/obj/s390x: fix SYNC instruction encoding + 2020-11-10 81322b9191 runtime/race: remove race from TestNoRaceAfterFunc2 + 2020-11-10 1c7650aa93 internal/poll: use copy_file_range only on Linux kernel >= 5.3 + 2020-11-10 1642cd78b5 cmd/go: update test_race_install expected output for CL 266368 Change-Id: I7ce5350ac9d0647236f1061a540c6751fb9faae9
Diffstat (limited to 'src/cmd/compile/internal/noder')
-rw-r--r--src/cmd/compile/internal/noder/import.go480
-rw-r--r--src/cmd/compile/internal/noder/lex.go193
-rw-r--r--src/cmd/compile/internal/noder/lex_test.go122
-rw-r--r--src/cmd/compile/internal/noder/noder.go1858
-rw-r--r--src/cmd/compile/internal/noder/posmap.go83
5 files changed, 2736 insertions, 0 deletions
diff --git a/src/cmd/compile/internal/noder/import.go b/src/cmd/compile/internal/noder/import.go
new file mode 100644
index 0000000000..747c30e6ff
--- /dev/null
+++ b/src/cmd/compile/internal/noder/import.go
@@ -0,0 +1,480 @@
+// Copyright 2009 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package noder
+
+import (
+ "errors"
+ "fmt"
+ "os"
+ pathpkg "path"
+ "runtime"
+ "sort"
+ "strconv"
+ "strings"
+ "unicode"
+ "unicode/utf8"
+
+ "cmd/compile/internal/base"
+ "cmd/compile/internal/ir"
+ "cmd/compile/internal/syntax"
+ "cmd/compile/internal/typecheck"
+ "cmd/compile/internal/types"
+ "cmd/internal/archive"
+ "cmd/internal/bio"
+ "cmd/internal/goobj"
+ "cmd/internal/objabi"
+ "cmd/internal/src"
+)
+
+func isDriveLetter(b byte) bool {
+ return 'a' <= b && b <= 'z' || 'A' <= b && b <= 'Z'
+}
+
+// is this path a local name? begins with ./ or ../ or /
+func islocalname(name string) bool {
+ return strings.HasPrefix(name, "/") ||
+ runtime.GOOS == "windows" && len(name) >= 3 && isDriveLetter(name[0]) && name[1] == ':' && name[2] == '/' ||
+ strings.HasPrefix(name, "./") || name == "." ||
+ strings.HasPrefix(name, "../") || name == ".."
+}
+
+func openPackage(path string) (*os.File, error) {
+ if islocalname(path) {
+ if base.Flag.NoLocalImports {
+ return nil, errors.New("local imports disallowed")
+ }
+
+ if base.Flag.Cfg.PackageFile != nil {
+ return os.Open(base.Flag.Cfg.PackageFile[path])
+ }
+
+ // try .a before .o. important for building libraries:
+ // if there is an array.o in the array.a library,
+ // want to find all of array.a, not just array.o.
+ if file, err := os.Open(fmt.Sprintf("%s.a", path)); err == nil {
+ return file, nil
+ }
+ if file, err := os.Open(fmt.Sprintf("%s.o", path)); err == nil {
+ return file, nil
+ }
+ return nil, errors.New("file not found")
+ }
+
+ // local imports should be canonicalized already.
+ // don't want to see "encoding/../encoding/base64"
+ // as different from "encoding/base64".
+ if q := pathpkg.Clean(path); q != path {
+ return nil, fmt.Errorf("non-canonical import path %q (should be %q)", path, q)
+ }
+
+ if base.Flag.Cfg.PackageFile != nil {
+ return os.Open(base.Flag.Cfg.PackageFile[path])
+ }
+
+ for _, dir := range base.Flag.Cfg.ImportDirs {
+ if file, err := os.Open(fmt.Sprintf("%s/%s.a", dir, path)); err == nil {
+ return file, nil
+ }
+ if file, err := os.Open(fmt.Sprintf("%s/%s.o", dir, path)); err == nil {
+ return file, nil
+ }
+ }
+
+ if objabi.GOROOT != "" {
+ suffix := ""
+ if base.Flag.InstallSuffix != "" {
+ suffix = "_" + base.Flag.InstallSuffix
+ } else if base.Flag.Race {
+ suffix = "_race"
+ } else if base.Flag.MSan {
+ suffix = "_msan"
+ }
+
+ if file, err := os.Open(fmt.Sprintf("%s/pkg/%s_%s%s/%s.a", objabi.GOROOT, objabi.GOOS, objabi.GOARCH, suffix, path)); err == nil {
+ return file, nil
+ }
+ if file, err := os.Open(fmt.Sprintf("%s/pkg/%s_%s%s/%s.o", objabi.GOROOT, objabi.GOOS, objabi.GOARCH, suffix, path)); err == nil {
+ return file, nil
+ }
+ }
+ return nil, errors.New("file not found")
+}
+
+// myheight tracks the local package's height based on packages
+// imported so far.
+var myheight int
+
+// resolveImportPath resolves an import path as it appears in a Go
+// source file to the package's full path.
+func resolveImportPath(path string) (string, error) {
+ // The package name main is no longer reserved,
+ // but we reserve the import path "main" to identify
+ // the main package, just as we reserve the import
+ // path "math" to identify the standard math package.
+ if path == "main" {
+ return "", errors.New("cannot import \"main\"")
+ }
+
+ if base.Ctxt.Pkgpath != "" && path == base.Ctxt.Pkgpath {
+ return "", fmt.Errorf("import %q while compiling that package (import cycle)", path)
+ }
+
+ if mapped, ok := base.Flag.Cfg.ImportMap[path]; ok {
+ path = mapped
+ }
+
+ if islocalname(path) {
+ if path[0] == '/' {
+ return "", errors.New("import path cannot be absolute path")
+ }
+
+ prefix := base.Flag.D
+ if prefix == "" {
+ // Questionable, but when -D isn't specified, historically we
+ // resolve local import paths relative to the directory the
+ // compiler's current directory, not the respective source
+ // file's directory.
+ prefix = base.Ctxt.Pathname
+ }
+ path = pathpkg.Join(prefix, path)
+
+ if err := checkImportPath(path, true); err != nil {
+ return "", err
+ }
+ }
+
+ return path, nil
+}
+
+// TODO(mdempsky): Return an error instead.
+func importfile(decl *syntax.ImportDecl) *types.Pkg {
+ if decl.Path.Kind != syntax.StringLit {
+ base.Errorf("import path must be a string")
+ return nil
+ }
+
+ path, err := strconv.Unquote(decl.Path.Value)
+ if err != nil {
+ base.Errorf("import path must be a string")
+ return nil
+ }
+
+ if err := checkImportPath(path, false); err != nil {
+ base.Errorf("%s", err.Error())
+ return nil
+ }
+
+ path, err = resolveImportPath(path)
+ if err != nil {
+ base.Errorf("%s", err)
+ return nil
+ }
+
+ importpkg := types.NewPkg(path, "")
+ if importpkg.Direct {
+ return importpkg // already fully loaded
+ }
+ importpkg.Direct = true
+ typecheck.Target.Imports = append(typecheck.Target.Imports, importpkg)
+
+ if path == "unsafe" {
+ return importpkg // initialized with universe
+ }
+
+ f, err := openPackage(path)
+ if err != nil {
+ base.Errorf("could not import %q: %v", path, err)
+ base.ErrorExit()
+ }
+ imp := bio.NewReader(f)
+ defer imp.Close()
+ file := f.Name()
+
+ // check object header
+ p, err := imp.ReadString('\n')
+ if err != nil {
+ base.Errorf("import %s: reading input: %v", file, err)
+ base.ErrorExit()
+ }
+
+ if p == "!<arch>\n" { // package archive
+ // package export block should be first
+ sz := archive.ReadHeader(imp.Reader, "__.PKGDEF")
+ if sz <= 0 {
+ base.Errorf("import %s: not a package file", file)
+ base.ErrorExit()
+ }
+ p, err = imp.ReadString('\n')
+ if err != nil {
+ base.Errorf("import %s: reading input: %v", file, err)
+ base.ErrorExit()
+ }
+ }
+
+ if !strings.HasPrefix(p, "go object ") {
+ base.Errorf("import %s: not a go object file: %s", file, p)
+ base.ErrorExit()
+ }
+ q := fmt.Sprintf("%s %s %s %s\n", objabi.GOOS, objabi.GOARCH, objabi.Version, objabi.Expstring())
+ if p[10:] != q {
+ base.Errorf("import %s: object is [%s] expected [%s]", file, p[10:], q)
+ base.ErrorExit()
+ }
+
+ // process header lines
+ for {
+ p, err = imp.ReadString('\n')
+ if err != nil {
+ base.Errorf("import %s: reading input: %v", file, err)
+ base.ErrorExit()
+ }
+ if p == "\n" {
+ break // header ends with blank line
+ }
+ }
+
+ // Expect $$B\n to signal binary import format.
+
+ // look for $$
+ var c byte
+ for {
+ c, err = imp.ReadByte()
+ if err != nil {
+ break
+ }
+ if c == '$' {
+ c, err = imp.ReadByte()
+ if c == '$' || err != nil {
+ break
+ }
+ }
+ }
+
+ // get character after $$
+ if err == nil {
+ c, _ = imp.ReadByte()
+ }
+
+ var fingerprint goobj.FingerprintType
+ switch c {
+ case '\n':
+ base.Errorf("cannot import %s: old export format no longer supported (recompile library)", path)
+ return nil
+
+ case 'B':
+ if base.Debug.Export != 0 {
+ fmt.Printf("importing %s (%s)\n", path, file)
+ }
+ imp.ReadByte() // skip \n after $$B
+
+ c, err = imp.ReadByte()
+ if err != nil {
+ base.Errorf("import %s: reading input: %v", file, err)
+ base.ErrorExit()
+ }
+
+ // Indexed format is distinguished by an 'i' byte,
+ // whereas previous export formats started with 'c', 'd', or 'v'.
+ if c != 'i' {
+ base.Errorf("import %s: unexpected package format byte: %v", file, c)
+ base.ErrorExit()
+ }
+ fingerprint = typecheck.ReadImports(importpkg, imp)
+
+ default:
+ base.Errorf("no import in %q", path)
+ base.ErrorExit()
+ }
+
+ // assume files move (get installed) so don't record the full path
+ if base.Flag.Cfg.PackageFile != nil {
+ // If using a packageFile map, assume path_ can be recorded directly.
+ base.Ctxt.AddImport(path, fingerprint)
+ } else {
+ // For file "/Users/foo/go/pkg/darwin_amd64/math.a" record "math.a".
+ base.Ctxt.AddImport(file[len(file)-len(path)-len(".a"):], fingerprint)
+ }
+
+ if importpkg.Height >= myheight {
+ myheight = importpkg.Height + 1
+ }
+
+ return importpkg
+}
+
+// The linker uses the magic symbol prefixes "go." and "type."
+// Avoid potential confusion between import paths and symbols
+// by rejecting these reserved imports for now. Also, people
+// "can do weird things in GOPATH and we'd prefer they didn't
+// do _that_ weird thing" (per rsc). See also #4257.
+var reservedimports = []string{
+ "go",
+ "type",
+}
+
+func checkImportPath(path string, allowSpace bool) error {
+ if path == "" {
+ return errors.New("import path is empty")
+ }
+
+ if strings.Contains(path, "\x00") {
+ return errors.New("import path contains NUL")
+ }
+
+ for _, ri := range reservedimports {
+ if path == ri {
+ return fmt.Errorf("import path %q is reserved and cannot be used", path)
+ }
+ }
+
+ for _, r := range path {
+ switch {
+ case r == utf8.RuneError:
+ return fmt.Errorf("import path contains invalid UTF-8 sequence: %q", path)
+ case r < 0x20 || r == 0x7f:
+ return fmt.Errorf("import path contains control character: %q", path)
+ case r == '\\':
+ return fmt.Errorf("import path contains backslash; use slash: %q", path)
+ case !allowSpace && unicode.IsSpace(r):
+ return fmt.Errorf("import path contains space character: %q", path)
+ case strings.ContainsRune("!\"#$%&'()*,:;<=>?[]^`{|}", r):
+ return fmt.Errorf("import path contains invalid character '%c': %q", r, path)
+ }
+ }
+
+ return nil
+}
+
+func pkgnotused(lineno src.XPos, path string, name string) {
+ // If the package was imported with a name other than the final
+ // import path element, show it explicitly in the error message.
+ // Note that this handles both renamed imports and imports of
+ // packages containing unconventional package declarations.
+ // Note that this uses / always, even on Windows, because Go import
+ // paths always use forward slashes.
+ elem := path
+ if i := strings.LastIndex(elem, "/"); i >= 0 {
+ elem = elem[i+1:]
+ }
+ if name == "" || elem == name {
+ base.ErrorfAt(lineno, "imported and not used: %q", path)
+ } else {
+ base.ErrorfAt(lineno, "imported and not used: %q as %s", path, name)
+ }
+}
+
+func mkpackage(pkgname string) {
+ if types.LocalPkg.Name == "" {
+ if pkgname == "_" {
+ base.Errorf("invalid package name _")
+ }
+ types.LocalPkg.Name = pkgname
+ } else {
+ if pkgname != types.LocalPkg.Name {
+ base.Errorf("package %s; expected %s", pkgname, types.LocalPkg.Name)
+ }
+ }
+}
+
+func clearImports() {
+ type importedPkg struct {
+ pos src.XPos
+ path string
+ name string
+ }
+ var unused []importedPkg
+
+ for _, s := range types.LocalPkg.Syms {
+ n := ir.AsNode(s.Def)
+ if n == nil {
+ continue
+ }
+ if n.Op() == ir.OPACK {
+ // throw away top-level package name left over
+ // from previous file.
+ // leave s->block set to cause redeclaration
+ // errors if a conflicting top-level name is
+ // introduced by a different file.
+ p := n.(*ir.PkgName)
+ if !p.Used && base.SyntaxErrors() == 0 {
+ unused = append(unused, importedPkg{p.Pos(), p.Pkg.Path, s.Name})
+ }
+ s.Def = nil
+ continue
+ }
+ if types.IsDotAlias(s) {
+ // throw away top-level name left over
+ // from previous import . "x"
+ // We'll report errors after type checking in CheckDotImports.
+ s.Def = nil
+ continue
+ }
+ }
+
+ sort.Slice(unused, func(i, j int) bool { return unused[i].pos.Before(unused[j].pos) })
+ for _, pkg := range unused {
+ pkgnotused(pkg.pos, pkg.path, pkg.name)
+ }
+}
+
+// CheckDotImports reports errors for any unused dot imports.
+func CheckDotImports() {
+ for _, pack := range dotImports {
+ if !pack.Used {
+ base.ErrorfAt(pack.Pos(), "imported and not used: %q", pack.Pkg.Path)
+ }
+ }
+
+ // No longer needed; release memory.
+ dotImports = nil
+ typecheck.DotImportRefs = nil
+}
+
+// dotImports tracks all PkgNames that have been dot-imported.
+var dotImports []*ir.PkgName
+
+// find all the exported symbols in package referenced by PkgName,
+// and make them available in the current package
+func importDot(pack *ir.PkgName) {
+ if typecheck.DotImportRefs == nil {
+ typecheck.DotImportRefs = make(map[*ir.Ident]*ir.PkgName)
+ }
+
+ opkg := pack.Pkg
+ for _, s := range opkg.Syms {
+ if s.Def == nil {
+ if _, ok := typecheck.DeclImporter[s]; !ok {
+ continue
+ }
+ }
+ if !types.IsExported(s.Name) || strings.ContainsRune(s.Name, 0xb7) { // 0xb7 = center dot
+ continue
+ }
+ s1 := typecheck.Lookup(s.Name)
+ if s1.Def != nil {
+ pkgerror := fmt.Sprintf("during import %q", opkg.Path)
+ typecheck.Redeclared(base.Pos, s1, pkgerror)
+ continue
+ }
+
+ id := ir.NewIdent(src.NoXPos, s)
+ typecheck.DotImportRefs[id] = pack
+ s1.Def = id
+ s1.Block = 1
+ }
+
+ dotImports = append(dotImports, pack)
+}
+
+// importName is like oldname,
+// but it reports an error if sym is from another package and not exported.
+func importName(sym *types.Sym) ir.Node {
+ n := oldname(sym)
+ if !types.IsExported(sym.Name) && sym.Pkg != types.LocalPkg {
+ n.SetDiag(true)
+ base.Errorf("cannot refer to unexported name %s.%s", sym.Pkg.Name, sym.Name)
+ }
+ return n
+}
diff --git a/src/cmd/compile/internal/noder/lex.go b/src/cmd/compile/internal/noder/lex.go
new file mode 100644
index 0000000000..cdca9e55f3
--- /dev/null
+++ b/src/cmd/compile/internal/noder/lex.go
@@ -0,0 +1,193 @@
+// Copyright 2009 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package noder
+
+import (
+ "fmt"
+ "strings"
+
+ "cmd/compile/internal/ir"
+ "cmd/compile/internal/syntax"
+ "cmd/internal/objabi"
+)
+
+func isSpace(c rune) bool {
+ return c == ' ' || c == '\t' || c == '\n' || c == '\r'
+}
+
+func isQuoted(s string) bool {
+ return len(s) >= 2 && s[0] == '"' && s[len(s)-1] == '"'
+}
+
+const (
+ funcPragmas = ir.Nointerface |
+ ir.Noescape |
+ ir.Norace |
+ ir.Nosplit |
+ ir.Noinline |
+ ir.NoCheckPtr |
+ ir.RegisterParams | // TODO remove after register abi is working
+ ir.CgoUnsafeArgs |
+ ir.UintptrEscapes |
+ ir.Systemstack |
+ ir.Nowritebarrier |
+ ir.Nowritebarrierrec |
+ ir.Yeswritebarrierrec
+
+ typePragmas = ir.NotInHeap
+)
+
+func pragmaFlag(verb string) ir.PragmaFlag {
+ switch verb {
+ case "go:build":
+ return ir.GoBuildPragma
+ case "go:nointerface":
+ if objabi.Fieldtrack_enabled != 0 {
+ return ir.Nointerface
+ }
+ case "go:noescape":
+ return ir.Noescape
+ case "go:norace":
+ return ir.Norace
+ case "go:nosplit":
+ return ir.Nosplit | ir.NoCheckPtr // implies NoCheckPtr (see #34972)
+ case "go:noinline":
+ return ir.Noinline
+ case "go:nocheckptr":
+ return ir.NoCheckPtr
+ case "go:systemstack":
+ return ir.Systemstack
+ case "go:nowritebarrier":
+ return ir.Nowritebarrier
+ case "go:nowritebarrierrec":
+ return ir.Nowritebarrierrec | ir.Nowritebarrier // implies Nowritebarrier
+ case "go:yeswritebarrierrec":
+ return ir.Yeswritebarrierrec
+ case "go:cgo_unsafe_args":
+ return ir.CgoUnsafeArgs | ir.NoCheckPtr // implies NoCheckPtr (see #34968)
+ case "go:uintptrescapes":
+ // For the next function declared in the file
+ // any uintptr arguments may be pointer values
+ // converted to uintptr. This directive
+ // ensures that the referenced allocated
+ // object, if any, is retained and not moved
+ // until the call completes, even though from
+ // the types alone it would appear that the
+ // object is no longer needed during the
+ // call. The conversion to uintptr must appear
+ // in the argument list.
+ // Used in syscall/dll_windows.go.
+ return ir.UintptrEscapes
+ case "go:registerparams": // TODO remove after register abi is working
+ return ir.RegisterParams
+ case "go:notinheap":
+ return ir.NotInHeap
+ }
+ return 0
+}
+
+// pragcgo is called concurrently if files are parsed concurrently.
+func (p *noder) pragcgo(pos syntax.Pos, text string) {
+ f := pragmaFields(text)
+
+ verb := strings.TrimPrefix(f[0], "go:")
+ f[0] = verb
+
+ switch verb {
+ case "cgo_export_static", "cgo_export_dynamic":
+ switch {
+ case len(f) == 2 && !isQuoted(f[1]):
+ case len(f) == 3 && !isQuoted(f[1]) && !isQuoted(f[2]):
+ default:
+ p.error(syntax.Error{Pos: pos, Msg: fmt.Sprintf(`usage: //go:%s local [remote]`, verb)})
+ return
+ }
+ case "cgo_import_dynamic":
+ switch {
+ case len(f) == 2 && !isQuoted(f[1]):
+ case len(f) == 3 && !isQuoted(f[1]) && !isQuoted(f[2]):
+ case len(f) == 4 && !isQuoted(f[1]) && !isQuoted(f[2]) && isQuoted(f[3]):
+ f[3] = strings.Trim(f[3], `"`)
+ if objabi.GOOS == "aix" && f[3] != "" {
+ // On Aix, library pattern must be "lib.a/object.o"
+ // or "lib.a/libname.so.X"
+ n := strings.Split(f[3], "/")
+ if len(n) != 2 || !strings.HasSuffix(n[0], ".a") || (!strings.HasSuffix(n[1], ".o") && !strings.Contains(n[1], ".so.")) {
+ p.error(syntax.Error{Pos: pos, Msg: `usage: //go:cgo_import_dynamic local [remote ["lib.a/object.o"]]`})
+ return
+ }
+ }
+ default:
+ p.error(syntax.Error{Pos: pos, Msg: `usage: //go:cgo_import_dynamic local [remote ["library"]]`})
+ return
+ }
+ case "cgo_import_static":
+ switch {
+ case len(f) == 2 && !isQuoted(f[1]):
+ default:
+ p.error(syntax.Error{Pos: pos, Msg: `usage: //go:cgo_import_static local`})
+ return
+ }
+ case "cgo_dynamic_linker":
+ switch {
+ case len(f) == 2 && isQuoted(f[1]):
+ f[1] = strings.Trim(f[1], `"`)
+ default:
+ p.error(syntax.Error{Pos: pos, Msg: `usage: //go:cgo_dynamic_linker "path"`})
+ return
+ }
+ case "cgo_ldflag":
+ switch {
+ case len(f) == 2 && isQuoted(f[1]):
+ f[1] = strings.Trim(f[1], `"`)
+ default:
+ p.error(syntax.Error{Pos: pos, Msg: `usage: //go:cgo_ldflag "arg"`})
+ return
+ }
+ default:
+ return
+ }
+ p.pragcgobuf = append(p.pragcgobuf, f)
+}
+
+// pragmaFields is similar to strings.FieldsFunc(s, isSpace)
+// but does not split when inside double quoted regions and always
+// splits before the start and after the end of a double quoted region.
+// pragmaFields does not recognize escaped quotes. If a quote in s is not
+// closed the part after the opening quote will not be returned as a field.
+func pragmaFields(s string) []string {
+ var a []string
+ inQuote := false
+ fieldStart := -1 // Set to -1 when looking for start of field.
+ for i, c := range s {
+ switch {
+ case c == '"':
+ if inQuote {
+ inQuote = false
+ a = append(a, s[fieldStart:i+1])
+ fieldStart = -1
+ } else {
+ inQuote = true
+ if fieldStart >= 0 {
+ a = append(a, s[fieldStart:i])
+ }
+ fieldStart = i
+ }
+ case !inQuote && isSpace(c):
+ if fieldStart >= 0 {
+ a = append(a, s[fieldStart:i])
+ fieldStart = -1
+ }
+ default:
+ if fieldStart == -1 {
+ fieldStart = i
+ }
+ }
+ }
+ if !inQuote && fieldStart >= 0 { // Last field might end at the end of the string.
+ a = append(a, s[fieldStart:])
+ }
+ return a
+}
diff --git a/src/cmd/compile/internal/noder/lex_test.go b/src/cmd/compile/internal/noder/lex_test.go
new file mode 100644
index 0000000000..85a3f06759
--- /dev/null
+++ b/src/cmd/compile/internal/noder/lex_test.go
@@ -0,0 +1,122 @@
+// Copyright 2016 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package noder
+
+import (
+ "reflect"
+ "runtime"
+ "testing"
+
+ "cmd/compile/internal/syntax"
+)
+
+func eq(a, b []string) bool {
+ if len(a) != len(b) {
+ return false
+ }
+ for i := 0; i < len(a); i++ {
+ if a[i] != b[i] {
+ return false
+ }
+ }
+ return true
+}
+
+func TestPragmaFields(t *testing.T) {
+ var tests = []struct {
+ in string
+ want []string
+ }{
+ {"", []string{}},
+ {" \t ", []string{}},
+ {`""""`, []string{`""`, `""`}},
+ {" a'b'c ", []string{"a'b'c"}},
+ {"1 2 3 4", []string{"1", "2", "3", "4"}},
+ {"\n☺\t☹\n", []string{"☺", "☹"}},
+ {`"1 2 " 3 " 4 5"`, []string{`"1 2 "`, `3`, `" 4 5"`}},
+ {`"1""2 3""4"`, []string{`"1"`, `"2 3"`, `"4"`}},
+ {`12"34"`, []string{`12`, `"34"`}},
+ {`12"34 `, []string{`12`}},
+ }
+
+ for _, tt := range tests {
+ got := pragmaFields(tt.in)
+ if !eq(got, tt.want) {
+ t.Errorf("pragmaFields(%q) = %v; want %v", tt.in, got, tt.want)
+ continue
+ }
+ }
+}
+
+func TestPragcgo(t *testing.T) {
+ type testStruct struct {
+ in string
+ want []string
+ }
+
+ var tests = []testStruct{
+ {`go:cgo_export_dynamic local`, []string{`cgo_export_dynamic`, `local`}},
+ {`go:cgo_export_dynamic local remote`, []string{`cgo_export_dynamic`, `local`, `remote`}},
+ {`go:cgo_export_dynamic local' remote'`, []string{`cgo_export_dynamic`, `local'`, `remote'`}},
+ {`go:cgo_export_static local`, []string{`cgo_export_static`, `local`}},
+ {`go:cgo_export_static local remote`, []string{`cgo_export_static`, `local`, `remote`}},
+ {`go:cgo_export_static local' remote'`, []string{`cgo_export_static`, `local'`, `remote'`}},
+ {`go:cgo_import_dynamic local`, []string{`cgo_import_dynamic`, `local`}},
+ {`go:cgo_import_dynamic local remote`, []string{`cgo_import_dynamic`, `local`, `remote`}},
+ {`go:cgo_import_static local`, []string{`cgo_import_static`, `local`}},
+ {`go:cgo_import_static local'`, []string{`cgo_import_static`, `local'`}},
+ {`go:cgo_dynamic_linker "/path/"`, []string{`cgo_dynamic_linker`, `/path/`}},
+ {`go:cgo_dynamic_linker "/p ath/"`, []string{`cgo_dynamic_linker`, `/p ath/`}},
+ {`go:cgo_ldflag "arg"`, []string{`cgo_ldflag`, `arg`}},
+ {`go:cgo_ldflag "a rg"`, []string{`cgo_ldflag`, `a rg`}},
+ }
+
+ if runtime.GOOS != "aix" {
+ tests = append(tests, []testStruct{
+ {`go:cgo_import_dynamic local remote "library"`, []string{`cgo_import_dynamic`, `local`, `remote`, `library`}},
+ {`go:cgo_import_dynamic local' remote' "lib rary"`, []string{`cgo_import_dynamic`, `local'`, `remote'`, `lib rary`}},
+ }...)
+ } else {
+ // cgo_import_dynamic with a library is slightly different on AIX
+ // as the library field must follow the pattern [libc.a/object.o].
+ tests = append(tests, []testStruct{
+ {`go:cgo_import_dynamic local remote "lib.a/obj.o"`, []string{`cgo_import_dynamic`, `local`, `remote`, `lib.a/obj.o`}},
+ // This test must fail.
+ {`go:cgo_import_dynamic local' remote' "library"`, []string{`<unknown position>: usage: //go:cgo_import_dynamic local [remote ["lib.a/object.o"]]`}},
+ }...)
+
+ }
+
+ var p noder
+ var nopos syntax.Pos
+ for _, tt := range tests {
+
+ p.err = make(chan syntax.Error)
+ gotch := make(chan [][]string, 1)
+ go func() {
+ p.pragcgobuf = nil
+ p.pragcgo(nopos, tt.in)
+ if p.pragcgobuf != nil {
+ gotch <- p.pragcgobuf
+ }
+ }()
+
+ select {
+ case e := <-p.err:
+ want := tt.want[0]
+ if e.Error() != want {
+ t.Errorf("pragcgo(%q) = %q; want %q", tt.in, e, want)
+ continue
+ }
+ case got := <-gotch:
+ want := [][]string{tt.want}
+ if !reflect.DeepEqual(got, want) {
+ t.Errorf("pragcgo(%q) = %q; want %q", tt.in, got, want)
+ continue
+ }
+ }
+
+ }
+}
diff --git a/src/cmd/compile/internal/noder/noder.go b/src/cmd/compile/internal/noder/noder.go
new file mode 100644
index 0000000000..5b5b09cb2d
--- /dev/null
+++ b/src/cmd/compile/internal/noder/noder.go
@@ -0,0 +1,1858 @@
+// Copyright 2016 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package noder
+
+import (
+ "fmt"
+ "go/constant"
+ "go/token"
+ "os"
+ "path/filepath"
+ "runtime"
+ "strconv"
+ "strings"
+ "unicode"
+ "unicode/utf8"
+
+ "cmd/compile/internal/base"
+ "cmd/compile/internal/dwarfgen"
+ "cmd/compile/internal/ir"
+ "cmd/compile/internal/syntax"
+ "cmd/compile/internal/typecheck"
+ "cmd/compile/internal/types"
+ "cmd/internal/objabi"
+ "cmd/internal/src"
+)
+
+func LoadPackage(filenames []string) {
+ base.Timer.Start("fe", "parse")
+
+ mode := syntax.CheckBranches
+
+ // Limit the number of simultaneously open files.
+ sem := make(chan struct{}, runtime.GOMAXPROCS(0)+10)
+
+ noders := make([]*noder, len(filenames))
+ for i, filename := range filenames {
+ p := noder{
+ err: make(chan syntax.Error),
+ trackScopes: base.Flag.Dwarf,
+ }
+ noders[i] = &p
+
+ filename := filename
+ go func() {
+ sem <- struct{}{}
+ defer func() { <-sem }()
+ defer close(p.err)
+ fbase := syntax.NewFileBase(filename)
+
+ f, err := os.Open(filename)
+ if err != nil {
+ p.error(syntax.Error{Msg: err.Error()})
+ return
+ }
+ defer f.Close()
+
+ p.file, _ = syntax.Parse(fbase, f, p.error, p.pragma, mode) // errors are tracked via p.error
+ }()
+ }
+
+ var lines uint
+ for _, p := range noders {
+ for e := range p.err {
+ p.errorAt(e.Pos, "%s", e.Msg)
+ }
+ lines += p.file.Lines
+ }
+ base.Timer.AddEvent(int64(lines), "lines")
+
+ for _, p := range noders {
+ p.node()
+ p.file = nil // release memory
+ }
+
+ if base.SyntaxErrors() != 0 {
+ base.ErrorExit()
+ }
+ types.CheckDclstack()
+
+ for _, p := range noders {
+ p.processPragmas()
+ }
+
+ // Typecheck.
+ types.LocalPkg.Height = myheight
+ typecheck.DeclareUniverse()
+ typecheck.TypecheckAllowed = true
+
+ // Process top-level declarations in phases.
+
+ // Phase 1: const, type, and names and types of funcs.
+ // This will gather all the information about types
+ // and methods but doesn't depend on any of it.
+ //
+ // We also defer type alias declarations until phase 2
+ // to avoid cycles like #18640.
+ // TODO(gri) Remove this again once we have a fix for #25838.
+
+ // Don't use range--typecheck can add closures to Target.Decls.
+ base.Timer.Start("fe", "typecheck", "top1")
+ for i := 0; i < len(typecheck.Target.Decls); i++ {
+ n := typecheck.Target.Decls[i]
+ if op := n.Op(); op != ir.ODCL && op != ir.OAS && op != ir.OAS2 && (op != ir.ODCLTYPE || !n.(*ir.Decl).X.Alias()) {
+ typecheck.Target.Decls[i] = typecheck.Stmt(n)
+ }
+ }
+
+ // Phase 2: Variable assignments.
+ // To check interface assignments, depends on phase 1.
+
+ // Don't use range--typecheck can add closures to Target.Decls.
+ base.Timer.Start("fe", "typecheck", "top2")
+ for i := 0; i < len(typecheck.Target.Decls); i++ {
+ n := typecheck.Target.Decls[i]
+ if op := n.Op(); op == ir.ODCL || op == ir.OAS || op == ir.OAS2 || op == ir.ODCLTYPE && n.(*ir.Decl).X.Alias() {
+ typecheck.Target.Decls[i] = typecheck.Stmt(n)
+ }
+ }
+
+ // Phase 3: Type check function bodies.
+ // Don't use range--typecheck can add closures to Target.Decls.
+ base.Timer.Start("fe", "typecheck", "func")
+ var fcount int64
+ for i := 0; i < len(typecheck.Target.Decls); i++ {
+ n := typecheck.Target.Decls[i]
+ if n.Op() == ir.ODCLFUNC {
+ if base.Flag.W > 1 {
+ s := fmt.Sprintf("\nbefore typecheck %v", n)
+ ir.Dump(s, n)
+ }
+ typecheck.FuncBody(n.(*ir.Func))
+ if base.Flag.W > 1 {
+ s := fmt.Sprintf("\nafter typecheck %v", n)
+ ir.Dump(s, n)
+ }
+ fcount++
+ }
+ }
+
+ // Phase 4: Check external declarations.
+ // TODO(mdempsky): This should be handled when type checking their
+ // corresponding ODCL nodes.
+ base.Timer.Start("fe", "typecheck", "externdcls")
+ for i, n := range typecheck.Target.Externs {
+ if n.Op() == ir.ONAME {
+ typecheck.Target.Externs[i] = typecheck.Expr(typecheck.Target.Externs[i])
+ }
+ }
+
+ // Phase 5: With all user code type-checked, it's now safe to verify map keys.
+ // With all user code typechecked, it's now safe to verify unused dot imports.
+ typecheck.CheckMapKeys()
+ CheckDotImports()
+ base.ExitIfErrors()
+}
+
+func (p *noder) errorAt(pos syntax.Pos, format string, args ...interface{}) {
+ base.ErrorfAt(p.makeXPos(pos), format, args...)
+}
+
+// TODO(gri) Can we eliminate fileh in favor of absFilename?
+func fileh(name string) string {
+ return objabi.AbsFile("", name, base.Flag.TrimPath)
+}
+
+func absFilename(name string) string {
+ return objabi.AbsFile(base.Ctxt.Pathname, name, base.Flag.TrimPath)
+}
+
+// noder transforms package syntax's AST into a Node tree.
+type noder struct {
+ posMap
+
+ file *syntax.File
+ linknames []linkname
+ pragcgobuf [][]string
+ err chan syntax.Error
+ importedUnsafe bool
+ importedEmbed bool
+ trackScopes bool
+
+ funcState *funcState
+}
+
+// funcState tracks all per-function state to make handling nested
+// functions easier.
+type funcState struct {
+ // scopeVars is a stack tracking the number of variables declared in
+ // the current function at the moment each open scope was opened.
+ scopeVars []int
+ marker dwarfgen.ScopeMarker
+
+ lastCloseScopePos syntax.Pos
+}
+
+func (p *noder) funcBody(fn *ir.Func, block *syntax.BlockStmt) {
+ outerFuncState := p.funcState
+ p.funcState = new(funcState)
+ typecheck.StartFuncBody(fn)
+
+ if block != nil {
+ body := p.stmts(block.List)
+ if body == nil {
+ body = []ir.Node{ir.NewBlockStmt(base.Pos, nil)}
+ }
+ fn.Body = body
+
+ base.Pos = p.makeXPos(block.Rbrace)
+ fn.Endlineno = base.Pos
+ }
+
+ typecheck.FinishFuncBody()
+ p.funcState.marker.WriteTo(fn)
+ p.funcState = outerFuncState
+}
+
+func (p *noder) openScope(pos syntax.Pos) {
+ fs := p.funcState
+ types.Markdcl()
+
+ if p.trackScopes {
+ fs.scopeVars = append(fs.scopeVars, len(ir.CurFunc.Dcl))
+ fs.marker.Push(p.makeXPos(pos))
+ }
+}
+
+func (p *noder) closeScope(pos syntax.Pos) {
+ fs := p.funcState
+ fs.lastCloseScopePos = pos
+ types.Popdcl()
+
+ if p.trackScopes {
+ scopeVars := fs.scopeVars[len(fs.scopeVars)-1]
+ fs.scopeVars = fs.scopeVars[:len(fs.scopeVars)-1]
+ if scopeVars == len(ir.CurFunc.Dcl) {
+ // no variables were declared in this scope, so we can retract it.
+ fs.marker.Unpush()
+ } else {
+ fs.marker.Pop(p.makeXPos(pos))
+ }
+ }
+}
+
+// closeAnotherScope is like closeScope, but it reuses the same mark
+// position as the last closeScope call. This is useful for "for" and
+// "if" statements, as their implicit blocks always end at the same
+// position as an explicit block.
+func (p *noder) closeAnotherScope() {
+ p.closeScope(p.funcState.lastCloseScopePos)
+}
+
+// linkname records a //go:linkname directive.
+type linkname struct {
+ pos syntax.Pos
+ local string
+ remote string
+}
+
+func (p *noder) node() {
+ p.importedUnsafe = false
+ p.importedEmbed = false
+
+ p.setlineno(p.file.PkgName)
+ mkpackage(p.file.PkgName.Value)
+
+ if pragma, ok := p.file.Pragma.(*pragmas); ok {
+ pragma.Flag &^= ir.GoBuildPragma
+ p.checkUnused(pragma)
+ }
+
+ typecheck.Target.Decls = append(typecheck.Target.Decls, p.decls(p.file.DeclList)...)
+
+ base.Pos = src.NoXPos
+ clearImports()
+}
+
+func (p *noder) processPragmas() {
+ for _, l := range p.linknames {
+ if !p.importedUnsafe {
+ p.errorAt(l.pos, "//go:linkname only allowed in Go files that import \"unsafe\"")
+ continue
+ }
+ n := ir.AsNode(typecheck.Lookup(l.local).Def)
+ if n == nil || n.Op() != ir.ONAME {
+ // TODO(mdempsky): Change to p.errorAt before Go 1.17 release.
+ // base.WarnfAt(p.makeXPos(l.pos), "//go:linkname must refer to declared function or variable (will be an error in Go 1.17)")
+ continue
+ }
+ if n.Sym().Linkname != "" {
+ p.errorAt(l.pos, "duplicate //go:linkname for %s", l.local)
+ continue
+ }
+ n.Sym().Linkname = l.remote
+ }
+ typecheck.Target.CgoPragmas = append(typecheck.Target.CgoPragmas, p.pragcgobuf...)
+}
+
+func (p *noder) decls(decls []syntax.Decl) (l []ir.Node) {
+ var cs constState
+
+ for _, decl := range decls {
+ p.setlineno(decl)
+ switch decl := decl.(type) {
+ case *syntax.ImportDecl:
+ p.importDecl(decl)
+
+ case *syntax.VarDecl:
+ l = append(l, p.varDecl(decl)...)
+
+ case *syntax.ConstDecl:
+ l = append(l, p.constDecl(decl, &cs)...)
+
+ case *syntax.TypeDecl:
+ l = append(l, p.typeDecl(decl))
+
+ case *syntax.FuncDecl:
+ l = append(l, p.funcDecl(decl))
+
+ default:
+ panic("unhandled Decl")
+ }
+ }
+
+ return
+}
+
+func (p *noder) importDecl(imp *syntax.ImportDecl) {
+ if imp.Path == nil || imp.Path.Bad {
+ return // avoid follow-on errors if there was a syntax error
+ }
+
+ if pragma, ok := imp.Pragma.(*pragmas); ok {
+ p.checkUnused(pragma)
+ }
+
+ ipkg := importfile(imp)
+ if ipkg == nil {
+ if base.Errors() == 0 {
+ base.Fatalf("phase error in import")
+ }
+ return
+ }
+
+ if ipkg == ir.Pkgs.Unsafe {
+ p.importedUnsafe = true
+ }
+ if ipkg.Path == "embed" {
+ p.importedEmbed = true
+ }
+
+ var my *types.Sym
+ if imp.LocalPkgName != nil {
+ my = p.name(imp.LocalPkgName)
+ } else {
+ my = typecheck.Lookup(ipkg.Name)
+ }
+
+ pack := ir.NewPkgName(p.pos(imp), my, ipkg)
+
+ switch my.Name {
+ case ".":
+ importDot(pack)
+ return
+ case "init":
+ base.ErrorfAt(pack.Pos(), "cannot import package as init - init must be a func")
+ return
+ case "_":
+ return
+ }
+ if my.Def != nil {
+ typecheck.Redeclared(pack.Pos(), my, "as imported package name")
+ }
+ my.Def = pack
+ my.Lastlineno = pack.Pos()
+ my.Block = 1 // at top level
+}
+
+func (p *noder) varDecl(decl *syntax.VarDecl) []ir.Node {
+ names := p.declNames(ir.ONAME, decl.NameList)
+ typ := p.typeExprOrNil(decl.Type)
+ exprs := p.exprList(decl.Values)
+
+ if pragma, ok := decl.Pragma.(*pragmas); ok {
+ varEmbed(p.makeXPos, names[0], decl, pragma, p.importedEmbed)
+ p.checkUnused(pragma)
+ }
+
+ var init []ir.Node
+ p.setlineno(decl)
+
+ if len(names) > 1 && len(exprs) == 1 {
+ as2 := ir.NewAssignListStmt(base.Pos, ir.OAS2, nil, exprs)
+ for _, v := range names {
+ as2.Lhs.Append(v)
+ typecheck.Declare(v, typecheck.DeclContext)
+ v.Ntype = typ
+ v.Defn = as2
+ if ir.CurFunc != nil {
+ init = append(init, ir.NewDecl(base.Pos, ir.ODCL, v))
+ }
+ }
+
+ return append(init, as2)
+ }
+
+ for i, v := range names {
+ var e ir.Node
+ if i < len(exprs) {
+ e = exprs[i]
+ }
+
+ typecheck.Declare(v, typecheck.DeclContext)
+ v.Ntype = typ
+
+ if ir.CurFunc != nil {
+ init = append(init, ir.NewDecl(base.Pos, ir.ODCL, v))
+ }
+ as := ir.NewAssignStmt(base.Pos, v, e)
+ init = append(init, as)
+ if e != nil || ir.CurFunc == nil {
+ v.Defn = as
+ }
+ }
+
+ if len(exprs) != 0 && len(names) != len(exprs) {
+ base.Errorf("assignment mismatch: %d variables but %d values", len(names), len(exprs))
+ }
+
+ return init
+}
+
+// constState tracks state between constant specifiers within a
+// declaration group. This state is kept separate from noder so nested
+// constant declarations are handled correctly (e.g., issue 15550).
+type constState struct {
+ group *syntax.Group
+ typ ir.Ntype
+ values []ir.Node
+ iota int64
+}
+
+func (p *noder) constDecl(decl *syntax.ConstDecl, cs *constState) []ir.Node {
+ if decl.Group == nil || decl.Group != cs.group {
+ *cs = constState{
+ group: decl.Group,
+ }
+ }
+
+ if pragma, ok := decl.Pragma.(*pragmas); ok {
+ p.checkUnused(pragma)
+ }
+
+ names := p.declNames(ir.OLITERAL, decl.NameList)
+ typ := p.typeExprOrNil(decl.Type)
+
+ var values []ir.Node
+ if decl.Values != nil {
+ values = p.exprList(decl.Values)
+ cs.typ, cs.values = typ, values
+ } else {
+ if typ != nil {
+ base.Errorf("const declaration cannot have type without expression")
+ }
+ typ, values = cs.typ, cs.values
+ }
+
+ nn := make([]ir.Node, 0, len(names))
+ for i, n := range names {
+ if i >= len(values) {
+ base.Errorf("missing value in const declaration")
+ break
+ }
+ v := values[i]
+ if decl.Values == nil {
+ v = ir.DeepCopy(n.Pos(), v)
+ }
+ typecheck.Declare(n, typecheck.DeclContext)
+
+ n.Ntype = typ
+ n.Defn = v
+ n.SetIota(cs.iota)
+
+ nn = append(nn, ir.NewDecl(p.pos(decl), ir.ODCLCONST, n))
+ }
+
+ if len(values) > len(names) {
+ base.Errorf("extra expression in const declaration")
+ }
+
+ cs.iota++
+
+ return nn
+}
+
+func (p *noder) typeDecl(decl *syntax.TypeDecl) ir.Node {
+ n := p.declName(ir.OTYPE, decl.Name)
+ typecheck.Declare(n, typecheck.DeclContext)
+
+ // decl.Type may be nil but in that case we got a syntax error during parsing
+ typ := p.typeExprOrNil(decl.Type)
+
+ n.Ntype = typ
+ n.SetAlias(decl.Alias)
+ if pragma, ok := decl.Pragma.(*pragmas); ok {
+ if !decl.Alias {
+ n.SetPragma(pragma.Flag & typePragmas)
+ pragma.Flag &^= typePragmas
+ }
+ p.checkUnused(pragma)
+ }
+
+ nod := ir.NewDecl(p.pos(decl), ir.ODCLTYPE, n)
+ if n.Alias() && !types.AllowsGoVersion(types.LocalPkg, 1, 9) {
+ base.ErrorfAt(nod.Pos(), "type aliases only supported as of -lang=go1.9")
+ }
+ return nod
+}
+
+func (p *noder) declNames(op ir.Op, names []*syntax.Name) []*ir.Name {
+ nodes := make([]*ir.Name, 0, len(names))
+ for _, name := range names {
+ nodes = append(nodes, p.declName(op, name))
+ }
+ return nodes
+}
+
+func (p *noder) declName(op ir.Op, name *syntax.Name) *ir.Name {
+ return ir.NewDeclNameAt(p.pos(name), op, p.name(name))
+}
+
+func (p *noder) funcDecl(fun *syntax.FuncDecl) ir.Node {
+ name := p.name(fun.Name)
+ t := p.signature(fun.Recv, fun.Type)
+ f := ir.NewFunc(p.pos(fun))
+
+ if fun.Recv == nil {
+ if name.Name == "init" {
+ name = renameinit()
+ if len(t.Params) > 0 || len(t.Results) > 0 {
+ base.ErrorfAt(f.Pos(), "func init must have no arguments and no return values")
+ }
+ typecheck.Target.Inits = append(typecheck.Target.Inits, f)
+ }
+
+ if types.LocalPkg.Name == "main" && name.Name == "main" {
+ if len(t.Params) > 0 || len(t.Results) > 0 {
+ base.ErrorfAt(f.Pos(), "func main must have no arguments and no return values")
+ }
+ }
+ } else {
+ f.Shortname = name
+ name = ir.BlankNode.Sym() // filled in by tcFunc
+ }
+
+ f.Nname = ir.NewNameAt(p.pos(fun.Name), name)
+ f.Nname.Func = f
+ f.Nname.Defn = f
+ f.Nname.Ntype = t
+
+ if pragma, ok := fun.Pragma.(*pragmas); ok {
+ f.Pragma = pragma.Flag & funcPragmas
+ if pragma.Flag&ir.Systemstack != 0 && pragma.Flag&ir.Nosplit != 0 {
+ base.ErrorfAt(f.Pos(), "go:nosplit and go:systemstack cannot be combined")
+ }
+ pragma.Flag &^= funcPragmas
+ p.checkUnused(pragma)
+ }
+
+ if fun.Recv == nil {
+ typecheck.Declare(f.Nname, ir.PFUNC)
+ }
+
+ p.funcBody(f, fun.Body)
+
+ if fun.Body != nil {
+ if f.Pragma&ir.Noescape != 0 {
+ base.ErrorfAt(f.Pos(), "can only use //go:noescape with external func implementations")
+ }
+ } else {
+ if base.Flag.Complete || strings.HasPrefix(ir.FuncName(f), "init.") {
+ // Linknamed functions are allowed to have no body. Hopefully
+ // the linkname target has a body. See issue 23311.
+ isLinknamed := false
+ for _, n := range p.linknames {
+ if ir.FuncName(f) == n.local {
+ isLinknamed = true
+ break
+ }
+ }
+ if !isLinknamed {
+ base.ErrorfAt(f.Pos(), "missing function body")
+ }
+ }
+ }
+
+ return f
+}
+
+func (p *noder) signature(recv *syntax.Field, typ *syntax.FuncType) *ir.FuncType {
+ var rcvr *ir.Field
+ if recv != nil {
+ rcvr = p.param(recv, false, false)
+ }
+ return ir.NewFuncType(p.pos(typ), rcvr,
+ p.params(typ.ParamList, true),
+ p.params(typ.ResultList, false))
+}
+
+func (p *noder) params(params []*syntax.Field, dddOk bool) []*ir.Field {
+ nodes := make([]*ir.Field, 0, len(params))
+ for i, param := range params {
+ p.setlineno(param)
+ nodes = append(nodes, p.param(param, dddOk, i+1 == len(params)))
+ }
+ return nodes
+}
+
+func (p *noder) param(param *syntax.Field, dddOk, final bool) *ir.Field {
+ var name *types.Sym
+ if param.Name != nil {
+ name = p.name(param.Name)
+ }
+
+ typ := p.typeExpr(param.Type)
+ n := ir.NewField(p.pos(param), name, typ, nil)
+
+ // rewrite ...T parameter
+ if typ, ok := typ.(*ir.SliceType); ok && typ.DDD {
+ if !dddOk {
+ // We mark these as syntax errors to get automatic elimination
+ // of multiple such errors per line (see ErrorfAt in subr.go).
+ base.Errorf("syntax error: cannot use ... in receiver or result parameter list")
+ } else if !final {
+ if param.Name == nil {
+ base.Errorf("syntax error: cannot use ... with non-final parameter")
+ } else {
+ p.errorAt(param.Name.Pos(), "syntax error: cannot use ... with non-final parameter %s", param.Name.Value)
+ }
+ }
+ typ.DDD = false
+ n.IsDDD = true
+ }
+
+ return n
+}
+
+func (p *noder) exprList(expr syntax.Expr) []ir.Node {
+ switch expr := expr.(type) {
+ case nil:
+ return nil
+ case *syntax.ListExpr:
+ return p.exprs(expr.ElemList)
+ default:
+ return []ir.Node{p.expr(expr)}
+ }
+}
+
+func (p *noder) exprs(exprs []syntax.Expr) []ir.Node {
+ nodes := make([]ir.Node, 0, len(exprs))
+ for _, expr := range exprs {
+ nodes = append(nodes, p.expr(expr))
+ }
+ return nodes
+}
+
+func (p *noder) expr(expr syntax.Expr) ir.Node {
+ p.setlineno(expr)
+ switch expr := expr.(type) {
+ case nil, *syntax.BadExpr:
+ return nil
+ case *syntax.Name:
+ return p.mkname(expr)
+ case *syntax.BasicLit:
+ n := ir.NewBasicLit(p.pos(expr), p.basicLit(expr))
+ if expr.Kind == syntax.RuneLit {
+ n.SetType(types.UntypedRune)
+ }
+ n.SetDiag(expr.Bad) // avoid follow-on errors if there was a syntax error
+ return n
+ case *syntax.CompositeLit:
+ n := ir.NewCompLitExpr(p.pos(expr), ir.OCOMPLIT, p.typeExpr(expr.Type), nil)
+ l := p.exprs(expr.ElemList)
+ for i, e := range l {
+ l[i] = p.wrapname(expr.ElemList[i], e)
+ }
+ n.List = l
+ base.Pos = p.makeXPos(expr.Rbrace)
+ return n
+ case *syntax.KeyValueExpr:
+ // use position of expr.Key rather than of expr (which has position of ':')
+ return ir.NewKeyExpr(p.pos(expr.Key), p.expr(expr.Key), p.wrapname(expr.Value, p.expr(expr.Value)))
+ case *syntax.FuncLit:
+ return p.funcLit(expr)
+ case *syntax.ParenExpr:
+ return ir.NewParenExpr(p.pos(expr), p.expr(expr.X))
+ case *syntax.SelectorExpr:
+ // parser.new_dotname
+ obj := p.expr(expr.X)
+ if obj.Op() == ir.OPACK {
+ pack := obj.(*ir.PkgName)
+ pack.Used = true
+ return importName(pack.Pkg.Lookup(expr.Sel.Value))
+ }
+ n := ir.NewSelectorExpr(base.Pos, ir.OXDOT, obj, p.name(expr.Sel))
+ n.SetPos(p.pos(expr)) // lineno may have been changed by p.expr(expr.X)
+ return n
+ case *syntax.IndexExpr:
+ return ir.NewIndexExpr(p.pos(expr), p.expr(expr.X), p.expr(expr.Index))
+ case *syntax.SliceExpr:
+ op := ir.OSLICE
+ if expr.Full {
+ op = ir.OSLICE3
+ }
+ x := p.expr(expr.X)
+ var index [3]ir.Node
+ for i, n := range &expr.Index {
+ if n != nil {
+ index[i] = p.expr(n)
+ }
+ }
+ return ir.NewSliceExpr(p.pos(expr), op, x, index[0], index[1], index[2])
+ case *syntax.AssertExpr:
+ return ir.NewTypeAssertExpr(p.pos(expr), p.expr(expr.X), p.typeExpr(expr.Type))
+ case *syntax.Operation:
+ if expr.Op == syntax.Add && expr.Y != nil {
+ return p.sum(expr)
+ }
+ x := p.expr(expr.X)
+ if expr.Y == nil {
+ pos, op := p.pos(expr), p.unOp(expr.Op)
+ switch op {
+ case ir.OADDR:
+ return typecheck.NodAddrAt(pos, x)
+ case ir.ODEREF:
+ return ir.NewStarExpr(pos, x)
+ }
+ return ir.NewUnaryExpr(pos, op, x)
+ }
+
+ pos, op, y := p.pos(expr), p.binOp(expr.Op), p.expr(expr.Y)
+ switch op {
+ case ir.OANDAND, ir.OOROR:
+ return ir.NewLogicalExpr(pos, op, x, y)
+ }
+ return ir.NewBinaryExpr(pos, op, x, y)
+ case *syntax.CallExpr:
+ n := ir.NewCallExpr(p.pos(expr), ir.OCALL, p.expr(expr.Fun), p.exprs(expr.ArgList))
+ n.IsDDD = expr.HasDots
+ return n
+
+ case *syntax.ArrayType:
+ var len ir.Node
+ if expr.Len != nil {
+ len = p.expr(expr.Len)
+ }
+ return ir.NewArrayType(p.pos(expr), len, p.typeExpr(expr.Elem))
+ case *syntax.SliceType:
+ return ir.NewSliceType(p.pos(expr), p.typeExpr(expr.Elem))
+ case *syntax.DotsType:
+ t := ir.NewSliceType(p.pos(expr), p.typeExpr(expr.Elem))
+ t.DDD = true
+ return t
+ case *syntax.StructType:
+ return p.structType(expr)
+ case *syntax.InterfaceType:
+ return p.interfaceType(expr)
+ case *syntax.FuncType:
+ return p.signature(nil, expr)
+ case *syntax.MapType:
+ return ir.NewMapType(p.pos(expr),
+ p.typeExpr(expr.Key), p.typeExpr(expr.Value))
+ case *syntax.ChanType:
+ return ir.NewChanType(p.pos(expr),
+ p.typeExpr(expr.Elem), p.chanDir(expr.Dir))
+
+ case *syntax.TypeSwitchGuard:
+ var tag *ir.Ident
+ if expr.Lhs != nil {
+ tag = ir.NewIdent(p.pos(expr.Lhs), p.name(expr.Lhs))
+ if ir.IsBlank(tag) {
+ base.Errorf("invalid variable name %v in type switch", tag)
+ }
+ }
+ return ir.NewTypeSwitchGuard(p.pos(expr), tag, p.expr(expr.X))
+ }
+ panic("unhandled Expr")
+}
+
+// sum efficiently handles very large summation expressions (such as
+// in issue #16394). In particular, it avoids left recursion and
+// collapses string literals.
+func (p *noder) sum(x syntax.Expr) ir.Node {
+ // While we need to handle long sums with asymptotic
+ // efficiency, the vast majority of sums are very small: ~95%
+ // have only 2 or 3 operands, and ~99% of string literals are
+ // never concatenated.
+
+ adds := make([]*syntax.Operation, 0, 2)
+ for {
+ add, ok := x.(*syntax.Operation)
+ if !ok || add.Op != syntax.Add || add.Y == nil {
+ break
+ }
+ adds = append(adds, add)
+ x = add.X
+ }
+
+ // nstr is the current rightmost string literal in the
+ // summation (if any), and chunks holds its accumulated
+ // substrings.
+ //
+ // Consider the expression x + "a" + "b" + "c" + y. When we
+ // reach the string literal "a", we assign nstr to point to
+ // its corresponding Node and initialize chunks to {"a"}.
+ // Visiting the subsequent string literals "b" and "c", we
+ // simply append their values to chunks. Finally, when we
+ // reach the non-constant operand y, we'll join chunks to form
+ // "abc" and reassign the "a" string literal's value.
+ //
+ // N.B., we need to be careful about named string constants
+ // (indicated by Sym != nil) because 1) we can't modify their
+ // value, as doing so would affect other uses of the string
+ // constant, and 2) they may have types, which we need to
+ // handle correctly. For now, we avoid these problems by
+ // treating named string constants the same as non-constant
+ // operands.
+ var nstr ir.Node
+ chunks := make([]string, 0, 1)
+
+ n := p.expr(x)
+ if ir.IsConst(n, constant.String) && n.Sym() == nil {
+ nstr = n
+ chunks = append(chunks, ir.StringVal(nstr))
+ }
+
+ for i := len(adds) - 1; i >= 0; i-- {
+ add := adds[i]
+
+ r := p.expr(add.Y)
+ if ir.IsConst(r, constant.String) && r.Sym() == nil {
+ if nstr != nil {
+ // Collapse r into nstr instead of adding to n.
+ chunks = append(chunks, ir.StringVal(r))
+ continue
+ }
+
+ nstr = r
+ chunks = append(chunks, ir.StringVal(nstr))
+ } else {
+ if len(chunks) > 1 {
+ nstr.SetVal(constant.MakeString(strings.Join(chunks, "")))
+ }
+ nstr = nil
+ chunks = chunks[:0]
+ }
+ n = ir.NewBinaryExpr(p.pos(add), ir.OADD, n, r)
+ }
+ if len(chunks) > 1 {
+ nstr.SetVal(constant.MakeString(strings.Join(chunks, "")))
+ }
+
+ return n
+}
+
+func (p *noder) typeExpr(typ syntax.Expr) ir.Ntype {
+ // TODO(mdempsky): Be stricter? typecheck should handle errors anyway.
+ n := p.expr(typ)
+ if n == nil {
+ return nil
+ }
+ if _, ok := n.(ir.Ntype); !ok {
+ ir.Dump("NOT NTYPE", n)
+ }
+ return n.(ir.Ntype)
+}
+
+func (p *noder) typeExprOrNil(typ syntax.Expr) ir.Ntype {
+ if typ != nil {
+ return p.typeExpr(typ)
+ }
+ return nil
+}
+
+func (p *noder) chanDir(dir syntax.ChanDir) types.ChanDir {
+ switch dir {
+ case 0:
+ return types.Cboth
+ case syntax.SendOnly:
+ return types.Csend
+ case syntax.RecvOnly:
+ return types.Crecv
+ }
+ panic("unhandled ChanDir")
+}
+
+func (p *noder) structType(expr *syntax.StructType) ir.Node {
+ l := make([]*ir.Field, 0, len(expr.FieldList))
+ for i, field := range expr.FieldList {
+ p.setlineno(field)
+ var n *ir.Field
+ if field.Name == nil {
+ n = p.embedded(field.Type)
+ } else {
+ n = ir.NewField(p.pos(field), p.name(field.Name), p.typeExpr(field.Type), nil)
+ }
+ if i < len(expr.TagList) && expr.TagList[i] != nil {
+ n.Note = constant.StringVal(p.basicLit(expr.TagList[i]))
+ }
+ l = append(l, n)
+ }
+
+ p.setlineno(expr)
+ return ir.NewStructType(p.pos(expr), l)
+}
+
+func (p *noder) interfaceType(expr *syntax.InterfaceType) ir.Node {
+ l := make([]*ir.Field, 0, len(expr.MethodList))
+ for _, method := range expr.MethodList {
+ p.setlineno(method)
+ var n *ir.Field
+ if method.Name == nil {
+ n = ir.NewField(p.pos(method), nil, importName(p.packname(method.Type)).(ir.Ntype), nil)
+ } else {
+ mname := p.name(method.Name)
+ if mname.IsBlank() {
+ base.Errorf("methods must have a unique non-blank name")
+ continue
+ }
+ sig := p.typeExpr(method.Type).(*ir.FuncType)
+ sig.Recv = fakeRecv()
+ n = ir.NewField(p.pos(method), mname, sig, nil)
+ }
+ l = append(l, n)
+ }
+
+ return ir.NewInterfaceType(p.pos(expr), l)
+}
+
+func (p *noder) packname(expr syntax.Expr) *types.Sym {
+ switch expr := expr.(type) {
+ case *syntax.Name:
+ name := p.name(expr)
+ if n := oldname(name); n.Name() != nil && n.Name().PkgName != nil {
+ n.Name().PkgName.Used = true
+ }
+ return name
+ case *syntax.SelectorExpr:
+ name := p.name(expr.X.(*syntax.Name))
+ def := ir.AsNode(name.Def)
+ if def == nil {
+ base.Errorf("undefined: %v", name)
+ return name
+ }
+ var pkg *types.Pkg
+ if def.Op() != ir.OPACK {
+ base.Errorf("%v is not a package", name)
+ pkg = types.LocalPkg
+ } else {
+ def := def.(*ir.PkgName)
+ def.Used = true
+ pkg = def.Pkg
+ }
+ return pkg.Lookup(expr.Sel.Value)
+ }
+ panic(fmt.Sprintf("unexpected packname: %#v", expr))
+}
+
+func (p *noder) embedded(typ syntax.Expr) *ir.Field {
+ op, isStar := typ.(*syntax.Operation)
+ if isStar {
+ if op.Op != syntax.Mul || op.Y != nil {
+ panic("unexpected Operation")
+ }
+ typ = op.X
+ }
+
+ sym := p.packname(typ)
+ n := ir.NewField(p.pos(typ), typecheck.Lookup(sym.Name), importName(sym).(ir.Ntype), nil)
+ n.Embedded = true
+
+ if isStar {
+ n.Ntype = ir.NewStarExpr(p.pos(op), n.Ntype)
+ }
+ return n
+}
+
+func (p *noder) stmts(stmts []syntax.Stmt) []ir.Node {
+ return p.stmtsFall(stmts, false)
+}
+
+func (p *noder) stmtsFall(stmts []syntax.Stmt, fallOK bool) []ir.Node {
+ var nodes []ir.Node
+ for i, stmt := range stmts {
+ s := p.stmtFall(stmt, fallOK && i+1 == len(stmts))
+ if s == nil {
+ } else if s.Op() == ir.OBLOCK && len(s.(*ir.BlockStmt).List) > 0 {
+ // Inline non-empty block.
+ // Empty blocks must be preserved for CheckReturn.
+ nodes = append(nodes, s.(*ir.BlockStmt).List...)
+ } else {
+ nodes = append(nodes, s)
+ }
+ }
+ return nodes
+}
+
+func (p *noder) stmt(stmt syntax.Stmt) ir.Node {
+ return p.stmtFall(stmt, false)
+}
+
+func (p *noder) stmtFall(stmt syntax.Stmt, fallOK bool) ir.Node {
+ p.setlineno(stmt)
+ switch stmt := stmt.(type) {
+ case nil, *syntax.EmptyStmt:
+ return nil
+ case *syntax.LabeledStmt:
+ return p.labeledStmt(stmt, fallOK)
+ case *syntax.BlockStmt:
+ l := p.blockStmt(stmt)
+ if len(l) == 0 {
+ // TODO(mdempsky): Line number?
+ return ir.NewBlockStmt(base.Pos, nil)
+ }
+ return ir.NewBlockStmt(src.NoXPos, l)
+ case *syntax.ExprStmt:
+ return p.wrapname(stmt, p.expr(stmt.X))
+ case *syntax.SendStmt:
+ return ir.NewSendStmt(p.pos(stmt), p.expr(stmt.Chan), p.expr(stmt.Value))
+ case *syntax.DeclStmt:
+ return ir.NewBlockStmt(src.NoXPos, p.decls(stmt.DeclList))
+ case *syntax.AssignStmt:
+ if stmt.Rhs == syntax.ImplicitOne {
+ one := constant.MakeInt64(1)
+ pos := p.pos(stmt)
+ n := ir.NewAssignOpStmt(pos, p.binOp(stmt.Op), p.expr(stmt.Lhs), ir.NewBasicLit(pos, one))
+ n.IncDec = true
+ return n
+ }
+
+ if stmt.Op != 0 && stmt.Op != syntax.Def {
+ n := ir.NewAssignOpStmt(p.pos(stmt), p.binOp(stmt.Op), p.expr(stmt.Lhs), p.expr(stmt.Rhs))
+ return n
+ }
+
+ rhs := p.exprList(stmt.Rhs)
+ if list, ok := stmt.Lhs.(*syntax.ListExpr); ok && len(list.ElemList) != 1 || len(rhs) != 1 {
+ n := ir.NewAssignListStmt(p.pos(stmt), ir.OAS2, nil, nil)
+ n.Def = stmt.Op == syntax.Def
+ n.Lhs = p.assignList(stmt.Lhs, n, n.Def)
+ n.Rhs = rhs
+ return n
+ }
+
+ n := ir.NewAssignStmt(p.pos(stmt), nil, nil)
+ n.Def = stmt.Op == syntax.Def
+ n.X = p.assignList(stmt.Lhs, n, n.Def)[0]
+ n.Y = rhs[0]
+ return n
+
+ case *syntax.BranchStmt:
+ var op ir.Op
+ switch stmt.Tok {
+ case syntax.Break:
+ op = ir.OBREAK
+ case syntax.Continue:
+ op = ir.OCONTINUE
+ case syntax.Fallthrough:
+ if !fallOK {
+ base.Errorf("fallthrough statement out of place")
+ }
+ op = ir.OFALL
+ case syntax.Goto:
+ op = ir.OGOTO
+ default:
+ panic("unhandled BranchStmt")
+ }
+ var sym *types.Sym
+ if stmt.Label != nil {
+ sym = p.name(stmt.Label)
+ }
+ return ir.NewBranchStmt(p.pos(stmt), op, sym)
+ case *syntax.CallStmt:
+ var op ir.Op
+ switch stmt.Tok {
+ case syntax.Defer:
+ op = ir.ODEFER
+ case syntax.Go:
+ op = ir.OGO
+ default:
+ panic("unhandled CallStmt")
+ }
+ return ir.NewGoDeferStmt(p.pos(stmt), op, p.expr(stmt.Call))
+ case *syntax.ReturnStmt:
+ n := ir.NewReturnStmt(p.pos(stmt), p.exprList(stmt.Results))
+ if len(n.Results) == 0 && ir.CurFunc != nil {
+ for _, ln := range ir.CurFunc.Dcl {
+ if ln.Class == ir.PPARAM {
+ continue
+ }
+ if ln.Class != ir.PPARAMOUT {
+ break
+ }
+ if ln.Sym().Def != ln {
+ base.Errorf("%s is shadowed during return", ln.Sym().Name)
+ }
+ }
+ }
+ return n
+ case *syntax.IfStmt:
+ return p.ifStmt(stmt)
+ case *syntax.ForStmt:
+ return p.forStmt(stmt)
+ case *syntax.SwitchStmt:
+ return p.switchStmt(stmt)
+ case *syntax.SelectStmt:
+ return p.selectStmt(stmt)
+ }
+ panic("unhandled Stmt")
+}
+
+func (p *noder) assignList(expr syntax.Expr, defn ir.InitNode, colas bool) []ir.Node {
+ if !colas {
+ return p.exprList(expr)
+ }
+
+ var exprs []syntax.Expr
+ if list, ok := expr.(*syntax.ListExpr); ok {
+ exprs = list.ElemList
+ } else {
+ exprs = []syntax.Expr{expr}
+ }
+
+ res := make([]ir.Node, len(exprs))
+ seen := make(map[*types.Sym]bool, len(exprs))
+
+ newOrErr := false
+ for i, expr := range exprs {
+ p.setlineno(expr)
+ res[i] = ir.BlankNode
+
+ name, ok := expr.(*syntax.Name)
+ if !ok {
+ p.errorAt(expr.Pos(), "non-name %v on left side of :=", p.expr(expr))
+ newOrErr = true
+ continue
+ }
+
+ sym := p.name(name)
+ if sym.IsBlank() {
+ continue
+ }
+
+ if seen[sym] {
+ p.errorAt(expr.Pos(), "%v repeated on left side of :=", sym)
+ newOrErr = true
+ continue
+ }
+ seen[sym] = true
+
+ if sym.Block == types.Block {
+ res[i] = oldname(sym)
+ continue
+ }
+
+ newOrErr = true
+ n := typecheck.NewName(sym)
+ typecheck.Declare(n, typecheck.DeclContext)
+ n.Defn = defn
+ defn.PtrInit().Append(ir.NewDecl(base.Pos, ir.ODCL, n))
+ res[i] = n
+ }
+
+ if !newOrErr {
+ base.ErrorfAt(defn.Pos(), "no new variables on left side of :=")
+ }
+ return res
+}
+
+func (p *noder) blockStmt(stmt *syntax.BlockStmt) []ir.Node {
+ p.openScope(stmt.Pos())
+ nodes := p.stmts(stmt.List)
+ p.closeScope(stmt.Rbrace)
+ return nodes
+}
+
+func (p *noder) ifStmt(stmt *syntax.IfStmt) ir.Node {
+ p.openScope(stmt.Pos())
+ init := p.stmt(stmt.Init)
+ n := ir.NewIfStmt(p.pos(stmt), p.expr(stmt.Cond), p.blockStmt(stmt.Then), nil)
+ if init != nil {
+ *n.PtrInit() = []ir.Node{init}
+ }
+ if stmt.Else != nil {
+ e := p.stmt(stmt.Else)
+ if e.Op() == ir.OBLOCK {
+ e := e.(*ir.BlockStmt)
+ n.Else = e.List
+ } else {
+ n.Else = []ir.Node{e}
+ }
+ }
+ p.closeAnotherScope()
+ return n
+}
+
+func (p *noder) forStmt(stmt *syntax.ForStmt) ir.Node {
+ p.openScope(stmt.Pos())
+ if r, ok := stmt.Init.(*syntax.RangeClause); ok {
+ if stmt.Cond != nil || stmt.Post != nil {
+ panic("unexpected RangeClause")
+ }
+
+ n := ir.NewRangeStmt(p.pos(r), nil, nil, p.expr(r.X), nil)
+ if r.Lhs != nil {
+ n.Def = r.Def
+ lhs := p.assignList(r.Lhs, n, n.Def)
+ n.Key = lhs[0]
+ if len(lhs) > 1 {
+ n.Value = lhs[1]
+ }
+ }
+ n.Body = p.blockStmt(stmt.Body)
+ p.closeAnotherScope()
+ return n
+ }
+
+ n := ir.NewForStmt(p.pos(stmt), p.stmt(stmt.Init), p.expr(stmt.Cond), p.stmt(stmt.Post), p.blockStmt(stmt.Body))
+ p.closeAnotherScope()
+ return n
+}
+
+func (p *noder) switchStmt(stmt *syntax.SwitchStmt) ir.Node {
+ p.openScope(stmt.Pos())
+
+ init := p.stmt(stmt.Init)
+ n := ir.NewSwitchStmt(p.pos(stmt), p.expr(stmt.Tag), nil)
+ if init != nil {
+ *n.PtrInit() = []ir.Node{init}
+ }
+
+ var tswitch *ir.TypeSwitchGuard
+ if l := n.Tag; l != nil && l.Op() == ir.OTYPESW {
+ tswitch = l.(*ir.TypeSwitchGuard)
+ }
+ n.Cases = p.caseClauses(stmt.Body, tswitch, stmt.Rbrace)
+
+ p.closeScope(stmt.Rbrace)
+ return n
+}
+
+func (p *noder) caseClauses(clauses []*syntax.CaseClause, tswitch *ir.TypeSwitchGuard, rbrace syntax.Pos) []*ir.CaseClause {
+ nodes := make([]*ir.CaseClause, 0, len(clauses))
+ for i, clause := range clauses {
+ p.setlineno(clause)
+ if i > 0 {
+ p.closeScope(clause.Pos())
+ }
+ p.openScope(clause.Pos())
+
+ n := ir.NewCaseStmt(p.pos(clause), p.exprList(clause.Cases), nil)
+ if tswitch != nil && tswitch.Tag != nil {
+ nn := typecheck.NewName(tswitch.Tag.Sym())
+ typecheck.Declare(nn, typecheck.DeclContext)
+ n.Var = nn
+ // keep track of the instances for reporting unused
+ nn.Defn = tswitch
+ }
+
+ // Trim trailing empty statements. We omit them from
+ // the Node AST anyway, and it's easier to identify
+ // out-of-place fallthrough statements without them.
+ body := clause.Body
+ for len(body) > 0 {
+ if _, ok := body[len(body)-1].(*syntax.EmptyStmt); !ok {
+ break
+ }
+ body = body[:len(body)-1]
+ }
+
+ n.Body = p.stmtsFall(body, true)
+ if l := len(n.Body); l > 0 && n.Body[l-1].Op() == ir.OFALL {
+ if tswitch != nil {
+ base.Errorf("cannot fallthrough in type switch")
+ }
+ if i+1 == len(clauses) {
+ base.Errorf("cannot fallthrough final case in switch")
+ }
+ }
+
+ nodes = append(nodes, n)
+ }
+ if len(clauses) > 0 {
+ p.closeScope(rbrace)
+ }
+ return nodes
+}
+
+func (p *noder) selectStmt(stmt *syntax.SelectStmt) ir.Node {
+ return ir.NewSelectStmt(p.pos(stmt), p.commClauses(stmt.Body, stmt.Rbrace))
+}
+
+func (p *noder) commClauses(clauses []*syntax.CommClause, rbrace syntax.Pos) []*ir.CommClause {
+ nodes := make([]*ir.CommClause, len(clauses))
+ for i, clause := range clauses {
+ p.setlineno(clause)
+ if i > 0 {
+ p.closeScope(clause.Pos())
+ }
+ p.openScope(clause.Pos())
+
+ nodes[i] = ir.NewCommStmt(p.pos(clause), p.stmt(clause.Comm), p.stmts(clause.Body))
+ }
+ if len(clauses) > 0 {
+ p.closeScope(rbrace)
+ }
+ return nodes
+}
+
+func (p *noder) labeledStmt(label *syntax.LabeledStmt, fallOK bool) ir.Node {
+ sym := p.name(label.Label)
+ lhs := ir.NewLabelStmt(p.pos(label), sym)
+
+ var ls ir.Node
+ if label.Stmt != nil { // TODO(mdempsky): Should always be present.
+ ls = p.stmtFall(label.Stmt, fallOK)
+ // Attach label directly to control statement too.
+ if ls != nil {
+ switch ls.Op() {
+ case ir.OFOR:
+ ls := ls.(*ir.ForStmt)
+ ls.Label = sym
+ case ir.ORANGE:
+ ls := ls.(*ir.RangeStmt)
+ ls.Label = sym
+ case ir.OSWITCH:
+ ls := ls.(*ir.SwitchStmt)
+ ls.Label = sym
+ case ir.OSELECT:
+ ls := ls.(*ir.SelectStmt)
+ ls.Label = sym
+ }
+ }
+ }
+
+ l := []ir.Node{lhs}
+ if ls != nil {
+ if ls.Op() == ir.OBLOCK {
+ ls := ls.(*ir.BlockStmt)
+ l = append(l, ls.List...)
+ } else {
+ l = append(l, ls)
+ }
+ }
+ return ir.NewBlockStmt(src.NoXPos, l)
+}
+
+var unOps = [...]ir.Op{
+ syntax.Recv: ir.ORECV,
+ syntax.Mul: ir.ODEREF,
+ syntax.And: ir.OADDR,
+
+ syntax.Not: ir.ONOT,
+ syntax.Xor: ir.OBITNOT,
+ syntax.Add: ir.OPLUS,
+ syntax.Sub: ir.ONEG,
+}
+
+func (p *noder) unOp(op syntax.Operator) ir.Op {
+ if uint64(op) >= uint64(len(unOps)) || unOps[op] == 0 {
+ panic("invalid Operator")
+ }
+ return unOps[op]
+}
+
+var binOps = [...]ir.Op{
+ syntax.OrOr: ir.OOROR,
+ syntax.AndAnd: ir.OANDAND,
+
+ syntax.Eql: ir.OEQ,
+ syntax.Neq: ir.ONE,
+ syntax.Lss: ir.OLT,
+ syntax.Leq: ir.OLE,
+ syntax.Gtr: ir.OGT,
+ syntax.Geq: ir.OGE,
+
+ syntax.Add: ir.OADD,
+ syntax.Sub: ir.OSUB,
+ syntax.Or: ir.OOR,
+ syntax.Xor: ir.OXOR,
+
+ syntax.Mul: ir.OMUL,
+ syntax.Div: ir.ODIV,
+ syntax.Rem: ir.OMOD,
+ syntax.And: ir.OAND,
+ syntax.AndNot: ir.OANDNOT,
+ syntax.Shl: ir.OLSH,
+ syntax.Shr: ir.ORSH,
+}
+
+func (p *noder) binOp(op syntax.Operator) ir.Op {
+ if uint64(op) >= uint64(len(binOps)) || binOps[op] == 0 {
+ panic("invalid Operator")
+ }
+ return binOps[op]
+}
+
+// checkLangCompat reports an error if the representation of a numeric
+// literal is not compatible with the current language version.
+func checkLangCompat(lit *syntax.BasicLit) {
+ s := lit.Value
+ if len(s) <= 2 || types.AllowsGoVersion(types.LocalPkg, 1, 13) {
+ return
+ }
+ // len(s) > 2
+ if strings.Contains(s, "_") {
+ base.ErrorfVers("go1.13", "underscores in numeric literals")
+ return
+ }
+ if s[0] != '0' {
+ return
+ }
+ radix := s[1]
+ if radix == 'b' || radix == 'B' {
+ base.ErrorfVers("go1.13", "binary literals")
+ return
+ }
+ if radix == 'o' || radix == 'O' {
+ base.ErrorfVers("go1.13", "0o/0O-style octal literals")
+ return
+ }
+ if lit.Kind != syntax.IntLit && (radix == 'x' || radix == 'X') {
+ base.ErrorfVers("go1.13", "hexadecimal floating-point literals")
+ }
+}
+
+func (p *noder) basicLit(lit *syntax.BasicLit) constant.Value {
+ // We don't use the errors of the conversion routines to determine
+ // if a literal string is valid because the conversion routines may
+ // accept a wider syntax than the language permits. Rely on lit.Bad
+ // instead.
+ if lit.Bad {
+ return constant.MakeUnknown()
+ }
+
+ switch lit.Kind {
+ case syntax.IntLit, syntax.FloatLit, syntax.ImagLit:
+ checkLangCompat(lit)
+ }
+
+ v := constant.MakeFromLiteral(lit.Value, tokenForLitKind[lit.Kind], 0)
+ if v.Kind() == constant.Unknown {
+ // TODO(mdempsky): Better error message?
+ p.errorAt(lit.Pos(), "malformed constant: %s", lit.Value)
+ }
+
+ return v
+}
+
+var tokenForLitKind = [...]token.Token{
+ syntax.IntLit: token.INT,
+ syntax.RuneLit: token.CHAR,
+ syntax.FloatLit: token.FLOAT,
+ syntax.ImagLit: token.IMAG,
+ syntax.StringLit: token.STRING,
+}
+
+func (p *noder) name(name *syntax.Name) *types.Sym {
+ return typecheck.Lookup(name.Value)
+}
+
+func (p *noder) mkname(name *syntax.Name) ir.Node {
+ // TODO(mdempsky): Set line number?
+ return mkname(p.name(name))
+}
+
+func (p *noder) wrapname(n syntax.Node, x ir.Node) ir.Node {
+ // These nodes do not carry line numbers.
+ // Introduce a wrapper node to give them the correct line.
+ switch x.Op() {
+ case ir.OTYPE, ir.OLITERAL:
+ if x.Sym() == nil {
+ break
+ }
+ fallthrough
+ case ir.ONAME, ir.ONONAME, ir.OPACK:
+ p := ir.NewParenExpr(p.pos(n), x)
+ p.SetImplicit(true)
+ return p
+ }
+ return x
+}
+
+func (p *noder) setlineno(n syntax.Node) {
+ if n != nil {
+ base.Pos = p.pos(n)
+ }
+}
+
+// error is called concurrently if files are parsed concurrently.
+func (p *noder) error(err error) {
+ p.err <- err.(syntax.Error)
+}
+
+// pragmas that are allowed in the std lib, but don't have
+// a syntax.Pragma value (see lex.go) associated with them.
+var allowedStdPragmas = map[string]bool{
+ "go:cgo_export_static": true,
+ "go:cgo_export_dynamic": true,
+ "go:cgo_import_static": true,
+ "go:cgo_import_dynamic": true,
+ "go:cgo_ldflag": true,
+ "go:cgo_dynamic_linker": true,
+ "go:embed": true,
+ "go:generate": true,
+}
+
+// *pragmas is the value stored in a syntax.pragmas during parsing.
+type pragmas struct {
+ Flag ir.PragmaFlag // collected bits
+ Pos []pragmaPos // position of each individual flag
+ Embeds []pragmaEmbed
+}
+
+type pragmaPos struct {
+ Flag ir.PragmaFlag
+ Pos syntax.Pos
+}
+
+type pragmaEmbed struct {
+ Pos syntax.Pos
+ Patterns []string
+}
+
+func (p *noder) checkUnused(pragma *pragmas) {
+ for _, pos := range pragma.Pos {
+ if pos.Flag&pragma.Flag != 0 {
+ p.errorAt(pos.Pos, "misplaced compiler directive")
+ }
+ }
+ if len(pragma.Embeds) > 0 {
+ for _, e := range pragma.Embeds {
+ p.errorAt(e.Pos, "misplaced go:embed directive")
+ }
+ }
+}
+
+func (p *noder) checkUnusedDuringParse(pragma *pragmas) {
+ for _, pos := range pragma.Pos {
+ if pos.Flag&pragma.Flag != 0 {
+ p.error(syntax.Error{Pos: pos.Pos, Msg: "misplaced compiler directive"})
+ }
+ }
+ if len(pragma.Embeds) > 0 {
+ for _, e := range pragma.Embeds {
+ p.error(syntax.Error{Pos: e.Pos, Msg: "misplaced go:embed directive"})
+ }
+ }
+}
+
+// pragma is called concurrently if files are parsed concurrently.
+func (p *noder) pragma(pos syntax.Pos, blankLine bool, text string, old syntax.Pragma) syntax.Pragma {
+ pragma, _ := old.(*pragmas)
+ if pragma == nil {
+ pragma = new(pragmas)
+ }
+
+ if text == "" {
+ // unused pragma; only called with old != nil.
+ p.checkUnusedDuringParse(pragma)
+ return nil
+ }
+
+ if strings.HasPrefix(text, "line ") {
+ // line directives are handled by syntax package
+ panic("unreachable")
+ }
+
+ if !blankLine {
+ // directive must be on line by itself
+ p.error(syntax.Error{Pos: pos, Msg: "misplaced compiler directive"})
+ return pragma
+ }
+
+ switch {
+ case strings.HasPrefix(text, "go:linkname "):
+ f := strings.Fields(text)
+ if !(2 <= len(f) && len(f) <= 3) {
+ p.error(syntax.Error{Pos: pos, Msg: "usage: //go:linkname localname [linkname]"})
+ break
+ }
+ // The second argument is optional. If omitted, we use
+ // the default object symbol name for this and
+ // linkname only serves to mark this symbol as
+ // something that may be referenced via the object
+ // symbol name from another package.
+ var target string
+ if len(f) == 3 {
+ target = f[2]
+ } else if base.Ctxt.Pkgpath != "" {
+ // Use the default object symbol name if the
+ // user didn't provide one.
+ target = objabi.PathToPrefix(base.Ctxt.Pkgpath) + "." + f[1]
+ } else {
+ p.error(syntax.Error{Pos: pos, Msg: "//go:linkname requires linkname argument or -p compiler flag"})
+ break
+ }
+ p.linknames = append(p.linknames, linkname{pos, f[1], target})
+
+ case text == "go:embed", strings.HasPrefix(text, "go:embed "):
+ args, err := parseGoEmbed(text[len("go:embed"):])
+ if err != nil {
+ p.error(syntax.Error{Pos: pos, Msg: err.Error()})
+ }
+ if len(args) == 0 {
+ p.error(syntax.Error{Pos: pos, Msg: "usage: //go:embed pattern..."})
+ break
+ }
+ pragma.Embeds = append(pragma.Embeds, pragmaEmbed{pos, args})
+
+ case strings.HasPrefix(text, "go:cgo_import_dynamic "):
+ // This is permitted for general use because Solaris
+ // code relies on it in golang.org/x/sys/unix and others.
+ fields := pragmaFields(text)
+ if len(fields) >= 4 {
+ lib := strings.Trim(fields[3], `"`)
+ if lib != "" && !safeArg(lib) && !isCgoGeneratedFile(pos) {
+ p.error(syntax.Error{Pos: pos, Msg: fmt.Sprintf("invalid library name %q in cgo_import_dynamic directive", lib)})
+ }
+ p.pragcgo(pos, text)
+ pragma.Flag |= pragmaFlag("go:cgo_import_dynamic")
+ break
+ }
+ fallthrough
+ case strings.HasPrefix(text, "go:cgo_"):
+ // For security, we disallow //go:cgo_* directives other
+ // than cgo_import_dynamic outside cgo-generated files.
+ // Exception: they are allowed in the standard library, for runtime and syscall.
+ if !isCgoGeneratedFile(pos) && !base.Flag.Std {
+ p.error(syntax.Error{Pos: pos, Msg: fmt.Sprintf("//%s only allowed in cgo-generated code", text)})
+ }
+ p.pragcgo(pos, text)
+ fallthrough // because of //go:cgo_unsafe_args
+ default:
+ verb := text
+ if i := strings.Index(text, " "); i >= 0 {
+ verb = verb[:i]
+ }
+ flag := pragmaFlag(verb)
+ const runtimePragmas = ir.Systemstack | ir.Nowritebarrier | ir.Nowritebarrierrec | ir.Yeswritebarrierrec
+ if !base.Flag.CompilingRuntime && flag&runtimePragmas != 0 {
+ p.error(syntax.Error{Pos: pos, Msg: fmt.Sprintf("//%s only allowed in runtime", verb)})
+ }
+ if flag == 0 && !allowedStdPragmas[verb] && base.Flag.Std {
+ p.error(syntax.Error{Pos: pos, Msg: fmt.Sprintf("//%s is not allowed in the standard library", verb)})
+ }
+ pragma.Flag |= flag
+ pragma.Pos = append(pragma.Pos, pragmaPos{flag, pos})
+ }
+
+ return pragma
+}
+
+// isCgoGeneratedFile reports whether pos is in a file
+// generated by cgo, which is to say a file with name
+// beginning with "_cgo_". Such files are allowed to
+// contain cgo directives, and for security reasons
+// (primarily misuse of linker flags), other files are not.
+// See golang.org/issue/23672.
+func isCgoGeneratedFile(pos syntax.Pos) bool {
+ return strings.HasPrefix(filepath.Base(filepath.Clean(fileh(pos.Base().Filename()))), "_cgo_")
+}
+
+// safeArg reports whether arg is a "safe" command-line argument,
+// meaning that when it appears in a command-line, it probably
+// doesn't have some special meaning other than its own name.
+// This is copied from SafeArg in cmd/go/internal/load/pkg.go.
+func safeArg(name string) bool {
+ if name == "" {
+ return false
+ }
+ c := name[0]
+ return '0' <= c && c <= '9' || 'A' <= c && c <= 'Z' || 'a' <= c && c <= 'z' || c == '.' || c == '_' || c == '/' || c >= utf8.RuneSelf
+}
+
+func mkname(sym *types.Sym) ir.Node {
+ n := oldname(sym)
+ if n.Name() != nil && n.Name().PkgName != nil {
+ n.Name().PkgName.Used = true
+ }
+ return n
+}
+
+// parseGoEmbed parses the text following "//go:embed" to extract the glob patterns.
+// It accepts unquoted space-separated patterns as well as double-quoted and back-quoted Go strings.
+// go/build/read.go also processes these strings and contains similar logic.
+func parseGoEmbed(args string) ([]string, error) {
+ var list []string
+ for args = strings.TrimSpace(args); args != ""; args = strings.TrimSpace(args) {
+ var path string
+ Switch:
+ switch args[0] {
+ default:
+ i := len(args)
+ for j, c := range args {
+ if unicode.IsSpace(c) {
+ i = j
+ break
+ }
+ }
+ path = args[:i]
+ args = args[i:]
+
+ case '`':
+ i := strings.Index(args[1:], "`")
+ if i < 0 {
+ return nil, fmt.Errorf("invalid quoted string in //go:embed: %s", args)
+ }
+ path = args[1 : 1+i]
+ args = args[1+i+1:]
+
+ case '"':
+ i := 1
+ for ; i < len(args); i++ {
+ if args[i] == '\\' {
+ i++
+ continue
+ }
+ if args[i] == '"' {
+ q, err := strconv.Unquote(args[:i+1])
+ if err != nil {
+ return nil, fmt.Errorf("invalid quoted string in //go:embed: %s", args[:i+1])
+ }
+ path = q
+ args = args[i+1:]
+ break Switch
+ }
+ }
+ if i >= len(args) {
+ return nil, fmt.Errorf("invalid quoted string in //go:embed: %s", args)
+ }
+ }
+
+ if args != "" {
+ r, _ := utf8.DecodeRuneInString(args)
+ if !unicode.IsSpace(r) {
+ return nil, fmt.Errorf("invalid quoted string in //go:embed: %s", args)
+ }
+ }
+ list = append(list, path)
+ }
+ return list, nil
+}
+
+func fakeRecv() *ir.Field {
+ return ir.NewField(base.Pos, nil, nil, types.FakeRecvType())
+}
+
+func (p *noder) funcLit(expr *syntax.FuncLit) ir.Node {
+ xtype := p.typeExpr(expr.Type)
+
+ fn := ir.NewFunc(p.pos(expr))
+ fn.SetIsHiddenClosure(ir.CurFunc != nil)
+
+ fn.Nname = ir.NewNameAt(p.pos(expr), ir.BlankNode.Sym()) // filled in by tcClosure
+ fn.Nname.Func = fn
+ fn.Nname.Ntype = xtype
+ fn.Nname.Defn = fn
+
+ clo := ir.NewClosureExpr(p.pos(expr), fn)
+ fn.OClosure = clo
+
+ p.funcBody(fn, expr.Body)
+
+ ir.FinishCaptureNames(base.Pos, ir.CurFunc, fn)
+
+ return clo
+}
+
+// A function named init is a special case.
+// It is called by the initialization before main is run.
+// To make it unique within a package and also uncallable,
+// the name, normally "pkg.init", is altered to "pkg.init.0".
+var renameinitgen int
+
+func renameinit() *types.Sym {
+ s := typecheck.LookupNum("init.", renameinitgen)
+ renameinitgen++
+ return s
+}
+
+// oldname returns the Node that declares symbol s in the current scope.
+// If no such Node currently exists, an ONONAME Node is returned instead.
+// Automatically creates a new closure variable if the referenced symbol was
+// declared in a different (containing) function.
+func oldname(s *types.Sym) ir.Node {
+ if s.Pkg != types.LocalPkg {
+ return ir.NewIdent(base.Pos, s)
+ }
+
+ n := ir.AsNode(s.Def)
+ if n == nil {
+ // Maybe a top-level declaration will come along later to
+ // define s. resolve will check s.Def again once all input
+ // source has been processed.
+ return ir.NewIdent(base.Pos, s)
+ }
+
+ if n, ok := n.(*ir.Name); ok {
+ // TODO(rsc): If there is an outer variable x and we
+ // are parsing x := 5 inside the closure, until we get to
+ // the := it looks like a reference to the outer x so we'll
+ // make x a closure variable unnecessarily.
+ return ir.CaptureName(base.Pos, ir.CurFunc, n)
+ }
+
+ return n
+}
+
+func varEmbed(makeXPos func(syntax.Pos) src.XPos, name *ir.Name, decl *syntax.VarDecl, pragma *pragmas, haveEmbed bool) {
+ if pragma.Embeds == nil {
+ return
+ }
+
+ pragmaEmbeds := pragma.Embeds
+ pragma.Embeds = nil
+ pos := makeXPos(pragmaEmbeds[0].Pos)
+
+ if !haveEmbed {
+ base.ErrorfAt(pos, "go:embed only allowed in Go files that import \"embed\"")
+ return
+ }
+ if len(decl.NameList) > 1 {
+ base.ErrorfAt(pos, "go:embed cannot apply to multiple vars")
+ return
+ }
+ if decl.Values != nil {
+ base.ErrorfAt(pos, "go:embed cannot apply to var with initializer")
+ return
+ }
+ if decl.Type == nil {
+ // Should not happen, since Values == nil now.
+ base.ErrorfAt(pos, "go:embed cannot apply to var without type")
+ return
+ }
+ if typecheck.DeclContext != ir.PEXTERN {
+ base.ErrorfAt(pos, "go:embed cannot apply to var inside func")
+ return
+ }
+
+ var embeds []ir.Embed
+ for _, e := range pragmaEmbeds {
+ embeds = append(embeds, ir.Embed{Pos: makeXPos(e.Pos), Patterns: e.Patterns})
+ }
+ typecheck.Target.Embeds = append(typecheck.Target.Embeds, name)
+ name.Embed = &embeds
+}
diff --git a/src/cmd/compile/internal/noder/posmap.go b/src/cmd/compile/internal/noder/posmap.go
new file mode 100644
index 0000000000..a6d3e2d7ef
--- /dev/null
+++ b/src/cmd/compile/internal/noder/posmap.go
@@ -0,0 +1,83 @@
+// Copyright 2021 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package noder
+
+import (
+ "cmd/compile/internal/base"
+ "cmd/compile/internal/syntax"
+ "cmd/internal/src"
+)
+
+// A posMap handles mapping from syntax.Pos to src.XPos.
+type posMap struct {
+ bases map[*syntax.PosBase]*src.PosBase
+ cache struct {
+ last *syntax.PosBase
+ base *src.PosBase
+ }
+}
+
+type poser interface{ Pos() syntax.Pos }
+type ender interface{ End() syntax.Pos }
+
+func (m *posMap) pos(p poser) src.XPos { return m.makeXPos(p.Pos()) }
+func (m *posMap) end(p ender) src.XPos { return m.makeXPos(p.End()) }
+
+func (m *posMap) makeXPos(pos syntax.Pos) src.XPos {
+ if !pos.IsKnown() {
+ // TODO(mdempsky): Investigate restoring base.Fatalf.
+ return src.NoXPos
+ }
+
+ posBase := m.makeSrcPosBase(pos.Base())
+ return base.Ctxt.PosTable.XPos(src.MakePos(posBase, pos.Line(), pos.Col()))
+}
+
+// makeSrcPosBase translates from a *syntax.PosBase to a *src.PosBase.
+func (m *posMap) makeSrcPosBase(b0 *syntax.PosBase) *src.PosBase {
+ // fast path: most likely PosBase hasn't changed
+ if m.cache.last == b0 {
+ return m.cache.base
+ }
+
+ b1, ok := m.bases[b0]
+ if !ok {
+ fn := b0.Filename()
+ if b0.IsFileBase() {
+ b1 = src.NewFileBase(fn, absFilename(fn))
+ } else {
+ // line directive base
+ p0 := b0.Pos()
+ p0b := p0.Base()
+ if p0b == b0 {
+ panic("infinite recursion in makeSrcPosBase")
+ }
+ p1 := src.MakePos(m.makeSrcPosBase(p0b), p0.Line(), p0.Col())
+ b1 = src.NewLinePragmaBase(p1, fn, fileh(fn), b0.Line(), b0.Col())
+ }
+ if m.bases == nil {
+ m.bases = make(map[*syntax.PosBase]*src.PosBase)
+ }
+ m.bases[b0] = b1
+ }
+
+ // update cache
+ m.cache.last = b0
+ m.cache.base = b1
+
+ return b1
+}
+
+func (m *posMap) join(other *posMap) {
+ if m.bases == nil {
+ m.bases = make(map[*syntax.PosBase]*src.PosBase)
+ }
+ for k, v := range other.bases {
+ if m.bases[k] != nil {
+ base.Fatalf("duplicate posmap bases")
+ }
+ m.bases[k] = v
+ }
+}