Reduced interface bloat
All checks were successful
/ test (push) Successful in 32s

This commit is contained in:
Eduard Urbach 2025-07-03 20:12:11 +02:00
parent ba2314db4a
commit b77d876ebb
Signed by: akyoto
GPG key ID: 49226B848C78F6C8
11 changed files with 36 additions and 37 deletions

View file

@ -2,14 +2,21 @@ package core
import (
"git.urbach.dev/cli/q/src/errors"
"git.urbach.dev/cli/q/src/ssa"
)
// CheckDeadCode checks for dead values.
func (f *Function) CheckDeadCode() error {
for instr := range f.Values {
if instr.IsConst() && instr.CountUsers() == 0 {
return errors.New(&UnusedValue{Value: instr.String()}, f.File, instr.Start())
if !instr.IsConst() {
continue
}
if len(instr.(ssa.HasLiveness).Users()) > 0 {
continue
}
return errors.New(&UnusedValue{Value: instr.String()}, f.File, instr.(ssa.HasSource).Start())
}
return nil