Skip to content

Commit b7792d6

Browse files
authored
Merge pull request #18163 from paldepind/rust-df-try-expr
Rust: Add flow through `?` operator
2 parents b54d8dc + ed6f873 commit b7792d6

File tree

4 files changed

+412
-313
lines changed

4 files changed

+412
-313
lines changed

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -884,6 +884,13 @@ module RustDataFlow implements InputSig<Location> {
884884
node1.asExpr() = access.getExpr() and
885885
node2.asExpr() = access
886886
)
887+
or
888+
exists(TryExprCfgNode try |
889+
node1.asExpr() = try.getExpr() and
890+
node2.asExpr() = try and
891+
c.(VariantPositionContent).getVariantCanonicalPath(0).getExtendedCanonicalPath() =
892+
["crate::option::Option::Some", "crate::result::Result::Ok"]
893+
)
887894
)
888895
or
889896
FlowSummaryImpl::Private::Steps::summaryReadStep(node1.(Node::FlowSummaryNode).getSummaryNode(),
@@ -1065,7 +1072,8 @@ private module Cached {
10651072
TSourceParameterNode(ParamBaseCfgNode p) or
10661073
TPatNode(PatCfgNode p) or
10671074
TExprPostUpdateNode(ExprCfgNode e) {
1068-
isArgumentForCall(e, _, _) or e = any(FieldExprCfgNode access).getExpr()
1075+
isArgumentForCall(e, _, _) or
1076+
e = [any(FieldExprCfgNode access).getExpr(), any(TryExprCfgNode try).getExpr()]
10691077
} or
10701078
TSsaNode(SsaImpl::DataFlowIntegration::SsaNode node) or
10711079
TFlowSummaryNode(FlowSummaryImpl::Private::SummaryNode sn)

0 commit comments

Comments
 (0)