Adapt ancillary analyses to record patterns

This commit is contained in:
Chris Smowton
2023-11-01 18:21:11 +00:00
parent daccd04087
commit 936c0206ea
4 changed files with 5 additions and 5 deletions

View File

@@ -80,9 +80,9 @@ predicate depends(RefType t, RefType dep) {
usesType(ioe.getCheckedType(), dep)
)
or
// the type accessed in a pattern-switch case statement in `t`.
// A type accessed in a pattern-switch case statement in `t`.
exists(PatternCase pc | t = pc.getEnclosingCallable().getDeclaringType() |
usesType(pc.getPattern().getType(), dep)
usesType(pc.getPattern().getAChildExpr*().getType(), dep)
)
)
}

View File

@@ -105,7 +105,7 @@ predicate numDepends(RefType t, RefType dep, int value) {
or
// the type accessed in a pattern-switch case statement in `t`.
exists(PatternCase pc | elem = pc and t = pc.getEnclosingCallable().getDeclaringType() |
usesType(pc.getDecl().getType(), dep)
usesType(pc.getPattern().getAChildExpr*().getType(), dep)
)
)
}

View File

@@ -180,7 +180,7 @@ private predicate switchCaseControls(SwitchCase sc, BasicBlock bb) {
selector = sc.getSelectorExpr() and
(
if sc instanceof PatternCase
then caseblock.getFirstNode() = sc.(PatternCase).getPattern().getControlFlowNode()
then caseblock.getANode() = sc.(PatternCase).getPattern().getControlFlowNode()
else (
caseblock.getFirstNode() = sc.getControlFlowNode() and
// Check there is no fall-through edge from a previous case:

View File

@@ -82,7 +82,7 @@ private predicate step(Node n1, Node n2) {
)
or
exists(PatternCase pc |
pc.getPattern() = def.(BaseSsaUpdate).getDefiningExpr() and
pc.getPattern().asBindingPattern() = def.(BaseSsaUpdate).getDefiningExpr() and
(
pc.getSwitch().getExpr() = n1.asExpr()
or