C++: support impure binary operations in HashCons

This commit is contained in:
Robert Marsh
2018-08-24 17:15:28 -07:00
parent b8bd285d64
commit 77c5a8e7bf
3 changed files with 11 additions and 3 deletions

View File

@@ -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

View File

@@ -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 |

View File

@@ -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++
}