Skip to content

Commit 5473162

Browse files
committed
QLSpec: Add documentation for expression pragmas
1 parent e2bc03c commit 5473162

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

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

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1001,6 +1001,7 @@ There are several kinds of expressions:
10011001
| postfix_cast
10021002
| callwithresults
10031003
| aggregation
1004+
| expression_pragma
10041005
| any
10051006
| range
10061007
| setliteral
@@ -1306,6 +1307,26 @@ The values of an ``any`` expression are those values of the expression for which
13061307

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

1310+
Expression Pragma
1311+
~~~~~~~~~~~~~~~~
1312+
1313+
Expression pragmas can be used to guide optimisation.
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 expression.
1321+
1322+
The type `only_bind_out` hints that uses 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 the result of expression pragma 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+
13091330
Ranges
13101331
~~~~~~
13111332

@@ -2131,6 +2152,7 @@ The complete grammar for QL is as follows:
21312152
| postfix_cast
21322153
| callwithresults
21332154
| aggregation
2155+
| expression_pragma
21342156
| any
21352157
| range
21362158
| setliteral
@@ -2162,6 +2184,10 @@ The complete grammar for QL is as follows:
21622184
| aggid ("[" expr "]")? "(" as_exprs ("order" "by" aggorderbys)? ")"
21632185
| "unique" "(" var_decls "|" (formula)? ("|" as_exprs)? ")"
21642186
2187+
expression_pragma ::= "pragma" "[" expression_pragma_type "]" "(" expr ")"
2188+
2189+
expression_pragma_type ::= "only_bind_out" | "only_bind_into"
2190+
21652191
aggid ::= "avg" | "concat" | "count" | "max" | "min" | "rank" | "strictconcat" | "strictcount" | "strictsum" | "sum"
21662192

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

0 commit comments

Comments
 (0)