Skip to content

Commit e1b2f81

Browse files
committed
Revert "update doc example to not use isBarrierGuard"
This reverts commit 28f8c1c.
1 parent a7ab9fd commit e1b2f81

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

docs/codeql/codeql-language-guides/using-flow-labels-for-precise-data-flow-analysis.rst

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -139,24 +139,29 @@ is a barrier guard blocking flow through the use of ``data`` on the right-hand s
139139
At this point we know that ``data`` has evaluated to a truthy value, so it cannot be ``null``
140140
anymore.
141141

142-
Implementing this additional condition is easy. We implement a predicate with the following signature:
142+
Implementing this additional condition is easy. We implement a subclass of ``DataFlow::BarrierGuardNode``:
143143

144144
.. code-block:: ql
145145
146-
private predicate truthinessCheck(DataFlow::GuardNode g, ControlFlowNode node, boolean branch) {
147-
exists(SsaVariable v |
148-
g = v.getAUse() and
149-
node = g and
150-
branch = true
151-
)
146+
class TruthinessCheck extends DataFlow::BarrierGuardNode, DataFlow::ValueNode {
147+
SsaVariable v;
148+
149+
TruthinessCheck() {
150+
astNode = v.getAUse()
151+
}
152+
153+
override predicate blocks(boolean outcome, Expr e) {
154+
outcome = true and
155+
e = astNode
156+
}
152157
}
153158
154-
and then use it to override predicate ``isBarrier`` in our configuration class:
159+
and then use it to override predicate ``isBarrierGuard`` in our configuration class:
155160

156161
.. code-block:: ql
157162
158-
override predicate isBarrier(DataFlow::Node node) {
159-
node = DataFlow::BarrierGuard<truthinessCheck/3>::getABarrierNode()
163+
override predicate isBarrierGuard(DataFlow::BarrierGuardNode guard) {
164+
guard instanceof TruthinessCheck
160165
}
161166
162167
With this change, we now flag the problematic case and don't flag the unproblematic case above.

0 commit comments

Comments
 (0)