Skip to content

Commit be8d58e

Browse files
committed
wip
1 parent 898de00 commit be8d58e

File tree

9 files changed

+929
-139
lines changed

9 files changed

+929
-139
lines changed

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -239,9 +239,8 @@ final class RecordExprCfgNode extends Nodes::RecordExprCfgNode {
239239
pragma[nomagic]
240240
ExprCfgNode getFieldExpr(string field) {
241241
exists(RecordExprField ref |
242-
ref = node.getRecordExprFieldList().getAField() and
243-
any(ChildMapping mapping).hasCfgChild(node, ref.getExpr(), this, result) and
244-
field = ref.getFieldName()
242+
ref = node.getFieldExpr(field) and
243+
any(ChildMapping mapping).hasCfgChild(node, ref.getExpr(), this, result)
245244
)
246245
}
247246
}

rust/ql/lib/codeql/rust/elements/internal/GenericArgListImpl.qll

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ private import codeql.rust.elements.internal.generated.GenericArgList
1111
* be referenced directly.
1212
*/
1313
module Impl {
14+
private import rust
15+
1416
// the following QLdoc is generated: if you need to edit it, do it in the schema file
1517
/**
1618
* The base class for generic arguments.
@@ -22,5 +24,15 @@ module Impl {
2224
override string toString() { result = this.toAbbreviatedString() }
2325

2426
override string toAbbreviatedString() { result = "<...>" }
27+
28+
/** Gets the `i`th type argument. */
29+
TypeRepr getTypeArgument(int i) {
30+
result =
31+
rank[i + 1](TypeRepr res, int j |
32+
res = this.getGenericArg(j).(TypeArg).getTypeRepr()
33+
|
34+
res order by j
35+
)
36+
}
2537
}
2638
}

rust/ql/lib/codeql/rust/elements/internal/GenericParamListImpl.qll

Lines changed: 12 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust/ql/lib/codeql/rust/elements/internal/RecordExprImpl.qll

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@ module Impl {
2727
class RecordExpr extends Generated::RecordExpr {
2828
override string toString() { result = this.getPath().toString() + " {...}" }
2929

30+
/** Gets the record expression for the field `field`. */
31+
pragma[nomagic]
32+
RecordExprField getFieldExpr(string name) {
33+
result = this.getRecordExprFieldList().getAField() and
34+
name = result.getFieldName()
35+
}
36+
3037
/** Gets the record field that matches the `name` field of this record expression. */
3138
pragma[nomagic]
3239
RecordField getRecordField(string name) {

0 commit comments

Comments
 (0)