MCPcopy
hub / github.com/uber-go/nilaway / mapGuardMissingAndReturnToFuncSite

Method mapGuardMissingAndReturnToFuncSite

inference/engine.go:152–173  ·  view source on GitHub ↗

mapGuardMissingAndReturnToFuncSite returns two maps: 1. A map with key being the function return site and value being the list of indices of guard-missing triggers matching the site. 2. A map with key being the function return site and value being the list of indices of return triggers matching the

(triggers []annotation.FullTrigger)

Source from the content-addressed store, hash-verified

150// 1. A map with key being the function return site and value being the list of indices of guard-missing triggers matching the site.
151// 2. A map with key being the function return site and value being the list of indices of return triggers matching the site.
152func (e *Engine) mapGuardMissingAndReturnToFuncSite(triggers []annotation.FullTrigger) (map[primitiveSite][]int, map[primitiveSite][]int) {
153 mapSiteGuardMissing := make(map[primitiveSite][]int)
154 mapSiteReturn := make(map[primitiveSite][]int)
155
156 for i, trigger := range triggers {
157 if p, ok := trigger.Producer.Annotation.(*annotation.GuardMissing); ok {
158 if o, ok := p.OldAnnotation.(*annotation.FuncReturn); ok && o.IsFromRichCheckEffectFunc {
159 site := e.primitive.site(o.UnderlyingSite(), p.Kind() == annotation.DeepConditional)
160 mapSiteGuardMissing[site] = append(mapSiteGuardMissing[site], i)
161 }
162 }
163 }
164
165 for i, trigger := range triggers {
166 if c, ok := trigger.Consumer.Annotation.(*annotation.UseAsReturn); ok && c.IsTrackingAlwaysSafe {
167 site := e.primitive.site(c.UnderlyingSite(), c.Kind() == annotation.DeepConditional)
168 mapSiteReturn[site] = append(mapSiteReturn[site], i)
169 }
170 }
171
172 return mapSiteGuardMissing, mapSiteReturn
173}
174
175// ObservePackage observes all the annotations and assertions computed locally about the current
176// package. The assertions are sorted based on whether they are already known to trigger without

Callers 1

ObservePackageMethod · 0.95

Calls 3

siteMethod · 0.80
UnderlyingSiteMethod · 0.65
KindMethod · 0.65

Tested by

no test coverage detected