From 631419a9125661c0008b53f461622556a9a2f56d Mon Sep 17 00:00:00 2001 From: Anders Schack-Mulligen Date: Tue, 1 Sep 2026 09:50:56 +0200 Subject: [PATCH 1/3] Unified: Add BinaryExpr.getAnOperand to FacadeAst. --- unified/ql/lib/codeql/unified/internal/AstExtra.qll | 2 -- unified/ql/lib/codeql/unified/internal/FacadeAst.qll | 5 +++++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/unified/ql/lib/codeql/unified/internal/AstExtra.qll b/unified/ql/lib/codeql/unified/internal/AstExtra.qll index 378712b86cb9..4b8f5a9f8bbf 100644 --- a/unified/ql/lib/codeql/unified/internal/AstExtra.qll +++ b/unified/ql/lib/codeql/unified/internal/AstExtra.qll @@ -10,8 +10,6 @@ module Public { */ class LogicalAndExpr extends BinaryExpr { LogicalAndExpr() { this.getOperator().getValue() = "&&" } - - Expr getAnOperand() { result = [this.getLeft(), this.getRight()] } } /** diff --git a/unified/ql/lib/codeql/unified/internal/FacadeAst.qll b/unified/ql/lib/codeql/unified/internal/FacadeAst.qll index 44adef76e425..60990e0016f9 100644 --- a/unified/ql/lib/codeql/unified/internal/FacadeAst.qll +++ b/unified/ql/lib/codeql/unified/internal/FacadeAst.qll @@ -49,6 +49,11 @@ module Unified { } } + /** A binary expression. */ + class BinaryExpr extends G::BinaryExpr { + Expr getAnOperand() { result = [this.getLeft(), this.getRight()] } + } + /** A function call */ class CallExpr extends G::CallExpr { /** Gets the named argument with the given `name`. */ From a1ac9b1c9b446aebee382a2b59dbaedb6a1d7254 Mon Sep 17 00:00:00 2001 From: Anders Schack-Mulligen Date: Tue, 1 Sep 2026 09:55:44 +0200 Subject: [PATCH 2/3] Unified: Add more logical expressions to AstExtra. --- .../lib/codeql/unified/internal/AstExtra.qll | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/unified/ql/lib/codeql/unified/internal/AstExtra.qll b/unified/ql/lib/codeql/unified/internal/AstExtra.qll index 4b8f5a9f8bbf..f5a9ad09caaa 100644 --- a/unified/ql/lib/codeql/unified/internal/AstExtra.qll +++ b/unified/ql/lib/codeql/unified/internal/AstExtra.qll @@ -5,13 +5,26 @@ 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() = "??" } + } + + /** A logical NOT expression. */ + class LogicalNotExpr extends UnaryExpr { + LogicalNotExpr() { this.getOperator().(PrefixOperator).getValue() = "!" } + } + /** * Declaration of a local or top-level variable. */ From 4f4ba85e56410adec1dcc0ec2d41c8e24d3a55b6 Mon Sep 17 00:00:00 2001 From: Anders Schack-Mulligen Date: Tue, 1 Sep 2026 10:07:17 +0200 Subject: [PATCH 3/3] Unified: Add qldoc. --- unified/ql/lib/codeql/unified/internal/FacadeAst.qll | 1 + 1 file changed, 1 insertion(+) diff --git a/unified/ql/lib/codeql/unified/internal/FacadeAst.qll b/unified/ql/lib/codeql/unified/internal/FacadeAst.qll index 60990e0016f9..af66648a345c 100644 --- a/unified/ql/lib/codeql/unified/internal/FacadeAst.qll +++ b/unified/ql/lib/codeql/unified/internal/FacadeAst.qll @@ -51,6 +51,7 @@ module Unified { /** A binary expression. */ class BinaryExpr extends G::BinaryExpr { + /** Gets an operand of this binary expression. */ Expr getAnOperand() { result = [this.getLeft(), this.getRight()] } }