Skip to content

Commit 98a0959

Browse files
committed
Docs: New "directional binding" pragmas
1 parent 2d618d6 commit 98a0959

File tree

1 file changed

+37
-4
lines changed

1 file changed

+37
-4
lines changed

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

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,6 @@ This means that it is part of the output of the QL program.
259259
Compiler pragmas
260260
================
261261

262-
**Available for**: |characteristic predicates|, |member predicates|, |non-member predicates|
263-
264262
The following compiler pragmas affect the compilation and optimization of queries. You
265263
should avoid using these annotations unless you experience significant performance issues.
266264

@@ -284,6 +282,8 @@ predicates.
284282
``pragma[inline]``
285283
------------------
286284

285+
**Available for**: |characteristic predicates|, |member predicates|, |non-member predicates|
286+
287287
The ``pragma[inline]`` annotation tells the QL optimizer to always inline the annotated predicate
288288
into the places where it is called. This can be useful when a predicate body is very expensive to
289289
compute entirely, as it ensures that the predicate is evaluated with the other contextual information
@@ -292,6 +292,8 @@ at the places where it is called.
292292
``pragma[noinline]``
293293
--------------------
294294

295+
**Available for**: |characteristic predicates|, |member predicates|, |non-member predicates|
296+
295297
The ``pragma[noinline]`` annotation is used to prevent a predicate from being inlined into the
296298
place where it is called. In practice, this annotation is useful when you've already grouped
297299
certain variables together in a "helper" predicate, to ensure that the relation is evaluated
@@ -301,6 +303,8 @@ work of the helper predicate, so it's a good idea to annotate it with ``pragma[n
301303
``pragma[nomagic]``
302304
-------------------
303305

306+
**Available for**: |characteristic predicates|, |member predicates|, |non-member predicates|
307+
304308
The ``pragma[nomagic]`` annotation is used to prevent the QL optimizer from performing the "magic sets"
305309
optimization on a predicate.
306310

@@ -314,6 +318,8 @@ Note that ``nomagic`` implies ``noinline``.
314318
``pragma[noopt]``
315319
-----------------
316320

321+
**Available for**: |characteristic predicates|, |member predicates|, |non-member predicates|
322+
317323
The ``pragma[noopt]`` annotation is used to prevent the QL optimizer from optimizing a
318324
predicate, except when it's absolutely necessary for compilation and evaluation to work.
319325

@@ -364,7 +370,33 @@ When you use this annotation, be aware of the following issues:
364370
succ.getSucc() = 3
365371
)
366372
}
367-
373+
374+
``pragma[only_bind_out]``
375+
-------------------------
376+
377+
**Available for**: |expressions|
378+
379+
The ``pragma[only_bind_out]`` annotation lets you specify the direction in which the QL compiler should bind expressions.
380+
This can be useful to improve performance in rare cases where the QL optimizer orders parts of the QL program in an inefficient way.
381+
382+
For example, ``x = pragma[only_bind_out](y)`` is semantically equivalent to ``x = y``, but has different binding behavior.
383+
``x = y`` binds ``x`` from ``y`` and vice versa, while ``x = pragma[only_bind_out](y)`` only binds ``x`` from ``y``.
384+
385+
For more information, see ":ref:`Binding <binding>`."
386+
387+
``pragma[only_bind_into]``
388+
--------------------------
389+
390+
**Available for**: |expressions|
391+
392+
The ``pragma[only_bind_into]`` annotation lets you specify the direction in which the QL compiler should bind expressions.
393+
This can be useful to improve performance in rare cases where the QL optimizer orders parts of the QL program in an inefficient way.
394+
395+
For example, ``x = pragma[only_bind_into](y)`` is semantically equivalent to ``x = y``, but has different binding behavior.
396+
``x = y`` binds ``x`` from ``y`` and vice versa, while ``x = pragma[only_bind_into](y)`` only binds ``y`` from ``x``.
397+
398+
For more information, see ":ref:`Binding <binding>`."
399+
368400
.. _language:
369401

370402
Language pragmas
@@ -413,4 +445,5 @@ The ``bindingset`` annotation takes a comma-separated list of variables.
413445
.. |fields| replace:: :ref:`fields <fields>`
414446
.. |modules| replace:: :ref:`modules <modules>`
415447
.. |aliases| replace:: :ref:`aliases <aliases>`
416-
.. |algebraic datatypes| replace:: :ref:`algebraic datatypes <algebraic-datatypes>`
448+
.. |algebraic datatypes| replace:: :ref:`algebraic datatypes <algebraic-datatypes>`
449+
.. |expressions| replace:: :ref:`expressions <expressions>`

0 commit comments

Comments
 (0)