Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7439de3

Browse files
committed
C++: Add a new test that demonstrates multiple out nodes.
1 parent 946e301 commit 7439de3

2 files changed

Lines changed: 49 additions & 0 deletions

File tree

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
| dispatch.cpp:60:18:60:29 | Call: new | Unexpected result: ir-count(indirect return)=3 |
2+
| dispatch.cpp:61:18:61:29 | Call: new | Unexpected result: ir-count(indirect return)=3 |
3+
| dispatch.cpp:65:10:65:21 | Call: new | Unexpected result: ir-count(indirect return)=3 |
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import TestUtilities.InlineExpectationsTest
2+
import cpp
3+
4+
module AstTest {
5+
private import semmle.code.cpp.dataflow.old.DataFlow::DataFlow
6+
private import semmle.code.cpp.dataflow.old.internal.DataFlowPrivate
7+
8+
class ASTMultipleOutNodesTest extends InlineExpectationsTest {
9+
ASTMultipleOutNodesTest() { this = "ASTMultipleOutNodesTest" }
10+
11+
override string getARelevantTag() { result = "ast-count(" + any(ReturnKind k).toString() + ")" }
12+
13+
override predicate hasActualResult(Location location, string element, string tag, string value) {
14+
exists(DataFlowCall call, int n, ReturnKind kind |
15+
call.getLocation() = location and
16+
n = strictcount(getAnOutNode(call, kind)) and
17+
n > 1 and
18+
element = call.toString() and
19+
tag = "ast-count(" + kind.toString() + ")" and
20+
value = n.toString()
21+
)
22+
}
23+
}
24+
}
25+
26+
module IRTest {
27+
private import semmle.code.cpp.ir.dataflow.DataFlow
28+
private import semmle.code.cpp.ir.dataflow.internal.DataFlowPrivate
29+
30+
class IRMultipleOutNodesTest extends InlineExpectationsTest {
31+
IRMultipleOutNodesTest() { this = "IRMultipleOutNodesTest" }
32+
33+
override string getARelevantTag() { result = "ir-count(" + any(ReturnKind k).toString() + ")" }
34+
35+
override predicate hasActualResult(Location location, string element, string tag, string value) {
36+
exists(DataFlowCall call, int n, ReturnKind kind |
37+
call.getLocation() = location and
38+
n = strictcount(getAnOutNode(call, kind)) and
39+
n > 1 and
40+
element = call.toString() and
41+
tag = "ir-count(" + kind.toString() + ")" and
42+
value = n.toString()
43+
)
44+
}
45+
}
46+
}

0 commit comments

Comments
 (0)