mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/compile: implement unsafe.Add and unsafe.Slice
Updates #19367. Updates #40481. Change-Id: Iabd2afdd0d520e5d68fd9e6dedd013335a4b3886 Reviewed-on: https://go-review.googlesource.com/c/go/+/312214 Run-TryBot: Matthew Dempsky <mdempsky@google.com> Trust: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Keith Randall <khr@golang.org>
This commit is contained in:
parent
0d32d9e8a8
commit
fadad851a3
20 changed files with 439 additions and 204 deletions
|
|
@ -29,6 +29,14 @@ func (g *irgen) expr(expr syntax.Expr) ir.Node {
|
|||
}
|
||||
switch {
|
||||
case tv.IsBuiltin():
|
||||
// Qualified builtins, such as unsafe.Add and unsafe.Slice.
|
||||
if expr, ok := expr.(*syntax.SelectorExpr); ok {
|
||||
if name, ok := expr.X.(*syntax.Name); ok {
|
||||
if _, ok := g.info.Uses[name].(*types2.PkgName); ok {
|
||||
return g.use(expr.Sel)
|
||||
}
|
||||
}
|
||||
}
|
||||
return g.use(expr.(*syntax.Name))
|
||||
case tv.IsType():
|
||||
return ir.TypeNode(g.typ(tv.Type))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue