mirror of
https://github.com/golang/go
synced 2024-11-12 12:30:21 -07:00
6d43587053
CL 122575 and its successors introduced a loop calling loadDWARF, whereas before we only called it once. Pass a single typeConv to each call, rather than creating a new one in loadDWARF itself. Change the maps from dwarf.Type to use string keys rather than dwarf.Type keys, since when the DWARF is reloaded the dwarf.Type pointers will be different. These changes permit typeConv.Type to return a consistent value for a given DWARF type, avoiding spurious type conversion errors due to typedefs loaded after the first loop iteration. Fixes #27340 Change-Id: Ic33467bbfca4c54e95909621b35ba2a58216d96e Reviewed-on: https://go-review.googlesource.com/c/152762 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
37 lines
931 B
Go
37 lines
931 B
Go
package issue9026
|
|
|
|
// This file appears in its own package since the assertion tests the
|
|
// per-package counter used to create fresh identifiers.
|
|
|
|
/*
|
|
typedef struct {} git_merge_file_input;
|
|
|
|
typedef struct {} git_merge_file_options;
|
|
|
|
void git_merge_file(
|
|
git_merge_file_input *in,
|
|
git_merge_file_options *opts) {}
|
|
*/
|
|
import "C"
|
|
import (
|
|
"fmt"
|
|
"testing"
|
|
)
|
|
|
|
func Test(t *testing.T) {
|
|
var in C.git_merge_file_input
|
|
var opts *C.git_merge_file_options
|
|
C.git_merge_file(&in, opts)
|
|
|
|
// Test that the generated type names are deterministic.
|
|
// (Previously this would fail about 10% of the time.)
|
|
//
|
|
// Brittle: the assertion may fail spuriously when the algorithm
|
|
// changes, but should remain stable otherwise.
|
|
got := fmt.Sprintf("%T %T", in, opts)
|
|
want := "issue9026._Ctype_struct___0 *issue9026._Ctype_struct___0"
|
|
if got != want {
|
|
t.Errorf("Non-deterministic type names: got %s, want %s", got, want)
|
|
}
|
|
}
|