mirror of
https://github.com/github/codeql.git
synced 2026-04-30 19:26:02 +02:00
Merge pull request #2750 from Cornelius-Riemenschneider/cpp-range-analysis-casts
C++: Support implicit casts better in range analysis
This commit is contained in:
@@ -59,3 +59,6 @@
|
||||
| test.cpp:183:10:183:10 | Load: i | test.cpp:175:23:175:23 | InitializeParameter: x | -1 | true | CompareLT: ... < ... | test.cpp:182:9:182:13 | test.cpp:182:9:182:13 |
|
||||
| test.cpp:185:10:185:10 | Load: i | test.cpp:175:23:175:23 | InitializeParameter: x | 0 | true | CompareLT: ... < ... | test.cpp:176:7:176:11 | test.cpp:176:7:176:11 |
|
||||
| test.cpp:187:10:187:10 | Store: i | test.cpp:175:23:175:23 | InitializeParameter: x | 0 | false | CompareLT: ... < ... | test.cpp:182:9:182:13 | test.cpp:182:9:182:13 |
|
||||
| test.cpp:199:10:199:10 | Load: i | test.cpp:197:25:197:25 | InitializeParameter: l | -1 | true | CompareLT: ... < ... | test.cpp:198:7:198:11 | test.cpp:198:7:198:11 |
|
||||
| test.cpp:202:11:202:11 | Load: i | test.cpp:197:25:197:25 | InitializeParameter: l | -3 | true | CompareLT: ... < ... | test.cpp:201:7:201:15 | test.cpp:201:7:201:15 |
|
||||
| test.cpp:208:10:208:10 | Load: x | test.cpp:206:24:206:24 | InitializeParameter: y | -3 | true | CompareLT: ... < ... | test.cpp:207:7:207:15 | test.cpp:207:7:207:15 |
|
||||
|
||||
@@ -186,3 +186,25 @@ int test15(int i, int x) {
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
// safe integer type conversion
|
||||
int test16(int i) {
|
||||
long l;
|
||||
l = i;
|
||||
}
|
||||
|
||||
// implicit integer casts
|
||||
void test17(int i, long l) {
|
||||
if (i < l) {
|
||||
sink(i);
|
||||
}
|
||||
if (i < l - 2) {
|
||||
sink (i);
|
||||
}
|
||||
}
|
||||
|
||||
void test18(int x, int y) {
|
||||
if (x < y - 2) {
|
||||
sink(x);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user