Skip to content

Commit 5c64a8c

Browse files
committed
Rust: Accept expected changes and fix other CI complaints
1 parent cd957ba commit 5c64a8c

17 files changed

+202
-19
lines changed

rust/ql/lib/codeql/rust/controlflow/CfgNodes.qll

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,10 +186,14 @@ final class CallExprCfgNode extends CallExprBaseCfgNode, Nodes::CallExprCfgNode
186186
final class FormatArgsExprCfgNode extends Nodes::FormatArgsExprCfgNode {
187187
private FormatArgsExprChildMapping node;
188188

189+
FormatArgsExprCfgNode() { node = this.getAstNode() }
190+
191+
/** Gets the `i`th argument of this format arguments expression (0-based). */
189192
ExprCfgNode getArgumentExpr(int i) {
190193
any(ChildMapping mapping).hasCfgChild(node, node.getArg(i).getExpr(), this, result)
191194
}
192195

196+
/** Gets a format argument of the `i`th format of this format arguments expression (0-based). */
193197
FormatTemplateVariableAccessCfgNode getFormatTemplateVariableAccess(int i) {
194198
exists(FormatTemplateVariableAccess v |
195199
v.getArgument() = node.getFormat(i).getArgument() and
@@ -199,11 +203,18 @@ final class FormatArgsExprCfgNode extends Nodes::FormatArgsExprCfgNode {
199203
}
200204
}
201205

206+
/**
207+
* A MacroCall. For example:
208+
* ```rust
209+
* todo!()
210+
* ```
211+
*/
202212
final class MacroCallCfgNode extends Nodes::MacroCallCfgNode {
203213
private MacroCallChildMapping node;
204214

205215
MacroCallCfgNode() { node = this.getAstNode() }
206216

217+
/** Gets the CFG node for the expansion of this macro call, if it exists. */
207218
CfgNode getExpandedNode() {
208219
any(ChildMapping mapping).hasCfgChild(node, node.getExpanded(), this, result)
209220
}

rust/ql/test/extractor-tests/generated/FormatArgsExpr/Format.expected

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
| gen_format.rs:5:21:5:22 | {} | getParent: | gen_format.rs:5:14:5:32 | FormatArgsExpr | getIndex: | 1 | hasArgument: | no |
2+
| gen_format.rs:7:21:7:46 | {value:#width$.precision$} | getParent: | gen_format.rs:7:14:7:47 | FormatArgsExpr | getIndex: | 1 | hasArgument: | yes |
3+
| gen_format_args_arg.rs:5:26:5:27 | {} | getParent: | gen_format_args_arg.rs:5:17:5:39 | FormatArgsExpr | getIndex: | 1 | hasArgument: | no |
24
| gen_format_args_expr.rs:6:19:6:20 | {} | getParent: | gen_format_args_expr.rs:6:17:6:37 | FormatArgsExpr | getIndex: | 1 | hasArgument: | no |
35
| gen_format_args_expr.rs:6:26:6:29 | {:?} | getParent: | gen_format_args_expr.rs:6:17:6:37 | FormatArgsExpr | getIndex: | 3 | hasArgument: | no |
46
| gen_format_args_expr.rs:7:19:7:21 | {b} | getParent: | gen_format_args_expr.rs:7:17:7:43 | FormatArgsExpr | getIndex: | 1 | hasArgument: | yes |

rust/ql/test/extractor-tests/generated/FormatArgsExpr/FormatArgsArg.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
| gen_format.rs:5:26:5:32 | FormatArgsArg | hasExpr: | yes | hasName: | no |
2+
| gen_format_args_arg.rs:5:32:5:38 | FormatArgsArg | hasExpr: | yes | hasName: | no |
23
| gen_format_args_expr.rs:6:33:6:33 | FormatArgsArg | hasExpr: | yes | hasName: | no |
34
| gen_format_args_expr.rs:6:36:6:36 | FormatArgsArg | hasExpr: | yes | hasName: | no |
45
| gen_format_args_expr.rs:7:35:7:37 | FormatArgsArg | hasExpr: | yes | hasName: | yes |

rust/ql/test/extractor-tests/generated/FormatArgsExpr/FormatArgsArg_getExpr.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
| gen_format.rs:5:26:5:32 | FormatArgsArg | gen_format.rs:5:26:5:32 | "world" |
2+
| gen_format_args_arg.rs:5:32:5:38 | FormatArgsArg | gen_format_args_arg.rs:5:32:5:38 | "world" |
23
| gen_format_args_expr.rs:6:33:6:33 | FormatArgsArg | gen_format_args_expr.rs:6:33:6:33 | 1 |
34
| gen_format_args_expr.rs:6:36:6:36 | FormatArgsArg | gen_format_args_expr.rs:6:36:6:36 | 2 |
45
| gen_format_args_expr.rs:7:35:7:37 | FormatArgsArg | gen_format_args_expr.rs:7:37:7:37 | 1 |

rust/ql/test/extractor-tests/generated/FormatArgsExpr/FormatArgsExpr.expected

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
| gen_format.rs:5:14:5:32 | FormatArgsExpr | getNumberOfArgs: | 1 | getNumberOfAttrs: | 0 | hasTemplate: | yes | getNumberOfFormats: | 1 |
2+
| gen_format.rs:7:14:7:47 | FormatArgsExpr | getNumberOfArgs: | 0 | getNumberOfAttrs: | 0 | hasTemplate: | yes | getNumberOfFormats: | 1 |
3+
| gen_format_args_arg.rs:5:17:5:39 | FormatArgsExpr | getNumberOfArgs: | 1 | getNumberOfAttrs: | 0 | hasTemplate: | yes | getNumberOfFormats: | 1 |
24
| gen_format_args_expr.rs:5:17:5:27 | FormatArgsExpr | getNumberOfArgs: | 0 | getNumberOfAttrs: | 0 | hasTemplate: | yes | getNumberOfFormats: | 0 |
35
| gen_format_args_expr.rs:6:17:6:37 | FormatArgsExpr | getNumberOfArgs: | 2 | getNumberOfAttrs: | 0 | hasTemplate: | yes | getNumberOfFormats: | 2 |
46
| gen_format_args_expr.rs:7:17:7:43 | FormatArgsExpr | getNumberOfArgs: | 2 | getNumberOfAttrs: | 0 | hasTemplate: | yes | getNumberOfFormats: | 2 |

rust/ql/test/extractor-tests/generated/FormatArgsExpr/FormatArgsExpr_getArg.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
| gen_format.rs:5:14:5:32 | FormatArgsExpr | 0 | gen_format.rs:5:26:5:32 | FormatArgsArg |
2+
| gen_format_args_arg.rs:5:17:5:39 | FormatArgsExpr | 0 | gen_format_args_arg.rs:5:32:5:38 | FormatArgsArg |
23
| gen_format_args_expr.rs:6:17:6:37 | FormatArgsExpr | 0 | gen_format_args_expr.rs:6:33:6:33 | FormatArgsArg |
34
| gen_format_args_expr.rs:6:17:6:37 | FormatArgsExpr | 1 | gen_format_args_expr.rs:6:36:6:36 | FormatArgsArg |
45
| gen_format_args_expr.rs:7:17:7:43 | FormatArgsExpr | 0 | gen_format_args_expr.rs:7:35:7:37 | FormatArgsArg |

rust/ql/test/extractor-tests/generated/FormatArgsExpr/FormatArgsExpr_getFormat.expected

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
| gen_format.rs:5:14:5:32 | FormatArgsExpr | 0 | gen_format.rs:5:21:5:22 | {} |
2+
| gen_format.rs:7:14:7:47 | FormatArgsExpr | 0 | gen_format.rs:7:21:7:46 | {value:#width$.precision$} |
3+
| gen_format_args_arg.rs:5:17:5:39 | FormatArgsExpr | 0 | gen_format_args_arg.rs:5:26:5:27 | {} |
24
| gen_format_args_expr.rs:6:17:6:37 | FormatArgsExpr | 0 | gen_format_args_expr.rs:6:19:6:20 | {} |
35
| gen_format_args_expr.rs:6:17:6:37 | FormatArgsExpr | 1 | gen_format_args_expr.rs:6:26:6:29 | {:?} |
46
| gen_format_args_expr.rs:7:17:7:43 | FormatArgsExpr | 0 | gen_format_args_expr.rs:7:19:7:21 | {b} |

rust/ql/test/extractor-tests/generated/FormatArgsExpr/FormatArgsExpr_getTemplate.expected

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
| gen_format.rs:5:14:5:32 | FormatArgsExpr | gen_format.rs:5:14:5:23 | "Hello {}\\n" |
2+
| gen_format.rs:7:14:7:47 | FormatArgsExpr | gen_format.rs:7:14:7:47 | "Value {value:#width$.precisio... |
3+
| gen_format_args_arg.rs:5:17:5:39 | FormatArgsExpr | gen_format_args_arg.rs:5:18:5:29 | "Hello, {}!" |
24
| gen_format_args_expr.rs:5:17:5:27 | FormatArgsExpr | gen_format_args_expr.rs:5:18:5:26 | "no args" |
35
| gen_format_args_expr.rs:6:17:6:37 | FormatArgsExpr | gen_format_args_expr.rs:6:18:6:30 | "{} foo {:?}" |
46
| gen_format_args_expr.rs:7:17:7:43 | FormatArgsExpr | gen_format_args_expr.rs:7:18:7:32 | "{b} foo {a:?}" |

rust/ql/test/extractor-tests/generated/FormatArgsExpr/FormatArgument.expected

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
| gen_format.rs:7:22:7:26 | value | getParent: | gen_format.rs:7:21:7:46 | {value:#width$.precision$} | hasVariable: | yes |
2+
| gen_format.rs:7:29:7:33 | width | getParent: | gen_format.rs:7:21:7:46 | {value:#width$.precision$} | hasVariable: | yes |
3+
| gen_format.rs:7:36:7:44 | precision | getParent: | gen_format.rs:7:21:7:46 | {value:#width$.precision$} | hasVariable: | yes |
14
| gen_format_args_expr.rs:7:20:7:20 | b | getParent: | gen_format_args_expr.rs:7:19:7:21 | {b} | hasVariable: | no |
25
| gen_format_args_expr.rs:7:28:7:28 | a | getParent: | gen_format_args_expr.rs:7:27:7:31 | {a:?} | hasVariable: | no |
36
| gen_format_args_expr.rs:9:20:9:20 | x | getParent: | gen_format_args_expr.rs:9:19:9:21 | {x} | hasVariable: | yes |

rust/ql/test/extractor-tests/generated/FormatArgsExpr/FormatArgument_getVariable.expected

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
| gen_format.rs:7:22:7:26 | value | gen_format.rs:7:22:7:26 | value |
2+
| gen_format.rs:7:29:7:33 | width | gen_format.rs:7:29:7:33 | width |
3+
| gen_format.rs:7:36:7:44 | precision | gen_format.rs:7:36:7:44 | precision |
14
| gen_format_args_expr.rs:9:20:9:20 | x | gen_format_args_expr.rs:9:20:9:20 | x |
25
| gen_format_args_expr.rs:9:25:9:25 | y | gen_format_args_expr.rs:9:25:9:25 | y |
36
| gen_format_argument.rs:5:22:5:26 | value | gen_format_argument.rs:5:22:5:26 | value |

0 commit comments

Comments
 (0)