@@ -8,7 +8,6 @@ private import codeql.util.Boolean
88private import codeql.dataflow.DataFlow
99private import codeql.dataflow.internal.DataFlowImpl
1010private import rust
11- private import codeql.rust.elements.Call
1211private import SsaImpl as SsaImpl
1312private import codeql.rust.controlflow.internal.Scope as Scope
1413private import codeql.rust.internal.PathResolution
@@ -57,7 +56,7 @@ final class DataFlowCallable extends TDataFlowCallable {
5756}
5857
5958final class DataFlowCall extends TDataFlowCall {
60- /** Gets the underlying call in the CFG , if any. */
59+ /** Gets the underlying call, if any. */
6160 Call asCall ( ) { this = TCall ( result ) }
6261
6362 predicate isSummaryCall (
@@ -134,16 +133,14 @@ final class ArgumentPosition extends ParameterPosition {
134133 Expr getArgument ( Call call ) {
135134 result = call .getPositionalArgument ( this .getPosition ( ) )
136135 or
137- result = call .getReceiver ( ) and this .isSelf ( )
136+ result = call .( MethodCall ) . getReceiver ( ) and this .isSelf ( )
138137 }
139138}
140139
141140/**
142141 * Holds if `arg` is an argument of `call` at the position `pos`.
143142 */
144143predicate isArgumentForCall ( Expr arg , Call call , ArgumentPosition pos ) {
145- // TODO: Handle index expressions as calls in data flow.
146- not call instanceof IndexExpr and
147144 arg = pos .getArgument ( call )
148145}
149146
@@ -293,10 +290,8 @@ predicate lambdaCreationExpr(Expr creation) {
293290 * Holds if `call` is a lambda call of kind `kind` where `receiver` is the
294291 * invoked expression.
295292 */
296- predicate lambdaCallExpr ( CallExpr call , LambdaCallKind kind , Expr receiver ) {
297- receiver = call .getFunction ( ) and
298- // All calls to complex expressions and local variable accesses are lambda call.
299- ( receiver instanceof PathExpr implies receiver = any ( Variable v ) .getAnAccess ( ) ) and
293+ predicate lambdaCallExpr ( ClosureCallExpr call , LambdaCallKind kind , Expr receiver ) {
294+ receiver = call .getClosureExpr ( ) and
300295 exists ( kind )
301296}
302297
@@ -666,10 +661,14 @@ module RustDataFlow implements InputSig<Location> {
666661
667662 pragma [ nomagic]
668663 additional predicate storeContentStep ( Node node1 , Content c , Node node2 ) {
669- exists ( CallExpr call , int pos |
670- node1 .asExpr ( ) = call .getArg ( pragma [ only_bind_into ] ( pos ) ) and
671- node2 .asExpr ( ) = call and
672- c = TTupleFieldContent ( call .getTupleField ( pragma [ only_bind_into ] ( pos ) ) )
664+ exists ( CallExpr ce , TupleField tf , int pos |
665+ node1 .asExpr ( ) = ce .getSyntacticArgument ( pos ) and
666+ node2 .asExpr ( ) = ce and
667+ c = TTupleFieldContent ( tf )
668+ |
669+ tf = ce .( TupleStructExpr ) .getTupleField ( pos )
670+ or
671+ tf = ce .( TupleVariantExpr ) .getTupleField ( pos )
673672 )
674673 or
675674 exists ( StructExpr re , string field |
@@ -715,7 +714,7 @@ module RustDataFlow implements InputSig<Location> {
715714 exists ( DataFlowCall call , int i |
716715 isArgumentNode ( node1 , call , TPositionalParameterPosition ( i ) ) and
717716 lambdaCall ( call , _, node2 .( PostUpdateNode ) .getPreUpdateNode ( ) ) and
718- c .( FunctionCallArgumentContent ) .getPosition ( ) = i
717+ c .( ClosureCallArgumentContent ) .getPosition ( ) = i
719718 )
720719 or
721720 VariableCapture:: storeStep ( node1 , c , node2 )
@@ -824,11 +823,7 @@ module RustDataFlow implements InputSig<Location> {
824823 */
825824 predicate lambdaCall ( DataFlowCall call , LambdaCallKind kind , Node receiver ) {
826825 (
827- receiver .asExpr ( ) = call .asCall ( ) .( CallExpr ) .getFunction ( ) and
828- // All calls to complex expressions and local variable accesses are lambda call.
829- exists ( Expr f | f = receiver .asExpr ( ) |
830- f instanceof PathExpr implies f = any ( Variable v ) .getAnAccess ( )
831- )
826+ receiver .asExpr ( ) = call .asCall ( ) .( ClosureCallExpr ) .getClosureExpr ( )
832827 or
833828 call .isSummaryCall ( _, receiver .( FlowSummaryNode ) .getSummaryNode ( ) )
834829 ) and
@@ -992,9 +987,7 @@ private module Cached {
992987 newtype TDataFlowCall =
993988 TCall ( Call call ) {
994989 Stages:: DataFlowStage:: ref ( ) and
995- call .hasEnclosingCfgScope ( ) and
996- // TODO: Handle index expressions as calls in data flow.
997- not call instanceof IndexExpr
990+ call .hasEnclosingCfgScope ( )
998991 } or
999992 TSummaryCall (
1000993 FlowSummaryImpl:: Public:: SummarizedCallable c , FlowSummaryImpl:: Private:: SummaryNode receiver
0 commit comments