Skip to content

Commit 52dc79e

Browse files
committed
Address review comments
1 parent 3e5f4b7 commit 52dc79e

File tree

4 files changed

+10
-26
lines changed

4 files changed

+10
-26
lines changed

rust/ql/lib/codeql/rust/dataflow/FlowSummary.qll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
private import rust
44
private import internal.FlowSummaryImpl as Impl
5-
private import internal.DataFlowImpl
5+
private import codeql.rust.elements.internal.CallExprBaseImpl::Impl as CallExprBaseImpl
66

77
// import all instances below
88
private module Summaries {
99
private import codeql.rust.Frameworks
1010

11-
// TODO: Used models-as-data when it's available
11+
// TODO: Use models-as-data when it's available
1212
private class UnwrapSummary extends SummarizedCallable::Range {
1313
UnwrapSummary() { this = "lang:core::_::<crate::option::Option>::unwrap" }
1414

@@ -30,7 +30,7 @@ module LibraryCallable {
3030
/** Gets a call to this library callable. */
3131
CallExprBase getACall() {
3232
exists(Resolvable r, string crate |
33-
r = getCallResolvable(result) and
33+
r = CallExprBaseImpl::getCallResolvable(result) and
3434
this = crate + r.getResolvedPath()
3535
|
3636
crate = r.getResolvedCrateOrigin() + "::_::"

rust/ql/lib/codeql/rust/dataflow/internal/DataFlowImpl.qll

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ module Node {
173173
override Location getLocation() { none() }
174174
}
175175

176-
/** A data-flow node used to model flow summaries. */
176+
/** A data flow node used to model flow summaries. */
177177
class FlowSummaryNode extends Node, TFlowSummaryNode {
178178
FlowSummaryImpl::Private::SummaryNode getSummaryNode() { this = TFlowSummaryNode(result) }
179179

@@ -375,10 +375,6 @@ module Node {
375375
/** Gets the node before the state update. */
376376
abstract Node getPreUpdateNode();
377377

378-
override CfgScope getCfgScope() { result = this.getPreUpdateNode().getCfgScope() }
379-
380-
override Location getLocation() { result = this.getPreUpdateNode().getLocation() }
381-
382378
override string toString() { result = "[post] " + this.getPreUpdateNode().toString() }
383379
}
384380

@@ -388,6 +384,10 @@ module Node {
388384
ExprPostUpdateNode() { this = TExprPostUpdateNode(n) }
389385

390386
override Node getPreUpdateNode() { result = TExprNode(n) }
387+
388+
override CfgScope getCfgScope() { result = n.getScope() }
389+
390+
override Location getLocation() { result = n.getLocation() }
391391
}
392392

393393
final class SummaryPostUpdateNode extends FlowSummaryNode, PostUpdateNode {
@@ -399,10 +399,6 @@ module Node {
399399

400400
override Node getPreUpdateNode() { result = pre }
401401

402-
override CfgScope getCfgScope() { result = PostUpdateNode.super.getCfgScope() }
403-
404-
override EmptyLocation getLocation() { result = PostUpdateNode.super.getLocation() }
405-
406402
final override string toString() { result = PostUpdateNode.super.toString() }
407403
}
408404

@@ -689,13 +685,6 @@ private module Aliases {
689685
class ContentSetAlias = ContentSet;
690686
}
691687

692-
pragma[nomagic]
693-
Resolvable getCallResolvable(CallExprBase call) {
694-
result = call.(MethodCallExpr)
695-
or
696-
result = call.(CallExpr).getFunction().(PathExpr).getPath()
697-
}
698-
699688
module RustDataFlow implements InputSig<Location> {
700689
private import Aliases
701690

rust/ql/lib/codeql/rust/dataflow/internal/FlowSummaryImpl.qll

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,7 @@ module Input implements InputSig<Location, RustDataFlow> {
1515

1616
ReturnKind getStandardReturnValueKind() { result = TNormalReturnKind() }
1717

18-
string encodeParameterPosition(ParameterPosition pos) {
19-
result = pos.getPosition().toString()
20-
or
21-
pos.isSelf() and
22-
result = "self"
23-
}
18+
string encodeParameterPosition(ParameterPosition pos) { result = pos.toString() }
2419

2520
predicate encodeArgumentPosition = encodeParameterPosition/1;
2621

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ module Impl {
1717
private import codeql.rust.elements.internal.PathExprImpl::Impl
1818

1919
pragma[nomagic]
20-
private Resolvable getCallResolvable(CallExprBase call) {
20+
Resolvable getCallResolvable(CallExprBase call) {
2121
result = call.(MethodCallExpr)
2222
or
2323
result = call.(CallExpr).getFunction().(PathExpr).getPath()

0 commit comments

Comments
 (0)