]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/cgo: don't cache bad pointer typedefs
authorIan Lance Taylor <iant@golang.org>
Tue, 11 Dec 2018 15:46:10 +0000 (07:46 -0800)
committerIan Lance Taylor <iant@golang.org>
Tue, 11 Dec 2018 15:57:38 +0000 (15:57 +0000)
The set of bad pointer typedefs changes as we see more typedefs, so
avoid looking in the cache when we find one.

Fixes #29175

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>

src/cmd/cgo/gcc.go

index 17a9936e6ac6bb906c8cca2ca025d191c1342025..321d4db040d64b20b98188366d4fe89f4fb026f1 100644 (file)
@@ -2177,12 +2177,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)