mirror of
https://github.com/github/codeql.git
synced 2026-03-18 13:36:47 +01:00
C++: Add constant analysis for bitwise operations now that these are no longer constant folded by IR construction.
This commit is contained in:
@@ -38,6 +38,12 @@ private int getBinaryInstructionValue(BinaryInstruction instr) {
|
||||
or
|
||||
instr instanceof DivInstruction and result = div(left, right)
|
||||
or
|
||||
instr instanceof BitOrInstruction and result = bitOr(left, right)
|
||||
or
|
||||
instr instanceof BitAndInstruction and result = bitAnd(left, right)
|
||||
or
|
||||
instr instanceof BitXorInstruction and result = bitXor(left, right)
|
||||
or
|
||||
instr instanceof CompareEQInstruction and result = compareEQ(left, right)
|
||||
or
|
||||
instr instanceof CompareNEInstruction and result = compareNE(left, right)
|
||||
|
||||
@@ -89,6 +89,18 @@ int compareLE(int a, int b) { if a <= b then result = 1 else result = 0 }
|
||||
bindingset[a, b]
|
||||
int compareGE(int a, int b) { if a >= b then result = 1 else result = 0 }
|
||||
|
||||
/** Returns `a >= b`. */
|
||||
bindingset[a, b]
|
||||
int bitOr(int a, int b) { result = a.bitOr(b) }
|
||||
|
||||
/** Returns `a >= b`. */
|
||||
bindingset[a, b]
|
||||
int bitAnd(int a, int b) { result = a.bitAnd(b) }
|
||||
|
||||
/** Returns `a >= b`. */
|
||||
bindingset[a, b]
|
||||
int bitXor(int a, int b) { result = a.bitXor(b) }
|
||||
|
||||
/**
|
||||
* Returns `-a`. If the negation would overflow, there is no result.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user