diff --git a/cpp/ql/test/library-tests/controlflow/guards/GuardsCompare.expected b/cpp/ql/test/library-tests/controlflow/guards/GuardsCompare.expected index 0216df7b31f..4d78c4016da 100644 --- a/cpp/ql/test/library-tests/controlflow/guards/GuardsCompare.expected +++ b/cpp/ql/test/library-tests/controlflow/guards/GuardsCompare.expected @@ -1308,3 +1308,137 @@ | test.cpp:334:11:334:11 | x | x >= 40 when x is Lower bound 40 | | test.cpp:338:9:338:9 | x | x < 51 when x is Upper bound 50 | | test.cpp:338:9:338:9 | x | x >= 40 when x is Lower bound 40 | +| test.cpp:345:10:345:25 | ... != ... | 0 != input+0 when ... != ... is true | +| test.cpp:345:10:345:25 | ... != ... | 0 == input+0 when ... != ... is false | +| test.cpp:345:10:345:25 | ... != ... | input != 0 when ... != ... is true | +| test.cpp:345:10:345:25 | ... != ... | input != 0+0 when ... != ... is true | +| test.cpp:345:10:345:25 | ... != ... | input == 0 when ... != ... is false | +| test.cpp:345:10:345:25 | ... != ... | input == 0+0 when ... != ... is false | +| test.cpp:349:11:349:22 | call to testNotNull1 | call to testNotNull1 != 0 when call to testNotNull1 is true | +| test.cpp:349:11:349:22 | call to testNotNull1 | call to testNotNull1 != 1 when call to testNotNull1 is false | +| test.cpp:349:11:349:22 | call to testNotNull1 | call to testNotNull1 == 0 when call to testNotNull1 is false | +| test.cpp:349:11:349:22 | call to testNotNull1 | call to testNotNull1 == 1 when call to testNotNull1 is true | +| test.cpp:350:7:350:12 | ... != ... | 0 != x+0 when ... != ... is true | +| test.cpp:350:7:350:12 | ... != ... | 0 == x+0 when ... != ... is false | +| test.cpp:350:7:350:12 | ... != ... | ... != ... != 0 when ... != ... is true | +| test.cpp:350:7:350:12 | ... != ... | ... != ... != 1 when ... != ... is false | +| test.cpp:350:7:350:12 | ... != ... | ... != ... == 0 when ... != ... is false | +| test.cpp:350:7:350:12 | ... != ... | ... != ... == 1 when ... != ... is true | +| test.cpp:350:7:350:12 | ... != ... | x != 0 when ... != ... is true | +| test.cpp:350:7:350:12 | ... != ... | x != 0+0 when ... != ... is true | +| test.cpp:350:7:350:12 | ... != ... | x == 0 when ... != ... is false | +| test.cpp:350:7:350:12 | ... != ... | x == 0+0 when ... != ... is false | +| test.cpp:356:7:356:22 | ... == ... | 0 != input+0 when ... == ... is false | +| test.cpp:356:7:356:22 | ... == ... | 0 == input+0 when ... == ... is true | +| test.cpp:356:7:356:22 | ... == ... | ... == ... != 0 when ... == ... is true | +| test.cpp:356:7:356:22 | ... == ... | ... == ... != 1 when ... == ... is false | +| test.cpp:356:7:356:22 | ... == ... | ... == ... == 0 when ... == ... is false | +| test.cpp:356:7:356:22 | ... == ... | ... == ... == 1 when ... == ... is true | +| test.cpp:356:7:356:22 | ... == ... | input != 0 when ... == ... is false | +| test.cpp:356:7:356:22 | ... == ... | input != 0+0 when ... == ... is false | +| test.cpp:356:7:356:22 | ... == ... | input == 0 when ... == ... is true | +| test.cpp:356:7:356:22 | ... == ... | input == 0+0 when ... == ... is true | +| test.cpp:361:10:361:26 | ... == ... | 0 != number+0 when ... == ... is false | +| test.cpp:361:10:361:26 | ... == ... | 0 == number+0 when ... == ... is true | +| test.cpp:361:10:361:26 | ... == ... | ... == ... != 0 when ... == ... is true | +| test.cpp:361:10:361:26 | ... == ... | ... == ... != 1 when ... == ... is false | +| test.cpp:361:10:361:26 | ... == ... | ... == ... == 0 when ... == ... is false | +| test.cpp:361:10:361:26 | ... == ... | ... == ... == 1 when ... == ... is true | +| test.cpp:361:10:361:26 | ... == ... | number != 0 when ... == ... is false | +| test.cpp:361:10:361:26 | ... == ... | number != 0+0 when ... == ... is false | +| test.cpp:361:10:361:26 | ... == ... | number == 0 when ... == ... is true | +| test.cpp:361:10:361:26 | ... == ... | number == 0+0 when ... == ... is true | +| test.cpp:365:7:365:9 | ! ... | ! ... != 0 when ! ... is true | +| test.cpp:365:7:365:9 | ! ... | ! ... != 1 when ! ... is false | +| test.cpp:365:7:365:9 | ! ... | ! ... == 0 when ! ... is false | +| test.cpp:365:7:365:9 | ! ... | ! ... == 1 when ! ... is true | +| test.cpp:365:7:365:9 | ! ... | s1 != 0 when ! ... is false | +| test.cpp:365:7:365:9 | ! ... | s1 != 1 when ! ... is true | +| test.cpp:365:7:365:9 | ! ... | s1 == 0 when ! ... is true | +| test.cpp:365:7:365:9 | ! ... | s1 == 1 when ! ... is false | +| test.cpp:365:7:365:16 | ... \|\| ... | ! ... != 1 when ... \|\| ... is false | +| test.cpp:365:7:365:16 | ... \|\| ... | ! ... == 0 when ... \|\| ... is false | +| test.cpp:365:7:365:16 | ... \|\| ... | s1 != 0 when ... \|\| ... is false | +| test.cpp:365:7:365:16 | ... \|\| ... | s1 == 1 when ... \|\| ... is false | +| test.cpp:365:7:365:16 | ... \|\| ... | s2 != 0 when ... \|\| ... is false | +| test.cpp:365:7:365:16 | ... \|\| ... | s2 == 1 when ... \|\| ... is false | +| test.cpp:365:8:365:9 | s1 | ! ... != 0 when s1 is false | +| test.cpp:365:8:365:9 | s1 | ! ... != 1 when s1 is true | +| test.cpp:365:8:365:9 | s1 | ! ... == 0 when s1 is true | +| test.cpp:365:8:365:9 | s1 | ! ... == 1 when s1 is false | +| test.cpp:365:8:365:9 | s1 | s1 != 0 when s1 is true | +| test.cpp:365:8:365:9 | s1 | s1 != 1 when s1 is false | +| test.cpp:365:8:365:9 | s1 | s1 == 0 when s1 is false | +| test.cpp:365:8:365:9 | s1 | s1 == 1 when s1 is true | +| test.cpp:365:14:365:16 | ! ... | ! ... != 0 when ! ... is true | +| test.cpp:365:14:365:16 | ! ... | ! ... != 1 when ! ... is false | +| test.cpp:365:14:365:16 | ! ... | ! ... == 0 when ! ... is false | +| test.cpp:365:14:365:16 | ! ... | ! ... == 1 when ! ... is true | +| test.cpp:365:14:365:16 | ! ... | s2 != 0 when ! ... is false | +| test.cpp:365:14:365:16 | ! ... | s2 != 1 when ! ... is true | +| test.cpp:365:14:365:16 | ! ... | s2 == 0 when ! ... is true | +| test.cpp:365:14:365:16 | ! ... | s2 == 1 when ! ... is false | +| test.cpp:365:15:365:16 | s2 | ! ... != 0 when s2 is false | +| test.cpp:365:15:365:16 | s2 | ! ... != 1 when s2 is true | +| test.cpp:365:15:365:16 | s2 | ! ... == 0 when s2 is true | +| test.cpp:365:15:365:16 | s2 | ! ... == 1 when s2 is false | +| test.cpp:365:15:365:16 | s2 | s2 != 0 when s2 is true | +| test.cpp:365:15:365:16 | s2 | s2 != 1 when s2 is false | +| test.cpp:365:15:365:16 | s2 | s2 == 0 when s2 is false | +| test.cpp:365:15:365:16 | s2 | s2 == 1 when s2 is true | +| test.cpp:371:29:371:32 | flag | flag != 0 when flag is true | +| test.cpp:371:29:371:32 | flag | flag != 1 when flag is false | +| test.cpp:371:29:371:32 | flag | flag == 0 when flag is false | +| test.cpp:371:29:371:32 | flag | flag == 1 when flag is true | +| test.cpp:372:10:372:13 | flag | flag != 0 when flag is true | +| test.cpp:372:10:372:13 | flag | flag != 1 when flag is false | +| test.cpp:372:10:372:13 | flag | flag == 0 when flag is false | +| test.cpp:372:10:372:13 | flag | flag == 1 when flag is true | +| test.cpp:376:7:376:18 | call to testNotNull1 | call to testNotNull1 != 0 when call to testNotNull1 is true | +| test.cpp:376:7:376:18 | call to testNotNull1 | call to testNotNull1 != 1 when call to testNotNull1 is false | +| test.cpp:376:7:376:18 | call to testNotNull1 | call to testNotNull1 == 0 when call to testNotNull1 is false | +| test.cpp:376:7:376:18 | call to testNotNull1 | call to testNotNull1 == 1 when call to testNotNull1 is true | +| test.cpp:382:7:382:18 | call to testNotNull2 | call to testNotNull2 != 0 when call to testNotNull2 is true | +| test.cpp:382:7:382:18 | call to testNotNull2 | call to testNotNull2 != 1 when call to testNotNull2 is false | +| test.cpp:382:7:382:18 | call to testNotNull2 | call to testNotNull2 == 0 when call to testNotNull2 is false | +| test.cpp:382:7:382:18 | call to testNotNull2 | call to testNotNull2 == 1 when call to testNotNull2 is true | +| test.cpp:388:7:388:29 | ... == ... | 0 != call to getNumOrDefault+0 when ... == ... is false | +| test.cpp:388:7:388:29 | ... == ... | 0 == call to getNumOrDefault+0 when ... == ... is true | +| test.cpp:388:7:388:29 | ... == ... | ... == ... != 0 when ... == ... is true | +| test.cpp:388:7:388:29 | ... == ... | ... == ... != 1 when ... == ... is false | +| test.cpp:388:7:388:29 | ... == ... | ... == ... == 0 when ... == ... is false | +| test.cpp:388:7:388:29 | ... == ... | ... == ... == 1 when ... == ... is true | +| test.cpp:388:7:388:29 | ... == ... | call to getNumOrDefault != 0 when ... == ... is false | +| test.cpp:388:7:388:29 | ... == ... | call to getNumOrDefault != 0+0 when ... == ... is false | +| test.cpp:388:7:388:29 | ... == ... | call to getNumOrDefault == 0 when ... == ... is true | +| test.cpp:388:7:388:29 | ... == ... | call to getNumOrDefault == 0+0 when ... == ... is true | +| test.cpp:394:7:394:47 | ... == ... | 0 != call to returnAIfNoneAreNull+0 when ... == ... is false | +| test.cpp:394:7:394:47 | ... == ... | 0 == call to returnAIfNoneAreNull+0 when ... == ... is true | +| test.cpp:394:7:394:47 | ... == ... | ... == ... != 0 when ... == ... is true | +| test.cpp:394:7:394:47 | ... == ... | ... == ... != 1 when ... == ... is false | +| test.cpp:394:7:394:47 | ... == ... | ... == ... == 0 when ... == ... is false | +| test.cpp:394:7:394:47 | ... == ... | ... == ... == 1 when ... == ... is true | +| test.cpp:394:7:394:47 | ... == ... | call to returnAIfNoneAreNull != 0 when ... == ... is false | +| test.cpp:394:7:394:47 | ... == ... | call to returnAIfNoneAreNull != 0+0 when ... == ... is false | +| test.cpp:394:7:394:47 | ... == ... | call to returnAIfNoneAreNull == 0 when ... == ... is true | +| test.cpp:394:7:394:47 | ... == ... | call to returnAIfNoneAreNull == 0+0 when ... == ... is true | +| test.cpp:400:11:400:25 | call to testEnumWrapper | call to testEnumWrapper != 1 when call to testEnumWrapper is not 1 | +| test.cpp:400:11:400:25 | call to testEnumWrapper | call to testEnumWrapper != 2 when call to testEnumWrapper is not 2 | +| test.cpp:400:11:400:25 | call to testEnumWrapper | call to testEnumWrapper == 1 when call to testEnumWrapper is 1 | +| test.cpp:400:11:400:25 | call to testEnumWrapper | call to testEnumWrapper == 2 when call to testEnumWrapper is 2 | +| test.cpp:411:7:411:8 | ! ... | ! ... != 0 when ! ... is true | +| test.cpp:411:7:411:8 | ! ... | ! ... != 1 when ! ... is false | +| test.cpp:411:7:411:8 | ! ... | ! ... == 0 when ! ... is false | +| test.cpp:411:7:411:8 | ! ... | ! ... == 1 when ! ... is true | +| test.cpp:411:7:411:8 | ! ... | o != 0 when ! ... is false | +| test.cpp:411:7:411:8 | ! ... | o != 1 when ! ... is true | +| test.cpp:411:7:411:8 | ! ... | o == 0 when ! ... is true | +| test.cpp:411:7:411:8 | ! ... | o == 1 when ! ... is false | +| test.cpp:411:8:411:8 | o | ! ... != 0 when o is false | +| test.cpp:411:8:411:8 | o | ! ... != 1 when o is true | +| test.cpp:411:8:411:8 | o | ! ... == 0 when o is true | +| test.cpp:411:8:411:8 | o | ! ... == 1 when o is false | +| test.cpp:411:8:411:8 | o | o != 0 when o is true | +| test.cpp:411:8:411:8 | o | o != 1 when o is false | +| test.cpp:411:8:411:8 | o | o == 0 when o is false | +| test.cpp:411:8:411:8 | o | o == 1 when o is true | diff --git a/cpp/ql/test/library-tests/controlflow/guards/GuardsControl.expected b/cpp/ql/test/library-tests/controlflow/guards/GuardsControl.expected index e9ef52f709d..d00a6012ef4 100644 --- a/cpp/ql/test/library-tests/controlflow/guards/GuardsControl.expected +++ b/cpp/ql/test/library-tests/controlflow/guards/GuardsControl.expected @@ -338,3 +338,85 @@ | test.cpp:330:7:330:7 | b | true | test.cpp:331:3:332:10 | { ... } | | test.cpp:334:11:334:11 | x | Lower bound 40 | test.cpp:336:3:338:7 | case ...: | | test.cpp:334:11:334:11 | x | Upper bound 50 | test.cpp:336:3:338:7 | case ...: | +| test.cpp:348:25:348:25 | y | not null | test.cpp:349:29:349:30 | 42 | +| test.cpp:348:25:348:25 | y | not null | test.cpp:350:15:351:7 | { ... } | +| test.cpp:348:25:348:25 | y | null | test.cpp:349:34:349:34 | 0 | +| test.cpp:349:11:349:22 | call to testNotNull1 | false | test.cpp:349:34:349:34 | 0 | +| test.cpp:349:11:349:22 | call to testNotNull1 | true | test.cpp:349:29:349:30 | 42 | +| test.cpp:349:11:349:22 | call to testNotNull1 | true | test.cpp:350:15:351:7 | { ... } | +| test.cpp:349:11:349:34 | ... ? ... : ... | not 0 | test.cpp:350:15:351:7 | { ... } | +| test.cpp:349:24:349:24 | y | not null | test.cpp:349:29:349:30 | 42 | +| test.cpp:349:24:349:24 | y | not null | test.cpp:350:15:351:7 | { ... } | +| test.cpp:349:24:349:24 | y | null | test.cpp:349:34:349:34 | 0 | +| test.cpp:349:29:349:30 | 42 | not 0 | test.cpp:350:15:351:7 | { ... } | +| test.cpp:350:7:350:7 | x | not 0 | test.cpp:350:15:351:7 | { ... } | +| test.cpp:350:7:350:12 | ... != ... | true | test.cpp:350:15:351:7 | { ... } | +| test.cpp:355:25:355:29 | input | not null | test.cpp:357:3:357:13 | return ... | +| test.cpp:355:25:355:29 | input | null | test.cpp:356:25:356:36 | return ... | +| test.cpp:356:7:356:11 | input | not null | test.cpp:357:3:357:13 | return ... | +| test.cpp:356:7:356:11 | input | null | test.cpp:356:25:356:36 | return ... | +| test.cpp:356:7:356:22 | ... == ... | false | test.cpp:357:3:357:13 | return ... | +| test.cpp:356:7:356:22 | ... == ... | true | test.cpp:356:25:356:36 | return ... | +| test.cpp:360:26:360:31 | number | not null | test.cpp:361:35:361:40 | number | +| test.cpp:360:26:360:31 | number | null | test.cpp:361:30:361:30 | 0 | +| test.cpp:361:10:361:15 | number | not null | test.cpp:361:35:361:40 | number | +| test.cpp:361:10:361:15 | number | null | test.cpp:361:30:361:30 | 0 | +| test.cpp:361:10:361:26 | ... == ... | false | test.cpp:361:35:361:40 | number | +| test.cpp:361:10:361:26 | ... == ... | true | test.cpp:361:30:361:30 | 0 | +| test.cpp:364:33:364:34 | s1 | not null | test.cpp:365:15:365:16 | s2 | +| test.cpp:364:33:364:34 | s1 | not null | test.cpp:366:3:366:12 | return ... | +| test.cpp:364:43:364:44 | s2 | not null | test.cpp:366:3:366:12 | return ... | +| test.cpp:365:7:365:9 | ! ... | false | test.cpp:365:15:365:16 | s2 | +| test.cpp:365:7:365:9 | ! ... | false | test.cpp:366:3:366:12 | return ... | +| test.cpp:365:7:365:16 | ... \|\| ... | false | test.cpp:366:3:366:12 | return ... | +| test.cpp:365:8:365:9 | s1 | not null | test.cpp:365:15:365:16 | s2 | +| test.cpp:365:8:365:9 | s1 | not null | test.cpp:366:3:366:12 | return ... | +| test.cpp:365:8:365:9 | s1 | true | test.cpp:365:15:365:16 | s2 | +| test.cpp:365:8:365:9 | s1 | true | test.cpp:366:3:366:12 | return ... | +| test.cpp:365:14:365:16 | ! ... | false | test.cpp:366:3:366:12 | return ... | +| test.cpp:365:15:365:16 | s2 | not null | test.cpp:366:3:366:12 | return ... | +| test.cpp:365:15:365:16 | s2 | true | test.cpp:366:3:366:12 | return ... | +| test.cpp:371:29:371:32 | flag | false | test.cpp:372:35:372:49 | FAILURE | +| test.cpp:371:29:371:32 | flag | true | test.cpp:372:17:372:31 | SUCCESS | +| test.cpp:372:10:372:13 | flag | false | test.cpp:372:35:372:49 | FAILURE | +| test.cpp:372:10:372:13 | flag | true | test.cpp:372:17:372:31 | SUCCESS | +| test.cpp:375:25:375:25 | p | not null | test.cpp:376:24:377:7 | { ... } | +| test.cpp:375:25:375:25 | p | null | test.cpp:378:10:379:7 | { ... } | +| test.cpp:375:33:375:33 | i | not null | test.cpp:390:10:391:7 | { ... } | +| test.cpp:375:50:375:50 | b | false | test.cpp:404:5:406:12 | case ...: | +| test.cpp:375:50:375:50 | b | true | test.cpp:401:5:403:12 | case ...: | +| test.cpp:376:7:376:18 | call to testNotNull1 | false | test.cpp:378:10:379:7 | { ... } | +| test.cpp:376:7:376:18 | call to testNotNull1 | true | test.cpp:376:24:377:7 | { ... } | +| test.cpp:376:20:376:20 | p | not null | test.cpp:376:24:377:7 | { ... } | +| test.cpp:376:20:376:20 | p | null | test.cpp:378:10:379:7 | { ... } | +| test.cpp:382:7:382:18 | call to testNotNull2 | false | test.cpp:384:10:385:7 | { ... } | +| test.cpp:382:7:382:18 | call to testNotNull2 | true | test.cpp:382:24:383:7 | { ... } | +| test.cpp:388:7:388:29 | ... == ... | false | test.cpp:390:10:391:7 | { ... } | +| test.cpp:388:7:388:29 | ... == ... | true | test.cpp:388:32:389:7 | { ... } | +| test.cpp:388:12:388:26 | call to getNumOrDefault | 0 | test.cpp:388:32:389:7 | { ... } | +| test.cpp:388:12:388:26 | call to getNumOrDefault | not 0 | test.cpp:390:10:391:7 | { ... } | +| test.cpp:388:28:388:28 | i | not null | test.cpp:390:10:391:7 | { ... } | +| test.cpp:394:7:394:47 | ... == ... | false | test.cpp:396:10:397:7 | { ... } | +| test.cpp:394:7:394:47 | ... == ... | true | test.cpp:394:50:395:7 | { ... } | +| test.cpp:394:15:394:34 | call to returnAIfNoneAreNull | 0 | test.cpp:394:50:395:7 | { ... } | +| test.cpp:394:15:394:34 | call to returnAIfNoneAreNull | not 0 | test.cpp:396:10:397:7 | { ... } | +| test.cpp:400:11:400:25 | call to testEnumWrapper | 1 | test.cpp:401:5:403:12 | case ...: | +| test.cpp:400:11:400:25 | call to testEnumWrapper | 2 | test.cpp:404:5:406:12 | case ...: | +| test.cpp:400:27:400:27 | b | false | test.cpp:404:5:406:12 | case ...: | +| test.cpp:400:27:400:27 | b | true | test.cpp:401:5:403:12 | case ...: | +| test.cpp:410:26:410:26 | o | not null | test.cpp:410:6:410:18 | ensureNotNull | +| test.cpp:410:26:410:26 | o | not null | test.cpp:412:1:412:1 | return ... | +| test.cpp:410:26:410:26 | o | null | test.cpp:410:6:410:18 | ensureNotNull | +| test.cpp:410:26:410:26 | o | null | test.cpp:411:11:411:18 | ExprStmt | +| test.cpp:411:7:411:8 | ! ... | false | test.cpp:410:6:410:18 | ensureNotNull | +| test.cpp:411:7:411:8 | ! ... | false | test.cpp:412:1:412:1 | return ... | +| test.cpp:411:7:411:8 | ! ... | true | test.cpp:410:6:410:18 | ensureNotNull | +| test.cpp:411:7:411:8 | ! ... | true | test.cpp:411:11:411:18 | ExprStmt | +| test.cpp:411:8:411:8 | o | false | test.cpp:410:6:410:18 | ensureNotNull | +| test.cpp:411:8:411:8 | o | false | test.cpp:411:11:411:18 | ExprStmt | +| test.cpp:411:8:411:8 | o | not null | test.cpp:410:6:410:18 | ensureNotNull | +| test.cpp:411:8:411:8 | o | not null | test.cpp:412:1:412:1 | return ... | +| test.cpp:411:8:411:8 | o | null | test.cpp:410:6:410:18 | ensureNotNull | +| test.cpp:411:8:411:8 | o | null | test.cpp:411:11:411:18 | ExprStmt | +| test.cpp:411:8:411:8 | o | true | test.cpp:410:6:410:18 | ensureNotNull | +| test.cpp:411:8:411:8 | o | true | test.cpp:412:1:412:1 | return ... | diff --git a/cpp/ql/test/library-tests/controlflow/guards/GuardsEnsure.expected b/cpp/ql/test/library-tests/controlflow/guards/GuardsEnsure.expected index 1f0b1197230..0de63fa505b 100644 --- a/cpp/ql/test/library-tests/controlflow/guards/GuardsEnsure.expected +++ b/cpp/ql/test/library-tests/controlflow/guards/GuardsEnsure.expected @@ -483,6 +483,24 @@ binary | test.cpp:318:6:318:18 | ... != ... | test.cpp:318:11:318:12 | 42 | >= | test.cpp:318:7:318:7 | a | 1 | test.cpp:318:21:320:3 | { ... } | | test.cpp:318:6:318:18 | ... != ... | test.cpp:318:18:318:18 | 0 | != | test.cpp:318:7:318:12 | ... < ... | 0 | test.cpp:318:21:320:3 | { ... } | | test.cpp:318:6:318:18 | ... != ... | test.cpp:318:18:318:18 | 0 | == | test.cpp:318:7:318:12 | ... < ... | 0 | test.cpp:320:10:322:3 | { ... } | +| test.cpp:350:7:350:12 | ... != ... | test.cpp:350:7:350:7 | x | != | test.cpp:350:12:350:12 | 0 | 0 | test.cpp:350:15:351:7 | { ... } | +| test.cpp:350:7:350:12 | ... != ... | test.cpp:350:12:350:12 | 0 | != | test.cpp:350:7:350:7 | x | 0 | test.cpp:350:15:351:7 | { ... } | +| test.cpp:356:7:356:22 | ... == ... | test.cpp:356:7:356:11 | input | != | test.cpp:356:16:356:22 | 0 | 0 | test.cpp:357:3:357:13 | return ... | +| test.cpp:356:7:356:22 | ... == ... | test.cpp:356:7:356:11 | input | == | test.cpp:356:16:356:22 | 0 | 0 | test.cpp:356:25:356:36 | return ... | +| test.cpp:356:7:356:22 | ... == ... | test.cpp:356:16:356:22 | 0 | != | test.cpp:356:7:356:11 | input | 0 | test.cpp:357:3:357:13 | return ... | +| test.cpp:356:7:356:22 | ... == ... | test.cpp:356:16:356:22 | 0 | == | test.cpp:356:7:356:11 | input | 0 | test.cpp:356:25:356:36 | return ... | +| test.cpp:361:10:361:26 | ... == ... | test.cpp:361:10:361:15 | number | != | test.cpp:361:20:361:26 | 0 | 0 | test.cpp:361:35:361:40 | number | +| test.cpp:361:10:361:26 | ... == ... | test.cpp:361:10:361:15 | number | == | test.cpp:361:20:361:26 | 0 | 0 | test.cpp:361:30:361:30 | 0 | +| test.cpp:361:10:361:26 | ... == ... | test.cpp:361:20:361:26 | 0 | != | test.cpp:361:10:361:15 | number | 0 | test.cpp:361:35:361:40 | number | +| test.cpp:361:10:361:26 | ... == ... | test.cpp:361:20:361:26 | 0 | == | test.cpp:361:10:361:15 | number | 0 | test.cpp:361:30:361:30 | 0 | +| test.cpp:388:7:388:29 | ... == ... | test.cpp:388:7:388:7 | 0 | != | test.cpp:388:12:388:26 | call to getNumOrDefault | 0 | test.cpp:390:10:391:7 | { ... } | +| test.cpp:388:7:388:29 | ... == ... | test.cpp:388:7:388:7 | 0 | == | test.cpp:388:12:388:26 | call to getNumOrDefault | 0 | test.cpp:388:32:389:7 | { ... } | +| test.cpp:388:7:388:29 | ... == ... | test.cpp:388:12:388:26 | call to getNumOrDefault | != | test.cpp:388:7:388:7 | 0 | 0 | test.cpp:390:10:391:7 | { ... } | +| test.cpp:388:7:388:29 | ... == ... | test.cpp:388:12:388:26 | call to getNumOrDefault | == | test.cpp:388:7:388:7 | 0 | 0 | test.cpp:388:32:389:7 | { ... } | +| test.cpp:394:7:394:47 | ... == ... | test.cpp:394:7:394:10 | 0 | != | test.cpp:394:15:394:34 | call to returnAIfNoneAreNull | 0 | test.cpp:396:10:397:7 | { ... } | +| test.cpp:394:7:394:47 | ... == ... | test.cpp:394:7:394:10 | 0 | == | test.cpp:394:15:394:34 | call to returnAIfNoneAreNull | 0 | test.cpp:394:50:395:7 | { ... } | +| test.cpp:394:7:394:47 | ... == ... | test.cpp:394:15:394:34 | call to returnAIfNoneAreNull | != | test.cpp:394:7:394:10 | 0 | 0 | test.cpp:396:10:397:7 | { ... } | +| test.cpp:394:7:394:47 | ... == ... | test.cpp:394:15:394:34 | call to returnAIfNoneAreNull | == | test.cpp:394:7:394:10 | 0 | 0 | test.cpp:394:50:395:7 | { ... } | unary | test.c:7:9:7:13 | ... > ... | test.c:7:9:7:9 | x | < | 1 | test.c:10:12:11:14 | { ... } | | test.c:7:9:7:13 | ... > ... | test.c:7:9:7:9 | x | >= | 1 | test.c:7:16:9:14 | { ... } | @@ -1300,3 +1318,118 @@ unary | test.cpp:330:7:330:7 | b | test.cpp:330:7:330:7 | b | == | 1 | test.cpp:331:3:332:10 | { ... } | | test.cpp:334:11:334:11 | x | test.cpp:334:11:334:11 | x | < | 51 | test.cpp:336:3:338:7 | case ...: | | test.cpp:334:11:334:11 | x | test.cpp:334:11:334:11 | x | >= | 40 | test.cpp:336:3:338:7 | case ...: | +| test.cpp:349:11:349:22 | call to testNotNull1 | test.cpp:349:11:349:22 | call to testNotNull1 | != | 0 | test.cpp:349:29:349:30 | 42 | +| test.cpp:349:11:349:22 | call to testNotNull1 | test.cpp:349:11:349:22 | call to testNotNull1 | != | 0 | test.cpp:350:15:351:7 | { ... } | +| test.cpp:349:11:349:22 | call to testNotNull1 | test.cpp:349:11:349:22 | call to testNotNull1 | != | 1 | test.cpp:349:34:349:34 | 0 | +| test.cpp:349:11:349:22 | call to testNotNull1 | test.cpp:349:11:349:22 | call to testNotNull1 | == | 0 | test.cpp:349:34:349:34 | 0 | +| test.cpp:349:11:349:22 | call to testNotNull1 | test.cpp:349:11:349:22 | call to testNotNull1 | == | 1 | test.cpp:349:29:349:30 | 42 | +| test.cpp:349:11:349:22 | call to testNotNull1 | test.cpp:349:11:349:22 | call to testNotNull1 | == | 1 | test.cpp:350:15:351:7 | { ... } | +| test.cpp:350:7:350:12 | ... != ... | test.cpp:350:7:350:7 | x | != | 0 | test.cpp:350:15:351:7 | { ... } | +| test.cpp:350:7:350:12 | ... != ... | test.cpp:350:7:350:12 | ... != ... | != | 0 | test.cpp:350:15:351:7 | { ... } | +| test.cpp:350:7:350:12 | ... != ... | test.cpp:350:7:350:12 | ... != ... | == | 1 | test.cpp:350:15:351:7 | { ... } | +| test.cpp:356:7:356:22 | ... == ... | test.cpp:356:7:356:11 | input | != | 0 | test.cpp:357:3:357:13 | return ... | +| test.cpp:356:7:356:22 | ... == ... | test.cpp:356:7:356:11 | input | == | 0 | test.cpp:356:25:356:36 | return ... | +| test.cpp:356:7:356:22 | ... == ... | test.cpp:356:7:356:22 | ... == ... | != | 0 | test.cpp:356:25:356:36 | return ... | +| test.cpp:356:7:356:22 | ... == ... | test.cpp:356:7:356:22 | ... == ... | != | 1 | test.cpp:357:3:357:13 | return ... | +| test.cpp:356:7:356:22 | ... == ... | test.cpp:356:7:356:22 | ... == ... | == | 0 | test.cpp:357:3:357:13 | return ... | +| test.cpp:356:7:356:22 | ... == ... | test.cpp:356:7:356:22 | ... == ... | == | 1 | test.cpp:356:25:356:36 | return ... | +| test.cpp:361:10:361:26 | ... == ... | test.cpp:361:10:361:15 | number | != | 0 | test.cpp:361:35:361:40 | number | +| test.cpp:361:10:361:26 | ... == ... | test.cpp:361:10:361:15 | number | == | 0 | test.cpp:361:30:361:30 | 0 | +| test.cpp:361:10:361:26 | ... == ... | test.cpp:361:10:361:26 | ... == ... | != | 0 | test.cpp:361:30:361:30 | 0 | +| test.cpp:361:10:361:26 | ... == ... | test.cpp:361:10:361:26 | ... == ... | != | 1 | test.cpp:361:35:361:40 | number | +| test.cpp:361:10:361:26 | ... == ... | test.cpp:361:10:361:26 | ... == ... | == | 0 | test.cpp:361:35:361:40 | number | +| test.cpp:361:10:361:26 | ... == ... | test.cpp:361:10:361:26 | ... == ... | == | 1 | test.cpp:361:30:361:30 | 0 | +| test.cpp:365:7:365:9 | ! ... | test.cpp:365:7:365:9 | ! ... | != | 1 | test.cpp:365:15:365:16 | s2 | +| test.cpp:365:7:365:9 | ! ... | test.cpp:365:7:365:9 | ! ... | != | 1 | test.cpp:366:3:366:12 | return ... | +| test.cpp:365:7:365:9 | ! ... | test.cpp:365:7:365:9 | ! ... | == | 0 | test.cpp:365:15:365:16 | s2 | +| test.cpp:365:7:365:9 | ! ... | test.cpp:365:7:365:9 | ! ... | == | 0 | test.cpp:366:3:366:12 | return ... | +| test.cpp:365:7:365:9 | ! ... | test.cpp:365:8:365:9 | s1 | != | 0 | test.cpp:365:15:365:16 | s2 | +| test.cpp:365:7:365:9 | ! ... | test.cpp:365:8:365:9 | s1 | != | 0 | test.cpp:366:3:366:12 | return ... | +| test.cpp:365:7:365:9 | ! ... | test.cpp:365:8:365:9 | s1 | == | 1 | test.cpp:365:15:365:16 | s2 | +| test.cpp:365:7:365:9 | ! ... | test.cpp:365:8:365:9 | s1 | == | 1 | test.cpp:366:3:366:12 | return ... | +| test.cpp:365:7:365:16 | ... \|\| ... | test.cpp:365:7:365:9 | ! ... | != | 1 | test.cpp:366:3:366:12 | return ... | +| test.cpp:365:7:365:16 | ... \|\| ... | test.cpp:365:7:365:9 | ! ... | == | 0 | test.cpp:366:3:366:12 | return ... | +| test.cpp:365:7:365:16 | ... \|\| ... | test.cpp:365:8:365:9 | s1 | != | 0 | test.cpp:366:3:366:12 | return ... | +| test.cpp:365:7:365:16 | ... \|\| ... | test.cpp:365:8:365:9 | s1 | == | 1 | test.cpp:366:3:366:12 | return ... | +| test.cpp:365:7:365:16 | ... \|\| ... | test.cpp:365:14:365:16 | ! ... | != | 1 | test.cpp:366:3:366:12 | return ... | +| test.cpp:365:7:365:16 | ... \|\| ... | test.cpp:365:14:365:16 | ! ... | == | 0 | test.cpp:366:3:366:12 | return ... | +| test.cpp:365:7:365:16 | ... \|\| ... | test.cpp:365:15:365:16 | s2 | != | 0 | test.cpp:366:3:366:12 | return ... | +| test.cpp:365:7:365:16 | ... \|\| ... | test.cpp:365:15:365:16 | s2 | == | 1 | test.cpp:366:3:366:12 | return ... | +| test.cpp:365:8:365:9 | s1 | test.cpp:365:7:365:9 | ! ... | != | 1 | test.cpp:365:15:365:16 | s2 | +| test.cpp:365:8:365:9 | s1 | test.cpp:365:7:365:9 | ! ... | != | 1 | test.cpp:366:3:366:12 | return ... | +| test.cpp:365:8:365:9 | s1 | test.cpp:365:7:365:9 | ! ... | == | 0 | test.cpp:365:15:365:16 | s2 | +| test.cpp:365:8:365:9 | s1 | test.cpp:365:7:365:9 | ! ... | == | 0 | test.cpp:366:3:366:12 | return ... | +| test.cpp:365:8:365:9 | s1 | test.cpp:365:8:365:9 | s1 | != | 0 | test.cpp:365:15:365:16 | s2 | +| test.cpp:365:8:365:9 | s1 | test.cpp:365:8:365:9 | s1 | != | 0 | test.cpp:366:3:366:12 | return ... | +| test.cpp:365:8:365:9 | s1 | test.cpp:365:8:365:9 | s1 | == | 1 | test.cpp:365:15:365:16 | s2 | +| test.cpp:365:8:365:9 | s1 | test.cpp:365:8:365:9 | s1 | == | 1 | test.cpp:366:3:366:12 | return ... | +| test.cpp:365:14:365:16 | ! ... | test.cpp:365:14:365:16 | ! ... | != | 1 | test.cpp:366:3:366:12 | return ... | +| test.cpp:365:14:365:16 | ! ... | test.cpp:365:14:365:16 | ! ... | == | 0 | test.cpp:366:3:366:12 | return ... | +| test.cpp:365:14:365:16 | ! ... | test.cpp:365:15:365:16 | s2 | != | 0 | test.cpp:366:3:366:12 | return ... | +| test.cpp:365:14:365:16 | ! ... | test.cpp:365:15:365:16 | s2 | == | 1 | test.cpp:366:3:366:12 | return ... | +| test.cpp:365:15:365:16 | s2 | test.cpp:365:14:365:16 | ! ... | != | 1 | test.cpp:366:3:366:12 | return ... | +| test.cpp:365:15:365:16 | s2 | test.cpp:365:14:365:16 | ! ... | == | 0 | test.cpp:366:3:366:12 | return ... | +| test.cpp:365:15:365:16 | s2 | test.cpp:365:15:365:16 | s2 | != | 0 | test.cpp:366:3:366:12 | return ... | +| test.cpp:365:15:365:16 | s2 | test.cpp:365:15:365:16 | s2 | == | 1 | test.cpp:366:3:366:12 | return ... | +| test.cpp:371:29:371:32 | flag | test.cpp:372:10:372:13 | flag | != | 0 | test.cpp:372:17:372:31 | SUCCESS | +| test.cpp:371:29:371:32 | flag | test.cpp:372:10:372:13 | flag | != | 1 | test.cpp:372:35:372:49 | FAILURE | +| test.cpp:371:29:371:32 | flag | test.cpp:372:10:372:13 | flag | == | 0 | test.cpp:372:35:372:49 | FAILURE | +| test.cpp:371:29:371:32 | flag | test.cpp:372:10:372:13 | flag | == | 1 | test.cpp:372:17:372:31 | SUCCESS | +| test.cpp:372:10:372:13 | flag | test.cpp:372:10:372:13 | flag | != | 0 | test.cpp:372:17:372:31 | SUCCESS | +| test.cpp:372:10:372:13 | flag | test.cpp:372:10:372:13 | flag | != | 1 | test.cpp:372:35:372:49 | FAILURE | +| test.cpp:372:10:372:13 | flag | test.cpp:372:10:372:13 | flag | == | 0 | test.cpp:372:35:372:49 | FAILURE | +| test.cpp:372:10:372:13 | flag | test.cpp:372:10:372:13 | flag | == | 1 | test.cpp:372:17:372:31 | SUCCESS | +| test.cpp:376:7:376:18 | call to testNotNull1 | test.cpp:376:7:376:18 | call to testNotNull1 | != | 0 | test.cpp:376:24:377:7 | { ... } | +| test.cpp:376:7:376:18 | call to testNotNull1 | test.cpp:376:7:376:18 | call to testNotNull1 | != | 1 | test.cpp:378:10:379:7 | { ... } | +| test.cpp:376:7:376:18 | call to testNotNull1 | test.cpp:376:7:376:18 | call to testNotNull1 | == | 0 | test.cpp:378:10:379:7 | { ... } | +| test.cpp:376:7:376:18 | call to testNotNull1 | test.cpp:376:7:376:18 | call to testNotNull1 | == | 1 | test.cpp:376:24:377:7 | { ... } | +| test.cpp:382:7:382:18 | call to testNotNull2 | test.cpp:382:7:382:18 | call to testNotNull2 | != | 0 | test.cpp:382:24:383:7 | { ... } | +| test.cpp:382:7:382:18 | call to testNotNull2 | test.cpp:382:7:382:18 | call to testNotNull2 | != | 1 | test.cpp:384:10:385:7 | { ... } | +| test.cpp:382:7:382:18 | call to testNotNull2 | test.cpp:382:7:382:18 | call to testNotNull2 | == | 0 | test.cpp:384:10:385:7 | { ... } | +| test.cpp:382:7:382:18 | call to testNotNull2 | test.cpp:382:7:382:18 | call to testNotNull2 | == | 1 | test.cpp:382:24:383:7 | { ... } | +| test.cpp:388:7:388:29 | ... == ... | test.cpp:388:7:388:29 | ... == ... | != | 0 | test.cpp:388:32:389:7 | { ... } | +| test.cpp:388:7:388:29 | ... == ... | test.cpp:388:7:388:29 | ... == ... | != | 1 | test.cpp:390:10:391:7 | { ... } | +| test.cpp:388:7:388:29 | ... == ... | test.cpp:388:7:388:29 | ... == ... | == | 0 | test.cpp:390:10:391:7 | { ... } | +| test.cpp:388:7:388:29 | ... == ... | test.cpp:388:7:388:29 | ... == ... | == | 1 | test.cpp:388:32:389:7 | { ... } | +| test.cpp:388:7:388:29 | ... == ... | test.cpp:388:12:388:26 | call to getNumOrDefault | != | 0 | test.cpp:390:10:391:7 | { ... } | +| test.cpp:388:7:388:29 | ... == ... | test.cpp:388:12:388:26 | call to getNumOrDefault | == | 0 | test.cpp:388:32:389:7 | { ... } | +| test.cpp:394:7:394:47 | ... == ... | test.cpp:394:7:394:47 | ... == ... | != | 0 | test.cpp:394:50:395:7 | { ... } | +| test.cpp:394:7:394:47 | ... == ... | test.cpp:394:7:394:47 | ... == ... | != | 1 | test.cpp:396:10:397:7 | { ... } | +| test.cpp:394:7:394:47 | ... == ... | test.cpp:394:7:394:47 | ... == ... | == | 0 | test.cpp:396:10:397:7 | { ... } | +| test.cpp:394:7:394:47 | ... == ... | test.cpp:394:7:394:47 | ... == ... | == | 1 | test.cpp:394:50:395:7 | { ... } | +| test.cpp:394:7:394:47 | ... == ... | test.cpp:394:15:394:34 | call to returnAIfNoneAreNull | != | 0 | test.cpp:396:10:397:7 | { ... } | +| test.cpp:394:7:394:47 | ... == ... | test.cpp:394:15:394:34 | call to returnAIfNoneAreNull | == | 0 | test.cpp:394:50:395:7 | { ... } | +| test.cpp:400:11:400:25 | call to testEnumWrapper | test.cpp:400:11:400:25 | call to testEnumWrapper | == | 1 | test.cpp:401:5:403:12 | case ...: | +| test.cpp:400:11:400:25 | call to testEnumWrapper | test.cpp:400:11:400:25 | call to testEnumWrapper | == | 2 | test.cpp:404:5:406:12 | case ...: | +| test.cpp:411:7:411:8 | ! ... | test.cpp:411:7:411:8 | ! ... | != | 0 | test.cpp:410:6:410:18 | ensureNotNull | +| test.cpp:411:7:411:8 | ! ... | test.cpp:411:7:411:8 | ! ... | != | 0 | test.cpp:411:11:411:18 | ExprStmt | +| test.cpp:411:7:411:8 | ! ... | test.cpp:411:7:411:8 | ! ... | != | 1 | test.cpp:410:6:410:18 | ensureNotNull | +| test.cpp:411:7:411:8 | ! ... | test.cpp:411:7:411:8 | ! ... | != | 1 | test.cpp:412:1:412:1 | return ... | +| test.cpp:411:7:411:8 | ! ... | test.cpp:411:7:411:8 | ! ... | == | 0 | test.cpp:410:6:410:18 | ensureNotNull | +| test.cpp:411:7:411:8 | ! ... | test.cpp:411:7:411:8 | ! ... | == | 0 | test.cpp:412:1:412:1 | return ... | +| test.cpp:411:7:411:8 | ! ... | test.cpp:411:7:411:8 | ! ... | == | 1 | test.cpp:410:6:410:18 | ensureNotNull | +| test.cpp:411:7:411:8 | ! ... | test.cpp:411:7:411:8 | ! ... | == | 1 | test.cpp:411:11:411:18 | ExprStmt | +| test.cpp:411:7:411:8 | ! ... | test.cpp:411:8:411:8 | o | != | 0 | test.cpp:410:6:410:18 | ensureNotNull | +| test.cpp:411:7:411:8 | ! ... | test.cpp:411:8:411:8 | o | != | 0 | test.cpp:412:1:412:1 | return ... | +| test.cpp:411:7:411:8 | ! ... | test.cpp:411:8:411:8 | o | != | 1 | test.cpp:410:6:410:18 | ensureNotNull | +| test.cpp:411:7:411:8 | ! ... | test.cpp:411:8:411:8 | o | != | 1 | test.cpp:411:11:411:18 | ExprStmt | +| test.cpp:411:7:411:8 | ! ... | test.cpp:411:8:411:8 | o | == | 0 | test.cpp:410:6:410:18 | ensureNotNull | +| test.cpp:411:7:411:8 | ! ... | test.cpp:411:8:411:8 | o | == | 0 | test.cpp:411:11:411:18 | ExprStmt | +| test.cpp:411:7:411:8 | ! ... | test.cpp:411:8:411:8 | o | == | 1 | test.cpp:410:6:410:18 | ensureNotNull | +| test.cpp:411:7:411:8 | ! ... | test.cpp:411:8:411:8 | o | == | 1 | test.cpp:412:1:412:1 | return ... | +| test.cpp:411:8:411:8 | o | test.cpp:411:7:411:8 | ! ... | != | 0 | test.cpp:410:6:410:18 | ensureNotNull | +| test.cpp:411:8:411:8 | o | test.cpp:411:7:411:8 | ! ... | != | 0 | test.cpp:411:11:411:18 | ExprStmt | +| test.cpp:411:8:411:8 | o | test.cpp:411:7:411:8 | ! ... | != | 1 | test.cpp:410:6:410:18 | ensureNotNull | +| test.cpp:411:8:411:8 | o | test.cpp:411:7:411:8 | ! ... | != | 1 | test.cpp:412:1:412:1 | return ... | +| test.cpp:411:8:411:8 | o | test.cpp:411:7:411:8 | ! ... | == | 0 | test.cpp:410:6:410:18 | ensureNotNull | +| test.cpp:411:8:411:8 | o | test.cpp:411:7:411:8 | ! ... | == | 0 | test.cpp:412:1:412:1 | return ... | +| test.cpp:411:8:411:8 | o | test.cpp:411:7:411:8 | ! ... | == | 1 | test.cpp:410:6:410:18 | ensureNotNull | +| test.cpp:411:8:411:8 | o | test.cpp:411:7:411:8 | ! ... | == | 1 | test.cpp:411:11:411:18 | ExprStmt | +| test.cpp:411:8:411:8 | o | test.cpp:411:8:411:8 | o | != | 0 | test.cpp:410:6:410:18 | ensureNotNull | +| test.cpp:411:8:411:8 | o | test.cpp:411:8:411:8 | o | != | 0 | test.cpp:412:1:412:1 | return ... | +| test.cpp:411:8:411:8 | o | test.cpp:411:8:411:8 | o | != | 1 | test.cpp:410:6:410:18 | ensureNotNull | +| test.cpp:411:8:411:8 | o | test.cpp:411:8:411:8 | o | != | 1 | test.cpp:411:11:411:18 | ExprStmt | +| test.cpp:411:8:411:8 | o | test.cpp:411:8:411:8 | o | == | 0 | test.cpp:410:6:410:18 | ensureNotNull | +| test.cpp:411:8:411:8 | o | test.cpp:411:8:411:8 | o | == | 0 | test.cpp:411:11:411:18 | ExprStmt | +| test.cpp:411:8:411:8 | o | test.cpp:411:8:411:8 | o | == | 1 | test.cpp:410:6:410:18 | ensureNotNull | +| test.cpp:411:8:411:8 | o | test.cpp:411:8:411:8 | o | == | 1 | test.cpp:412:1:412:1 | return ... | diff --git a/cpp/ql/test/library-tests/controlflow/guards/GuardsInline.expected b/cpp/ql/test/library-tests/controlflow/guards/GuardsInline.expected new file mode 100644 index 00000000000..8beb8bb2b15 --- /dev/null +++ b/cpp/ql/test/library-tests/controlflow/guards/GuardsInline.expected @@ -0,0 +1,27 @@ +| test.cpp:351:5:351:7 | Call: call to chk | '42:not 0' | +| test.cpp:351:5:351:7 | Call: call to chk | '... ? ... : ...:not 0' | +| test.cpp:351:5:351:7 | Call: call to chk | 'call to testNotNull1:true' | +| test.cpp:351:5:351:7 | Call: call to chk | 'x != 0:true' | +| test.cpp:351:5:351:7 | Call: call to chk | 'x:not 0' | +| test.cpp:351:5:351:7 | Call: call to chk | 'y:not null' | +| test.cpp:377:5:377:7 | Call: call to chk | 'call to testNotNull1:true' | +| test.cpp:377:5:377:7 | Call: call to chk | 'p:not null' | +| test.cpp:379:5:379:7 | Call: call to chk | 'call to testNotNull1:false' | +| test.cpp:379:5:379:7 | Call: call to chk | p:null | +| test.cpp:383:5:383:7 | Call: call to chk | 'call to testNotNull2:true' | +| test.cpp:385:5:385:7 | Call: call to chk | 'call to testNotNull2:false' | +| test.cpp:389:5:389:7 | Call: call to chk | '0 == call to getNumOrDefault:true' | +| test.cpp:389:5:389:7 | Call: call to chk | 'call to getNumOrDefault:0' | +| test.cpp:391:5:391:7 | Call: call to chk | '0 == call to getNumOrDefault:false' | +| test.cpp:391:5:391:7 | Call: call to chk | 'call to getNumOrDefault:not 0' | +| test.cpp:391:5:391:7 | Call: call to chk | 'i:not null' | +| test.cpp:395:5:395:7 | Call: call to chk | '0 == call to returnAIfNoneAreNull:true' | +| test.cpp:395:5:395:7 | Call: call to chk | 'call to returnAIfNoneAreNull:0' | +| test.cpp:397:5:397:7 | Call: call to chk | '0 == call to returnAIfNoneAreNull:false' | +| test.cpp:397:5:397:7 | Call: call to chk | 'call to returnAIfNoneAreNull:not 0' | +| test.cpp:402:7:402:9 | Call: call to chk | 'call to testEnumWrapper:1' | +| test.cpp:402:7:402:9 | Call: call to chk | 'call to testEnumWrapper=SUCCESS:true' | +| test.cpp:402:7:402:9 | Call: call to chk | b:true | +| test.cpp:405:7:405:9 | Call: call to chk | 'call to testEnumWrapper:2' | +| test.cpp:405:7:405:9 | Call: call to chk | 'call to testEnumWrapper=FAILURE:true' | +| test.cpp:405:7:405:9 | Call: call to chk | b:false | diff --git a/cpp/ql/test/library-tests/controlflow/guards/GuardsInline.ql b/cpp/ql/test/library-tests/controlflow/guards/GuardsInline.ql new file mode 100644 index 00000000000..a6875080d37 --- /dev/null +++ b/cpp/ql/test/library-tests/controlflow/guards/GuardsInline.ql @@ -0,0 +1,44 @@ +import cpp +import semmle.code.cpp.controlflow.Guards +import codeql.util.Boolean + +bindingset[s] +string escape(string s) { if s.matches("% %") then result = "'" + s + "'" else result = s } + +Expr getUnconverted(Element e) { + not e instanceof Expr and + result = e + or + result = e.(Expr).getUnconverted() +} + +string ppGuard(IRGuardCondition g, GuardValue val) { + exists(BinaryOperation bin | + bin = getUnconverted(g.getAst()) and + result = + bin.getLeftOperand() + " " + bin.getOperator() + " " + bin.getRightOperand() + ":" + val + ) + or + exists(SwitchCase cc, Expr s, string value | + cc = g.getAst() and + cc.getExpr() = s and + result = cc.getSwitchStmt().getExpr() + "=" + value + ":" + val + | + value = cc.getExpr().toString() + or + cc.isDefault() and value = "default" + ) +} + +query predicate guarded(CallInstruction c, string guard) { + c.getStaticCallTarget().hasName("chk") and + exists(IRGuardCondition g, IRBlock bb, GuardValue val | + g.valueControls(bb, val) and + c.getBlock() = bb + | + guard = escape(ppGuard(g, val)) + or + not exists(ppGuard(g, val)) and + guard = escape(getUnconverted(g.getAst()).toString() + ":" + val) + ) +} diff --git a/cpp/ql/test/library-tests/controlflow/guards/GuardsInline.qlref b/cpp/ql/test/library-tests/controlflow/guards/GuardsInline.qlref new file mode 100644 index 00000000000..5a66d6da1a0 --- /dev/null +++ b/cpp/ql/test/library-tests/controlflow/guards/GuardsInline.qlref @@ -0,0 +1,2 @@ +query: GuardsInline.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql \ No newline at end of file diff --git a/cpp/ql/test/library-tests/controlflow/guards/test.cpp b/cpp/ql/test/library-tests/controlflow/guards/test.cpp index bb0fe83c7c7..49772506351 100644 --- a/cpp/ql/test/library-tests/controlflow/guards/test.cpp +++ b/cpp/ql/test/library-tests/controlflow/guards/test.cpp @@ -337,4 +337,82 @@ void test_constant_value_and_case_range(bool b) // should not be guarded by `foo() = 40..50` use(x); } -} \ No newline at end of file +} + +void chk(); + +bool testNotNull1(void* input) { + return input != nullptr; +} + +void test_ternary(void* y) { + int x = testNotNull1(y) ? 42 : 0; + if (x != 0) { + chk(); // $ guarded='... ? ... : ...:not 0' guarded='42:not 0' guarded='call to testNotNull1:true' guarded='x != 0:true' guarded='x:not 0' guarded='y:not null' + } +} + +bool testNotNull2(void* input) { + if (input == nullptr) return false; + return true; +} + +int getNumOrDefault(int* number) { + return number == nullptr ? 0 : *number; +} + +char returnAIfNoneAreNull(char* s1, char* s2) { + if (!s1 || !s2) return '\0'; + return 'a'; +} + +enum class Status { SUCCESS = 1, FAILURE = 2 }; + +Status testEnumWrapper(bool flag) { + return flag ? Status::SUCCESS : Status::FAILURE; +} + +void testWrappers(void* p, int* i, char* s, bool b) { + if (testNotNull1(p)) { + chk(); // $ guarded='p:not null' guarded='call to testNotNull1:true' + } else { + chk(); // $ guarded=p:null guarded='call to testNotNull1:false' + } + + if (testNotNull2(p)) { + chk(); // $ guarded='call to testNotNull2:true' MISSING: guarded='p:not null' + } else { + chk(); // $ guarded='call to testNotNull2:false' + } + + if (0 == getNumOrDefault(i)) { + chk(); // $ guarded='0 == call to getNumOrDefault:true' guarded='call to getNumOrDefault:0' + } else { + chk(); // $ guarded='0 == call to getNumOrDefault:false' guarded='call to getNumOrDefault:not 0' guarded='i:not null' + } + + if ('\0' == returnAIfNoneAreNull(s, "suffix")) { + chk(); // $ guarded='0 == call to returnAIfNoneAreNull:true' guarded='call to returnAIfNoneAreNull:0' + } else { + chk(); // $ guarded='0 == call to returnAIfNoneAreNull:false' guarded='call to returnAIfNoneAreNull:not 0' MISSING: guarded='s:not null' + } + + switch (testEnumWrapper(b)) { + case Status::SUCCESS: + chk(); // $ guarded='call to testEnumWrapper=SUCCESS:true' guarded='call to testEnumWrapper:1' guarded=b:true + break; + case Status::FAILURE: + chk(); // $ guarded='call to testEnumWrapper=FAILURE:true' guarded='call to testEnumWrapper:2' guarded=b:false + break; + } +} + +void ensureNotNull(void* o) { + if (!o) throw 42; +} + +void testExceptionWrapper(void* s) { + chk(); // nothing guards here + ensureNotNull(s); + chk(); // $ MISSING: guarded='call to ensureNotNull:no exception' guarded='s:not null' +}