From 2ebd4bc1d58075db2f234f49d80781fff207e07a Mon Sep 17 00:00:00 2001 From: John Mulligan Date: Mon, 13 Sep 2021 16:24:37 -0400 Subject: [PATCH] implements: ignore some C package calls that are just noise Signed-off-by: John Mulligan --- .../implements/internal/implements/gosrc.go | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/contrib/implements/internal/implements/gosrc.go b/contrib/implements/internal/implements/gosrc.go index de4f2d6..b20a5a0 100644 --- a/contrib/implements/internal/implements/gosrc.go +++ b/contrib/implements/internal/implements/gosrc.go @@ -12,6 +12,26 @@ import ( "strings" ) +// ignoreCCalls is a map of calls from "C" that we know we can just ignore. +// ignoring this stuff makes the number of tracked entries smaller, fewer logs, +// and less stuff to iterate over in other code. +var ignoreCCalls = map[string]bool{ + // some special cgo calls + "CString": true, + "CBytes": true, + "GoString": true, + "GoBytes": true, + // common utility functions + "free": true, + // common types + "int": true, + "int64_t": true, + "uint64_t": true, + "size_t": true, + "ssize_t": true, + "uintptr_t": true, +} + type goFunction struct { shortName string fullName string @@ -89,7 +109,11 @@ func (v *visitor) checkCalled(s *ast.SelectorExpr) { return } if "C" == ident.String() { - v.callMap[s.Sel.String()] = v.currentFunc + cname := s.Sel.String() + if ignoreCCalls[cname] { + return + } + v.callMap[cname] = v.currentFunc logger.Printf("updated %s in call map\n", s.Sel.String()) } }