From 2b08e3604de50db97513322330baf4a4f3ff98a3 Mon Sep 17 00:00:00 2001 From: xushiwei Date: Sat, 13 Jul 2024 12:47:29 +0800 Subject: [PATCH] TestConstBool; Test allocaCStrs --- cl/builtin_test.go | 7 +++++++ ssa/memory.go | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/cl/builtin_test.go b/cl/builtin_test.go index a8916d49..e2b0fce2 100644 --- a/cl/builtin_test.go +++ b/cl/builtin_test.go @@ -27,6 +27,12 @@ import ( "golang.org/x/tools/go/ssa" ) +func TestConstBool(t *testing.T) { + if v, ok := constBool(nil); v || ok { + t.Fatal("constBool?") + } +} + func TestToBackground(t *testing.T) { if v := toBackground(""); v != llssa.InGo { t.Fatal("toBackground:", v) @@ -144,6 +150,7 @@ func TestErrBuiltin(t *testing.T) { test("alloca", func(ctx *context) { ctx.alloca(nil, nil) }) test("allocaCStr", func(ctx *context) { ctx.allocaCStr(nil, nil) }) test("allocaCStrs", func(ctx *context) { ctx.allocaCStrs(nil, nil) }) + test("allocaCStrs(Nonconst)", func(ctx *context) { ctx.allocaCStrs(nil, []ssa.Value{nil, &ssa.Parameter{}}) }) test("string", func(ctx *context) { ctx.string(nil, nil) }) test("stringData", func(ctx *context) { ctx.stringData(nil, nil) }) test("funcAddr", func(ctx *context) { ctx.funcAddr(nil, nil) }) diff --git a/ssa/memory.go b/ssa/memory.go index cc94fc8a..d14fd71b 100644 --- a/ssa/memory.go +++ b/ssa/memory.go @@ -144,12 +144,14 @@ func (b Builder) Alloca(n Expr) (ret Expr) { return } +/* TODO(xsw): // AllocaU allocates uninitialized space for n*sizeof(elem) bytes. func (b Builder) AllocaU(elem Type, n ...int64) (ret Expr) { prog := b.Prog size := SizeOf(prog, elem, n...) return Expr{b.Alloca(size).impl, prog.Pointer(elem)} } +*/ // AllocaCStr allocates space for copy it from a Go string. func (b Builder) AllocaCStr(gostr Expr) (ret Expr) { @@ -230,6 +232,7 @@ func (b Builder) ArrayAlloca(telem Type, n Expr) (ret Expr) { return } +/* TODO(xsw): // ArrayAlloc allocates zero initialized space for an array of n elements of type telem. func (b Builder) ArrayAlloc(telem Type, n Expr) (ret Expr) { prog := b.Prog @@ -239,6 +242,7 @@ func (b Builder) ArrayAlloc(telem Type, n Expr) (ret Expr) { ret.Type = prog.Pointer(telem) return } +*/ // -----------------------------------------------------------------------------