File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed
go/ql/lib/semmle/go/dataflow Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -93,9 +93,20 @@ private module Internal {
9393
9494 /**
9595 * Holds if the `i`th node of basic block `bb` reads source variable `v`.
96+ *
97+ * We also add a synthetic uncertain read at the exit node of the declaring
98+ * function for captured variables. This ensures that definitions of captured
99+ * variables are included in the SSA graph even when the variable is not
100+ * locally read in the declaring function (but may be read by a nested function).
96101 */
97102 predicate variableRead ( BasicBlock bb , int i , SourceVariable v , boolean certain ) {
98103 useAt ( bb , i , v ) and certain = true
104+ or
105+ v .isCaptured ( ) and
106+ bb .getScope ( ) = v .getDeclaringFunction ( ) and
107+ bb .getLastNode ( ) .isExitNode ( ) and
108+ i = bb .length ( ) - 1 and
109+ certain = false
99110 }
100111 }
101112}
You can’t perform that action at this time.
0 commit comments