@@ -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 ( ClosureCall call , LambdaCallKind kind , Expr receiver ) {
294+ receiver = call .getClosureExpr ( ) and
300295 exists ( kind )
301296}
302297
@@ -666,8 +661,8 @@ 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
664+ exists ( ParenArgsExpr call , int pos |
665+ node1 .asExpr ( ) = call .getArgument ( pragma [ only_bind_into ] ( pos ) ) and
671666 node2 .asExpr ( ) = call and
672667 c = TTupleFieldContent ( call .getTupleField ( pragma [ only_bind_into ] ( pos ) ) )
673668 )
@@ -818,7 +813,7 @@ module RustDataFlow implements InputSig<Location> {
818813 // pointer. Except if the path occurs directly in a call, then it's just a
819814 // call to the function and not a function being passed as data.
820815 resolvePath ( e .( PathExpr ) .getPath ( ) ) = c .asCfgScope ( ) and
821- not any ( CallExpr call ) .getFunction ( ) = e
816+ not any ( ParenArgsExpr call ) .getBase ( ) = e
822817 )
823818 }
824819
@@ -828,11 +823,7 @@ module RustDataFlow implements InputSig<Location> {
828823 */
829824 predicate lambdaCall ( DataFlowCall call , LambdaCallKind kind , Node receiver ) {
830825 (
831- receiver .asExpr ( ) = call .asCall ( ) .( CallExpr ) .getFunction ( ) and
832- // All calls to complex expressions and local variable accesses are lambda call.
833- exists ( Expr f | f = receiver .asExpr ( ) |
834- f instanceof PathExpr implies f = any ( Variable v ) .getAnAccess ( )
835- )
826+ receiver .asExpr ( ) = call .asCall ( ) .( ClosureCall ) .getClosureExpr ( )
836827 or
837828 call .isSummaryCall ( _, receiver .( FlowSummaryNode ) .getSummaryNode ( ) )
838829 ) and
@@ -996,9 +987,7 @@ private module Cached {
996987 newtype TDataFlowCall =
997988 TCall ( Call call ) {
998989 Stages:: DataFlowStage:: ref ( ) and
999- call .hasEnclosingCfgScope ( ) and
1000- // TODO: Handle index expressions as calls in data flow.
1001- not call instanceof IndexExpr
990+ call .hasEnclosingCfgScope ( )
1002991 } or
1003992 TSummaryCall (
1004993 FlowSummaryImpl:: Public:: SummarizedCallable c , FlowSummaryImpl:: Private:: SummaryNode receiver
0 commit comments