mirror of
https://github.com/github/codeql.git
synced 2026-05-01 03:35:13 +02:00
Apply suggestions from code review
Co-Authored-By: Dave Bartolomeo <42150477+dave-bartolomeo@users.noreply.github.com>
This commit is contained in:
@@ -11,7 +11,7 @@ private class IntValue = Ints::IntValue;
|
||||
|
||||
private predicate hasResultMemoryAccess(Instruction instr, IRVariable var, Type type, IntValue startBitOffset,
|
||||
IntValue endBitOffset) {
|
||||
resultPointsTo(instr.getResultAddressOperand().getAnyDef(), var, startBitOffset) and
|
||||
resultPointsTo(instr.getResultAddress(), var, startBitOffset) and
|
||||
type = instr.getResultType() and
|
||||
if exists(instr.getResultSize()) then
|
||||
endBitOffset = Ints::add(startBitOffset, Ints::mul(instr.getResultSize(), 8))
|
||||
@@ -21,7 +21,7 @@ private predicate hasResultMemoryAccess(Instruction instr, IRVariable var, Type
|
||||
|
||||
private predicate hasOperandMemoryAccess(MemoryOperand operand, IRVariable var, Type type, IntValue startBitOffset,
|
||||
IntValue endBitOffset) {
|
||||
resultPointsTo(operand.getAddressOperand().getAnyDef(), var, startBitOffset) and
|
||||
resultPointsTo(operand.getAddress().getAnyDef(), var, startBitOffset) and
|
||||
type = operand.getType() and
|
||||
if exists(operand.getSize()) then
|
||||
endBitOffset = Ints::add(startBitOffset, Ints::mul(operand.getSize(), 8))
|
||||
|
||||
@@ -22,8 +22,8 @@ IntValue getConstantValue(Instruction instr) {
|
||||
result = getConstantValue(instr.(CopyInstruction).getSourceValue()) or
|
||||
exists(PhiInstruction phi |
|
||||
phi = instr and
|
||||
result = max(PhiInputOperand operand | operand = phi.getAnOperand() | getConstantValue(operand.getAnyDef())) and
|
||||
result = min(PhiInputOperand operand | operand = phi.getAnOperand() | getConstantValue(operand.getAnyDef()))
|
||||
result = max(PhiInputOperand operand | operand = phi.getAnOperand() | getConstantValue(operand.getDef())) and
|
||||
result = min(PhiInputOperand operand | operand = phi.getAnOperand() | getConstantValue(operand.getDef()))
|
||||
)
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ predicate valueFlowStep(Instruction i, Operand op, int delta) {
|
||||
i.(AddInstruction).getAnOperand() = x and
|
||||
op != x
|
||||
|
|
||||
delta = getValue(getConstantValue(x.getAnyDef()))
|
||||
delta = getValue(getConstantValue(x.getDef()))
|
||||
)
|
||||
or
|
||||
exists(Operand x |
|
||||
|
||||
@@ -331,12 +331,12 @@ private predicate binaryOpSigns(BinaryInstruction i, Sign lhs, Sign rhs) {
|
||||
}
|
||||
|
||||
private Sign unguardedOperandSign(Operand operand) {
|
||||
result = instructionSign(operand.getAnyDef()) and
|
||||
result = instructionSign(operand.getDef()) and
|
||||
not hasGuard(operand, result)
|
||||
}
|
||||
|
||||
private Sign guardedOperandSign(Operand operand) {
|
||||
result = instructionSign(operand.getAnyDef()) and
|
||||
result = instructionSign(operand.getDef()) and
|
||||
hasGuard(operand, result)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user