Skip to content
This repository was archived by the owner on Jan 5, 2023. It is now read-only.

Commit 9c640ff

Browse files
author
Max Schaefer
committed
Add a new test for FunctionInputsAndOutputs.
1 parent c905149 commit 9c640ff

8 files changed

+32
-0
lines changed

ql/test/library-tests/semmle/go/dataflow/FunctionInputsAndOutputs/FunctionInput_getEntryNode.expected

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
| parameter 0 | main.go:55:2:55:27 | call to Printf | main.go:55:13:55:20 | "%d, %d" |
44
| parameter 0 | main.go:57:2:57:27 | call to Printf | main.go:57:13:57:20 | "%d, %d" |
55
| parameter 0 | reset.go:12:2:12:21 | call to Reset | reset.go:12:15:12:20 | source |
6+
| parameter 0 | tst2.go:10:9:10:26 | call to NewEncoder | tst2.go:10:25:10:25 | w |
7+
| parameter 0 | tst2.go:10:9:10:39 | call to Encode | tst2.go:10:35:10:38 | data |
68
| parameter 0 | tst.go:10:2:10:29 | call to ReadFrom | tst.go:10:23:10:28 | reader |
79
| parameter 0 | tst.go:16:2:16:12 | call to test5 | tst.go:16:8:16:8 | x |
810
| parameter 0 | tst.go:18:2:18:12 | call to test5 | tst.go:18:8:18:8 | s |
@@ -17,6 +19,7 @@
1719
| parameter 2 | main.go:57:2:57:27 | call to Printf | main.go:57:26:57:26 | y |
1820
| receiver | main.go:53:14:53:21 | call to bump | main.go:53:14:53:14 | c |
1921
| receiver | reset.go:12:2:12:21 | call to Reset | reset.go:12:2:12:7 | reader |
22+
| receiver | tst2.go:10:9:10:39 | call to Encode | tst2.go:10:9:10:26 | call to NewEncoder |
2023
| receiver | tst.go:10:2:10:29 | call to ReadFrom | tst.go:10:2:10:12 | bytesBuffer |
2124
| result | tst.go:9:17:9:33 | call to new | tst.go:9:2:9:12 | definition of bytesBuffer |
2225
| result 0 | tst.go:9:17:9:33 | call to new | tst.go:9:2:9:12 | definition of bytesBuffer |

ql/test/library-tests/semmle/go/dataflow/FunctionInputsAndOutputs/FunctionInput_getExitNode.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
| parameter 0 | main.go:13:1:20:1 | function declaration | main.go:13:10:13:11 | definition of op |
33
| parameter 0 | main.go:40:1:48:1 | function declaration | main.go:40:12:40:12 | definition of b |
44
| parameter 0 | reset.go:8:1:16:1 | function declaration | reset.go:8:27:8:27 | definition of r |
5+
| parameter 0 | tst2.go:8:1:12:1 | function declaration | tst2.go:8:12:8:15 | definition of data |
56
| parameter 0 | tst.go:8:1:11:1 | function declaration | tst.go:8:12:8:17 | definition of reader |
67
| parameter 0 | tst.go:15:1:19:1 | function declaration | tst.go:15:12:15:12 | definition of x |
78
| parameter 1 | main.go:5:1:11:1 | function declaration | main.go:5:20:5:20 | definition of x |
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1+
| file://:0:0:0:0 | Encode | tst2.go:10:35:10:38 | data | tst2.go:10:9:10:26 | call to NewEncoder |
12
| file://:0:0:0:0 | ReadFrom | tst.go:10:23:10:28 | reader | tst.go:9:2:9:12 | definition of bytesBuffer |
23
| file://:0:0:0:0 | Reset | reset.go:12:15:12:20 | source | reset.go:11:6:11:11 | definition of reader |

ql/test/library-tests/semmle/go/dataflow/FunctionInputsAndOutputs/FunctionOutput_getEntryNode.expected

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@
1111
| result 0 | main.go:40:1:48:1 | function declaration | main.go:40:21:40:23 | zero value for int |
1212
| result 0 | main.go:40:1:48:1 | function declaration | main.go:45:10:45:10 | 0 |
1313
| result 0 | main.go:40:1:48:1 | function declaration | main.go:47:9:47:9 | 0 |
14+
| result 0 | tst2.go:8:1:12:1 | function declaration | tst2.go:11:9:11:9 | w |
1415
| result 1 | main.go:31:1:33:1 | function declaration | main.go:32:13:32:14 | 42 |
1516
| result 1 | main.go:35:1:38:1 | function declaration | main.go:35:22:35:22 | zero value for y |
1617
| result 1 | main.go:35:1:38:1 | function declaration | main.go:36:9:36:10 | 42 |
1718
| result 1 | main.go:40:1:48:1 | function declaration | main.go:40:26:40:26 | zero value for y |
1819
| result 1 | main.go:40:1:48:1 | function declaration | main.go:42:3:42:5 | rhs of increment statement |
1920
| result 1 | main.go:40:1:48:1 | function declaration | main.go:45:13:45:13 | 1 |
2021
| result 1 | main.go:40:1:48:1 | function declaration | main.go:47:12:47:12 | 4 |
22+
| result 1 | tst2.go:8:1:12:1 | function declaration | tst2.go:11:12:11:14 | err |
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,26 @@
11
| parameter 0 | reset.go:12:2:12:21 | call to Reset | reset.go:9:2:9:7 | definition of source |
2+
| parameter 0 | tst2.go:10:9:10:26 | call to NewEncoder | tst2.go:9:6:9:6 | definition of w |
3+
| parameter 0 | tst2.go:10:9:10:39 | call to Encode | tst2.go:8:12:8:15 | definition of data |
24
| parameter 0 | tst.go:10:2:10:29 | call to ReadFrom | tst.go:8:12:8:17 | definition of reader |
35
| parameter 0 | tst.go:16:2:16:12 | call to test5 | tst.go:15:12:15:12 | definition of x |
46
| parameter 1 | tst.go:16:2:16:12 | call to test5 | tst.go:15:15:15:15 | definition of y |
57
| receiver | main.go:53:14:53:21 | call to bump | main.go:52:2:52:2 | definition of c |
68
| receiver | reset.go:12:2:12:21 | call to Reset | reset.go:11:6:11:11 | definition of reader |
9+
| receiver | tst2.go:10:9:10:39 | call to Encode | tst2.go:10:9:10:26 | call to NewEncoder |
710
| receiver | tst.go:10:2:10:29 | call to ReadFrom | tst.go:9:2:9:12 | definition of bytesBuffer |
811
| result | main.go:51:2:51:14 | call to op | main.go:51:2:51:14 | call to op |
912
| result | main.go:53:2:53:22 | call to op2 | main.go:53:2:53:22 | call to op2 |
1013
| result | main.go:53:14:53:21 | call to bump | main.go:53:14:53:21 | call to bump |
14+
| result | tst2.go:10:9:10:26 | call to NewEncoder | tst2.go:10:9:10:26 | call to NewEncoder |
15+
| result | tst2.go:10:9:10:39 | call to Encode | tst2.go:10:9:10:39 | call to Encode |
1116
| result | tst.go:9:17:9:33 | call to new | tst.go:9:17:9:33 | call to new |
1217
| result 0 | main.go:51:2:51:14 | call to op | main.go:51:2:51:14 | call to op |
1318
| result 0 | main.go:53:2:53:22 | call to op2 | main.go:53:2:53:22 | call to op2 |
1419
| result 0 | main.go:53:14:53:21 | call to bump | main.go:53:14:53:21 | call to bump |
1520
| result 0 | main.go:54:10:54:15 | call to test | main.go:54:2:54:15 | ... := ...[0] |
1621
| result 0 | main.go:56:9:56:15 | call to test2 | main.go:56:2:56:15 | ... = ...[0] |
22+
| result 0 | tst2.go:10:9:10:26 | call to NewEncoder | tst2.go:10:9:10:26 | call to NewEncoder |
23+
| result 0 | tst2.go:10:9:10:39 | call to Encode | tst2.go:10:9:10:39 | call to Encode |
1724
| result 0 | tst.go:9:17:9:33 | call to new | tst.go:9:17:9:33 | call to new |
1825
| result 1 | main.go:54:10:54:15 | call to test | main.go:54:2:54:15 | ... := ...[1] |
1926
| result 1 | main.go:56:9:56:15 | call to test2 | main.go:56:2:56:15 | ... = ...[1] |
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
| main.go:51:2:51:14 | call to op | main.go:51:2:51:14 | call to op | result |
22
| main.go:53:2:53:22 | call to op2 | main.go:53:2:53:22 | call to op2 | result |
33
| main.go:53:14:53:21 | call to bump | main.go:53:14:53:21 | call to bump | result |
4+
| tst2.go:10:9:10:26 | call to NewEncoder | tst2.go:10:9:10:26 | call to NewEncoder | result |
5+
| tst2.go:10:9:10:39 | call to Encode | tst2.go:10:9:10:39 | call to Encode | result |
46
| tst.go:9:17:9:33 | call to new | tst.go:9:17:9:33 | call to new | result |

ql/test/library-tests/semmle/go/dataflow/FunctionInputsAndOutputs/FunctionOutput_isResult_int.expected

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,9 @@
88
| main.go:54:10:54:15 | call to test | main.go:54:2:54:15 | ... := ...[1] | 1 | result 1 |
99
| main.go:56:9:56:15 | call to test2 | main.go:56:2:56:15 | ... = ...[0] | 0 | result 0 |
1010
| main.go:56:9:56:15 | call to test2 | main.go:56:2:56:15 | ... = ...[1] | 1 | result 1 |
11+
| tst2.go:10:9:10:26 | call to NewEncoder | tst2.go:10:9:10:26 | call to NewEncoder | 0 | result |
12+
| tst2.go:10:9:10:26 | call to NewEncoder | tst2.go:10:9:10:26 | call to NewEncoder | 0 | result 0 |
13+
| tst2.go:10:9:10:39 | call to Encode | tst2.go:10:9:10:39 | call to Encode | 0 | result |
14+
| tst2.go:10:9:10:39 | call to Encode | tst2.go:10:9:10:39 | call to Encode | 0 | result 0 |
1115
| tst.go:9:17:9:33 | call to new | tst.go:9:17:9:33 | call to new | 0 | result |
1216
| tst.go:9:17:9:33 | call to new | tst.go:9:17:9:33 | call to new | 0 | result 0 |
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package main
2+
3+
import (
4+
"encoding/json"
5+
"io"
6+
)
7+
8+
func test7(data interface{}) (io.Writer, error) {
9+
var w io.Writer
10+
err := json.NewEncoder(w).Encode(data)
11+
return w, err
12+
}

0 commit comments

Comments
 (0)