cmd/compile: add clear(x) builtin

To clear map, and zero content of slice.

Updates #56351

Change-Id: I5f81dfbc465500f5acadaf2c6beb9b5f0d2c4045
Reviewed-on: https://go-review.googlesource.com/c/go/+/453395
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
This commit is contained in:
Cuong Manh Le 2022-11-25 16:11:45 +07:00 committed by Gopher Robot
parent bb4ea80bef
commit b89a840d65
17 changed files with 256 additions and 142 deletions

View file

@ -39,6 +39,7 @@ func walkStmt(n ir.Node) ir.Node {
ir.OAS2RECV,
ir.OAS2FUNC,
ir.OAS2MAPR,
ir.OCLEAR,
ir.OCLOSE,
ir.OCOPY,
ir.OCALLINTER,