Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
live_uintptrkeepalive.go64 linesDownload Raw Back to test
1// errorcheck -0 -m -live -std2 3//go:build !windows && !js && !wasip14 5// Copyright 2015 The Go Authors. All rights reserved.6// Use of this source code is governed by a BSD-style7// license that can be found in the LICENSE file.8 9// Test escape analysis and liveness inferred for uintptrkeepalive functions.10//11// This behavior is enabled automatically for function declarations with no12// bodies (assembly, linkname), as well as explicitly on complete functions13// with //go:uintptrkeepalive.14//15// This is most important for syscall.Syscall (and similar functions), so we16// test it explicitly.17 18package p19 20import (21	"syscall"22	"unsafe"23)24 25func implicit(uintptr) // ERROR "assuming ~p0 is unsafe uintptr"26 27//go:uintptrkeepalive28//go:nosplit29func explicit(uintptr) {30}31 32func autotmpImplicit() { // ERROR "can inline autotmpImplicit"33	var t int34	implicit(uintptr(unsafe.Pointer(&t))) // ERROR "live at call to implicit: .?autotmp" "stack object .autotmp_[0-9]+ unsafe.Pointer$"35}36 37func autotmpExplicit() { // ERROR "can inline autotmpExplicit"38	var t int39	explicit(uintptr(unsafe.Pointer(&t))) // ERROR "live at call to explicit: .?autotmp" "stack object .autotmp_[0-9]+ unsafe.Pointer$"40}41 42func autotmpSyscall() { // ERROR "can inline autotmpSyscall"43	var v int44	syscall.Syscall(0, 1, uintptr(unsafe.Pointer(&v)), 2) // ERROR "live at call to Syscall: .?autotmp" "stack object .autotmp_[0-9]+ unsafe.Pointer$"45}46 47func localImplicit() { // ERROR "can inline localImplicit"48	var t int49	p := unsafe.Pointer(&t)50	implicit(uintptr(p)) // ERROR "live at call to implicit: .?autotmp" "stack object .autotmp_[0-9]+ unsafe.Pointer$"51}52 53func localExplicit() { // ERROR "can inline localExplicit"54	var t int55	p := unsafe.Pointer(&t)56	explicit(uintptr(p)) // ERROR "live at call to explicit: .?autotmp" "stack object .autotmp_[0-9]+ unsafe.Pointer$"57}58 59func localSyscall() { // ERROR "can inline localSyscall"60	var v int61	p := unsafe.Pointer(&v)62	syscall.Syscall(0, 1, uintptr(p), 2) // ERROR "live at call to Syscall: .?autotmp" "stack object .autotmp_[0-9]+ unsafe.Pointer$"63}64 
codekingpro/portable-devtools · Team Ai