Skip to content

Commit d38cd4a

Browse files
authored
Merge pull request #8156 from alexet/alexet/expression-pragma-doc
QLSpeciifcation: Add documentation for expression pragmas
2 parents 8b926f6 + 6b9ccd6 commit d38cd4a

File tree

1 file changed

+34
-4
lines changed

1 file changed

+34
-4
lines changed

docs/codeql/ql-language-reference/ql-language-specification.rst

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -998,10 +998,14 @@ There are several kinds of expressions:
998998
| literal
999999
| variable
10001000
| super_expr
1001-
| callwithresult
10021001
| postfix_cast
1002+
| callwithresults
10031003
| aggregation
1004+
| expression_pragma
10041005
| any
1006+
| range
1007+
| setliteral
1008+
10051009

10061010
Parenthesized expressions
10071011
~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -1303,6 +1307,26 @@ The values of an ``any`` expression are those values of the expression for which
13031307

13041308
The abbreviated cases for an ``any`` expression are interpreted in the same way as for an aggregation.
13051309

1310+
Expression Pragma
1311+
~~~~~~~~~~~~~~~~~
1312+
1313+
Expression pragmas can be used to guide optimization.
1314+
1315+
::
1316+
expression_pragma ::= "pragma" "[" expression_pragma_type "]" "(" expr ")"
1317+
1318+
expression_pragma_type ::= "only_bind_out" | "only_bind_into"
1319+
1320+
The values of an expression pragma are the values of the contained expression.
1321+
1322+
The type `only_bind_out` hints that uses of the result of the expression pragma should not be used to guide the evaluation of the result of the contained expression.
1323+
When checking to see that all values are bound the compiler does not assume that if the result of the expression pragma is bound then the result of the contained
1324+
expression is bound.
1325+
1326+
The type `only_bind_into` hints that uses of the contained expression should not be used to guide the evaluation of the result of the expression pragma.
1327+
When checking to see that all values are bound the compiler does not assume that if the result of the contained expression is bound then the result of the
1328+
expression pragma is bound.
1329+
13061330
Ranges
13071331
~~~~~~
13081332

@@ -1506,9 +1530,10 @@ A range check has the following syntax:
15061530

15071531
::
15081532

1509-
inrange ::= expr "in" range
1533+
inrange ::= expr "in" (range | setliteral)
1534+
15101535

1511-
The formula is equivalent to ``expr "=" range``.
1536+
The formula is equivalent to ``expr "=" range`` or ``expr "=" setliteral``.
15121537

15131538
Calls
15141539
~~~~~
@@ -2107,7 +2132,7 @@ The complete grammar for QL is as follows:
21072132

21082133
instanceof ::= expr "instanceof" type
21092134

2110-
inrange ::= expr "in" range
2135+
inrange ::= expr "in" (range | setliteral)
21112136

21122137
call ::= predicateRef (closure)? "(" (exprs)? ")"
21132138
| primary "." predicateName (closure)? "(" (exprs)? ")"
@@ -2128,6 +2153,7 @@ The complete grammar for QL is as follows:
21282153
| postfix_cast
21292154
| callwithresults
21302155
| aggregation
2156+
| expression_pragma
21312157
| any
21322158
| range
21332159
| setliteral
@@ -2159,6 +2185,10 @@ The complete grammar for QL is as follows:
21592185
| aggid ("[" expr "]")? "(" as_exprs ("order" "by" aggorderbys)? ")"
21602186
| "unique" "(" var_decls "|" (formula)? ("|" as_exprs)? ")"
21612187
2188+
expression_pragma ::= "pragma" "[" expression_pragma_type "]" "(" expr ")"
2189+
2190+
expression_pragma_type ::= "only_bind_out" | "only_bind_into"
2191+
21622192
aggid ::= "avg" | "concat" | "count" | "max" | "min" | "rank" | "strictconcat" | "strictcount" | "strictsum" | "sum"
21632193

21642194
aggorderbys ::= aggorderby ("," aggorderby)*

0 commit comments

Comments
 (0)