diff --git a/cpp/ql/src/semmle/code/cpp/ir/internal/Instruction.qll b/cpp/ql/src/semmle/code/cpp/ir/internal/Instruction.qll index d00999f894a..241f8cadd46 100644 --- a/cpp/ql/src/semmle/code/cpp/ir/internal/Instruction.qll +++ b/cpp/ql/src/semmle/code/cpp/ir/internal/Instruction.qll @@ -66,6 +66,13 @@ module InstructionSanity { count(instr.getOperand(tag)) > 1 and not tag instanceof UnmodeledUseOperand } + + query predicate operandAcrossFunctions( + Instruction op, Instruction operand, OperandTag tag + ) { + operand = op.getOperand(tag) and + operand.getFunctionIR() != op.getFunctionIR() + } } /** @@ -302,7 +309,6 @@ class Instruction extends Construction::TInstruction { * an operand with tag `useTag`. */ final predicate hasUse(Instruction useInstruction, OperandTag useTag) { - useInstruction.getFunctionIR() = funcIR and this = useInstruction.getOperand(useTag) } } diff --git a/cpp/ql/src/semmle/code/cpp/ssa/internal/aliased_ssa/Instruction.qll b/cpp/ql/src/semmle/code/cpp/ssa/internal/aliased_ssa/Instruction.qll index d00999f894a..241f8cadd46 100644 --- a/cpp/ql/src/semmle/code/cpp/ssa/internal/aliased_ssa/Instruction.qll +++ b/cpp/ql/src/semmle/code/cpp/ssa/internal/aliased_ssa/Instruction.qll @@ -66,6 +66,13 @@ module InstructionSanity { count(instr.getOperand(tag)) > 1 and not tag instanceof UnmodeledUseOperand } + + query predicate operandAcrossFunctions( + Instruction op, Instruction operand, OperandTag tag + ) { + operand = op.getOperand(tag) and + operand.getFunctionIR() != op.getFunctionIR() + } } /** @@ -302,7 +309,6 @@ class Instruction extends Construction::TInstruction { * an operand with tag `useTag`. */ final predicate hasUse(Instruction useInstruction, OperandTag useTag) { - useInstruction.getFunctionIR() = funcIR and this = useInstruction.getOperand(useTag) } } diff --git a/cpp/ql/src/semmle/code/cpp/ssa/internal/ssa/Instruction.qll b/cpp/ql/src/semmle/code/cpp/ssa/internal/ssa/Instruction.qll index d00999f894a..241f8cadd46 100644 --- a/cpp/ql/src/semmle/code/cpp/ssa/internal/ssa/Instruction.qll +++ b/cpp/ql/src/semmle/code/cpp/ssa/internal/ssa/Instruction.qll @@ -66,6 +66,13 @@ module InstructionSanity { count(instr.getOperand(tag)) > 1 and not tag instanceof UnmodeledUseOperand } + + query predicate operandAcrossFunctions( + Instruction op, Instruction operand, OperandTag tag + ) { + operand = op.getOperand(tag) and + operand.getFunctionIR() != op.getFunctionIR() + } } /** @@ -302,7 +309,6 @@ class Instruction extends Construction::TInstruction { * an operand with tag `useTag`. */ final predicate hasUse(Instruction useInstruction, OperandTag useTag) { - useInstruction.getFunctionIR() = funcIR and this = useInstruction.getOperand(useTag) } }