-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Java: Introduce Modulus analysis. #301
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
2ac1c3a
to
1a66f7e
Compare
Added a commit including test to fix a regression relative to the ParityAnalysis when the array length is a constant. |
@@ -1,4 +1,6 @@ | |||
/** | |||
* DEPRECATED: semmle.code.java.dataflow.ModulusAnalysis instead. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing word "use" before the library name.
Ditto further below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
Fix filenames in source archives
Extract a clinit method for Kotlin files
This replaces the parity analysis with a more general modulus analysis. The basis of the analysis is the same
Bound
class as is used in the range analysis, so the inferred facts are of the form:e = b + v (mod m)
wheree
is an expression,b
is aBound
, andv
andm
are integers. The simple case of a constant congruence facte = v (mod m)
is then given byexprModulus(e, any(ZeroBound zb), v, m)
. This allows the range analysis to strengthen bounds further. As an example,for(int i = 0; i < 3*n; i+=3)
is inferred to be equivalent tofor(int i = 0; i < 3*n - 2; i+=3)
.The
gcd
predicate is currently implemented only for small numbers, but will be replaced with the built-in predicate once 1.19 is released.The PR is structured with individually reviewable commits.