Java: Fix RangeAnalysis/ModulusAnalysis.

This commit is contained in:
Anders Schack-Mulligen
2026-02-09 14:05:07 +01:00
parent 6fbdb2c52b
commit 1e9dcea88b
3 changed files with 38 additions and 2 deletions

View File

@@ -220,6 +220,8 @@ module Sem implements Semantic<Location> {
int getBlockId1(BasicBlock bb) { idOf(bb, result) }
string getBlockId2(BasicBlock bb) { bb.getFirstNode().getIdTag() = result }
class Guard extends G::Guards_v2::Guard {
Expr asExpr() { result = this }
}

View File

@@ -23,7 +23,9 @@ private predicate idOfAst(BB::ExprParent x, int y) = equivalenceRelation(id/2)(x
private predicate idOf(BasicBlock x, int y) { idOfAst(x.getFirstNode().getAstNode(), y) }
private int getId(BasicBlock bb) { idOf(bb, result) }
private int getId1(BasicBlock bb) { idOf(bb, result) }
private string getId2(BasicBlock bb) { bb.getFirstNode().getIdTag() = result }
/**
* Declarations to be exposed to users of SsaReadPositionCommon
@@ -39,7 +41,7 @@ module Public {
rank[r](SsaReadPositionPhiInputEdge e |
e.phiInput(phi, _)
|
e order by getId(e.getOrigBlock())
e order by getId1(e.getOrigBlock()), getId2(e.getOrigBlock())
)
}
}

View File

@@ -706,6 +706,14 @@ module Make0<LocationSig Location, AstSig<Location> Ast> {
*/
abstract AstNode getAstNode();
/**
* INTERNAL: Do not use.
*
* Gets a tag such that the pair `(getAstNode(), getIdTag())` uniquely
* identifies this node.
*/
abstract string getIdTag();
/** Gets a textual representation of this node. */
abstract string toString();
@@ -727,6 +735,8 @@ module Make0<LocationSig Location, AstSig<Location> Ast> {
override AstNode getAstNode() { result = n }
override string getIdTag() { result = "before" }
override string toString() {
if postOrInOrder(n) then result = "Before " + n.toString() else result = n.toString()
}
@@ -739,6 +749,8 @@ module Make0<LocationSig Location, AstSig<Location> Ast> {
override AstNode getAstNode() { result = n }
override string getIdTag() { result = "ast" }
override string toString() { result = n.toString() }
}
@@ -750,6 +762,12 @@ module Make0<LocationSig Location, AstSig<Location> Ast> {
override AstNode getAstNode() { result = n }
override string getIdTag() {
t.getValue() = true and result = "after-true"
or
t.getValue() = false and result = "after-false"
}
override string toString() { result = "After " + n.toString() + " [" + t.toString() + "]" }
}
@@ -760,6 +778,8 @@ module Make0<LocationSig Location, AstSig<Location> Ast> {
override AstNode getAstNode() { result = n }
override string getIdTag() { result = "after" }
override string toString() { result = "After " + n.toString() }
}
@@ -773,6 +793,8 @@ module Make0<LocationSig Location, AstSig<Location> Ast> {
NormalSuccessor getSuccessorType() { additionalNode(n, tag, result) }
override string getIdTag() { result = "add. " + tag }
override string toString() { result = tag + " " + n.toString() }
}
@@ -785,6 +807,8 @@ module Make0<LocationSig Location, AstSig<Location> Ast> {
override AstNode getAstNode() { result = c }
override string getIdTag() { result = "entry" }
override string toString() { result = "Entry" }
}
@@ -799,6 +823,12 @@ module Make0<LocationSig Location, AstSig<Location> Ast> {
override AstNode getAstNode() { result = c }
override string getIdTag() {
normal = true and result = "exit-normal"
or
normal = false and result = "exit-exc"
}
override string toString() {
normal = true and result = "Normal Exit"
or
@@ -826,6 +856,8 @@ module Make0<LocationSig Location, AstSig<Location> Ast> {
override AstNode getAstNode() { result = c }
override string getIdTag() { result = "exit" }
override string toString() { result = "Exit" }
}