mirror of
https://github.com/github/codeql.git
synced 2026-04-21 15:05:56 +02:00
Adapt ancillary analyses to record patterns
This commit is contained in:
@@ -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)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user