MCPcopy Index your code
hub / github.com/uber-go/nilaway / backpropAcrossSend

Function backpropAcrossSend

assertion/function/assertiontree/backprop.go:122–146  ·  view source on GitHub ↗

backpropAcrossSend handles backpropagation for send statements. It is designed to be called from backpropAcrossNode as a special handler.

(rootNode *RootAssertionNode, node *ast.SendStmt)

Source from the content-addressed store, hash-verified

120// backpropAcrossSend handles backpropagation for send statements. It is designed to be called from
121// backpropAcrossNode as a special handler.
122func backpropAcrossSend(rootNode *RootAssertionNode, node *ast.SendStmt) error {
123 // Note that for channel sends, we have:
124 // (1) A send to a nil channel blocks forever;
125 // (2) A send to a closed channel panics.
126 // (1) falls out of scope for NilAway and hence we do not create a consumer here for the
127 // channel variable. For (2), since we do not track the state of the channels, we currently
128 // cannot support it.
129 // TODO: rethink our strategy of handling channels (#192).
130 consumer, err := exprAsAssignmentConsumer(rootNode, node, nil)
131 if err != nil {
132 return err
133 }
134 if consumer != nil {
135 rootNode.AddConsumption(&annotation.ConsumeTrigger{
136 Annotation: consumer,
137 Expr: node.Value,
138 Guards: guard.NoGuards(),
139 })
140 }
141
142 rootNode.AddComputation(node.Chan)
143 rootNode.AddComputation(node.Value)
144
145 return nil
146}
147
148// backpropAcrossReturn handles backpropagation for return statements. It is designed to be called
149// from backpropAcrossNode as a special handler.

Callers 1

backpropAcrossNodeFunction · 0.85

Calls 4

NoGuardsFunction · 0.92
exprAsAssignmentConsumerFunction · 0.85
AddConsumptionMethod · 0.80
AddComputationMethod · 0.80

Tested by

no test coverage detected