File tree Expand file tree Collapse file tree 6 files changed +19
-2
lines changed
src/semmle/code/cpp/controlflow
test/library-tests/controlflow/guards-ir Expand file tree Collapse file tree 6 files changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -10,12 +10,13 @@ class GuardCondition extends Expr {
1010 exists ( IRGuardCondition ir | this = ir .getUnconvertedResultExpression ( ) )
1111 or
1212 // no binary operators in the IR
13- exists ( Instruction ir |
14- this .( BinaryLogicalOperation ) .getAnOperand ( ) . getFullyConverted ( ) = ir . getAST ( )
13+ exists ( GuardCondition gc |
14+ this .( BinaryLogicalOperation ) .getAnOperand ( ) = gc
1515 )
1616 or
1717 // the IR short-circuits if(!x)
1818 (
19+ // don't produce a guard condition for `y = !x` and other non-short-circuited cases
1920 not exists ( Instruction inst | this .getFullyConverted ( ) = inst .getAST ( ) ) and
2021 exists ( IRGuardCondition ir | this .( NotExpr ) .getOperand ( ) = ir .getAST ( ) )
2122 )
Original file line number Diff line number Diff line change 2727| test.c:138:9:138:9 | i |
2828| test.c:146:7:146:8 | ! ... |
2929| test.c:146:8:146:8 | x |
30+ | test.c:152:10:152:10 | x |
31+ | test.c:152:10:152:15 | ... && ... |
32+ | test.c:152:15:152:15 | y |
3033| test.cpp:18:8:18:10 | call to get |
3134| test.cpp:31:7:31:13 | ... == ... |
3235| test.cpp:42:13:42:20 | call to getABool |
Original file line number Diff line number Diff line change 8282| test.c:138:9:138:9 | i | true | 138 | 139 |
8383| test.c:146:7:146:8 | ! ... | true | 146 | 147 |
8484| test.c:146:8:146:8 | x | false | 146 | 147 |
85+ | test.c:152:10:152:10 | x | true | 151 | 152 |
86+ | test.c:152:10:152:10 | x | true | 152 | 152 |
87+ | test.c:152:10:152:15 | ... && ... | true | 151 | 152 |
88+ | test.c:152:15:152:15 | y | true | 151 | 152 |
8589| test.cpp:18:8:18:10 | call to get | true | 19 | 19 |
8690| test.cpp:31:7:31:13 | ... == ... | false | 30 | 30 |
8791| test.cpp:31:7:31:13 | ... == ... | false | 34 | 34 |
Original file line number Diff line number Diff line change 2121| test.c:137:7:137:7 | 0 |
2222| test.c:138:9:138:9 | i |
2323| test.c:146:8:146:8 | x |
24+ | test.c:152:10:152:10 | x |
25+ | test.c:152:15:152:15 | y |
2426| test.cpp:18:8:18:12 | (bool)... |
2527| test.cpp:31:7:31:13 | ... == ... |
2628| test.cpp:42:13:42:20 | call to getABool |
Original file line number Diff line number Diff line change 7878| test.c:137:7:137:7 | 0 | true | 139 | 139 |
7979| test.c:138:9:138:9 | i | true | 139 | 139 |
8080| test.c:146:8:146:8 | x | false | 147 | 147 |
81+ | test.c:152:10:152:10 | x | true | 152 | 152 |
82+ | test.c:152:15:152:15 | y | true | 152 | 152 |
8183| test.cpp:18:8:18:12 | (bool)... | true | 0 | 0 |
8284| test.cpp:31:7:31:13 | ... == ... | false | 34 | 34 |
8385| test.cpp:31:7:31:13 | ... == ... | true | 30 | 30 |
Original file line number Diff line number Diff line change @@ -147,3 +147,8 @@ void test5(int x) {
147147 test3 ();
148148 }
149149}
150+
151+ void test6 (int x , int y ) {
152+ return x && y ;
153+ }
154+
You can’t perform that action at this time.
0 commit comments