diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2018-06-30 19:34:41 +0200 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2018-06-30 19:34:41 +0200 |
| commit | 664ef9a3e1016e80fc1fcbbef6e9f66a2ededfe6 (patch) | |
| tree | 3f5829d9ad2ada25336f3bf98b85a65ec517c22e /pkg/compiler/compiler.go | |
| parent | 9054fae0162950c1fd961819f64b1ac90e5930b3 (diff) | |
pkg/compiler: check for unused declarations
Error on unused structs/unions/resources/flags.
Finds tons of bugs.
Diffstat (limited to 'pkg/compiler/compiler.go')
| -rw-r--r-- | pkg/compiler/compiler.go | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/pkg/compiler/compiler.go b/pkg/compiler/compiler.go index f49576561..b44a698ca 100644 --- a/pkg/compiler/compiler.go +++ b/pkg/compiler/compiler.go @@ -60,12 +60,14 @@ func Compile(desc *ast.Description, consts map[string]uint64, target *targets.Ta intFlags: make(map[string]*ast.IntFlags), strFlags: make(map[string]*ast.StrFlags), used: make(map[string]bool), + usedTypedefs: make(map[string]bool), structDescs: make(map[prog.StructKey]*prog.StructDesc), structNodes: make(map[*prog.StructDesc]*ast.Struct), structVarlen: make(map[string]bool), } for name, n := range builtinTypedefs { comp.typedefs[name] = n + comp.usedTypedefs[name] = true } for name, n := range builtinStrFlags { comp.strFlags[name] = n @@ -116,13 +118,14 @@ type compiler struct { warnings []warn ptrSize uint64 - unsupported map[string]bool - resources map[string]*ast.Resource - typedefs map[string]*ast.TypeDef - structs map[string]*ast.Struct - intFlags map[string]*ast.IntFlags - strFlags map[string]*ast.StrFlags - used map[string]bool // contains used structs/resources + unsupported map[string]bool + resources map[string]*ast.Resource + typedefs map[string]*ast.TypeDef + structs map[string]*ast.Struct + intFlags map[string]*ast.IntFlags + strFlags map[string]*ast.StrFlags + used map[string]bool // contains used structs/resources + usedTypedefs map[string]bool structDescs map[prog.StructKey]*prog.StructDesc structNodes map[*prog.StructDesc]*ast.Struct |
