Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 936c020

Browse files
committed
Adapt ancillary analyses to record patterns
1 parent daccd04 commit 936c020

4 files changed

Lines changed: 5 additions & 5 deletions

File tree

java/ql/lib/semmle/code/java/Dependency.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,9 @@ predicate depends(RefType t, RefType dep) {
8080
usesType(ioe.getCheckedType(), dep)
8181
)
8282
or
83-
// the type accessed in a pattern-switch case statement in `t`.
83+
// A type accessed in a pattern-switch case statement in `t`.
8484
exists(PatternCase pc | t = pc.getEnclosingCallable().getDeclaringType() |
85-
usesType(pc.getPattern().getType(), dep)
85+
usesType(pc.getPattern().getAChildExpr*().getType(), dep)
8686
)
8787
)
8888
}

java/ql/lib/semmle/code/java/DependencyCounts.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ predicate numDepends(RefType t, RefType dep, int value) {
105105
or
106106
// the type accessed in a pattern-switch case statement in `t`.
107107
exists(PatternCase pc | elem = pc and t = pc.getEnclosingCallable().getDeclaringType() |
108-
usesType(pc.getDecl().getType(), dep)
108+
usesType(pc.getPattern().getAChildExpr*().getType(), dep)
109109
)
110110
)
111111
}

java/ql/lib/semmle/code/java/controlflow/Guards.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ private predicate switchCaseControls(SwitchCase sc, BasicBlock bb) {
180180
selector = sc.getSelectorExpr() and
181181
(
182182
if sc instanceof PatternCase
183-
then caseblock.getFirstNode() = sc.(PatternCase).getPattern().getControlFlowNode()
183+
then caseblock.getANode() = sc.(PatternCase).getPattern().getControlFlowNode()
184184
else (
185185
caseblock.getFirstNode() = sc.getControlFlowNode() and
186186
// Check there is no fall-through edge from a previous case:

java/ql/lib/semmle/code/java/dispatch/ObjFlow.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ private predicate step(Node n1, Node n2) {
8282
)
8383
or
8484
exists(PatternCase pc |
85-
pc.getPattern() = def.(BaseSsaUpdate).getDefiningExpr() and
85+
pc.getPattern().asBindingPattern() = def.(BaseSsaUpdate).getDefiningExpr() and
8686
(
8787
pc.getSwitch().getExpr() = n1.asExpr()
8888
or

0 commit comments

Comments
 (0)