Skip to content

Conversation

@paldepind
Copy link
Contributor

@paldepind paldepind commented Oct 24, 2025

A few inconsequential refactors that I did while working on #20645.

Going through each commit is probably easiest, as the commit descriptions have some details for most commits.

This helps for debugging.
The proposition in the true branch implied the condition, so `or` is more appropriate. Also eliminated an existentially quantified variable.
The last disjunct in `boundFromGuard` is moved into `linearBoundFromGuard`. This avoids repeating the calculation for `boundValue`.

`getBounds` and `getExprTypeBounds` are turned into predicates with result. Their middle argument was the "output" which was confusing.
@github-actions github-actions bot added the C++ label Oct 24, 2025
@paldepind paldepind marked this pull request as ready for review October 24, 2025 14:54
@paldepind paldepind requested a review from a team as a code owner October 24, 2025 14:54
Copilot AI review requested due to automatic review settings October 24, 2025 14:54
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors the simple range analysis library in C++ with improvements to code clarity, consistency, and maintainability. The changes include correcting typos in comments, simplifying conditional logic, and restructuring helper predicates.

Key Changes:

  • Simplified conditional expressions by converting if-then-else to disjunctions and using ternary operators where appropriate
  • Refactored helper predicates to use result-returning functions instead of output parameters
  • Added proper class wrapper for RelationStrictness type with string representation

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
test.c Fixed spelling errors in comments ("guardPhy" → "guardPhi", "basic" → "basic block")
SimpleRangeAnalysis.qll Refactored conditional logic, simplified predicates, and restructured bound computation helpers to improve code clarity
RangeAnalysisUtils.qll Added RelationStrictness class wrapper with toString() method and improved documentation formatting

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@paldepind paldepind added the no-change-note-required This PR does not need a change note label Oct 27, 2025
Copy link
Contributor

@geoffw0 geoffw0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes and DCA LGTM.

One question out of curiosity.

upperBoundFromGuard(guard, access, guardUB, branch) and
defUB = getFullyConvertedUpperBounds(access)
|
defUB = getFullyConvertedUpperBounds(access) and
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For what reason do you prefer and over | here?

Copy link
Contributor Author

@paldepind paldepind Oct 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my experience | is usually used for some reason. Either because there is an or afterwards or because the thing before and after are somehow different. Here there doesn't seem to be any reason, so going with the default and seems clearer :)

@paldepind paldepind merged commit 35b4a36 into github:main Oct 27, 2025
17 of 18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C++ no-change-note-required This PR does not need a change note

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants