FuncDecl bugfix: even in C, we need to add ctx for method

This commit is contained in:
xushiwei
2024-05-12 23:37:12 +08:00
parent f7dfab481b
commit acfbe6902a
4 changed files with 13 additions and 30 deletions

View File

@@ -57,8 +57,11 @@ func (p Program) Type(typ types.Type, bg Background) Type {
// FuncDecl converts a Go/C function declaration into raw type.
func (p Program) FuncDecl(sig *types.Signature, bg Background) Type {
recv := sig.Recv()
if bg == InGo {
sig = p.gocvt.cvtFunc(sig, sig.Recv())
sig = p.gocvt.cvtFunc(sig, recv)
} else if recv != nil { // even in C, we need to add ctx for method
sig = FuncAddCtx(recv, sig)
}
return &aType{p.toLLVMFunc(sig), rawType{sig}, vkFuncDecl}
}