diff --git a/unified/ql/lib/codeql/unified/internal/AstExtra.qll b/unified/ql/lib/codeql/unified/internal/AstExtra.qll index df98711c975..ba625aad5fe 100644 --- a/unified/ql/lib/codeql/unified/internal/AstExtra.qll +++ b/unified/ql/lib/codeql/unified/internal/AstExtra.qll @@ -5,6 +5,39 @@ private import unified module Public { + /** + * A logical 'and' expression with short-circuiting. + */ + class LogicalAndExpr extends BinaryExpr { + LogicalAndExpr() { this.getOperator().getValue() = "&&" } + + Expr getAnOperand() { result = [this.getLeft(), this.getRight()] } + } + + /** + * Declaration of a local or top-level variable. + */ + class LocalVariableDeclaration extends VariableDeclaration { + private Block block; + + LocalVariableDeclaration() { this = block.getStmt(_) } + + /** Gets the block in which this variable is declared. */ + Block getDeclaringBlock() { result = block } + } + + /** + * Declaration of a local or top-level function. + */ + class LocalFunctionDeclaration extends FunctionDeclaration { + private Block block; + + LocalFunctionDeclaration() { this = block.getStmt(_) } + + /** Gets the block in which this function is declared. */ + Block getDeclaringBlock() { result = block } + } + /** * A comment appearing in the source code. */