go/src/cmd/compile/internal/noder
Matthew Dempsky d5c5808534 cmd/compile/internal/syntax: add Unparen and UnpackListExpr helpers
We've added Unparen to go/ast, so add syntax.Unparen to be
consistent (and because it's similarly useful).

Also, types2 and noder both have similar functions for unpacking
ListExprs, so might as well add a common implementation in package
syntax too.

Finally, addressing the TODO: UnpackListExpr is small enough to be
inlined (when default optimizations are enabled), and for typical uses
of UnpackListExpr (e.g., "range UnpackListExpr(x)") the single-element
slice result is stack allocated in the caller. This CL adds a test
using testing.AllocsPerRun to ensure this remains so in the future.

Change-Id: I96a5591d202193ed5bf1ce6f290919107e3dc01b
Reviewed-on: https://go-review.googlesource.com/c/go/+/522336
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
2023-08-24 07:17:27 +00:00
..
codes.go
decl.go
export.go
expr.go cmd/compile/internal/syntax: add Unparen and UnpackListExpr helpers 2023-08-24 07:17:27 +00:00
helpers.go cmd/compile/internal/typecheck: add selector helpers 2023-08-20 05:57:18 +00:00
import.go
irgen.go cmd/compile: use types2.Sizes instead of compiler own implementation 2023-08-16 21:01:11 +00:00
lex.go
lex_test.go
linker.go cmd/compile/internal/types: simplify iterating all parameters 2023-08-22 20:57:01 +00:00
noder.go cmd/compile: remove go:wasmimport restriction 2023-05-11 15:21:09 +00:00
posmap.go
quirks.go cmd/compile/internal/syntax: add Unparen and UnpackListExpr helpers 2023-08-24 07:17:27 +00:00
reader.go cmd/compile/internal/noder: elide statically known "if" statements 2023-08-23 18:01:55 +00:00
stencil.go
stmt.go cmd/compile/internal/noder: remove un-used funcs/vars 2023-07-21 02:39:32 +00:00
types.go cmd/compile/internal/noder: remove un-used funcs/vars 2023-07-21 02:39:32 +00:00
unified.go cmd/compile: redo IsRuntimePkg/IsReflectPkg predicate 2023-08-22 19:18:21 +00:00
writer.go cmd/compile/internal/syntax: add Unparen and UnpackListExpr helpers 2023-08-24 07:17:27 +00:00