mirror of
https://github.com/github/codeql.git
synced 2026-04-28 02:05:14 +02:00
Rename Pattern to PatternExpr to avoid clashing with Regex::Pattern
This commit is contained in:
@@ -1563,7 +1563,7 @@ class InstanceOfExpr extends Expr, @instanceofexpr {
|
||||
/**
|
||||
* Gets the pattern of an `x instanceof T pattern` expression, if any.
|
||||
*/
|
||||
Pattern getPattern() { result.isNthChildOf(this, 2) }
|
||||
PatternExpr getPattern() { result.isNthChildOf(this, 2) }
|
||||
|
||||
/**
|
||||
* Holds if this `instanceof` expression uses pattern matching.
|
||||
@@ -2559,5 +2559,5 @@ class RecordPatternExpr extends Expr, @recordpatternexpr {
|
||||
/**
|
||||
* Gets the `i`th subpattern of this record pattern.
|
||||
*/
|
||||
Pattern getSubPattern(int i) { result.isNthChildOf(this, i) }
|
||||
PatternExpr getSubPattern(int i) { result.isNthChildOf(this, i) }
|
||||
}
|
||||
|
||||
@@ -504,7 +504,7 @@ class SwitchCase extends Stmt, @case {
|
||||
*/
|
||||
class ConstCase extends SwitchCase {
|
||||
ConstCase() {
|
||||
exists(Expr e | e.getParent() = this and e.getIndex() >= 0 and not e instanceof Pattern) and
|
||||
exists(Expr e | e.getParent() = this and e.getIndex() >= 0 and not e instanceof PatternExpr) and
|
||||
// For backward compatibility, we don't include `case null, default:` here, on the assumption
|
||||
// this will come as a surprise to CodeQL that predates that statement's validity.
|
||||
not isNullDefaultCase(this)
|
||||
@@ -532,12 +532,12 @@ class ConstCase extends SwitchCase {
|
||||
*
|
||||
* Note binding patterns are represented as `LocalVariableDeclExpr`s.
|
||||
*/
|
||||
class Pattern extends Expr {
|
||||
Pattern() {
|
||||
class PatternExpr extends Expr {
|
||||
PatternExpr() {
|
||||
(
|
||||
this.getParent() instanceof SwitchCase or
|
||||
this.getParent() instanceof InstanceOfExpr or
|
||||
this.getParent() instanceof Pattern
|
||||
this.getParent() instanceof PatternExpr
|
||||
) and
|
||||
(this instanceof LocalVariableDeclExpr or this instanceof RecordPatternExpr)
|
||||
}
|
||||
@@ -555,12 +555,12 @@ class Pattern extends Expr {
|
||||
|
||||
/** A pattern case of a `switch` statement */
|
||||
class PatternCase extends SwitchCase {
|
||||
Pattern pattern;
|
||||
PatternExpr pattern;
|
||||
|
||||
PatternCase() { pattern.isNthChildOf(this, 0) }
|
||||
|
||||
/** Gets this case's pattern. */
|
||||
Pattern getPattern() { result.isNthChildOf(this, 0) }
|
||||
PatternExpr getPattern() { result = pattern }
|
||||
|
||||
/** Gets the guard applicable to this pattern case, if any. */
|
||||
Expr getGuard() { result.isNthChildOf(this, -3) }
|
||||
|
||||
@@ -267,7 +267,7 @@ predicate readStep(Node node1, ContentSet f, Node node2) {
|
||||
node2.asExpr() = get
|
||||
)
|
||||
or
|
||||
exists(RecordPatternExpr rpe, Pattern subPattern, int i |
|
||||
exists(RecordPatternExpr rpe, PatternExpr subPattern, int i |
|
||||
node1.asExpr() = rpe and
|
||||
subPattern = rpe.getSubPattern(i) and
|
||||
node2.asExpr() = subPattern and
|
||||
|
||||
@@ -204,7 +204,7 @@ private predicate simpleLocalFlowStep0(Node node1, Node node2) {
|
||||
exists(SsaExplicitUpdate upd |
|
||||
upd.getDefiningExpr().(VariableAssign).getSource() = node1.asExpr() or
|
||||
upd.getDefiningExpr().(AssignOp) = node1.asExpr() or
|
||||
upd.getDefiningExpr().(Pattern).asBindingPattern() = node1.asExpr()
|
||||
upd.getDefiningExpr().(PatternExpr).asBindingPattern() = node1.asExpr()
|
||||
|
|
||||
node2.asExpr() = upd.getAFirstUse() and
|
||||
not capturedVariableRead(node2)
|
||||
|
||||
Reference in New Issue
Block a user