syzkaller/pkg/ast/filter.go
Dokyung Song 11c256cdcd sys/fuchsia: prune unused structs in syscall description generated by fidlgen
After generating syscall description for fidl files using fidlgen, prune
all unused structs using the exact same mechanism used by the compiler's
check for unused structs. This allows the FIDL compiler to support
modular compilation; it does not need to have global knowledge of
whether each struct is used or not.
2018-09-11 13:01:53 +02:00

15 lines
400 B
Go

// Copyright 2018 syzkaller project authors. All rights reserved.
// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
package ast
func (desc *Description) Filter(predicate func(Node) bool) *Description {
desc1 := &Description{}
for _, n := range desc.Nodes {
if predicate(n) {
desc1.Nodes = append(desc1.Nodes, n.Clone())
}
}
return desc1
}