Skip to content

Commit

Permalink
ssa: complex type name
Browse files Browse the repository at this point in the history
  • Loading branch information
cpunion committed Sep 19, 2024
1 parent 75574e9 commit 7c535ff
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
29 changes: 28 additions & 1 deletion cl/_testdata/debug/in.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,29 @@ func FuncWithAllTypeParams(
err,
fn,
)
return 1, errors.New("Some error")
// Expected:
// all variables: i8 i16 i32 i64 i u8 u16 u32 u64 u f32 f64 b c64 c128 slice arr arr2 s e f pf pi intr m c err fn globalInt globalStruct globalStructPtr
// i8: '\x01'
// i16: 2
// i32: 3
// i64: 4
// i: 5
// u8: '\x06'
// u16: 7
// u32: 8
// u64: 9
// u: 10
// f32: 11
// f64: 12
// b: true
// c64: complex64(real = 13, imag = 14)
// c128: complex128(real = 15, imag = 16)
// slice: []int[21, 22, 23]
// arr: [3]int[24, 25, 26)
// arr2: [3]E[(i = 27), (i = 28), (i = 29)]
// s: hello
// e: (i = 30)
return 1, errors.New("some error")
}

func main() {
Expand Down Expand Up @@ -164,7 +186,12 @@ func main() {
println("called function with types")
println(globalStructPtr)
println(&globalStruct)
// Expected:
// all variables: globalInt globalStruct globalStructPtr s i err
// s.i8: '\x01'
// s.i16: 2
println("done")
println("")
}

var globalInt int = 301
Expand Down
5 changes: 4 additions & 1 deletion ssa/di.go
Original file line number Diff line number Diff line change
Expand Up @@ -334,12 +334,15 @@ func (b diBuilder) createChanType(name string, t Type, pos token.Position) DITyp

func (b diBuilder) createComplexType(t Type) DIType {
var tfield Type
var tyName string
if t.RawType().(*types.Basic).Kind() == types.Complex128 {
tfield = b.prog.Float64()
tyName = "complex128"
} else {
tfield = b.prog.Float32()
tyName = "complex64"
}
return b.doCreateStructType("complex", t, token.Position{}, func(ditStruct DIType) []llvm.Metadata {
return b.doCreateStructType(tyName, t, token.Position{}, func(ditStruct DIType) []llvm.Metadata {
return []llvm.Metadata{
b.createMemberType("real", t, tfield, 0),
b.createMemberType("imag", t, tfield, 1),
Expand Down

0 comments on commit 7c535ff

Please sign in to comment.