From 57cc316ecdfd569a6f33cf1e90533dafe1fdb78d Mon Sep 17 00:00:00 2001 From: Mathias Vorreiter Pedersen Date: Wed, 17 May 2023 15:42:38 +0100 Subject: [PATCH] C++: Fix bug for single-instruction basic blocks. --- .../code/cpp/ir/implementation/aliased_ssa/IRBlock.qll | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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) )