diff --git a/unified/ql/lib/codeql/unified/internal/AstExtra.qll b/unified/ql/lib/codeql/unified/internal/AstExtra.qll index 378712b86cb9..f5a9ad09caaa 100644 --- a/unified/ql/lib/codeql/unified/internal/AstExtra.qll +++ b/unified/ql/lib/codeql/unified/internal/AstExtra.qll @@ -5,13 +5,24 @@ private import unified module Public { - /** - * A logical 'and' expression with short-circuiting. - */ + /** A short-circuiting logical AND expression. */ class LogicalAndExpr extends BinaryExpr { LogicalAndExpr() { this.getOperator().getValue() = "&&" } + } + + /** A short-circuiting logical OR expression. */ + class LogicalOrExpr extends BinaryExpr { + LogicalOrExpr() { this.getOperator().getValue() = "||" } + } + + /** A short-circuiting null-coalescing expression. */ + class NullCoalescingExpr extends BinaryExpr { + NullCoalescingExpr() { this.getOperator().getValue() = "??" } + } - Expr getAnOperand() { result = [this.getLeft(), this.getRight()] } + /** A logical NOT expression. */ + class LogicalNotExpr extends UnaryExpr { + LogicalNotExpr() { this.getOperator().(PrefixOperator).getValue() = "!" } } /** diff --git a/unified/ql/lib/codeql/unified/internal/FacadeAst.qll b/unified/ql/lib/codeql/unified/internal/FacadeAst.qll index 44adef76e425..af66648a345c 100644 --- a/unified/ql/lib/codeql/unified/internal/FacadeAst.qll +++ b/unified/ql/lib/codeql/unified/internal/FacadeAst.qll @@ -49,6 +49,12 @@ module Unified { } } + /** A binary expression. */ + class BinaryExpr extends G::BinaryExpr { + /** Gets an operand of this binary expression. */ + Expr getAnOperand() { result = [this.getLeft(), this.getRight()] } + } + /** A function call */ class CallExpr extends G::CallExpr { /** Gets the named argument with the given `name`. */