Skip to content

Commit bd70ab4

Browse files
committed
Binary: Add consistency queries.
1 parent 1d52fff commit bd70ab4

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

  • binary/ql/lib/semmle/code/binary/ast/ir/internal/Instruction0
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
private import TranslatedElement
2+
private import TranslatedInstruction
3+
private import semmle.code.binary.ast.ir.internal.InstructionTag
4+
private import Instruction0::Instruction0
5+
private import codeql.controlflow.SuccessorType
6+
7+
query predicate nonUniqueSuccessor(Instruction i, SuccessorType t, int k) {
8+
k = strictcount(i.getSuccessor(t)) and
9+
k > 1
10+
}
11+
12+
query predicate nonUniqueResultVariable(Instruction i, int k) {
13+
strictcount(i.getResultVariable()) = k and
14+
k > 1
15+
}
16+
17+
query predicate nonUniqueOpcode(TranslatedInstruction ti, InstructionTag tag, int k) {
18+
strictcount(Opcode opcode | ti.hasInstruction(opcode, tag, _)) = k and
19+
k > 1
20+
}
21+
22+
query predicate nonUniqueVariableOperand(
23+
TranslatedInstruction ti, InstructionTag tag, OperandTag operandTag, int k
24+
) {
25+
strictcount(ti.getVariableOperand(tag, operandTag)) = k and
26+
k > 1
27+
}

0 commit comments

Comments
 (0)