Skip to content

Commit 64ab7c7

Browse files
authored
Merge pull request #19717 from hvitved/rust/use-get-arg-param
Rust: Use `get(An){Arg,Param}` helper predicates
2 parents 1bd6446 + e41b4f4 commit 64ab7c7

File tree

7 files changed

+10
-10
lines changed

7 files changed

+10
-10
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class BreakExprTargetChildMapping extends ParentAstNode, Expr {
5959
}
6060

6161
class CallExprBaseChildMapping extends ParentAstNode, CallExprBase {
62-
override predicate relevantChild(AstNode child) { child = this.getArgList().getAnArg() }
62+
override predicate relevantChild(AstNode child) { child = this.getAnArg() }
6363
}
6464

6565
class StructExprChildMapping extends ParentAstNode, StructExpr {

rust/ql/lib/codeql/rust/controlflow/internal/ControlFlowGraphImpl.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ class CallableScopeTree extends StandardTree, PreOrderTree, PostOrderTree, Scope
8787
i = 0 and
8888
result = this.getParamList().getSelfParam()
8989
or
90-
result = this.getParamList().getParam(i - 1)
90+
result = this.getParam(i - 1)
9191
or
9292
i = this.getParamList().getNumberOfParams() + 1 and
9393
result = this.getBody()
@@ -543,7 +543,7 @@ module ExprTrees {
543543

544544
class MethodCallExprTree extends StandardPostOrderTree, MethodCallExpr {
545545
override AstNode getChildNode(int i) {
546-
if i = 0 then result = this.getReceiver() else result = this.getArgList().getArg(i - 1)
546+
if i = 0 then result = this.getReceiver() else result = this.getArg(i - 1)
547547
}
548548
}
549549

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ module Impl {
5555
pragma[nomagic]
5656
private PathResolution::ItemNode getResolvedFunctionAndPos(int pos) {
5757
result = getResolvedFunction(this) and
58-
exists(this.getArgList().getArg(pos))
58+
exists(this.getArg(pos))
5959
}
6060

6161
/**

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,9 @@ module Impl {
9595
not text.charAt(0).isUppercase() and
9696
// exclude parameters from functions without a body as these are trait method declarations
9797
// without implementations
98-
not exists(Function f | not f.hasBody() and f.getParamList().getAParam().getPat() = pat) and
98+
not exists(Function f | not f.hasBody() and f.getAParam().getPat() = pat) and
9999
// exclude parameters from function pointer types (e.g. `x` in `fn(x: i32) -> i32`)
100-
not exists(FnPtrTypeRepr fp | fp.getParamList().getParam(_).getPat() = pat)
100+
not exists(FnPtrTypeRepr fp | fp.getParamList().getAParam().getPat() = pat)
101101
)
102102
}
103103

rust/ql/lib/codeql/rust/internal/Type.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ class SelfTypeParameter extends TypeParameter, TSelfTypeParameter {
352352
class ImplTraitTypeTypeParameter extends ImplTraitType, TypeParameter {
353353
private Function function;
354354

355-
ImplTraitTypeTypeParameter() { impl = function.getParamList().getAParam().getTypeRepr() }
355+
ImplTraitTypeTypeParameter() { impl = function.getAParam().getTypeRepr() }
356356

357357
override Function getFunction() { result = function }
358358

rust/ql/lib/codeql/rust/internal/TypeInference.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1100,7 +1100,7 @@ private module AwaitExprMatchingInput implements MatchingInputSig {
11001100

11011101
Type getDeclaredType(DeclarationPosition dpos, TypePath path) {
11021102
dpos.isSelf() and
1103-
result = this.getParamList().getParam(0).getTypeRepr().(TypeMention).resolveTypeAt(path)
1103+
result = this.getParam(0).getTypeRepr().(TypeMention).resolveTypeAt(path)
11041104
or
11051105
dpos.isOutput() and
11061106
result = this.getRetType().getTypeRepr().(TypeMention).resolveTypeAt(path)
@@ -1199,7 +1199,7 @@ private module MethodCall {
11991199
Expr receiver;
12001200

12011201
CallExprMethodCall() {
1202-
receiver = this.getArgList().getArg(0) and
1202+
receiver = this.getArg(0) and
12031203
exists(Path path, Function f |
12041204
path = this.getFunction().(PathExpr).getPath() and
12051205
f = resolvePath(path) and

rust/ql/src/utils/modelgenerator/internal/CaptureModels.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ module ModelGeneratorCommonInput implements
7979

8080
bindingset[c]
8181
string paramReturnNodeAsExactOutput(Callable c, DataFlowImpl::ParameterPosition pos) {
82-
result = parameterExactAccess(c.getParamList().getParam(pos.getPosition()))
82+
result = parameterExactAccess(c.getParam(pos.getPosition()))
8383
or
8484
pos.isSelf() and result = qualifierString()
8585
}

0 commit comments

Comments
 (0)