Make FunctionOutput.isResult(0) match single results

This commit is contained in:
Owen Mansel-Chan
2020-05-27 09:57:19 +01:00
parent ae2ed877ee
commit 4be805966f
2 changed files with 14 additions and 2 deletions

View File

@@ -100,7 +100,11 @@ private class ResultInput extends FunctionInput, TInResult {
override predicate isResult() { index = -1 }
override predicate isResult(int i) { i = index and i >= 0 }
override predicate isResult(int i) {
index = -1 and i = 0
or
i = index and i >= 0
}
override DataFlow::Node getEntryNode(DataFlow::CallNode c) {
exists(DataFlow::PostUpdateNode pun, DataFlow::Node init |
@@ -181,7 +185,11 @@ private class OutResult extends FunctionOutput, TOutResult {
override predicate isResult() { index = -1 }
override predicate isResult(int i) { i = index and i >= 0 }
override predicate isResult(int i) {
index = -1 and i = 0
or
i = index and i >= 0
}
override DataFlow::Node getEntryNode(FuncDef f) {
// return expressions

View File

@@ -1,4 +1,8 @@
| main.go:51:2:51:14 | call to op | main.go:51:2:51:14 | call to op | 0 | result |
| main.go:53:2:53:22 | call to op2 | main.go:53:2:53:22 | call to op2 | 0 | result |
| main.go:53:14:53:21 | call to bump | main.go:53:14:53:21 | call to bump | 0 | result |
| main.go:54:10:54:15 | call to test | main.go:54:2:54:15 | ... := ...[0] | 0 | result 0 |
| main.go:54:10:54:15 | call to test | main.go:54:2:54:15 | ... := ...[1] | 1 | result 1 |
| main.go:56:9:56:15 | call to test2 | main.go:56:2:56:15 | ... = ...[0] | 0 | result 0 |
| main.go:56:9:56:15 | call to test2 | main.go:56:2:56:15 | ... = ...[1] | 1 | result 1 |
| tst.go:9:17:9:33 | call to new | tst.go:9:17:9:33 | call to new | 0 | result |