1
0
mirror of https://github.com/golang/go synced 2024-07-03 08:51:14 +00:00

[dev.regabi] cmd/compile: check for recursive import in ImportBody

After earlier importer refactorings, most of the importer is now
reentrant, so we don't need to guard against it at Resolve. The only
remaining part that is still not reentrant is inline body importing,
so move the recursive-import check there.

Passes toolstash -cmp.

Change-Id: Ia828f880a03e6125b102668c12a155d4c253d26b
Reviewed-on: https://go-review.googlesource.com/c/go/+/280515
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
This commit is contained in:
Matthew Dempsky 2020-12-27 11:26:12 -08:00
parent fda7ec3a3f
commit 76136be027
2 changed files with 6 additions and 7 deletions

View File

@ -71,7 +71,12 @@ func ImportBody(fn *ir.Func) {
base.Fatalf("missing import reader for %v", fn)
}
if inimport {
base.Fatalf("recursive inimport")
}
inimport = true
r.doInline(fn)
inimport = false
}
func importReaderFor(sym *types.Sym, importers map[*types.Sym]iimporterAndOffset) *importReader {

View File

@ -251,13 +251,7 @@ func Resolve(n ir.Node) (res ir.Node) {
}
}
if inimport {
base.Fatalf("recursive inimport")
}
inimport = true
n = expandDecl(n)
inimport = false
return n
return expandDecl(n)
}
r := ir.AsNode(n.Sym().Def)