mirror of
https://github.com/github/codeql.git
synced 2026-05-03 20:58:03 +02:00
C++: Fix BinaryLogicalOperators always being guards
This commit is contained in:
@@ -10,12 +10,13 @@ class GuardCondition extends Expr {
|
||||
exists(IRGuardCondition ir | this = ir.getUnconvertedResultExpression())
|
||||
or
|
||||
// no binary operators in the IR
|
||||
exists(Instruction ir |
|
||||
this.(BinaryLogicalOperation).getAnOperand().getFullyConverted() = ir.getAST()
|
||||
exists(GuardCondition gc |
|
||||
this.(BinaryLogicalOperation).getAnOperand()= gc
|
||||
)
|
||||
or
|
||||
// the IR short-circuits if(!x)
|
||||
(
|
||||
// don't produce a guard condition for `y = !x` and other non-short-circuited cases
|
||||
not exists (Instruction inst | this.getFullyConverted() = inst.getAST()) and
|
||||
exists(IRGuardCondition ir | this.(NotExpr).getOperand() = ir.getAST())
|
||||
)
|
||||
|
||||
@@ -27,6 +27,9 @@
|
||||
| test.c:138:9:138:9 | i |
|
||||
| test.c:146:7:146:8 | ! ... |
|
||||
| test.c:146:8:146:8 | x |
|
||||
| test.c:152:10:152:10 | x |
|
||||
| test.c:152:10:152:15 | ... && ... |
|
||||
| test.c:152:15:152:15 | y |
|
||||
| test.cpp:18:8:18:10 | call to get |
|
||||
| test.cpp:31:7:31:13 | ... == ... |
|
||||
| test.cpp:42:13:42:20 | call to getABool |
|
||||
|
||||
@@ -82,6 +82,10 @@
|
||||
| test.c:138:9:138:9 | i | true | 138 | 139 |
|
||||
| test.c:146:7:146:8 | ! ... | true | 146 | 147 |
|
||||
| test.c:146:8:146:8 | x | false | 146 | 147 |
|
||||
| test.c:152:10:152:10 | x | true | 151 | 152 |
|
||||
| test.c:152:10:152:10 | x | true | 152 | 152 |
|
||||
| test.c:152:10:152:15 | ... && ... | true | 151 | 152 |
|
||||
| test.c:152:15:152:15 | y | true | 151 | 152 |
|
||||
| test.cpp:18:8:18:10 | call to get | true | 19 | 19 |
|
||||
| test.cpp:31:7:31:13 | ... == ... | false | 30 | 30 |
|
||||
| test.cpp:31:7:31:13 | ... == ... | false | 34 | 34 |
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
| test.c:137:7:137:7 | 0 |
|
||||
| test.c:138:9:138:9 | i |
|
||||
| test.c:146:8:146:8 | x |
|
||||
| test.c:152:10:152:10 | x |
|
||||
| test.c:152:15:152:15 | y |
|
||||
| test.cpp:18:8:18:12 | (bool)... |
|
||||
| test.cpp:31:7:31:13 | ... == ... |
|
||||
| test.cpp:42:13:42:20 | call to getABool |
|
||||
|
||||
@@ -78,6 +78,8 @@
|
||||
| test.c:137:7:137:7 | 0 | true | 139 | 139 |
|
||||
| test.c:138:9:138:9 | i | true | 139 | 139 |
|
||||
| test.c:146:8:146:8 | x | false | 147 | 147 |
|
||||
| test.c:152:10:152:10 | x | true | 152 | 152 |
|
||||
| test.c:152:15:152:15 | y | true | 152 | 152 |
|
||||
| test.cpp:18:8:18:12 | (bool)... | true | 0 | 0 |
|
||||
| test.cpp:31:7:31:13 | ... == ... | false | 34 | 34 |
|
||||
| test.cpp:31:7:31:13 | ... == ... | true | 30 | 30 |
|
||||
|
||||
@@ -147,3 +147,8 @@ void test5(int x) {
|
||||
test3();
|
||||
}
|
||||
}
|
||||
|
||||
void test6(int x, int y) {
|
||||
return x && y;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user