Skip to content

Commit 3d968c6

Browse files
committed
C++: Move the 'getArgumentIndex' into the abstract 'Position' class. It is implemented in all subclasses anyway.
1 parent 94e08e3 commit 3d968c6

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

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

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ private class PrimaryArgumentNode extends ArgumentNode, OperandNode {
371371
PrimaryArgumentNode() { exists(CallInstruction call | op = call.getAnArgumentOperand()) }
372372

373373
override predicate argumentOf(DataFlowCall call, ArgumentPosition pos) {
374-
op = call.getArgumentOperand(pos.(DirectPosition).getIndex())
374+
op = call.getArgumentOperand(pos.(DirectPosition).getArgumentIndex())
375375
}
376376
}
377377

@@ -410,8 +410,16 @@ class ParameterPosition = Position;
410410
class ArgumentPosition = Position;
411411

412412
abstract class Position extends TPosition {
413+
/** Gets a textual representation of this position. */
413414
abstract string toString();
414415

416+
/**
417+
* Gets the argument index of this position. The qualifier of a call has
418+
* argument index `-1`.
419+
*/
420+
abstract int getArgumentIndex();
421+
422+
/** Gets the indirection index of this position. */
415423
abstract int getIndirectionIndex();
416424
}
417425

@@ -428,7 +436,7 @@ class DirectPosition extends Position, TDirectPosition {
428436
result = index.toString()
429437
}
430438

431-
int getIndex() { result = index }
439+
override int getArgumentIndex() { result = index }
432440

433441
final override int getIndirectionIndex() { result = 0 }
434442
}
@@ -445,7 +453,7 @@ class IndirectionPosition extends Position, TIndirectionPosition {
445453
else result = repeatStars(indirectionIndex) + argumentIndex.toString()
446454
}
447455

448-
int getArgumentIndex() { result = argumentIndex }
456+
override int getArgumentIndex() { result = argumentIndex }
449457

450458
final override int getIndirectionIndex() { result = indirectionIndex }
451459
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,11 +229,11 @@ private module SpeculativeTaintFlow {
229229
not exists(DataFlowDispatch::viableCallable(call)) and
230230
src.(DataFlowPrivate::ArgumentNode).argumentOf(call, argpos)
231231
|
232-
not argpos.(DirectPosition).getIndex() = -1 and
232+
not argpos.(DirectPosition).getArgumentIndex() = -1 and
233233
sink.(PostUpdateNode)
234234
.getPreUpdateNode()
235235
.(DataFlowPrivate::ArgumentNode)
236-
.argumentOf(call, any(DirectPosition qualpos | qualpos.getIndex() = -1))
236+
.argumentOf(call, any(DirectPosition qualpos | qualpos.getArgumentIndex() = -1))
237237
or
238238
sink.(DataFlowPrivate::OutNode).getCall() = call
239239
)

0 commit comments

Comments
 (0)