Skip to content

update QL specification on annotations for parameterised modules #13263

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
May 23, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 39 additions & 28 deletions docs/codeql/ql-language-reference/ql-language-specification.rst
Original file line number Diff line number Diff line change
Expand Up @@ -704,12 +704,14 @@ Various kinds of syntax can have *annotations* applied to them. Annotations are
simpleAnnotation ::= "abstract"
| "cached"
| "external"
| "extensible"
| "final"
| "transient"
| "library"
| "private"
| "deprecated"
| "override"
| "additional"
| "query"

argsAnnotation ::= "pragma" "[" ("inline" | "inline_late" | "noinline" | "nomagic" | "noopt" | "assume_small_delta") "]"
Expand All @@ -725,31 +727,36 @@ Simple annotations

The following table summarizes the syntactic constructs which can be marked with each annotation in a valid program; for example, an ``abstract`` annotation preceding a character is invalid.

+----------------+---------+------------+-------------------+-----------------------+---------+--------+---------+---------+
| Annotation | Classes | Characters | Member predicates | Non-member predicates | Imports | Fields | Modules | Aliases |
+================+=========+============+===================+=======================+=========+========+=========+=========+
| ``abstract`` | yes | | yes | | | | | |
+----------------+---------+------------+-------------------+-----------------------+---------+--------+---------+---------+
| ``cached`` | yes | yes | yes | yes | | | yes | |
+----------------+---------+------------+-------------------+-----------------------+---------+--------+---------+---------+
| ``external`` | | | | yes | | | | |
+----------------+---------+------------+-------------------+-----------------------+---------+--------+---------+---------+
| ``final`` | yes | | yes | | | yes | | yes |
+----------------+---------+------------+-------------------+-----------------------+---------+--------+---------+---------+
| ``transient`` | | | | yes | | | | |
+----------------+---------+------------+-------------------+-----------------------+---------+--------+---------+---------+
| ``library`` | yes | | | | | | | |
+----------------+---------+------------+-------------------+-----------------------+---------+--------+---------+---------+
| ``private`` | yes | | yes | yes | yes | yes | yes | yes |
+----------------+---------+------------+-------------------+-----------------------+---------+--------+---------+---------+
| ``deprecated`` | yes | | yes | yes | | yes | yes | yes |
+----------------+---------+------------+-------------------+-----------------------+---------+--------+---------+---------+
| ``override`` | | | yes | | | yes | | |
+----------------+---------+------------+-------------------+-----------------------+---------+--------+---------+---------+
| ``query`` | | | | yes | | | | yes |
+----------------+---------+------------+-------------------+-----------------------+---------+--------+---------+---------+
+----------------+---------+------------+-------------------+-----------------------+---------+--------+---------+---------+------------+
| Annotation | Classes | Characters | Member predicates | Non-member predicates | Imports | Fields | Modules | Aliases | Signatures |
+================+=========+============+===================+=======================+=========+========+=========+=========+============+
| ``abstract`` | yes | | yes | | | | | | |
+----------------+---------+------------+-------------------+-----------------------+---------+--------+---------+---------+------------+
| ``cached`` | yes | yes | yes | yes | | | yes | | |
+----------------+---------+------------+-------------------+-----------------------+---------+--------+---------+---------+------------+
| ``external`` | | | | yes | | | | | |
+----------------+---------+------------+-------------------+-----------------------+---------+--------+---------+---------+------------+
| ``extensible`` | | | | yes | | | | | |
+----------------+---------+------------+-------------------+-----------------------+---------+--------+---------+---------+------------+
| ``final`` | yes | | yes | | | yes | | (yes) | |
+----------------+---------+------------+-------------------+-----------------------+---------+--------+---------+---------+------------+
| ``transient`` | | | | yes | | | | | |
+----------------+---------+------------+-------------------+-----------------------+---------+--------+---------+---------+------------+
| ``library`` | (yes) | | | | | | | | |
+----------------+---------+------------+-------------------+-----------------------+---------+--------+---------+---------+------------+
| ``private`` | yes | | yes | yes | yes | yes | yes | yes | yes |
+----------------+---------+------------+-------------------+-----------------------+---------+--------+---------+---------+------------+
| ``deprecated`` | yes | | yes | yes | | yes | yes | yes | yes |
+----------------+---------+------------+-------------------+-----------------------+---------+--------+---------+---------+------------+
| ``override`` | | | yes | | | yes | | | |
+----------------+---------+------------+-------------------+-----------------------+---------+--------+---------+---------+------------+
| ``additional`` | yes | | | yes | | | yes | yes | yes |
+----------------+---------+------------+-------------------+-----------------------+---------+--------+---------+---------+------------+
| ``query`` | | | | yes | | | | yes | |
+----------------+---------+------------+-------------------+-----------------------+---------+--------+---------+---------+------------+

The ``library`` annotation is only usable within a QLL file, not a QL file.
The ``final`` annotation is usable on type aliases, but not on module aliases and predicate aliases.

Annotations on aliases apply to the name introduced by the alias. An alias may, for example, have different privacy to the name it aliases.

Expand Down Expand Up @@ -799,11 +806,13 @@ Binding sets are checked by the QL compiler in the following way:

A predicate may have several different binding sets, which can be stated by using multiple ``bindingset`` annotations on the same predicate.

+----------------+---------+------------+-------------------+-----------------------+---------+--------+---------+---------+
| Pragma | Classes | Characters | Member predicates | Non-member predicates | Imports | Fields | Modules | Aliases |
+================+=========+============+===================+=======================+=========+========+=========+=========+
| ``bindingset`` | | yes | yes | yes | | | | |
+----------------+---------+------------+-------------------+-----------------------+---------+--------+---------+---------+
+----------------+---------+------------+-------------------+-----------------------+---------+--------+---------+---------+------------+
| Pragma | Classes | Characters | Member predicates | Non-member predicates | Imports | Fields | Modules | Aliases | Signatures |
+================+=========+============+===================+=======================+=========+========+=========+=========+============+
| ``bindingset`` | | yes | yes | yes | | | | | (yes) |
+----------------+---------+------------+-------------------+-----------------------+---------+--------+---------+---------+------------+

The ``bindingset`` pragma is usable with type signatures and predicate signatures, but not with module signatures.

QLDoc
-----
Expand Down Expand Up @@ -2159,12 +2168,14 @@ The complete grammar for QL is as follows:
simpleAnnotation ::= "abstract"
| "cached"
| "external"
| "extensible"
| "final"
| "transient"
| "library"
| "private"
| "deprecated"
| "override"
| "additional"
| "query"

argsAnnotation ::= "pragma" "[" ("inline" | "inline_late" | "noinline" | "nomagic" | "noopt" | "assume_small_delta") "]"
Expand Down