Merge pull request #838 from cpunion/unsafe-fix

fix unsafe
This commit is contained in:
xushiwei
2024-10-23 10:57:22 +08:00
committed by GitHub
4 changed files with 399 additions and 3 deletions

View File

@@ -124,7 +124,9 @@ func (b Builder) SliceData(x Expr) Expr {
log.Printf("SliceData %v\n", x.impl)
}
ptr := llvm.CreateExtractValue(b.impl, x.impl, 0)
return Expr{ptr, b.Prog.VoidPtr()}
ty := x.Type.RawType()
tySlice := ty.Underlying().(*types.Slice)
return Expr{ptr, b.Prog.Pointer(b.Prog.rawType(tySlice.Elem()))}
}
// SliceLen returns the length of a slice.

View File

@@ -1182,6 +1182,8 @@ func (b Builder) BuiltinCall(fn string, args ...Expr) (ret Expr) {
if len(args) > 0 {
return b.compareSelect(token.GTR, args[0], args[1:]...)
}
case "Add":
return b.Advance(args[0], args[1])
}
panic("todo: " + fn)
}