mirror of
https://github.com/github/codeql.git
synced 2025-12-22 11:46:32 +01:00
C++: Recurse through 'LogicalNotInstruction' in 'getConstantValue'.
This commit is contained in:
@@ -12,6 +12,9 @@ int getConstantValue(Instruction instr) {
|
|||||||
or
|
or
|
||||||
result = getConstantValue(instr.(CopyInstruction).getSourceValue())
|
result = getConstantValue(instr.(CopyInstruction).getSourceValue())
|
||||||
or
|
or
|
||||||
|
getConstantValue(instr.(LogicalNotInstruction).getUnary()) != 0 and
|
||||||
|
result = 0
|
||||||
|
or
|
||||||
exists(PhiInstruction phi |
|
exists(PhiInstruction phi |
|
||||||
phi = instr and
|
phi = instr and
|
||||||
result = unique(Operand op | op = phi.getAnInputOperand() | getConstantValue(op.getDef()))
|
result = unique(Operand op | op = phi.getAnInputOperand() | getConstantValue(op.getDef()))
|
||||||
@@ -26,28 +29,25 @@ private predicate binaryInstructionOperands(BinaryInstruction instr, int left, i
|
|||||||
|
|
||||||
pragma[noinline]
|
pragma[noinline]
|
||||||
private int getBinaryInstructionValue(BinaryInstruction instr) {
|
private int getBinaryInstructionValue(BinaryInstruction instr) {
|
||||||
exists(int left, int right |
|
exists(int left, int right | binaryInstructionOperands(instr, left, right) |
|
||||||
binaryInstructionOperands(instr, left, right) and
|
instr instanceof AddInstruction and result = add(left, right)
|
||||||
(
|
or
|
||||||
instr instanceof AddInstruction and result = add(left, right)
|
instr instanceof SubInstruction and result = sub(left, right)
|
||||||
or
|
or
|
||||||
instr instanceof SubInstruction and result = sub(left, right)
|
instr instanceof MulInstruction and result = mul(left, right)
|
||||||
or
|
or
|
||||||
instr instanceof MulInstruction and result = mul(left, right)
|
instr instanceof DivInstruction and result = div(left, right)
|
||||||
or
|
or
|
||||||
instr instanceof DivInstruction and result = div(left, right)
|
instr instanceof CompareEQInstruction and result = compareEQ(left, right)
|
||||||
or
|
or
|
||||||
instr instanceof CompareEQInstruction and result = compareEQ(left, right)
|
instr instanceof CompareNEInstruction and result = compareNE(left, right)
|
||||||
or
|
or
|
||||||
instr instanceof CompareNEInstruction and result = compareNE(left, right)
|
instr instanceof CompareLTInstruction and result = compareLT(left, right)
|
||||||
or
|
or
|
||||||
instr instanceof CompareLTInstruction and result = compareLT(left, right)
|
instr instanceof CompareGTInstruction and result = compareGT(left, right)
|
||||||
or
|
or
|
||||||
instr instanceof CompareGTInstruction and result = compareGT(left, right)
|
instr instanceof CompareLEInstruction and result = compareLE(left, right)
|
||||||
or
|
or
|
||||||
instr instanceof CompareLEInstruction and result = compareLE(left, right)
|
instr instanceof CompareGEInstruction and result = compareGE(left, right)
|
||||||
or
|
|
||||||
instr instanceof CompareGEInstruction and result = compareGE(left, right)
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user