Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 235a069

Browse files
committed
C++: Fix 'asParameter' to handle references.
1 parent 2cebd5c commit 235a069

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,13 @@ class Node extends TIRDataFlowNode {
235235
Expr asIndirectArgument() { result = this.asIndirectArgument(_) }
236236

237237
/** Gets the positional parameter corresponding to this node, if any. */
238-
Parameter asParameter() { result = this.asParameter(0) }
238+
Parameter asParameter() {
239+
exists(int indirectionIndex | result = this.asParameter(indirectionIndex) |
240+
if result.getUnspecifiedType() instanceof ReferenceType
241+
then indirectionIndex = 1
242+
else indirectionIndex = 0
243+
)
244+
}
239245

240246
/**
241247
* Gets the uninitialized local variable corresponding to this node, if

0 commit comments

Comments
 (0)