]> Cypherpunks repositories - gostls13.git/commit
cgo: fix dwarf type parsing
authorGustavo Niemeyer <gustavo@niemeyer.net>
Sun, 6 Mar 2011 23:05:57 +0000 (18:05 -0500)
committerRuss Cox <rsc@golang.org>
Sun, 6 Mar 2011 23:05:57 +0000 (18:05 -0500)
commit99686ec789f7eacaad6d30e39243759c00035685
tree064c0cb1b4d9ac0e6e11bdbaae7b2d279e538c6a
parent04ca4f824281bf0a17a5aaa5b1586978779b6200
cgo: fix dwarf type parsing

The recursive algorithm used to parse types in cgo
has a bug related to building the C type representation.

As an example, when the recursion starts at a type *T,
the C type representation won't be known until type T
itself is parsed.  But then, it is possible that type T
references the type **T internally.  The latter
representation is built based on the one of *T, which
started the recursion, so it won't attempt to parse it
again, and will instead use the current representation
value for *T, which is still empty at this point.

This problem was fixed by introducing a simple TypeRepr
type which builds the string representation lazily,
analogous to how the Go type information is built within
the same algorithm.  This way, even if a type
representation is still unknown at some level in the
recursion, representations dependant on it can still
be created correctly.

R=rsc
CC=golang-dev
https://golang.org/cl/4244052
src/cmd/cgo/gcc.go
src/cmd/cgo/main.go
src/cmd/cgo/out.go