qtil
advanced-security/qtil-swift 0.0.3
Search

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 Set is not properly constrained, then the results of someOperand() and otherOperand() may not be different operands. Always bind the Set to be a singular instance, e.g. exists(TwoOperands<BinaryExpr>::Set set | ... ), and never mix getASet calls, e.g. ...::getASet(e).someOperand().... and ...::getASet(e).otherOperand()......
  • The Set class extends the operand returned by someOperand(). This perhaps unexpected approach is done to allow the CodeQL engine to perform optimizations by inlining which would not be possible if the Set class was a newtype of all operand pairs, while allowing that someOperand() and otherOperand() to consistent and different.

For an alternative, more minimal API see the set predicate.

Import path

import qtil.ast.TwoOperands

Direct supertypes

Fields

other

Since this class extends Operand, the field other holds the other one.

parent

The operation that uses this set of two operands.

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().

someOperand

Get some operand of the operation that is different from otherOperand().

Inherited predicates

inst

Convenience method to cast this to the instance type T.

from Type
toStringfrom Type

Charpred