]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: remove isLiteral
authorCuong Manh Le <cuong.manhle.vn@gmail.com>
Tue, 27 Oct 2020 10:08:57 +0000 (17:08 +0700)
committerCuong Manh Le <cuong.manhle.vn@gmail.com>
Tue, 27 Oct 2020 18:23:46 +0000 (18:23 +0000)
It has duplicated logic with "n.isGoConst".

Passes toolstash-check.

Change-Id: I5bf871ef81c7188ca09dae29c7ff55b3a254d972
Reviewed-on: https://go-review.googlesource.com/c/go/+/265437
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
src/cmd/compile/internal/gc/sinit.go

index 9c4dcd739cfe36d9b3ff04fb342bd6db19a48e49..212fcc022dba36dcfe26dc1a3695800eedfec762 100644 (file)
@@ -375,11 +375,6 @@ func readonlystaticname(t *types.Type) *Node {
        return n
 }
 
-func isLiteral(n *Node) bool {
-       // Treat nils as zeros rather than literals.
-       return n.Op == OLITERAL && n.Val().Ctype() != CTNIL
-}
-
 func (n *Node) isSimpleName() bool {
        return n.Op == ONAME && n.Class() != PAUTOHEAP && n.Class() != PEXTERN
 }
@@ -404,7 +399,7 @@ const (
 func getdyn(n *Node, top bool) initGenType {
        switch n.Op {
        default:
-               if isLiteral(n) {
+               if n.isGoConst() {
                        return initConst
                }
                return initDynamic
@@ -559,7 +554,7 @@ func fixedlit(ctxt initContext, kind initKind, n *Node, var_ *Node, init *Nodes)
                        continue
                }
 
-               islit := isLiteral(value)
+               islit := value.isGoConst()
                if (kind == initKindStatic && !islit) || (kind == initKindDynamic && islit) {
                        continue
                }
@@ -732,7 +727,7 @@ func slicelit(ctxt initContext, n *Node, var_ *Node, init *Nodes) {
                        continue
                }
 
-               if vstat != nil && isLiteral(value) { // already set by copy from static value
+               if vstat != nil && value.isGoConst() { // already set by copy from static value
                        continue
                }