Skip to content

Commit e012dce

Browse files
authored
Merge pull request #4334 from github/faster-skip-copy-value-instructions
C++: Manual recursion in `skipCopyValueInstructions`
2 parents 3ef3e6e + f794eaa commit e012dce

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -355,14 +355,16 @@ private class ArrayToPointerConvertInstruction extends ConvertInstruction {
355355
}
356356
}
357357

358-
private Instruction skipOneCopyValueInstruction(Instruction instr) {
359-
not instr instanceof CopyValueInstruction and result = instr
358+
private Instruction skipOneCopyValueInstructionRec(CopyValueInstruction copy) {
359+
copy.getUnary() = result and not result instanceof CopyValueInstruction
360360
or
361-
result = instr.(CopyValueInstruction).getUnary()
361+
result = skipOneCopyValueInstructionRec(copy.getUnary())
362362
}
363363

364364
private Instruction skipCopyValueInstructions(Instruction instr) {
365-
result = skipOneCopyValueInstruction*(instr) and not result instanceof CopyValueInstruction
365+
not result instanceof CopyValueInstruction and result = instr
366+
or
367+
result = skipOneCopyValueInstructionRec(instr)
366368
}
367369

368370
private predicate arrayReadStep(Node node1, ArrayContent a, Node node2) {

0 commit comments

Comments
 (0)