Skip to content

Commit f85f99c

Browse files
author
james
committed
update ql-language-reference links
1 parent e5fff64 commit f85f99c

15 files changed

+42
-42
lines changed

docs/language/README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Project structure
1818
The documentation currently consists of the following Sphinx projects:
1919

2020
- ``learn-ql``–help topics to help you learn CodeQL and write queries
21-
- ``ql-handbook``–an overview of important concepts in QL, the language that underlies CodeQL analysis
21+
- ``ql-language-reference``–an overview of important concepts in QL, the language that underlies CodeQL analysis
2222
- ``support``–the languages and frameworks currently supported in CodeQL analysis
2323
- ``ql-training``–source files for the CodeQL training and variant analysis examples slide decks
2424

docs/language/learn-ql/about-data-flow-analysis.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ flow between functions and through object properties. Global data flow, however,
4949
graph that do not precisely correspond to the flow of values, but model whether some value at runtime may be derived from another, for instance through a string manipulating
5050
operation.
5151

52-
The data flow graph is computed using `classes <https://help.semmle.com/QL/ql-handbook/types.html#classes>`__ to model the program elements that represent the graph's nodes.
53-
The flow of data between the nodes is modeled using `predicates <https://help.semmle.com/QL/ql-handbook/predicates.html>`__ to compute the graph's edges.
52+
The data flow graph is computed using `classes <https://help.semmle.com/QL/ql-language-reference/types.html#classes>`__ to model the program elements that represent the graph's nodes.
53+
The flow of data between the nodes is modeled using `predicates <https://help.semmle.com/QL/ql-language-reference/predicates.html>`__ to compute the graph's edges.
5454

5555
Computing an accurate and complete data flow graph presents several challenges:
5656

docs/language/learn-ql/beginner/catch-the-fire-starter.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Read the examples below to learn how to define predicates and classes in QL. The
1414
Select the southerners
1515
----------------------
1616

17-
This time you only need to consider a specific group of villagers, namely those living in the south of the village. Instead of writing ``getLocation() = "south"`` in all your queries, you could define a new `predicate <https://help.semmle.com/QL/ql-handbook/predicates.html>`__ ``isSouthern``:
17+
This time you only need to consider a specific group of villagers, namely those living in the south of the village. Instead of writing ``getLocation() = "south"`` in all your queries, you could define a new `predicate <https://help.semmle.com/QL/ql-language-reference/predicates.html>`__ ``isSouthern``:
1818

1919
.. code-block:: ql
2020
@@ -41,7 +41,7 @@ You can now list all southerners using:
4141
where isSouthern(p)
4242
select p
4343
44-
This is already a nice way to simplify the logic, but we could be more efficient. Currently, the query looks at every ``Person p``, and then restricts to those who satisfy ``isSouthern(p)``. Instead, we could define a new `class <https://help.semmle.com/QL/ql-handbook/types.html#classes>`__ ``Southerner`` containing precisely the people we want to consider.
44+
This is already a nice way to simplify the logic, but we could be more efficient. Currently, the query looks at every ``Person p``, and then restricts to those who satisfy ``isSouthern(p)``. Instead, we could define a new `class <https://help.semmle.com/QL/ql-language-reference/types.html#classes>`__ ``Southerner`` containing precisely the people we want to consider.
4545

4646
.. code-block:: ql
4747

docs/language/learn-ql/beginner/cross-the-river.rst

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ A solution should be a set of instructions for how to ferry the items, such as "
2020
across the river, and come back with nothing. Then ferry the cabbage across, and come back with ..."
2121

2222
There are lots of ways to approach this problem and implement it in QL. Before you start, make
23-
sure that you are familiar with how to define `classes <https://help.semmle.com/QL/ql-handbook/types.html#classes>`__
24-
and `predicates <https://help.semmle.com/QL/ql-handbook/predicates.html>`__ in QL.
23+
sure that you are familiar with how to define `classes <https://help.semmle.com/QL/ql-language-reference/types.html#classes>`__
24+
and `predicates <https://help.semmle.com/QL/ql-language-reference/predicates.html>`__ in QL.
2525
The following walkthrough is just one of many possible implementations, so have a go at writing your
2626
own query too! To find more example queries, see the list :ref:`below <alternatives>`.
2727

@@ -69,7 +69,7 @@ For example, if the man is on the left shore, the goat on the right shore, and t
6969
shore, the state should be ``Left, Right, Left, Left``.
7070

7171
You may find it helpful to introduce some variables that refer to the shore on which the man and the cargo items are. These
72-
temporary variables in the body of a class are called `fields <https://help.semmle.com/QL/ql-handbook/types.html#fields>`__.
72+
temporary variables in the body of a class are called `fields <https://help.semmle.com/QL/ql-language-reference/types.html#fields>`__.
7373

7474
.. container:: toggle
7575

@@ -159,12 +159,12 @@ could ferry the goat back and forth any number of times without ever reaching an
159159
Such a path would have an infinite number of river crossings without ever solving the puzzle.
160160

161161
One way to restrict our paths to a finite number of river crossings is to define a
162-
`member predicate <https://help.semmle.com/QL/ql-handbook/types.html#member-predicates>`__
162+
`member predicate <https://help.semmle.com/QL/ql-language-reference/types.html#member-predicates>`__
163163
``State reachesVia(string path, int steps)``.
164164
The result of this predicate is any state that is reachable from the current state (``this``) via
165165
the given path in a specified finite number of steps.
166166

167-
You can write this as a `recursive predicate <https://help.semmle.com/QL/ql-handbook/recursion.html>`__,
167+
You can write this as a `recursive predicate <https://help.semmle.com/QL/ql-language-reference/recursion.html>`__,
168168
with the following base case and recursion step:
169169

170170
- If ``this`` *is* the result state, then it (trivially) reaches the result state via an
@@ -218,7 +218,7 @@ the given path without revisiting any previously visited states.
218218
Display the results
219219
~~~~~~~~~~~~~~~~~~~
220220

221-
Once you've defined all the necessary classes and predicates, write a `select clause <https://help.semmle.com/QL/ql-handbook/queries.html#select-clauses>`__
221+
Once you've defined all the necessary classes and predicates, write a `select clause <https://help.semmle.com/QL/ql-language-reference/queries.html#select-clauses>`__
222222
that returns the resulting path.
223223

224224
.. container:: toggle
@@ -230,7 +230,7 @@ that returns the resulting path.
230230
.. literalinclude:: river-crossing.ql
231231
:lines: 115-117
232232

233-
The `don't-care expression <https://help.semmle.com/QL/ql-handbook/expressions.html#don-t-care-expressions>`__ (``_``),
233+
The `don't-care expression <https://help.semmle.com/QL/ql-language-reference/expressions.html#don-t-care-expressions>`__ (``_``),
234234
as the second argument to the ``reachesVia`` predicate, represents any value of ``visitedStates``.
235235

236236
For now, the path defined in ``reachesVia`` just lists the order of cargo items to ferry.
@@ -254,12 +254,12 @@ Here are some more example queries that solve the river crossing puzzle:
254254
➤ `See solution in the query console on LGTM.com <https://lgtm.com/query/659603593702729237/>`__
255255

256256
#. This query models the man and the cargo items in a different way, using an
257-
`abstract <https://help.semmle.com/QL/ql-handbook/annotations.html#abstract>`__
257+
`abstract <https://help.semmle.com/QL/ql-language-reference/annotations.html#abstract>`__
258258
class and predicate. It also displays the resulting path in a more visual way.
259259

260260
➤ `See solution in the query console on LGTM.com <https://lgtm.com/query/1025323464423811143/>`__
261261

262-
#. This query introduces `algebraic datatypes <https://help.semmle.com/QL/ql-handbook/types.html#algebraic-datatypes>`__
262+
#. This query introduces `algebraic datatypes <https://help.semmle.com/QL/ql-language-reference/types.html#algebraic-datatypes>`__
263263
to model the situation, instead of defining everything as a subclass of ``string``.
264264

265265
➤ `See solution in the query console on LGTM.com <https://lgtm.com/query/7260748307619718263/>`__

docs/language/learn-ql/beginner/crown-the-rightful-heir.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ You can translate this into QL as follows:
106106
result = parentOf(ancestorOf(p))
107107
}
108108
109-
As you can see, you have used the predicate ``ancestorOf()`` inside its own definition. This is an example of `recursion <https://help.semmle.com/QL/ql-handbook/recursion.html>`__.
109+
As you can see, you have used the predicate ``ancestorOf()`` inside its own definition. This is an example of `recursion <https://help.semmle.com/QL/ql-language-reference/recursion.html>`__.
110110

111111
This kind of recursion, where the same operation (in this case ``parentOf()``) is applied multiple times, is very common in QL, and is known as the *transitive closure* of the operation. There are two special symbols ``+`` and ``*`` that are extremely useful when working with transitive closures:
112112

docs/language/learn-ql/beginner/find-the-thief.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ There is too much information to search through by hand, so you decide to use yo
5353
QL libraries
5454
------------
5555

56-
We've defined a number of QL `predicates <https://help.semmle.com/QL/ql-handbook/predicates.html>`__ to help you extract data from your table. A QL predicate is a mini-query that expresses a relation between various pieces of data and describes some of their properties. In this case, the predicates give you information about a person, for example their height or age.
56+
We've defined a number of QL `predicates <https://help.semmle.com/QL/ql-language-reference/predicates.html>`__ to help you extract data from your table. A QL predicate is a mini-query that expresses a relation between various pieces of data and describes some of their properties. In this case, the predicates give you information about a person, for example their height or age.
5757

5858
+--------------------+----------------------------------------------------------------------------------------+
5959
| Predicate | Description |
@@ -84,14 +84,14 @@ The villagers answered "yes" to the question "Is the thief taller than 150cm?" T
8484
where t.getHeight() > 150
8585
select t
8686
87-
The first line, ``from Person t``, declares that ``t`` must be a ``Person``. We say that the `type <https://help.semmle.com/QL/ql-handbook/types.html>`__ of ``t`` is ``Person``.
87+
The first line, ``from Person t``, declares that ``t`` must be a ``Person``. We say that the `type <https://help.semmle.com/QL/ql-language-reference/types.html>`__ of ``t`` is ``Person``.
8888

8989
Before you use the rest of your answers in your QL search, here are some more tools and examples to help you write your own QL queries:
9090

9191
Logical connectives
9292
-------------------
9393

94-
Using `logical connectives <https://help.semmle.com/QL/ql-handbook/formulas.html#logical-connectives>`__, you can write more complex queries that combine different pieces of information.
94+
Using `logical connectives <https://help.semmle.com/QL/ql-language-reference/formulas.html#logical-connectives>`__, you can write more complex queries that combine different pieces of information.
9595

9696
For example, if you know that the thief is older than 30 *and* has brown hair, you can use the following ``where`` clause to link two predicates:
9797

@@ -157,7 +157,7 @@ Notice that we have only temporarily introduced the variable ``c`` and we didn't
157157

158158
Note
159159

160-
If you are familiar with logic, you may notice that ``exists`` in QL corresponds to the existential `quantifier <https://help.semmle.com/QL/ql-handbook/formulas.html#quantified-formulas>`__ in logic. QL also has a universal quantifier ``forall(vars | formula 1 | formula 2)`` which is logically equivalent to ``not exists(vars | formula 1 | not formula 2)``.
160+
If you are familiar with logic, you may notice that ``exists`` in QL corresponds to the existential `quantifier <https://help.semmle.com/QL/ql-language-reference/formulas.html#quantified-formulas>`__ in logic. QL also has a universal quantifier ``forall(vars | formula 1 | formula 2)`` which is logically equivalent to ``not exists(vars | formula 1 | not formula 2)``.
161161

162162
The real investigation
163163
----------------------
@@ -218,7 +218,7 @@ You are getting closer to solving the mystery! Unfortunately, you still have qui
218218
More advanced queries
219219
---------------------
220220

221-
What if you want to find the oldest, youngest, tallest, or shortest person in the village? As mentioned in the previous topic, you can do this using ``exists``. However, there is also a more efficient way to do this in QL using functions like ``max`` and ``min``. These are examples of `aggregates <https://help.semmle.com/QL/ql-handbook/expressions.html#aggregations>`__.
221+
What if you want to find the oldest, youngest, tallest, or shortest person in the village? As mentioned in the previous topic, you can do this using ``exists``. However, there is also a more efficient way to do this in QL using functions like ``max`` and ``min``. These are examples of `aggregates <https://help.semmle.com/QL/ql-language-reference/expressions.html#aggregations>`__.
222222

223223
In general, an aggregate is a function that performs an operation on multiple pieces of data and returns a single value as its output. Common aggregates are ``count``, ``max``, ``min``, ``avg`` (average) and ``sum``. The general way to use an aggregate is:
224224

docs/language/learn-ql/cpp/refining-a-query-to-account-for-edge-cases.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ You may also wish to consider methods called by constructors that assign to the
102102
int m_value;
103103
};
104104
105-
This case can be excluded by creating a recursive predicate. The recursive predicate is given a function and a field, then checks whether the function assigns to the field. The predicate runs itself on all the functions called by the function that it has been given. By passing the constructor to this predicate, we can check for assignments of a field in all functions called by the constructor, and then do the same for all functions called by those functions all the way down the tree of function calls. For more information, see "`Recursion <https://help.semmle.com/QL/ql-handbook/recursion.html>`__" in the QL language reference.
105+
This case can be excluded by creating a recursive predicate. The recursive predicate is given a function and a field, then checks whether the function assigns to the field. The predicate runs itself on all the functions called by the function that it has been given. By passing the constructor to this predicate, we can check for assignments of a field in all functions called by the constructor, and then do the same for all functions called by those functions all the way down the tree of function calls. For more information, see "`Recursion <https://help.semmle.com/QL/ql-language-reference/recursion.html>`__" in the QL language reference.
106106

107107
.. code-block:: ql
108108
@@ -126,7 +126,7 @@ This case can be excluded by creating a recursive predicate. The recursive predi
126126
Refinement 4—simplifying the query
127127
----------------------------------
128128

129-
Finally we can simplify the query by using the transitive closure operator. In this final version of the query, ``c.calls*(fun)`` resolves to the set of all functions that are ``c`` itself, are called by ``c``, are called by a function that is called by ``c``, and so on. This eliminates the need to make a new predicate all together. For more information, see "`Transitive closures <https://help.semmle.com/QL/ql-handbook/recursion.html#transitive-closures>`__" in the QL language reference.
129+
Finally we can simplify the query by using the transitive closure operator. In this final version of the query, ``c.calls*(fun)`` resolves to the set of all functions that are ``c`` itself, are called by ``c``, are called by a function that is called by ``c``, and so on. This eliminates the need to make a new predicate all together. For more information, see "`Transitive closures <https://help.semmle.com/QL/ql-language-reference/recursion.html#transitive-closures>`__" in the QL language reference.
130130

131131
.. code-block:: ql
132132

docs/language/learn-ql/go/basic-query-for-go-code.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@ After the initial ``import`` statement, this simple query comprises three parts
9999
| ``where recv = m.getReceiver() and | Defines a condition on the variables. | ``recv = m.getReceiver()`` states that ``recv`` must be the receiver variable of ``m``. |
100100
| w.writesField(recv.getARead(), f, _) and | | |
101101
| not recv.getType() instanceof PointerType`` | | ``w.writesField(recv.getARead(), f, _)`` states that ``w`` must be a ___location in the code where field ``f`` of ``recv`` is modified. |
102-
| | | We use a `'don't-care' expression <https://help.semmle.com/QL/ql-handbook/expressions.html#don-t-care-expressions>`__ _ for the |
103-
| | | value that is written to ``f``—the actual value doesn't matter in this query. |
102+
| | | We use a `'don't-care' expression <https://help.semmle.com/QL/ql-language-reference/expressions.html#don-t-care-expressions>`__ ``_``|
103+
| | | for the value that is written to ``f``—the actual value doesn't matter in this query. |
104104
| | | |
105105
| | | ``not recv.getType() instanceof PointerType`` states that ``m`` is not a pointer method. |
106106
+---------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+

docs/language/learn-ql/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,4 @@ CodeQL is based on a powerful query language called QL. The following topics hel
3636
Further reading
3737
***************
3838

39-
- `QL language reference <https://help.semmle.com/QL/ql-handbook/index.html>`__: A description of important concepts in QL and a formal specification of the QL language.
39+
- `QL language reference <https://help.semmle.com/QL/ql-language-reference/index.html>`__: A description of important concepts in QL and a formal specification of the QL language.

docs/language/learn-ql/introduction-to-ql.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,4 +159,4 @@ Further reading
159159

160160
- To find out more about how to write your own queries, try working through the ":doc:`QL tutorials <beginner/ql-tutorials>`."
161161
- For an overview of the other available resources, see ":doc:`Learning CodeQL <../index>`."
162-
- For a more technical description of the underlying language, see the "`QL language reference <https://help.semmle.com/QL/ql-handbook>`__."
162+
- For a more technical description of the underlying language, see the "`QL language reference <https://help.semmle.com/QL/ql-language-reference>`__."

0 commit comments

Comments
 (0)