Skip to content

Commit c04546d

Browse files
committed
C++: Use named code blocks.
1 parent 308d027 commit c04546d

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

docs/codeql/codeql-language-guides/advanced-dataflow-scenarios-cpp.rst

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ A regular dataflow query such as the following query:
6161
will catch most things such as:
6262

6363
.. code-block:: cpp
64+
:caption: Example 1
6465
6566
struct A {
6667
const int *p;
@@ -116,6 +117,7 @@ For example, consider an alternative setup where our source of data starts as th
116117
This would match the call to ``write_user_input_to`` in the following example:
117118

118119
.. code-block:: cpp
120+
:caption: Example 2
119121
120122
void write_user_input_to(void*);
121123
void use_value(int);
@@ -194,13 +196,14 @@ We have an important choice here: Should ``n2`` be the node corresponding to the
194196
Using asIndirectExpr
195197
~~~~~~~~~~~~~~~~~~~~
196198

197-
If we use ``n2.asIndirectExpr() = fa`` we specify that flow moves to what ``fa`` points to. This allows data to flow through a later dereference, which is exactly what we need to track data flow from ``p`` to ``*p`` in ``process_user_data``.
199+
If we use ``n2.asIndirectExpr() = fa`` we specify that flow in example 2 moves to what ``fa`` points to. This allows data to flow through a later dereference, which is exactly what we need to track data flow from ``p`` to ``*p`` in ``process_user_data``.
198200

199201
Thus we get the required flow path.
200202

201203
Consider a slightly different sink:
202204

203205
.. code-block:: cpp
206+
:caption: Example 3
204207
205208
void write_user_input_to(void*);
206209
void use_pointer(int*);
@@ -239,7 +242,7 @@ The only difference between the previous example and this one is that our data e
239242
Using asExpr
240243
~~~~~~~~~~~~
241244

242-
Alternatively, this flow could also be tracked by:
245+
Alternatively, the flow in example 2 could also be tracked by:
243246
1. Changing ``isAdditionalFlowStep`` so that it targets the dataflow node that represents the value of the ``FieldAccess`` instead of the value it points to, and
244247
2. Changing ``isSink`` to specify that we're interested in tracking the value the argument passed to ``use_pointer`` (instead of the value of what the argument points to).
245248

@@ -291,6 +294,7 @@ Passing the address of a variable to ``use_pointer``
291294
Consider an alternative scenario where ``U`` contains a single ``int`` data, and we pass the address of data to ``use_pointer`` as seen below.
292295

293296
.. code-block:: cpp
297+
:caption: Example 4
294298
295299
void write_user_input_to(void*);
296300
void use_pointer(int*);
@@ -368,6 +372,7 @@ The previous section demonstrated how to add flow from qualifiers to field acces
368372
To set the stage, consider the following scenario:
369373

370374
.. code-block:: cpp
375+
:caption: Example 5
371376
372377
struct A {
373378
const int *p;

0 commit comments

Comments
 (0)