]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: remove base.Ctxt.Pkgpath fallback paths
authorMatthew Dempsky <mdempsky@google.com>
Fri, 13 May 2022 23:07:06 +0000 (16:07 -0700)
committerMatthew Dempsky <mdempsky@google.com>
Mon, 16 May 2022 20:19:45 +0000 (20:19 +0000)
Historically, the compiler set types.LocalPkg.Path to "", so a lot of
compiler code checks for this, and then falls back to using
base.Ctxt.Pkgpath instead.

Since CL 393715, we now initialize types.LocalPkg.Path to
base.Ctxt.Pkgpath, so these code paths can now simply rely on Pkg.Path
always being meaningful.

Updates #51734.

Change-Id: I0aedbd7cf8e14edbfef781106a9510344d468f2c
Reviewed-on: https://go-review.googlesource.com/c/go/+/406317
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: David Chase <drchase@google.com>
src/cmd/compile/internal/pkginit/init.go
src/cmd/compile/internal/ssagen/ssa.go
src/cmd/compile/internal/staticdata/embed.go
src/cmd/compile/internal/types/type.go

index 67942c37c09e19a60de8c842e415b8244798df90..8c60e3bfd616eb993f37f470b514bb9d64e00e00 100644 (file)
@@ -169,7 +169,7 @@ func Task() *ir.Name {
                fns = append(fns, fn.Nname.Linksym())
        }
 
-       if len(deps) == 0 && len(fns) == 0 && types.LocalPkg.Name != "main" && types.LocalPkg.Name != "runtime" {
+       if len(deps) == 0 && len(fns) == 0 && types.LocalPkg.Path != "main" && types.LocalPkg.Path != "runtime" {
                return nil // nothing to initialize
        }
 
index c4f99941047938c921a55eb362f8ffb2ece327be..a7778d37fb39200b00f297d8140dacb38b3b8322 100644 (file)
@@ -4760,9 +4760,6 @@ func findIntrinsic(sym *types.Sym) intrinsicBuilder {
                return nil
        }
        pkg := sym.Pkg.Path
-       if sym.Pkg == types.LocalPkg {
-               pkg = base.Ctxt.Pkgpath
-       }
        if sym.Pkg == ir.Pkgs.Runtime {
                pkg = "runtime"
        }
index 48eaa07a5e59df242587f1e8e9fda6bd73122c1b..8d4dedff598fb399895e436aef43f24d7cc9bdc5 100644 (file)
@@ -67,7 +67,7 @@ func embedFileList(v *ir.Name, kind int) []string {
 
 // embedKind determines the kind of embedding variable.
 func embedKind(typ *types.Type) int {
-       if typ.Sym() != nil && typ.Sym().Name == "FS" && (typ.Sym().Pkg.Path == "embed" || (typ.Sym().Pkg == types.LocalPkg && base.Ctxt.Pkgpath == "embed")) {
+       if typ.Sym() != nil && typ.Sym().Name == "FS" && typ.Sym().Pkg.Path == "embed" {
                return embedFiles
        }
        if typ.Kind() == types.TSTRING {
index 2ec4f05c55fcc362d53d84b7fc10d809eeb4a692..1ea239ea328aa13dc7ba132c47da9f442d764821 100644 (file)
@@ -2088,9 +2088,6 @@ func IsRuntimePkg(p *Pkg) bool {
 
 // IsReflectPkg reports whether p is package reflect.
 func IsReflectPkg(p *Pkg) bool {
-       if p == LocalPkg {
-               return base.Ctxt.Pkgpath == "reflect"
-       }
        return p.Path == "reflect"
 }