mirror of
https://github.com/github/codeql.git
synced 2026-05-05 05:35:13 +02:00
C++: support impure binary operations in HashCons
This commit is contained in:
@@ -288,7 +288,6 @@ private predicate mk_Conversion(Type t, HC child, Conversion conv) {
|
||||
}
|
||||
|
||||
private predicate analyzableBinaryOp(BinaryOperation op) {
|
||||
op.isPure() and
|
||||
strictcount (op.getLeftOperand().getFullyConverted()) = 1 and
|
||||
strictcount (op.getRightOperand().getFullyConverted()) = 1 and
|
||||
strictcount (op.getOperator()) = 1
|
||||
|
||||
@@ -63,3 +63,6 @@
|
||||
| test.cpp:141:12:141:17 | call to getInt | 141:c12-c17 141:c29-c34 |
|
||||
| test.cpp:146:10:146:11 | ih | 146:c10-c11 146:c31-c32 |
|
||||
| test.cpp:146:13:146:25 | call to getDoubledInt | 146:c13-c25 146:c34-c46 |
|
||||
| test.cpp:150:3:150:3 | x | 150:c3-c3 150:c9-c9 151:c3-c3 151:c9-c9 152:c12-c12 |
|
||||
| test.cpp:150:3:150:5 | ... ++ | 150:c3-c5 150:c9-c11 151:c3-c5 151:c9-c11 152:c10-c12 |
|
||||
| test.cpp:150:3:150:11 | ... + ... | 150:c3-c11 151:c3-c11 |
|
||||
|
||||
@@ -138,10 +138,16 @@ class IntHolder {
|
||||
|
||||
public:
|
||||
int getDoubledInt() {
|
||||
return getInt() + this->getInt();
|
||||
return getInt() + this->getInt(); // getInt() and this->getInt() should be the same
|
||||
}
|
||||
};
|
||||
|
||||
int quadrupleInt(IntHolder ih) {
|
||||
int test09(IntHolder ih) {
|
||||
return ih.getDoubledInt() + ih.getDoubledInt();
|
||||
}
|
||||
|
||||
int test10(int x) {
|
||||
x++ + x++;
|
||||
x++ + x++; // same as above
|
||||
return ++x; // ++x is not the same as x++
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user