Simplify return type of int domain comparison predicates#1962
Open
Simplify return type of int domain comparison predicates#1962
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates all integer value domains so comparison predicates (lt, gt, le, ge, eq, ne) return bool option instead of an int-domain value, simplifying domain implementations and downstream uses (eliminating most to_bool wrappers and standardizing “unknown” results).
Changes:
- Change the
IntDomainpredicate signatures tobool optionand update domain implementations accordingly. - Adapt analyses/utilities which consume comparisons (e.g., base evaluation, OOB checks) to handle
bool optiondirectly (and reintroduce[0,1]when an int result is required). - Update unit tests and property-based tests for the new predicate return type.
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/unit/cdomains/intDomainTest.ml | Adjusts assertions to expect bool option results from comparisons. |
| src/domains/intDomainProperties.ml | Updates IntegerSet-based properties to aggregate bool option predicate results and adapts validity checks. |
| src/cdomain/value/cdomains/offset.ml | Removes Idx.to_bool wrapper since Idx.eq now returns bool option. |
| src/cdomain/value/cdomains/intDomain_intf.ml | Changes predicate signatures in the int-domain interfaces to bool option. |
| src/cdomain/value/cdomains/intDomain0.ml | Updates lifted int-domain predicate plumbing to return bool option. |
| src/cdomain/value/cdomains/int/intervalSetDomain.ml | Converts comparison implementations to return bool option and simplifies boolean negation handling. |
| src/cdomain/value/cdomains/int/intervalDomain.ml | Converts interval comparisons to bool option. |
| src/cdomain/value/cdomains/int/intDomTuple.ml | Adapts tuple domain to map/merge bool option predicate results across subdomains. |
| src/cdomain/value/cdomains/int/enumsDomain.ml | Converts comparisons to bool option and updates ne accordingly. |
| src/cdomain/value/cdomains/int/defExcDomain.ml | Converts equality predicates to bool option and adjusts logical-not handling. |
| src/cdomain/value/cdomains/int/congruenceDomain.ml | Converts comparisons to bool option and updates tracing pretty-printers. |
| src/cdomain/value/cdomains/int/bitfieldDomain.ml | Converts comparisons to bool option and simplifies ne. |
| src/cdomain/value/cdomains/arrayDomain.ml | Uses bool option comparisons directly for array OOB checks. |
| src/analyses/memOutOfBounds.ml | Removes to_bool wrapper around predicate results and handles bool option directly. |
| src/analyses/baseInvariant.ml | Updates sign checks to compare predicate results directly to Some true. |
| src/analyses/base.ml | Introduces helper to convert bool option predicate results back into [0,1] int intervals where needed by expression evaluation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is like #1906 but for all the int domains.
This makes the implementations of the domains slightly nicer. But it also makes most usages of these predicates easier by not having to always use
ID.to_boolaround them.It also avoids strange inconsistencies that previously existed between the domains, where some returned an abstraction of just 0 or 1, but others returned top
int. Now this is defined once and for all in base which has the only non-to_boolusage of these comparisons.TODO