C#/Java: Adjust Guards instantiations.

This commit is contained in:
Anders Schack-Mulligen
2026-05-07 13:46:52 +02:00
parent 48785a0a76
commit 072166ba88
2 changed files with 10 additions and 4 deletions

View File

@@ -85,12 +85,12 @@ private module GuardsInput implements SharedGuards::InputSig<Location, ControlFl
predicate matchEdge(BasicBlock bb1, BasicBlock bb2) {
bb1.getASuccessor(any(MatchingSuccessor s | s.getValue() = true)) = bb2 and
bb1.getLastNode() = AstNode.super.getControlFlowNode()
bb1.getLastNode() = super.getPattern().getControlFlowNode()
}
predicate nonMatchEdge(BasicBlock bb1, BasicBlock bb2) {
bb1.getASuccessor(any(MatchingSuccessor s | s.getValue() = false)) = bb2 and
bb1.getLastNode() = AstNode.super.getControlFlowNode()
bb1.getLastNode() = super.getPattern().getControlFlowNode()
}
}

View File

@@ -168,14 +168,20 @@ private module GuardsInput implements SharedGuards::InputSig<Location, ControlFl
)
}
private ControlFlowNode getPatternNode() {
result = this.(J::PatternCase).getUniquePattern().getControlFlowNode()
or
result = unique(Expr e | this.(J::ConstCase).getValue(_) = e).getControlFlowNode()
}
predicate matchEdge(BasicBlock bb1, BasicBlock bb2) {
bb1.getASuccessor(any(MatchingSuccessor s | s.getValue() = true)) = bb2 and
bb1.getLastNode() = super.getControlFlowNode()
bb1.getLastNode() = this.getPatternNode()
}
predicate nonMatchEdge(BasicBlock bb1, BasicBlock bb2) {
bb1.getASuccessor(any(MatchingSuccessor s | s.getValue() = false)) = bb2 and
bb1.getLastNode() = super.getControlFlowNode()
bb1.getLastNode() = this.getPatternNode()
}
}