Skip to content

Commit 1ec868e

Browse files
committed
QL: various improvements to Ast.qll
1 parent 95ae113 commit 1ec868e

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

ql/ql/src/codeql_ql/ast/Ast.qll

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ class AstNode extends TAstNode {
6363
pred = directMember("getQLDoc") and result = this.getQLDoc()
6464
}
6565

66+
/** Gets any child of this node. */
67+
AstNode getAChild() { result = this.getAChild(_) }
68+
6669
/**
6770
* Gets the primary QL class for the ast node.
6871
*/
@@ -1238,14 +1241,7 @@ class Boolean extends Literal {
12381241

12391242
/** A comparison symbol, such as `"<"` or `"="`. */
12401243
class ComparisonSymbol extends string {
1241-
ComparisonSymbol() {
1242-
this = "=" or
1243-
this = "!=" or
1244-
this = "<" or
1245-
this = ">" or
1246-
this = "<=" or
1247-
this = ">="
1248-
}
1244+
ComparisonSymbol() { this = ["=", "!=", "<", ">", "<=", ">="] }
12491245
}
12501246

12511247
/** A comparison formula, such as `x < 3` or `y = true`. */
@@ -1287,10 +1283,7 @@ class Quantifier extends TQuantifier, Formula {
12871283
}
12881284

12891285
/** Gets the ith variable declaration of this quantifier. */
1290-
VarDecl getArgument(int i) {
1291-
i >= 1 and
1292-
toQL(result) = quant.getChild(i - 1)
1293-
}
1286+
VarDecl getArgument(int i) { toQL(result) = quant.getChild(i + 1) }
12941287

12951288
/** Gets an argument of this quantifier. */
12961289
VarDecl getAnArgument() { result = this.getArgument(_) }
@@ -1661,6 +1654,15 @@ class FullAggregate extends TFullAggregate, Aggregate {
16611654
}
16621655
}
16631656

1657+
/**
1658+
* A "any" expression, such as `any(int i | i > 0).toString()`.
1659+
*/
1660+
class Any extends FullAggregate {
1661+
Any() { this.getKind() = "any" }
1662+
1663+
override string getAPrimaryQlClass() { result = "Any" }
1664+
}
1665+
16641666
/**
16651667
* A "rank" expression, such as `rank[4](int i | i = [5 .. 15] | i)`.
16661668
*/
@@ -1855,7 +1857,7 @@ class ExprAnnotation extends TExprAnnotation, Expr {
18551857

18561858
/** A function symbol, such as `+` or `*`. */
18571859
class FunctionSymbol extends string {
1858-
FunctionSymbol() { this = "+" or this = "-" or this = "*" or this = "/" or this = "%" }
1860+
FunctionSymbol() { this = ["+", "-", "*", "/", "%"] }
18591861
}
18601862

18611863
/**

0 commit comments

Comments
 (0)