@@ -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,7 +133,7 @@ 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
@@ -293,10 +292,8 @@ predicate lambdaCreationExpr(Expr creation) {
293292 * Holds if `call` is a lambda call of kind `kind` where `receiver` is the
294293 * invoked expression.
295294 */
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
295+ predicate lambdaCallExpr ( ClosureCallExpr call , LambdaCallKind kind , Expr receiver ) {
296+ receiver = call .getClosureExpr ( ) and
300297 exists ( kind )
301298}
302299
@@ -666,10 +663,14 @@ module RustDataFlow implements InputSig<Location> {
666663
667664 pragma [ nomagic]
668665 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 ) ) )
666+ exists ( CallExpr ce , TupleField tf , int pos |
667+ node1 .asExpr ( ) = ce .getSyntacticArgument ( pos ) and
668+ node2 .asExpr ( ) = ce and
669+ c = TTupleFieldContent ( tf )
670+ |
671+ tf = ce .( TupleStructExpr ) .getTupleField ( pos )
672+ or
673+ tf = ce .( TupleVariantExpr ) .getTupleField ( pos )
673674 )
674675 or
675676 exists ( StructExpr re , string field |
@@ -715,7 +716,7 @@ module RustDataFlow implements InputSig<Location> {
715716 exists ( DataFlowCall call , int i |
716717 isArgumentNode ( node1 , call , TPositionalParameterPosition ( i ) ) and
717718 lambdaCall ( call , _, node2 .( PostUpdateNode ) .getPreUpdateNode ( ) ) and
718- c .( FunctionCallArgumentContent ) .getPosition ( ) = i
719+ c .( ClosureCallArgumentContent ) .getPosition ( ) = i
719720 )
720721 or
721722 VariableCapture:: storeStep ( node1 , c , node2 )
@@ -824,11 +825,7 @@ module RustDataFlow implements InputSig<Location> {
824825 */
825826 predicate lambdaCall ( DataFlowCall call , LambdaCallKind kind , Node receiver ) {
826827 (
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- )
828+ receiver .asExpr ( ) = call .asCall ( ) .( ClosureCallExpr ) .getClosureExpr ( )
832829 or
833830 call .isSummaryCall ( _, receiver .( FlowSummaryNode ) .getSummaryNode ( ) )
834831 ) and
0 commit comments