diff options
author | Ian Lance Taylor <iant@golang.org> | 2018-12-11 07:46:10 -0800 |
---|---|---|
committer | Filippo Valsorda <filippo@golang.org> | 2018-12-14 20:23:55 +0000 |
commit | 17bf5e903184a271b04eb917a42b528c5730f38c (patch) | |
tree | 8942466645870ff3b666dc41cd07297ecce306b5 | |
parent | 5128a419b3abd4ef10475c0c96eede78363dc267 (diff) | |
download | go-17bf5e903184a271b04eb917a42b528c5730f38c.tar.gz go-17bf5e903184a271b04eb917a42b528c5730f38c.zip |
[release-branch.go1.11] cmd/cgo: don't cache bad pointer typedefs
The set of bad pointer typedefs changes as we see more typedefs, so
avoid looking in the cache when we find one.
Updates #29175
Fixes #29272
Change-Id: Idd82289bdd8628d11a983fa5ec96517e3a5bcbf1
Reviewed-on: https://go-review.googlesource.com/c/153597
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
(cherry picked from commit 01e072db5d26c224dfbe7763a5b94ab23c163983)
Reviewed-on: https://go-review.googlesource.com/c/154299
Run-TryBot: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
-rw-r--r-- | src/cmd/cgo/gcc.go | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/cmd/cgo/gcc.go b/src/cmd/cgo/gcc.go index 588b7ed072..c2f089ee39 100644 --- a/src/cmd/cgo/gcc.go +++ b/src/cmd/cgo/gcc.go @@ -1900,12 +1900,22 @@ func (c *typeConv) FinishType(pos token.Pos) { // Type returns a *Type with the same memory layout as // dtype when used as the type of a variable or a struct field. func (c *typeConv) Type(dtype dwarf.Type, pos token.Pos) *Type { + // Always recompute bad pointer typedefs, as the set of such + // typedefs changes as we see more types. + checkCache := true + if dtt, ok := dtype.(*dwarf.TypedefType); ok && c.badPointerTypedef(dtt) { + checkCache = false + } + key := dtype.String() - if t, ok := c.m[key]; ok { - if t.Go == nil { - fatalf("%s: type conversion loop at %s", lineno(pos), dtype) + + if checkCache { + if t, ok := c.m[key]; ok { + if t.Go == nil { + fatalf("%s: type conversion loop at %s", lineno(pos), dtype) + } + return t } - return t } t := new(Type) |