diff --git a/cpp/ql/lib/semmle/code/cpp/ir/implementation/aliased_ssa/Instruction.qll b/cpp/ql/lib/semmle/code/cpp/ir/implementation/aliased_ssa/Instruction.qll index 189ffce2903e..53a225c2e89f 100644 --- a/cpp/ql/lib/semmle/code/cpp/ir/implementation/aliased_ssa/Instruction.qll +++ b/cpp/ql/lib/semmle/code/cpp/ir/implementation/aliased_ssa/Instruction.qll @@ -247,8 +247,7 @@ class Instruction extends Construction::TStageInstruction { * Gets the type of the result produced by this instruction. If the instruction does not produce * a result, its result type will be `IRVoidType`. */ - cached - final IRType getResultIRType() { result = this.getResultLanguageType().getIRType() } + final IRType getResultIRType() { result = Construction::getInstructionResultIRType(this) } /** * Gets the type of the result produced by this instruction. If the diff --git a/cpp/ql/lib/semmle/code/cpp/ir/implementation/aliased_ssa/internal/SSAConstruction.qll b/cpp/ql/lib/semmle/code/cpp/ir/implementation/aliased_ssa/internal/SSAConstruction.qll index 209c42726b7d..d2e68c733041 100644 --- a/cpp/ql/lib/semmle/code/cpp/ir/implementation/aliased_ssa/internal/SSAConstruction.qll +++ b/cpp/ql/lib/semmle/code/cpp/ir/implementation/aliased_ssa/internal/SSAConstruction.qll @@ -429,6 +429,11 @@ private module Cached { instr = unreachedInstruction(_) and result = Language::getVoidType() } + cached + IRType getInstructionResultIRType(Instruction instr) { + result = instr.getResultLanguageType().getIRType() + } + /** * Holds if `opcode` is the opcode that specifies the operation performed by `instr`. * diff --git a/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/Instruction.qll b/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/Instruction.qll index 189ffce2903e..53a225c2e89f 100644 --- a/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/Instruction.qll +++ b/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/Instruction.qll @@ -247,8 +247,7 @@ class Instruction extends Construction::TStageInstruction { * Gets the type of the result produced by this instruction. If the instruction does not produce * a result, its result type will be `IRVoidType`. */ - cached - final IRType getResultIRType() { result = this.getResultLanguageType().getIRType() } + final IRType getResultIRType() { result = Construction::getInstructionResultIRType(this) } /** * Gets the type of the result produced by this instruction. If the diff --git a/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/IRConstruction.qll b/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/IRConstruction.qll index 96a01954d17f..7bea8178d141 100644 --- a/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/IRConstruction.qll +++ b/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/IRConstruction.qll @@ -377,6 +377,10 @@ CppType getInstructionResultType(TStageInstruction instr) { result = getVoidType() } +IRType getInstructionResultIRType(Instruction instr) { + result = instr.getResultLanguageType().getIRType() +} + predicate getInstructionOpcode(Opcode opcode, TStageInstruction instr) { getInstructionTranslatedElement(instr).hasInstruction(opcode, getInstructionTag(instr), _) or diff --git a/cpp/ql/lib/semmle/code/cpp/ir/implementation/unaliased_ssa/Instruction.qll b/cpp/ql/lib/semmle/code/cpp/ir/implementation/unaliased_ssa/Instruction.qll index 189ffce2903e..53a225c2e89f 100644 --- a/cpp/ql/lib/semmle/code/cpp/ir/implementation/unaliased_ssa/Instruction.qll +++ b/cpp/ql/lib/semmle/code/cpp/ir/implementation/unaliased_ssa/Instruction.qll @@ -247,8 +247,7 @@ class Instruction extends Construction::TStageInstruction { * Gets the type of the result produced by this instruction. If the instruction does not produce * a result, its result type will be `IRVoidType`. */ - cached - final IRType getResultIRType() { result = this.getResultLanguageType().getIRType() } + final IRType getResultIRType() { result = Construction::getInstructionResultIRType(this) } /** * Gets the type of the result produced by this instruction. If the diff --git a/cpp/ql/lib/semmle/code/cpp/ir/implementation/unaliased_ssa/internal/SSAConstruction.qll b/cpp/ql/lib/semmle/code/cpp/ir/implementation/unaliased_ssa/internal/SSAConstruction.qll index 209c42726b7d..d2e68c733041 100644 --- a/cpp/ql/lib/semmle/code/cpp/ir/implementation/unaliased_ssa/internal/SSAConstruction.qll +++ b/cpp/ql/lib/semmle/code/cpp/ir/implementation/unaliased_ssa/internal/SSAConstruction.qll @@ -429,6 +429,11 @@ private module Cached { instr = unreachedInstruction(_) and result = Language::getVoidType() } + cached + IRType getInstructionResultIRType(Instruction instr) { + result = instr.getResultLanguageType().getIRType() + } + /** * Holds if `opcode` is the opcode that specifies the operation performed by `instr`. *