@@ -395,34 +395,27 @@ module Impl {
395395 }
396396
397397 /** Holds if `e` occurs in the LHS of an assignment or compound assignment. */
398- private predicate assignLhs ( Expr e , boolean compound ) {
399- exists ( BinaryExpr be , string op |
400- op = be .getOperatorName ( ) .regexpCapture ( "(.*)=" , 1 ) and
401- e = be .getLhs ( )
402- |
403- op = "" and compound = false
404- or
405- op != "" and compound = true
406- )
398+ private predicate assignmentExprDescendant ( Expr e ) {
399+ e = any ( AssignmentExpr ae ) .getLhs ( )
407400 or
408401 exists ( Expr mid |
409- assignLhs ( mid , compound ) and
410- getImmediateParent ( e ) = mid
402+ assignmentExprDescendant ( mid ) and
403+ getImmediateParent ( e ) = mid and
404+ not mid .( PrefixExpr ) .getOperatorName ( ) = "*"
411405 )
412406 }
413407
414408 /** A variable write. */
415409 class VariableWriteAccess extends VariableAccess {
416- VariableWriteAccess ( ) { assignLhs ( this , _ ) }
410+ VariableWriteAccess ( ) { assignmentExprDescendant ( this ) }
417411 }
418412
419413 /** A variable read. */
420414 class VariableReadAccess extends VariableAccess {
421415 VariableReadAccess ( ) {
422- not this instanceof VariableWriteAccess
423- or
424- // consider LHS in compound assignments both reads and writes
425- assignLhs ( this , true )
416+ not this instanceof VariableWriteAccess and
417+ not this = any ( RefExpr re ) .getExpr ( ) and
418+ not this = any ( CompoundAssignmentExpr cae ) .getLhs ( )
426419 }
427420 }
428421
0 commit comments