diff --git a/cpp/ql/lib/semmle/code/cpp/ir/implementation/aliased_ssa/IRBlock.qll b/cpp/ql/lib/semmle/code/cpp/ir/implementation/aliased_ssa/IRBlock.qll index 34a7abf7b5e..4de4279b54c 100644 --- a/cpp/ql/lib/semmle/code/cpp/ir/implementation/aliased_ssa/IRBlock.qll +++ b/cpp/ql/lib/semmle/code/cpp/ir/implementation/aliased_ssa/IRBlock.qll @@ -271,8 +271,9 @@ private module Cached { /** Holds if `i` is the `index`th instruction in `block`. */ cached Instruction getInstruction(TIRBlock block, int index) { - exists(Instruction first | - block = MkIRBlock(first) and + exists(Instruction first | block = MkIRBlock(first) | + first = result and index = 0 + or index = getMemberIndex(result) and BlockAdjacency::getEquivalenceClass(first) = BlockAdjacency::getEquivalenceClass(result) )