|
4 | 4 | */ |
5 | 5 |
|
6 | 6 | private import rust |
7 | | -private import codeql.rust.elements.Call |
8 | 7 | private import ControlFlowGraph |
9 | 8 | private import internal.ControlFlowGraphImpl as CfgImpl |
10 | 9 | private import internal.CfgNodes |
@@ -201,62 +200,67 @@ final class BreakExprCfgNode extends Nodes::BreakExprCfgNode { |
201 | 200 | } |
202 | 201 |
|
203 | 202 | /** |
204 | | - * A function or method call expression. See `CallExpr` and `MethodCallExpr` for further details. |
| 203 | + * A method call expression. For example: |
| 204 | + * ```rust |
| 205 | + * x.foo(42); |
| 206 | + * x.foo::<u32, u64>(42); |
| 207 | + * ``` |
205 | 208 | */ |
206 | | -final class CallExprBaseCfgNode extends Nodes::CallExprBaseCfgNode { |
207 | | - private CallExprBaseChildMapping node; |
| 209 | +final class MethodCallExprCfgNode extends Nodes::MethodCallExprCfgNode { |
| 210 | + private MethodCallExprChildMapping node; |
208 | 211 |
|
209 | | - CallExprBaseCfgNode() { node = this.getAstNode() } |
| 212 | + MethodCallExprCfgNode() { node = this.getAstNode() } |
210 | 213 |
|
211 | 214 | /** Gets the `i`th argument of this call. */ |
212 | 215 | ExprCfgNode getArgument(int i) { |
213 | 216 | any(ChildMapping mapping).hasCfgChild(node, node.getArgList().getArg(i), this, result) |
214 | 217 | } |
215 | 218 | } |
216 | 219 |
|
217 | | -/** |
218 | | - * A method call expression. For example: |
219 | | - * ```rust |
220 | | - * x.foo(42); |
221 | | - * x.foo::<u32, u64>(42); |
222 | | - * ``` |
223 | | - */ |
224 | | -final class MethodCallExprCfgNode extends CallExprBaseCfgNode, Nodes::MethodCallExprCfgNode { } |
225 | | - |
226 | 220 | /** |
227 | 221 | * A CFG node that calls a function. |
228 | 222 | * |
229 | 223 | * This class abstract over the different ways in which a function can be called in Rust. |
230 | 224 | */ |
231 | | -final class CallCfgNode extends ExprCfgNode { |
232 | | - private Call node; |
| 225 | +final class CallExprCfgNode extends ExprCfgNode { |
| 226 | + private CallExpr node; |
233 | 227 |
|
234 | | - CallCfgNode() { node = this.getAstNode() } |
| 228 | + CallExprCfgNode() { node = this.getAstNode() } |
235 | 229 |
|
236 | 230 | /** Gets the underlying `Call`. */ |
237 | | - Call getCall() { result = node } |
| 231 | + CallExpr getCall() { result = node } |
238 | 232 |
|
239 | 233 | /** Gets the receiver of this call if it is a method call. */ |
240 | 234 | ExprCfgNode getReceiver() { |
241 | 235 | any(ChildMapping mapping).hasCfgChild(node, node.getReceiver(), this, result) |
242 | 236 | } |
243 | 237 |
|
244 | 238 | /** Gets the `i`th argument of this call, if any. */ |
245 | | - ExprCfgNode getPositionalArgument(int i) { |
246 | | - any(ChildMapping mapping).hasCfgChild(node, node.getPositionalArgument(i), this, result) |
| 239 | + ExprCfgNode getArgument(int i) { |
| 240 | + any(ChildMapping mapping).hasCfgChild(node, node.getArgument(i), this, result) |
247 | 241 | } |
248 | 242 | } |
249 | 243 |
|
250 | 244 | /** |
251 | | - * A function call expression. For example: |
| 245 | + * An expression with parenthesized arguments. For example: |
252 | 246 | * ```rust |
253 | 247 | * foo(42); |
254 | 248 | * foo::<u32, u64>(42); |
255 | 249 | * foo[0](42); |
256 | 250 | * foo(1) = 4; |
| 251 | + * Option::Some(42); |
257 | 252 | * ``` |
258 | 253 | */ |
259 | | -final class CallExprCfgNode extends CallExprBaseCfgNode, Nodes::CallExprCfgNode { } |
| 254 | +final class ParenArgsExprCfgNode extends Nodes::ParenArgsExprCfgNode { |
| 255 | + private ParenArgsExprChildMapping node; |
| 256 | + |
| 257 | + ParenArgsExprCfgNode() { node = this.getAstNode() } |
| 258 | + |
| 259 | + /** Gets the `i`th argument of this call. */ |
| 260 | + ExprCfgNode getArgument(int i) { |
| 261 | + any(ChildMapping mapping).hasCfgChild(node, node.getArgList().getArg(i), this, result) |
| 262 | + } |
| 263 | +} |
260 | 264 |
|
261 | 265 | /** |
262 | 266 | * A FormatArgsExpr. For example: |
|
0 commit comments