aboutsummaryrefslogtreecommitdiffstats
path: root/prog/analysis.go
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2020-05-01 17:19:27 +0200
committerDmitry Vyukov <dvyukov@google.com>2020-05-02 12:16:06 +0200
commit58da4c35b15200b7279f18ea15bc8644618aae78 (patch)
tree412d59572c980c4eb582d6d0e187eb6ec32345c9 /prog/analysis.go
parentbc734e7ada413654f1b7d948b2a857260a52dd9c (diff)
prog: introduce Field type
Remvoe FieldName from Type and add a separate Field type that holds field name. Use Field for struct fields, union options and syscalls arguments, only these really have names. Reduces size of sys/linux/gen/amd64.go from 5665583 to 5201321 (-8.2%). Allows to not create new type for squashed any pointer. But main advantages will follow, e.g. removing StructDesc, using TypeRef in Arg, etc. Update #1580
Diffstat (limited to 'prog/analysis.go')
-rw-r--r--prog/analysis.go5
1 files changed, 4 insertions, 1 deletions
diff --git a/prog/analysis.go b/prog/analysis.go
index e1fbaa557..9300240b5 100644
--- a/prog/analysis.go
+++ b/prog/analysis.go
@@ -101,6 +101,7 @@ func (s *state) analyzeImpl(c *Call, resources bool) {
type ArgCtx struct {
Parent *[]Arg // GroupArg.Inner (for structs) or Call.Args containing this arg
+ Fields []Field // Fields of the parent struct/syscall
Base *PointerArg // pointer to the base of the heap object containing this arg
Offset uint64 // offset of this arg from the base
Stop bool // if set by the callback, subargs of this arg are not visited
@@ -116,6 +117,7 @@ func ForeachArg(c *Call, f func(Arg, *ArgCtx)) {
foreachArgImpl(c.Ret, ctx, f)
}
ctx.Parent = &c.Args
+ ctx.Fields = c.Meta.Args
for _, arg := range c.Args {
foreachArgImpl(arg, ctx, f)
}
@@ -128,8 +130,9 @@ func foreachArgImpl(arg Arg, ctx ArgCtx, f func(Arg, *ArgCtx)) {
}
switch a := arg.(type) {
case *GroupArg:
- if _, ok := a.Type().(*StructType); ok {
+ if typ, ok := a.Type().(*StructType); ok {
ctx.Parent = &a.Inner
+ ctx.Fields = typ.Fields
}
var totalSize uint64
for _, arg1 := range a.Inner {