|
| 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