| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,23 +1,17 @@ | |||
| 1 | 1 | private import cpp | |
| 2 | 2 | private import semmle.code.cpp.commons.Scanf | |
| 3 | + private import semmle.code.cpp.controlflow.IRGuards | ||
| 4 | + private import semmle.code.cpp.ir.ValueNumbering | ||
| 3 | 5 | ||
| 4 | 6 | private predicate exprInBooleanContext(Expr e) { | |
| 5 | - e.getParent() instanceof BinaryLogicalOperation | ||
| 6 | - or | ||
| 7 | - e.getParent() instanceof UnaryLogicalOperation | ||
| 8 | - or | ||
| 9 | - e = any(IfStmt ifStmt).getCondition() | ||
| 10 | - or | ||
| 11 | - e = any(WhileStmt whileStmt).getCondition() | ||
| 12 | - or | ||
| 13 | - exists(EqualityOperation eqOp, Expr other | | ||
| 14 | - eqOp.hasOperands(e, other) and | ||
| 15 | - other.getValue() = "0" | ||
| 16 | - ) | ||
| 17 | - or | ||
| 18 | - exists(Variable v | | ||
| 19 | - v.getAnAssignedValue() = e and | ||
| 20 | - forex(Expr use | use = v.getAnAccess() | exprInBooleanContext(use)) | ||
| 7 | + exists(IRGuardCondition gc | | ||
| 8 | + exists(Instruction i, ConstantInstruction zero | | ||
| 9 | + zero.getValue() = "0" and | ||
| 10 | + i.getUnconvertedResultExpression() = e and | ||
| 11 | + gc.comparesEq(valueNumber(i).getAUse(), zero.getAUse(), 0, _, _) | ||
| 12 | + ) | ||
| 13 | + or | ||
| 14 | + gc.getUnconvertedResultExpression() = e | ||
| 21 | 15 | ) | |
| 22 | 16 | } | |
| 23 | 17 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments