Skip to content

Commit

Permalink
ssa: debug info types.Named -> typedef
Browse files Browse the repository at this point in the history
  • Loading branch information
cpunion committed Sep 24, 2024
1 parent c83dead commit b80e3d4
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions ssa/di.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,8 @@ func (b diBuilder) createType(name string, ty Type, pos token.Position) DIType {
case *types.Pointer:
return b.createPointerType(name, b.prog.rawType(t.Elem()), pos)
case *types.Named:
ty = b.prog.rawType(t.Underlying())
pos = b.positioner.Position(t.Obj().Pos())
return b.diTypeEx(name, ty, pos)
// Create typedef type for named types
return b.createTypedefType(name, ty, pos)
case *types.Interface:
ty := b.prog.rtType("Iface")
return b.createInterfaceType(name, ty)
Expand Down Expand Up @@ -263,6 +262,18 @@ func (b diBuilder) createAutoVariable(scope DIScope, pos token.Position, name st
}
}

func (b diBuilder) createTypedefType(name string, ty Type, pos token.Position) DIType {
underlyingType := b.diType(b.prog.rawType(ty.RawType().(*types.Named).Underlying()), pos)
typ := b.di.CreateTypedef(llvm.DITypedef{
Name: name,
Type: underlyingType.ll,
File: b.file(pos.Filename).ll,
Line: pos.Line,
AlignInBits: uint32(b.prog.sizes.Alignof(ty.RawType()) * 8),
})
return &aDIType{typ}
}

func (b diBuilder) createStringType() DIType {
ty := b.prog.rtType("String")
return b.doCreateStructType("string", ty, token.Position{}, func(ditStruct DIType) []llvm.Metadata {
Expand Down

0 comments on commit b80e3d4

Please sign in to comment.