C++: Range analysis for unsigned AssignMulExpr

This is essentially a copy-paste job of `AssignAddExpr`, together with
the math from the `UnsignedMulExpr` support.
This commit is contained in:
Jonas Jensen
2020-08-13 15:10:20 +02:00
parent f90d779122
commit fe72b559d3
4 changed files with 80 additions and 0 deletions

View File

@@ -501,6 +501,15 @@
| test.c:488:28:488:29 | ul | 10 |
| test.c:488:33:488:34 | ul | 10 |
| test.c:489:12:489:17 | result | 0 |
| test.c:495:7:495:8 | ui | 0 |
| test.c:495:19:495:20 | ui | 0 |
| test.c:496:5:496:6 | ui | 2 |
| test.c:496:11:496:12 | ui | 2 |
| test.c:497:12:497:13 | ui | 4 |
| test.c:501:3:501:9 | uiconst | 10 |
| test.c:504:3:504:9 | ulconst | 10 |
| test.c:505:10:505:16 | uiconst | 40 |
| test.c:505:20:505:26 | ulconst | 40 |
| test.cpp:10:7:10:7 | b | -2147483648 |
| test.cpp:11:5:11:5 | x | -2147483648 |
| test.cpp:13:10:13:10 | x | -2147483648 |

View File

@@ -490,3 +490,17 @@ unsigned long mult_lower_bound(unsigned int ui, unsigned long ul) {
}
return 0;
}
unsigned long mul_assign(unsigned int ui) {
if (ui <= 10 && ui >= 2) {
ui *= ui + 0;
return ui; // 4 .. 100
}
unsigned int uiconst = 10;
uiconst *= 4;
unsigned long ulconst = 10;
ulconst *= 4;
return uiconst + ulconst; // 40 .. 40 for both
}

View File

@@ -501,6 +501,15 @@
| test.c:488:28:488:29 | ul | 18446744073709552000 |
| test.c:488:33:488:34 | ul | 18446744073709552000 |
| test.c:489:12:489:17 | result | 18446744073709552000 |
| test.c:495:7:495:8 | ui | 4294967295 |
| test.c:495:19:495:20 | ui | 10 |
| test.c:496:5:496:6 | ui | 10 |
| test.c:496:11:496:12 | ui | 10 |
| test.c:497:12:497:13 | ui | 100 |
| test.c:501:3:501:9 | uiconst | 10 |
| test.c:504:3:504:9 | ulconst | 10 |
| test.c:505:10:505:16 | uiconst | 40 |
| test.c:505:20:505:26 | ulconst | 40 |
| test.cpp:10:7:10:7 | b | 2147483647 |
| test.cpp:11:5:11:5 | x | 2147483647 |
| test.cpp:13:10:13:10 | x | 2147483647 |