mirror of
https://github.com/github/codeql.git
synced 2025-12-23 20:26:32 +01:00
C++: Add a new test that demonstrates multiple out nodes.
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
| dispatch.cpp:60:18:60:29 | Call: new | Unexpected result: ir-count(indirect return)=3 |
|
||||
| dispatch.cpp:61:18:61:29 | Call: new | Unexpected result: ir-count(indirect return)=3 |
|
||||
| dispatch.cpp:65:10:65:21 | Call: new | Unexpected result: ir-count(indirect return)=3 |
|
||||
@@ -0,0 +1,46 @@
|
||||
import TestUtilities.InlineExpectationsTest
|
||||
import cpp
|
||||
|
||||
module AstTest {
|
||||
private import semmle.code.cpp.dataflow.old.DataFlow::DataFlow
|
||||
private import semmle.code.cpp.dataflow.old.internal.DataFlowPrivate
|
||||
|
||||
class ASTMultipleOutNodesTest extends InlineExpectationsTest {
|
||||
ASTMultipleOutNodesTest() { this = "ASTMultipleOutNodesTest" }
|
||||
|
||||
override string getARelevantTag() { result = "ast-count(" + any(ReturnKind k).toString() + ")" }
|
||||
|
||||
override predicate hasActualResult(Location location, string element, string tag, string value) {
|
||||
exists(DataFlowCall call, int n, ReturnKind kind |
|
||||
call.getLocation() = location and
|
||||
n = strictcount(getAnOutNode(call, kind)) and
|
||||
n > 1 and
|
||||
element = call.toString() and
|
||||
tag = "ast-count(" + kind.toString() + ")" and
|
||||
value = n.toString()
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module IRTest {
|
||||
private import semmle.code.cpp.ir.dataflow.DataFlow
|
||||
private import semmle.code.cpp.ir.dataflow.internal.DataFlowPrivate
|
||||
|
||||
class IRMultipleOutNodesTest extends InlineExpectationsTest {
|
||||
IRMultipleOutNodesTest() { this = "IRMultipleOutNodesTest" }
|
||||
|
||||
override string getARelevantTag() { result = "ir-count(" + any(ReturnKind k).toString() + ")" }
|
||||
|
||||
override predicate hasActualResult(Location location, string element, string tag, string value) {
|
||||
exists(DataFlowCall call, int n, ReturnKind kind |
|
||||
call.getLocation() = location and
|
||||
n = strictcount(getAnOutNode(call, kind)) and
|
||||
n > 1 and
|
||||
element = call.toString() and
|
||||
tag = "ir-count(" + kind.toString() + ")" and
|
||||
value = n.toString()
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user