File tree Expand file tree Collapse file tree 2 files changed +19
-8
lines changed
csharp/ql/lib/semmle/code/csharp Expand file tree Collapse file tree 2 files changed +19
-8
lines changed Original file line number Diff line number Diff line change @@ -700,6 +700,8 @@ module AssignableDefinitions {
700700
701701 /**
702702 * A local variable definition in a pattern, for example `x is int i`.
703+ *
704+ * TODO: SHOULD THIS BE RENAMED OR SHOULD IT GENERALIZED TO ALL PATTERN DEFINITIONS?
703705 */
704706 class PatternDefinition extends AssignableDefinition , TPatternDefinition {
705707 TopLevelPatternDecl tlpd ;
@@ -712,8 +714,7 @@ module AssignableDefinitions {
712714 /** Gets the underlying local variable declaration. */
713715 LocalVariableDeclExpr getDeclaration ( ) { result = tlpd }
714716
715- override Expr getSource ( ) { result = this .getMatch ( ) .getExpr ( ) }
716-
717+ //override Expr getSource() { result = this.getMatch().getExpr() }
717718 override string toString ( ) { result = this .getDeclaration ( ) .toString ( ) }
718719 }
719720
Original file line number Diff line number Diff line change @@ -601,6 +601,13 @@ module LocalFlow {
601601 e2 = we
602602 )
603603 or
604+ exists ( IsExpr ie |
605+ scope = ie and
606+ isSuccessor = true and
607+ e1 = ie .getExpr ( ) and
608+ e2 = ie .getPattern ( )
609+ )
610+ or
604611 scope = any ( AssignExpr ae | ae .getLValue ( ) .( TupleExpr ) = e2 and ae .getRValue ( ) = e1 ) and
605612 isSuccessor = false
606613 or
@@ -624,9 +631,9 @@ module LocalFlow {
624631 scope = def .getExpr ( ) and
625632 isSuccessor = true
626633 or
627- scope = def . ( AssignableDefinitions :: PatternDefinition ) . getMatch ( ) . ( IsExpr ) and
628- isSuccessor = false
629- or
634+ // or
635+ // scope = def.(AssignableDefinitions::PatternDefinition).getMatch().(IsExpr) and
636+ // isSuccessor = false
630637 exists ( Switch s |
631638 s .getACase ( ) = def .( AssignableDefinitions:: PatternDefinition ) .getMatch ( ) and
632639 isSuccessor = true
@@ -639,10 +646,13 @@ module LocalFlow {
639646 or
640647 // Needed for read steps for pattern matching involving properties.
641648 scope = def .getExpr ( ) and
642- e .( VariablePatternExpr ) .getVariableDeclExpr ( ) =
643- def .( AssignableDefinitions:: LocalVariableDefinition ) .getExpr ( ) and
649+ e .( VariablePatternExpr ) .getVariableDeclExpr ( ) = def .getExpr ( ) and
644650 exactScope = false and
645- isSuccessor = false
651+ isSuccessor = false and
652+ (
653+ def instanceof AssignableDefinitions:: PatternDefinition or
654+ def instanceof AssignableDefinitions:: LocalVariableDefinition
655+ )
646656 }
647657 }
648658
You can’t perform that action at this time.
0 commit comments