diff --git a/rust/ql/lib/codeql/rust/dataflow/FlowSummary.qll b/rust/ql/lib/codeql/rust/dataflow/FlowSummary.qll index bbeb33ad13a..3d238c05fd0 100644 --- a/rust/ql/lib/codeql/rust/dataflow/FlowSummary.qll +++ b/rust/ql/lib/codeql/rust/dataflow/FlowSummary.qll @@ -2,13 +2,13 @@ private import rust private import internal.FlowSummaryImpl as Impl -private import internal.DataFlowImpl +private import codeql.rust.elements.internal.CallExprBaseImpl::Impl as CallExprBaseImpl // import all instances below private module Summaries { private import codeql.rust.Frameworks - // TODO: Used models-as-data when it's available + // TODO: Use models-as-data when it's available private class UnwrapSummary extends SummarizedCallable::Range { UnwrapSummary() { this = "lang:core::_::::unwrap" } @@ -30,7 +30,7 @@ module LibraryCallable { /** Gets a call to this library callable. */ CallExprBase getACall() { exists(Resolvable r, string crate | - r = getCallResolvable(result) and + r = CallExprBaseImpl::getCallResolvable(result) and this = crate + r.getResolvedPath() | crate = r.getResolvedCrateOrigin() + "::_::" diff --git a/rust/ql/lib/codeql/rust/dataflow/internal/DataFlowImpl.qll b/rust/ql/lib/codeql/rust/dataflow/internal/DataFlowImpl.qll index 8c15353b58b..9161d409da2 100644 --- a/rust/ql/lib/codeql/rust/dataflow/internal/DataFlowImpl.qll +++ b/rust/ql/lib/codeql/rust/dataflow/internal/DataFlowImpl.qll @@ -173,7 +173,7 @@ module Node { override Location getLocation() { none() } } - /** A data-flow node used to model flow summaries. */ + /** A data flow node used to model flow summaries. */ class FlowSummaryNode extends Node, TFlowSummaryNode { FlowSummaryImpl::Private::SummaryNode getSummaryNode() { this = TFlowSummaryNode(result) } @@ -375,10 +375,6 @@ module Node { /** Gets the node before the state update. */ abstract Node getPreUpdateNode(); - override CfgScope getCfgScope() { result = this.getPreUpdateNode().getCfgScope() } - - override Location getLocation() { result = this.getPreUpdateNode().getLocation() } - override string toString() { result = "[post] " + this.getPreUpdateNode().toString() } } @@ -388,6 +384,10 @@ module Node { ExprPostUpdateNode() { this = TExprPostUpdateNode(n) } override Node getPreUpdateNode() { result = TExprNode(n) } + + override CfgScope getCfgScope() { result = n.getScope() } + + override Location getLocation() { result = n.getLocation() } } final class SummaryPostUpdateNode extends FlowSummaryNode, PostUpdateNode { @@ -399,10 +399,6 @@ module Node { override Node getPreUpdateNode() { result = pre } - override CfgScope getCfgScope() { result = PostUpdateNode.super.getCfgScope() } - - override EmptyLocation getLocation() { result = PostUpdateNode.super.getLocation() } - final override string toString() { result = PostUpdateNode.super.toString() } } @@ -689,13 +685,6 @@ private module Aliases { class ContentSetAlias = ContentSet; } -pragma[nomagic] -Resolvable getCallResolvable(CallExprBase call) { - result = call.(MethodCallExpr) - or - result = call.(CallExpr).getFunction().(PathExpr).getPath() -} - module RustDataFlow implements InputSig { private import Aliases diff --git a/rust/ql/lib/codeql/rust/dataflow/internal/FlowSummaryImpl.qll b/rust/ql/lib/codeql/rust/dataflow/internal/FlowSummaryImpl.qll index 1292a936afd..3503ad07332 100644 --- a/rust/ql/lib/codeql/rust/dataflow/internal/FlowSummaryImpl.qll +++ b/rust/ql/lib/codeql/rust/dataflow/internal/FlowSummaryImpl.qll @@ -15,12 +15,7 @@ module Input implements InputSig { ReturnKind getStandardReturnValueKind() { result = TNormalReturnKind() } - string encodeParameterPosition(ParameterPosition pos) { - result = pos.getPosition().toString() - or - pos.isSelf() and - result = "self" - } + string encodeParameterPosition(ParameterPosition pos) { result = pos.toString() } predicate encodeArgumentPosition = encodeParameterPosition/1; diff --git a/rust/ql/lib/codeql/rust/elements/internal/CallExprBaseImpl.qll b/rust/ql/lib/codeql/rust/elements/internal/CallExprBaseImpl.qll index d0e4049a05d..3729bb8eeb7 100644 --- a/rust/ql/lib/codeql/rust/elements/internal/CallExprBaseImpl.qll +++ b/rust/ql/lib/codeql/rust/elements/internal/CallExprBaseImpl.qll @@ -17,7 +17,7 @@ module Impl { private import codeql.rust.elements.internal.PathExprImpl::Impl pragma[nomagic] - private Resolvable getCallResolvable(CallExprBase call) { + Resolvable getCallResolvable(CallExprBase call) { result = call.(MethodCallExpr) or result = call.(CallExpr).getFunction().(PathExpr).getPath()