Make bpfix not modify the input tree

Make a new object called Fixer to hold the state of the tree, and
make a copy of the input tree so the original doesn't get modified.

Test: bpfix_test.go
Change-Id: I1dc6fd99158c8b0e1db029df99e6cf72699a5e63
This commit is contained in:
Colin Cross
2018-04-11 16:10:18 -07:00
parent 02b4da53a7
commit adee968a4b
4 changed files with 68 additions and 24 deletions

View File

@@ -239,7 +239,8 @@ func convertFile(filename string, buffer *bytes.Buffer) (string, []error) {
}
// check for common supported but undesirable structures and clean them up
err := bpfix.FixTree(tree, bpfix.NewFixRequest().AddAll())
fixer := bpfix.NewFixer(tree)
tree, err := fixer.Fix(bpfix.NewFixRequest().AddAll())
if err != nil {
return "", []error{err}
}