Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions unified/ql/lib/codeql/unified/internal/AstExtra.qll
Original file line number Diff line number Diff line change
Expand Up @@ -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() = "||" }
Comment on lines +13 to +15
}

/** 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() = "!" }
}

/**
Expand Down
6 changes: 6 additions & 0 deletions unified/ql/lib/codeql/unified/internal/FacadeAst.qll
Original file line number Diff line number Diff line change
Expand Up @@ -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`. */
Expand Down
Loading