aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/types/sym.go
diff options
context:
space:
mode:
authorMatthew Dempsky <mdempsky@google.com>2018-04-09 15:22:01 -0700
committerMatthew Dempsky <mdempsky@google.com>2018-04-09 22:58:00 +0000
commit71bac7efe45b18894415a169b669cb1df95d8079 (patch)
treeec906595c5389235a7adce3b54cfc4ba07836a08 /src/cmd/compile/internal/types/sym.go
parentc5dd2543932878e23228ca38d3e3bd621a47fbb5 (diff)
downloadgo-71bac7efe45b18894415a169b669cb1df95d8079.tar.gz
go-71bac7efe45b18894415a169b669cb1df95d8079.zip
cmd/compile: rename gc.exportname to types.IsExported
gofmt -r 'exportname(s) -> types.IsExported(s)' Passes toolstash-check. Change-Id: I6b428bd039c135be66d8b81c325d4e08bae69f24 Reviewed-on: https://go-review.googlesource.com/105938 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src/cmd/compile/internal/types/sym.go')
-rw-r--r--src/cmd/compile/internal/types/sym.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/cmd/compile/internal/types/sym.go b/src/cmd/compile/internal/types/sym.go
index 00328fa44f..e9b454d83a 100644
--- a/src/cmd/compile/internal/types/sym.go
+++ b/src/cmd/compile/internal/types/sym.go
@@ -7,6 +7,8 @@ package types
import (
"cmd/internal/obj"
"cmd/internal/src"
+ "unicode"
+ "unicode/utf8"
)
// Sym represents an object name. Most commonly, this is a Go identifier naming
@@ -74,3 +76,13 @@ func (sym *Sym) Linksym() *obj.LSym {
}
return Ctxt.Lookup(sym.LinksymName())
}
+
+// IsExported reports whether name is an exported Go symbol (that is,
+// whether it begins with an upper-case letter).
+func IsExported(name string) bool {
+ if r := name[0]; r < utf8.RuneSelf {
+ return 'A' <= r && r <= 'Z'
+ }
+ r, _ := utf8.DecodeRuneInString(name)
+ return unicode.IsUpper(r)
+}