Skip to content

Commit 32ed82e

Browse files
authored
Merge pull request #14154 from MathiasVP/fix-off-by-one-in-asDefiningArgument
2 parents 2182bf1 + 3f63467 commit 32ed82e

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
category: minorAnalysis
3+
---
4+
* The `DataFlow::asDefiningArgument` predicate now takes its argument from the range starting at `1` instead of `2`. Queries that depend on the single-parameter version of `DataFlow::asDefiningArgument` should have their arguments updated accordingly.

cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DataFlowUtil.qll

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -254,9 +254,7 @@ class Node extends TIRDataFlowNode {
254254
* after the `f` has returned.
255255
*/
256256
Expr asDefiningArgument(int index) {
257-
// Subtract one because `DefinitionByReferenceNode` is defined to be in
258-
// the range `[0 ... n - 1]` for some `n` instead of `[1 ... n]`.
259-
this.(DefinitionByReferenceNode).getIndirectionIndex() = index - 1 and
257+
this.(DefinitionByReferenceNode).getIndirectionIndex() = index and
260258
result = this.(DefinitionByReferenceNode).getArgument()
261259
}
262260

0 commit comments

Comments
 (0)