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

Commit f0e1147

Browse files
committed
Make CallNode.getResult(0) match single results
1 parent 4be8059 commit f0e1147

6 files changed

Lines changed: 15 additions & 5 deletions

File tree

ql/src/experimental/frameworks/Gin.qll

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,6 @@ private module Gin {
7272
)
7373
|
7474
this = call.getResult(0)
75-
or
76-
this = call.getResult()
7775
)
7876
or
7977
// Field reads:
@@ -104,8 +102,6 @@ private module Gin {
104102
call.getTarget().hasQualifiedName(packagePath, typeName, ["ByName", "Get"])
105103
|
106104
this = call.getResult(0)
107-
or
108-
this = call.getResult()
109105
)
110106
)
111107
}

ql/src/semmle/go/dataflow/internal/DataFlowUtil.qll

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,11 @@ class CallNode extends ExprNode {
328328
FunctionNode getCallback(int i) { result.getASuccessor*() = this.getArgument(i) }
329329

330330
/** Gets the data-flow node corresponding to the `i`th result of this call. */
331-
Node getResult(int i) { result = extractTupleElement(this, i) }
331+
Node getResult(int i) {
332+
not getType() instanceof TupleType and i = 0 and result = this
333+
or
334+
result = extractTupleElement(this, i)
335+
}
332336

333337
/**
334338
* Gets the data-flow node corresponding to the result of this call.

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@
1414
| receiver | main.go:53:14:53:21 | call to bump | main.go:53:14:53:14 | c |
1515
| receiver | tst.go:10:2:10:29 | call to ReadFrom | tst.go:10:2:10:12 | bytesBuffer |
1616
| result | tst.go:9:17:9:33 | call to new | tst.go:9:2:9:12 | definition of bytesBuffer |
17+
| 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/FunctionOutput_getExitNode.expected

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@
44
| result | main.go:53:2:53:22 | call to op2 | main.go:53:2:53:22 | call to op2 |
55
| result | main.go:53:14:53:21 | call to bump | main.go:53:14:53:21 | call to bump |
66
| result | tst.go:9:17:9:33 | call to new | tst.go:9:17:9:33 | call to new |
7+
| result 0 | main.go:51:2:51:14 | call to op | main.go:51:2:51:14 | call to op |
8+
| result 0 | main.go:53:2:53:22 | call to op2 | main.go:53:2:53:22 | call to op2 |
9+
| result 0 | main.go:53:14:53:21 | call to bump | main.go:53:14:53:21 | call to bump |
710
| result 0 | main.go:54:10:54:15 | call to test | main.go:54:2:54:15 | ... := ...[0] |
811
| result 0 | main.go:56:9:56:15 | call to test2 | main.go:56:2:56:15 | ... = ...[0] |
12+
| result 0 | tst.go:9:17:9:33 | call to new | tst.go:9:17:9:33 | call to new |
913
| result 1 | main.go:54:10:54:15 | call to test | main.go:54:2:54:15 | ... := ...[1] |
1014
| result 1 | main.go:56:9:56:15 | call to test2 | main.go:56:2:56:15 | ... = ...[1] |
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
| main.go:51:2:51:14 | call to op | main.go:51:2:51:14 | call to op | 0 | result |
2+
| main.go:51:2:51:14 | call to op | main.go:51:2:51:14 | call to op | 0 | result 0 |
23
| main.go:53:2:53:22 | call to op2 | main.go:53:2:53:22 | call to op2 | 0 | result |
4+
| main.go:53:2:53:22 | call to op2 | main.go:53:2:53:22 | call to op2 | 0 | result 0 |
35
| main.go:53:14:53:21 | call to bump | main.go:53:14:53:21 | call to bump | 0 | result |
6+
| main.go:53:14:53:21 | call to bump | main.go:53:14:53:21 | call to bump | 0 | result 0 |
47
| main.go:54:10:54:15 | call to test | main.go:54:2:54:15 | ... := ...[0] | 0 | result 0 |
58
| main.go:54:10:54:15 | call to test | main.go:54:2:54:15 | ... := ...[1] | 1 | result 1 |
69
| main.go:56:9:56:15 | call to test2 | main.go:56:2:56:15 | ... = ...[0] | 0 | result 0 |
710
| main.go:56:9:56:15 | call to test2 | main.go:56:2:56:15 | ... = ...[1] | 1 | result 1 |
811
| tst.go:9:17:9:33 | call to new | tst.go:9:17:9:33 | call to new | 0 | result |
12+
| tst.go:9:17:9:33 | call to new | tst.go:9:17:9:33 | call to new | 0 | result 0 |
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
| main.go:9:9:9:14 | call to test | 0 | main.go:9:2:9:14 | ... = ...[0] |
22
| main.go:9:9:9:14 | call to test | 1 | main.go:9:2:9:14 | ... = ...[1] |
3+
| main.go:14:8:14:24 | call to make | 0 | main.go:14:8:14:24 | call to make |

0 commit comments

Comments
 (0)