diff options
| author | Matthew Dempsky <mdempsky@google.com> | 2023-09-06 14:00:30 -0700 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2023-09-08 18:50:24 +0000 |
| commit | 18c6ec1e4a62d25ce9801174c1c17360eb95233c (patch) | |
| tree | adfcf0d69f611aae2a688fa38db1dd3babf3ca54 /src/cmd/compile/internal/noder/expr.go | |
| parent | c6d550a6683cebb2a11d7fa91823edf7db1d58a5 (diff) | |
| download | go-18c6ec1e4a62d25ce9801174c1c17360eb95233c.tar.xz | |
cmd/compile/internal/noder: stop preserving original const strings
One of the more tedious quirks of the original frontend (i.e.,
typecheck) to preserve was that it preserved the original
representation of constants into the backend. To fit into the unified
IR model, I ended up implementing a fairly heavyweight workaround:
simply record the original constant's string expression in the export
data, so that diagnostics could still report it back, and match the
old test expectations.
But now that there's just a single frontend to support, it's easy
enough to just update the test expectations and drop this support for
"raw" constant expressions.
Change-Id: I1d859c5109d679879d937a2b213e777fbddf4f2f
Reviewed-on: https://go-review.googlesource.com/c/go/+/526376
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Diffstat (limited to 'src/cmd/compile/internal/noder/expr.go')
| -rw-r--r-- | src/cmd/compile/internal/noder/expr.go | 34 |
1 files changed, 0 insertions, 34 deletions
diff --git a/src/cmd/compile/internal/noder/expr.go b/src/cmd/compile/internal/noder/expr.go deleted file mode 100644 index 14ef3b958f..0000000000 --- a/src/cmd/compile/internal/noder/expr.go +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2021 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package noder - -import ( - "fmt" - - "cmd/compile/internal/ir" - "cmd/compile/internal/syntax" -) - -// constExprOp returns an ir.Op that represents the outermost -// operation of the given constant expression. It's intended for use -// with ir.RawOrigExpr. -func constExprOp(expr syntax.Expr) ir.Op { - switch expr := expr.(type) { - default: - panic(fmt.Sprintf("%s: unexpected expression: %T", expr.Pos(), expr)) - - case *syntax.BasicLit: - return ir.OLITERAL - case *syntax.Name, *syntax.SelectorExpr: - return ir.ONAME - case *syntax.CallExpr: - return ir.OCALL - case *syntax.Operation: - if expr.Y == nil { - return unOps[expr.Op] - } - return binOps[expr.Op] - } -} |
