Class TwoOperands::Set
A class that represents a pair of operands of the same operation, where the two operands are different.
Example usage:
predicate myBinaryTest(Expr a, Expr b) {
exists(TwoOperands<BinaryExpr>::Set set |
set.someOperand().isInteger() and
set.otherOperand().isConstant()
)
}
There are two things to be careful about when using this class:
- If the
Setis not properly constrained, then the results ofsomeOperand()andotherOperand()may not be different operands. Always bind theSetto be a singular instance, e.g.exists(TwoOperands<BinaryExpr>::Set set | ... ), and never mixgetASetcalls, e.g....::getASet(e).someOperand().... and ...::getASet(e).otherOperand()...... - The
Setclass extends the operand returned bysomeOperand(). This perhaps unexpected approach is done to allow the CodeQL engine to perform optimizations by inlining which would not be possible if theSetclass was anewtypeof all operand pairs, while allowing thatsomeOperand()andotherOperand()to consistent and different.
For an alternative, more minimal API see the set predicate.
Import path
import qtil.ast.TwoOperandsDirect supertypes
Fields
Predicates
| getOperation | Get the operation that uses this set of two operands. |
| otherOperand | Get the other operand of the operation, which is different from |
| someOperand | Get some operand of the operation that is different from |