@@ -2,9 +2,16 @@ private import unified
22private import AllDataFlow
33private import codeql.unified.internal.ExprPositions
44
5- private predicate hasPostUpdate ( Expr expr ) {
5+ private predicate hasIncomingValueAtCfgNode ( Expr expr , ControlFlowNode cfgNode ) {
6+ exists ( AstNode declOrAssignment |
7+ hasIncomingValue ( expr , declOrAssignment ) and
8+ cfgNode .injects ( declOrAssignment )
9+ )
10+ }
11+
12+ private predicate hasPostUpdate ( Expr expr , ControlFlowNode cfgNode ) {
613 exists ( MemberAccessExpr member |
7- ( hasIncomingValue ( member , _ ) or hasPostUpdate ( member ) ) and
14+ ( hasIncomingValueAtCfgNode ( member , cfgNode ) or hasPostUpdate ( member , cfgNode ) ) and
815 expr = member .getBase ( )
916 )
1017}
@@ -16,28 +23,27 @@ predicate performsVariableAccess(
1623 Expr expr , LocalVariable var , VariableRefKind kind , ControlFlowNode cfgNode
1724) {
1825 exists ( LocalVariableAccess access | var = access .getLocalVariable ( ) and expr = access |
19- hasResultValue ( access ) and kind .isRead ( ) and cfgNode .isAfter ( expr )
26+ hasResultValue ( access ) and kind .isRead ( ) and cfgNode .asExpr ( ) = expr
2027 or
21- hasIncomingValue ( access , _ ) and kind .isWrite ( ) and cfgNode . asExpr ( ) = expr // TODO: use more precise CFG node
28+ hasIncomingValueAtCfgNode ( access , cfgNode ) and kind .isWrite ( )
2229 or
23- hasPostUpdate ( access ) and kind .isPostUpdate ( ) and cfgNode . asExpr ( ) = expr // TODO: use more precise CFG node
30+ hasPostUpdate ( access , cfgNode ) and kind .isPostUpdate ( )
2431 )
2532 or
2633 exists ( UnqualifiedMemberAccess access |
2734 access .isInstanceAccess ( ) and var = access .getImplicitQualifierVariable ( ) and expr = access
2835 |
2936 kind .isRead ( ) and cfgNode .isBefore ( access )
3037 or
31- ( hasIncomingValue ( access , _) or hasPostUpdate ( access ) ) and
32- kind .isPostUpdate ( ) and
33- cfgNode .asExpr ( ) = access // TODO: use more precise CFG node
38+ ( hasIncomingValueAtCfgNode ( access , cfgNode ) or hasPostUpdate ( access , cfgNode ) ) and
39+ kind .isPostUpdate ( )
3440 )
3541}
3642
3743newtype TDataFlowNode =
3844 TValueNode ( Expr expr ) { hasResultValue ( expr ) or hasIncomingValue ( expr , _) } or
3945 TStrictlyIncomingValue ( Expr expr ) { hasResultValue ( expr ) and hasIncomingValue ( expr , _) } or
40- TExprPostUpdateNode ( Expr expr ) { hasPostUpdate ( expr ) } or
46+ TExprPostUpdateNode ( Expr expr ) { hasPostUpdate ( expr , _ ) } or
4147 TLocalVariableRefNode ( Expr expr , LocalVariable var , VariableRefKind kind ) {
4248 performsVariableAccess ( expr , var , kind , _)
4349 } or
0 commit comments