Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 2.1k
Rangeanalysis: Simplify Guards integration.#19571
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -145,7 +145,7 @@ private predicate isNonFallThroughPredecessor(SwitchCase sc, ControlFlowNode pre | ||
| * Evaluating a switch case to true corresponds to taking that switch case, and | ||
| * evaluating it to false corresponds to taking some other branch. | ||
| */ | ||
| class Guard extends ExprParent { | ||
| final class Guard extends ExprParent { | ||
| Guard() { | ||
| this.(Expr).getType() instanceof BooleanType and not this instanceof BooleanLiteral | ||
| or | ||
| @@ -360,6 +360,18 @@ private predicate guardControls_v3(Guard guard, BasicBlock controlled, boolean b | ||
| ) | ||
| } | ||
| pragma[nomagic] | ||
CopilotAI | ||
| private predicate guardControlsBranchEdge_v2( | ||
| Guard guard, BasicBlock bb1, BasicBlock bb2, boolean branch | ||
| ) { | ||
| guard.hasBranchEdge(bb1, bb2, branch) | ||
| or | ||
| exists(Guard g, boolean b | | ||
| guardControlsBranchEdge_v2(g, bb1, bb2, b) and | ||
| implies_v2(g, b, guard, branch) | ||
| ) | ||
| } | ||
| pragma[nomagic] | ||
| private predicate guardControlsBranchEdge_v3( | ||
| Guard guard, BasicBlock bb1, BasicBlock bb2, boolean branch | ||
| @@ -372,6 +384,27 @@ private predicate guardControlsBranchEdge_v3( | ||
| ) | ||
| } | ||
| /** INTERNAL: Use `Guard` instead. */ | ||
| final class Guard_v2 extends Guard { | ||
| /** | ||
| * Holds if this guard evaluating to `branch` controls the control-flow | ||
| * branch edge from `bb1` to `bb2`. That is, following the edge from | ||
| * `bb1` to `bb2` implies that this guard evaluated to `branch`. | ||
| */ | ||
| predicate controlsBranchEdge(BasicBlock bb1, BasicBlock bb2, boolean branch) { | ||
| guardControlsBranchEdge_v2(this, bb1, bb2, branch) | ||
| } | ||
| /** | ||
| * Holds if this guard evaluating to `branch` directly or indirectly controls | ||
| * the block `controlled`. That is, the evaluation of `controlled` is | ||
| * dominated by this guard evaluating to `branch`. | ||
| */ | ||
| predicate controls(BasicBlock controlled, boolean branch) { | ||
| guardControls_v2(this, controlled, branch) | ||
| } | ||
| } | ||
| private predicate equalityGuard(Guard g, Expr e1, Expr e2, boolean polarity) { | ||
| exists(EqualityTest eqtest | | ||
| eqtest = g and | ||
Uh oh!
There was an error while loading. Please reload this page.
CopilotAIMay 23, 2025
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.
[nitpick] Add a brief doc comment explaining
controlsto match the JavaGuard_v2documentation and improve clarity for future maintainers.