@@ -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 (
@@ -132,7 +131,7 @@ final class ParameterPosition extends TParameterPosition {
132131final class ArgumentPosition extends ParameterPosition {
133132 /** Gets the argument of `call` at this position, if any. */
134133 Expr getArgument ( Call call ) {
135- result = call .getPositionalArgument ( this .getPosition ( ) )
134+ result = call .getArgument ( this .getPosition ( ) )
136135 or
137136 result = call .getReceiver ( ) and this .isSelf ( )
138137 }
@@ -142,8 +141,6 @@ final class ArgumentPosition extends ParameterPosition {
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
@@ -664,12 +659,19 @@ module RustDataFlow implements InputSig<Location> {
664659 )
665660 }
666661
662+ pragma [ nomagic]
663+ private TupleField getCallExprTupleField ( CallExpr call , int pos ) {
664+ result = call .( TupleStructExpr ) .getStruct ( ) .getTupleField ( pos )
665+ or
666+ result = call .( TupleVariantExpr ) .getVariant ( ) .getTupleField ( pos )
667+ }
668+
667669 pragma [ nomagic]
668670 additional predicate storeContentStep ( Node node1 , Content c , Node node2 ) {
669671 exists ( CallExpr call , int pos |
670- node1 .asExpr ( ) = call .getArg ( pragma [ only_bind_into ] ( pos ) ) and
672+ node1 .asExpr ( ) = call .getArgument ( pragma [ only_bind_into ] ( pos ) ) and
671673 node2 .asExpr ( ) = call and
672- c = TTupleFieldContent ( call . getTupleField ( pragma [ only_bind_into ] ( pos ) ) )
674+ c = TTupleFieldContent ( getCallExprTupleField ( call , pragma [ only_bind_into ] ( pos ) ) )
673675 )
674676 or
675677 exists ( StructExpr re , string field |
@@ -824,11 +826,7 @@ module RustDataFlow implements InputSig<Location> {
824826 */
825827 predicate lambdaCall ( DataFlowCall call , LambdaCallKind kind , Node receiver ) {
826828 (
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- )
829+ receiver .asExpr ( ) = call .asCall ( ) .( ClosureCallExpr ) .getClosureExpr ( )
832830 or
833831 call .isSummaryCall ( _, receiver .( FlowSummaryNode ) .getSummaryNode ( ) )
834832 ) and
@@ -992,9 +990,7 @@ private module Cached {
992990 newtype TDataFlowCall =
993991 TCall ( Call call ) {
994992 Stages:: DataFlowStage:: ref ( ) and
995- call .hasEnclosingCfgScope ( ) and
996- // TODO: Handle index expressions as calls in data flow.
997- not call instanceof IndexExpr
993+ call .hasEnclosingCfgScope ( )
998994 } or
999995 TSummaryCall (
1000996 FlowSummaryImpl:: Public:: SummarizedCallable c , FlowSummaryImpl:: Private:: SummaryNode receiver
0 commit comments