diff options
| author | Dokyung Song <dokyungs@google.com> | 2018-09-06 15:49:23 -0700 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2018-09-11 13:01:53 +0200 |
| commit | 11c256cdcd601b67fcf5611fe8aed55b9ff00143 (patch) | |
| tree | 63bff88ba1faed749a2fddad2b22e8d56d5b9981 /pkg/ast | |
| parent | e3d1d545d390055ca67987d27243e0d2b37feedd (diff) | |
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.
Diffstat (limited to 'pkg/ast')
| -rw-r--r-- | pkg/ast/filter.go | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/pkg/ast/filter.go b/pkg/ast/filter.go new file mode 100644 index 000000000..a36114e82 --- /dev/null +++ b/pkg/ast/filter.go @@ -0,0 +1,14 @@ +// 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 +} |
