|
5 | 5 | import cpp |
6 | 6 | import semmle.code.cpp.dataflow.new.TaintTracking |
7 | 7 | import semmle.code.cpp.commons.DateTime |
| 8 | +import semmle.code.cpp.valuenumbering.HashCons |
8 | 9 |
|
9 | 10 | /** |
10 | 11 | * Get the top-level `BinaryOperation` enclosing the expression e. |
@@ -63,42 +64,11 @@ Expr moduloCheckNEQ_0(NEExpr neq, int modVal) { |
63 | 64 | * Returns if the two expressions resolve to the same value, albeit it is a fuzzy attempt. |
64 | 65 | * SSA is not fit for purpose here as calls break SSA equivalence. |
65 | 66 | */ |
| 67 | +bindingset[e1,e2] |
| 68 | +pragma[inline_late] |
66 | 69 | predicate exprEq_propertyPermissive(Expr e1, Expr e2) { |
67 | 70 | not e1 = e2 and |
68 | | - ( |
69 | | - DataFlow::localFlow(DataFlow::exprNode(e1), DataFlow::exprNode(e2)) |
70 | | - or |
71 | | - if e1 instanceof ThisExpr and e2 instanceof ThisExpr |
72 | | - then any() |
73 | | - else |
74 | | - /* If it's a direct Access, check that the target is the same. */ |
75 | | - if e1 instanceof Access |
76 | | - then e1.(Access).getTarget() = e2.(Access).getTarget() |
77 | | - else |
78 | | - /* If it's a Call, compare qualifiers and only permit no-argument Calls. */ |
79 | | - if e1 instanceof Call |
80 | | - then |
81 | | - e1.(Call).getTarget() = e2.(Call).getTarget() and |
82 | | - e1.(Call).getNumberOfArguments() = 0 and |
83 | | - e2.(Call).getNumberOfArguments() = 0 and |
84 | | - if e1.(Call).hasQualifier() |
85 | | - then exprEq_propertyPermissive(e1.(Call).getQualifier(), e2.(Call).getQualifier()) |
86 | | - else any() |
87 | | - else |
88 | | - /* If it's a binaryOperation, compare op and recruse */ |
89 | | - if e1 instanceof BinaryOperation |
90 | | - then |
91 | | - e1.(BinaryOperation).getOperator() = e2.(BinaryOperation).getOperator() and |
92 | | - exprEq_propertyPermissive(e1.(BinaryOperation).getLeftOperand(), |
93 | | - e2.(BinaryOperation).getLeftOperand()) and |
94 | | - exprEq_propertyPermissive(e1.(BinaryOperation).getRightOperand(), |
95 | | - e2.(BinaryOperation).getRightOperand()) |
96 | | - else |
97 | | - // Otherwise fail (and permit the raising of a finding) |
98 | | - if e1 instanceof Literal |
99 | | - then e1.(Literal).getValue() = e2.(Literal).getValue() |
100 | | - else none() |
101 | | - ) |
| 71 | + hashCons(e1) = hashCons(e2) |
102 | 72 | } |
103 | 73 |
|
104 | 74 | /** |
|
0 commit comments