]> Cypherpunks repositories - gostls13.git/commitdiff
go/ast: don't remove function bodies when filtering exports
authorRobert Griesemer <gri@golang.org>
Thu, 6 Oct 2011 23:07:56 +0000 (16:07 -0700)
committerRobert Griesemer <gri@golang.org>
Thu, 6 Oct 2011 23:07:56 +0000 (16:07 -0700)
This is a semantic but no API change. It is a cleaner
implementation of pure filtering. Applications that
need function bodies stripped can easily do this them-
selves.

R=rsc
CC=golang-dev
https://golang.org/cl/5206046

src/pkg/go/ast/filter.go

index 1bd8990f835a20e01ee616b15e7f3db2665147d4..d7d4b4b6b6d6e3dfc5620f8cf6050151846406ae 100644 (file)
@@ -18,8 +18,7 @@ func exportFilter(name string) bool {
 // only exported nodes remain: all top-level identifiers which are not exported
 // and their associated information (such as type, initial value, or function
 // body) are removed. Non-exported fields and methods of exported types are
-// stripped, and the function bodies of exported functions are set to nil.
-// The File.Comments list is not changed.
+// stripped. The File.Comments list is not changed.
 //
 // FileExports returns true if there are exported declarationa;
 // it returns false otherwise.
@@ -206,9 +205,6 @@ func FilterDecl(decl Decl, f Filter) bool {
                d.Specs = filterSpecList(d.Specs, f)
                return len(d.Specs) > 0
        case *FuncDecl:
-               if f == exportFilter {
-                       d.Body = nil // strip body
-               }
                return f(d.Name.Name)
        }
        return false