diff options
author | Jamie Liu <jamieliu@google.com> | 2021-09-22 18:09:49 -0700 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2021-09-22 18:12:06 -0700 |
commit | de750eb1d3ef2c8c60274c62c4463392b29b45c7 (patch) | |
tree | da2a629132588acc051f8a82bd380d253e328570 /tools/go_fieldenum/main.go | |
parent | d8772545113ff941d34a4eae5f43df3f39d3547f (diff) |
Add Execve and ExitNotifyParent checkpoints.
Call sites for the two checkpoints aren't added yet.
PiperOrigin-RevId: 398375903
Diffstat (limited to 'tools/go_fieldenum/main.go')
-rw-r--r-- | tools/go_fieldenum/main.go | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/tools/go_fieldenum/main.go b/tools/go_fieldenum/main.go index 68dfdb3db..d801bea1b 100644 --- a/tools/go_fieldenum/main.go +++ b/tools/go_fieldenum/main.go @@ -55,6 +55,7 @@ func main() { // Determine which types are marked "+fieldenum" and will consequently have // code generated. + var typeNames []string fieldEnumTypes := make(map[string]fieldEnumTypeInfo) for _, f := range inputFiles { for _, decl := range f.Decls { @@ -75,6 +76,7 @@ func main() { if !ok { log.Fatalf("Type %s is marked +fieldenum, but is not a struct", name) } + typeNames = append(typeNames, name) fieldEnumTypes[name] = fieldEnumTypeInfo{ prefix: prefix, structType: st, @@ -86,9 +88,10 @@ func main() { } // Collect information for each type for which code is being generated. - structInfos := make([]structInfo, 0, len(fieldEnumTypes)) + structInfos := make([]structInfo, 0, len(typeNames)) needSyncAtomic := false - for typeName, typeInfo := range fieldEnumTypes { + for _, typeName := range typeNames { + typeInfo := fieldEnumTypes[typeName] var si structInfo si.name = typeName si.prefix = typeInfo.prefix @@ -204,13 +207,6 @@ func structFieldName(f *ast.Field) string { } } -// Workaround for Go defect (map membership test isn't usable in an -// expression). -func fetContains(xs map[string]*ast.StructType, x string) bool { - _, ok := xs[x] - return ok -} - func (si *structInfo) writeTo(b *strings.Builder) { fmt.Fprintf(b, "// A %sField represents a field in %s.\n", si.prefix, si.name) fmt.Fprintf(b, "type %sField uint\n\n", si.prefix) |