C++: Add test for extensible range analysis

This commit demonstrates that the range is too wide before custom
modeling has been added to the test.
This commit is contained in:
Jonas Jensen
2020-08-14 10:06:12 +02:00
parent bf7732ec9d
commit ee3312503e
3 changed files with 21 additions and 0 deletions

View File

@@ -0,0 +1,9 @@
/// Adds its arguments (requires custom modeling in QL)
int custom_add_function(int a, int b);
int test_extensibility_add(int x) {
if (x >= -10 && x <= 10) {
int result = custom_add_function(x, 100);
return result; // should be 90 .. 110
}
}

View File

@@ -0,0 +1,4 @@
| extensibility.c:5:7:5:7 | x | -2.147483648E9 | 2.147483647E9 |
| extensibility.c:5:19:5:19 | x | -10.0 | 2.147483647E9 |
| extensibility.c:6:38:6:38 | x | -10.0 | 10.0 |
| extensibility.c:7:12:7:17 | result | -2.147483648E9 | 2.147483647E9 |

View File

@@ -0,0 +1,8 @@
import semmle.code.cpp.rangeanalysis.SimpleRangeAnalysis
import experimental.semmle.code.cpp.models.interfaces.SimpleRangeAnalysisExpr
from VariableAccess expr, float lower, float upper
where
lower = lowerBound(expr) and
upper = upperBound(expr)
select expr, lower, upper