mirror of
https://github.com/github/codeql.git
synced 2026-07-08 21:15:32 +02:00
unified: Add a few more AST helper classes
This commit is contained in:
@@ -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.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user