FAQ
Reviewers: gri,

Message:
Hello gri@golang.org (cc: golang-dev@googlegroups.com),

I'd like you to review this change to
https://code.google.com/p/go.tools


Description:
go.tools/ssa: eliminate remaining uses of operands of "untyped" type.

Added sanity check.

Please review this at https://codereview.appspot.com/37270043/

Affected files (+16, -4 lines):
    M ssa/builder.go
    M ssa/const.go
    M ssa/example_test.go
    M ssa/sanity.go


Index: ssa/builder.go
===================================================================
--- a/ssa/builder.go
+++ b/ssa/builder.go
@@ -1890,7 +1890,8 @@
     if s.Tok == token.DEC {
      op = token.SUB
     }
- b.assignOp(fn, b.addr(fn, s.X, false), vOne, op)
+ loc := b.addr(fn, s.X, false)
+ b.assignOp(fn, loc, NewConst(vOne.Value, loc.typ()), op)

    case *ast.AssignStmt:
     switch s.Tok {
Index: ssa/const.go
===================================================================
--- a/ssa/const.go
+++ b/ssa/const.go
@@ -22,9 +22,10 @@
    return &Const{typ, val}
   }

-// intConst returns an untyped integer constant that evaluates to i.
+// intConst returns an 'int' constant that evaluates to i.
+// (i is an int64 in case the host is narrower than the target.)
   func intConst(i int64) *Const {
- return NewConst(exact.MakeInt64(i), types.Typ[types.UntypedInt])
+ return NewConst(exact.MakeInt64(i), types.Typ[types.Int])
   }

   // nilConst returns a nil constant of the specified type, which may
Index: ssa/example_test.go
===================================================================
--- a/ssa/example_test.go
+++ b/ssa/example_test.go
@@ -101,7 +101,7 @@
    // func main():

// .0.entry:
P:0 S:0
    // t0 = new [1]interface{} (varargs)
*[1]interface{}
- // t1 = &t0[0:untyped integer]
*interface{}
+ // t1 = &t0[0:int]
*interface{}
    // t2 = make interface{} <- string ("Hello, World!":string)
interface{}
    // *t1 = t2
    // t3 = slice t0[:]
[]interface{}
Index: ssa/sanity.go
===================================================================
--- a/ssa/sanity.go
+++ b/ssa/sanity.go
@@ -325,6 +325,16 @@
      if val == nil {
       continue // a nil operand is ok
      }
+
+ // Check that "untyped" types only appear on constant operands.
+ if _, ok := (*op).(*Const); !ok {
+ if basic, ok := (*op).Type().(*types.Basic); ok {
+ if basic.Info()&types.IsUntyped != 0 {
+ s.errorf("operand #%d of %s is untyped: %s", i, instr, basic)
+ }
+ }
+ }
+
      // Check that Operands that are also Instructions belong to same
function.
      // TODO(adonovan): also check their block dominates block b.
      if val, ok := val.(Instruction); ok {


--

---
You received this message because you are subscribed to the Google Groups "golang-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

  • Gri at Dec 4, 2013 at 6:43 pm
    LGTM

    https://codereview.appspot.com/37270043/

    --

    ---
    You received this message because you are subscribed to the Google Groups "golang-dev" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-dev+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Adonovan at Dec 4, 2013 at 6:59 pm
    *** Submitted as
    https://code.google.com/p/go/source/detail?r=55504f60f053&repo=tools ***

    go.tools/ssa: eliminate remaining uses of operands of "untyped" type.

    Added sanity check.

    R=gri
    CC=golang-dev
    https://codereview.appspot.com/37270043


    https://codereview.appspot.com/37270043/

    --

    ---
    You received this message because you are subscribed to the Google Groups "golang-dev" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-dev+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-dev @
categoriesgo
postedDec 4, '13 at 6:39p
activeDec 4, '13 at 6:59p
posts3
users2
websitegolang.org

2 users in discussion

Adonovan: 2 posts Gri: 1 post

People

Translate

site design / logo © 2021 Grokbase