Skip to content

Commit df6d68b

Browse files
authored
Merge pull request #9618 from aschackmull/dataflow/deprecate-barrierguard-class
Dataflow: Deprecate BarrierGuard class
2 parents 24ba5cc + f8f9b7d commit df6d68b

File tree

195 files changed

+2585
-1295
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

195 files changed

+2585
-1295
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
category: deprecated
3+
---
4+
* The `BarrierGuard` class has been deprecated. Such barriers and sanitizers can now instead be created using the new `BarrierGuard` parameterized module.

cpp/ql/lib/semmle/code/cpp/dataflow/internal/DataFlowImpl.qll

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -90,14 +90,20 @@ abstract class Configuration extends string {
9090
/** Holds if data flow out of `node` is prohibited. */
9191
predicate isBarrierOut(Node node) { none() }
9292

93-
/** Holds if data flow through nodes guarded by `guard` is prohibited. */
94-
predicate isBarrierGuard(BarrierGuard guard) { none() }
93+
/**
94+
* DEPRECATED: Use `isBarrier` and `BarrierGuard` module instead.
95+
*
96+
* Holds if data flow through nodes guarded by `guard` is prohibited.
97+
*/
98+
deprecated predicate isBarrierGuard(BarrierGuard guard) { none() }
9599

96100
/**
101+
* DEPRECATED: Use `isBarrier` and `BarrierGuard` module instead.
102+
*
97103
* Holds if data flow through nodes guarded by `guard` is prohibited when
98104
* the flow state is `state`
99105
*/
100-
predicate isBarrierGuard(BarrierGuard guard, FlowState state) { none() }
106+
deprecated predicate isBarrierGuard(BarrierGuard guard, FlowState state) { none() }
101107

102108
/**
103109
* Holds if data may flow from `node1` to `node2` in addition to the normal data-flow steps.
@@ -335,6 +341,29 @@ private predicate outBarrier(NodeEx node, Configuration config) {
335341
)
336342
}
337343

344+
/** A bridge class to access the deprecated `isBarrierGuard`. */
345+
private class BarrierGuardGuardedNodeBridge extends Unit {
346+
abstract predicate guardedNode(Node n, Configuration config);
347+
348+
abstract predicate guardedNode(Node n, FlowState state, Configuration config);
349+
}
350+
351+
private class BarrierGuardGuardedNode extends BarrierGuardGuardedNodeBridge {
352+
deprecated override predicate guardedNode(Node n, Configuration config) {
353+
exists(BarrierGuard g |
354+
config.isBarrierGuard(g) and
355+
n = g.getAGuardedNode()
356+
)
357+
}
358+
359+
deprecated override predicate guardedNode(Node n, FlowState state, Configuration config) {
360+
exists(BarrierGuard g |
361+
config.isBarrierGuard(g, state) and
362+
n = g.getAGuardedNode()
363+
)
364+
}
365+
}
366+
338367
pragma[nomagic]
339368
private predicate fullBarrier(NodeEx node, Configuration config) {
340369
exists(Node n | node.asNode() = n |
@@ -348,10 +377,7 @@ private predicate fullBarrier(NodeEx node, Configuration config) {
348377
not config.isSink(n) and
349378
not config.isSink(n, _)
350379
or
351-
exists(BarrierGuard g |
352-
config.isBarrierGuard(g) and
353-
n = g.getAGuardedNode()
354-
)
380+
any(BarrierGuardGuardedNodeBridge b).guardedNode(n, config)
355381
)
356382
}
357383

@@ -360,10 +386,7 @@ private predicate stateBarrier(NodeEx node, FlowState state, Configuration confi
360386
exists(Node n | node.asNode() = n |
361387
config.isBarrier(n, state)
362388
or
363-
exists(BarrierGuard g |
364-
config.isBarrierGuard(g, state) and
365-
n = g.getAGuardedNode()
366-
)
389+
any(BarrierGuardGuardedNodeBridge b).guardedNode(n, state, config)
367390
)
368391
}
369392

cpp/ql/lib/semmle/code/cpp/dataflow/internal/DataFlowImpl2.qll

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -90,14 +90,20 @@ abstract class Configuration extends string {
9090
/** Holds if data flow out of `node` is prohibited. */
9191
predicate isBarrierOut(Node node) { none() }
9292

93-
/** Holds if data flow through nodes guarded by `guard` is prohibited. */
94-
predicate isBarrierGuard(BarrierGuard guard) { none() }
93+
/**
94+
* DEPRECATED: Use `isBarrier` and `BarrierGuard` module instead.
95+
*
96+
* Holds if data flow through nodes guarded by `guard` is prohibited.
97+
*/
98+
deprecated predicate isBarrierGuard(BarrierGuard guard) { none() }
9599

96100
/**
101+
* DEPRECATED: Use `isBarrier` and `BarrierGuard` module instead.
102+
*
97103
* Holds if data flow through nodes guarded by `guard` is prohibited when
98104
* the flow state is `state`
99105
*/
100-
predicate isBarrierGuard(BarrierGuard guard, FlowState state) { none() }
106+
deprecated predicate isBarrierGuard(BarrierGuard guard, FlowState state) { none() }
101107

102108
/**
103109
* Holds if data may flow from `node1` to `node2` in addition to the normal data-flow steps.
@@ -335,6 +341,29 @@ private predicate outBarrier(NodeEx node, Configuration config) {
335341
)
336342
}
337343

344+
/** A bridge class to access the deprecated `isBarrierGuard`. */
345+
private class BarrierGuardGuardedNodeBridge extends Unit {
346+
abstract predicate guardedNode(Node n, Configuration config);
347+
348+
abstract predicate guardedNode(Node n, FlowState state, Configuration config);
349+
}
350+
351+
private class BarrierGuardGuardedNode extends BarrierGuardGuardedNodeBridge {
352+
deprecated override predicate guardedNode(Node n, Configuration config) {
353+
exists(BarrierGuard g |
354+
config.isBarrierGuard(g) and
355+
n = g.getAGuardedNode()
356+
)
357+
}
358+
359+
deprecated override predicate guardedNode(Node n, FlowState state, Configuration config) {
360+
exists(BarrierGuard g |
361+
config.isBarrierGuard(g, state) and
362+
n = g.getAGuardedNode()
363+
)
364+
}
365+
}
366+
338367
pragma[nomagic]
339368
private predicate fullBarrier(NodeEx node, Configuration config) {
340369
exists(Node n | node.asNode() = n |
@@ -348,10 +377,7 @@ private predicate fullBarrier(NodeEx node, Configuration config) {
348377
not config.isSink(n) and
349378
not config.isSink(n, _)
350379
or
351-
exists(BarrierGuard g |
352-
config.isBarrierGuard(g) and
353-
n = g.getAGuardedNode()
354-
)
380+
any(BarrierGuardGuardedNodeBridge b).guardedNode(n, config)
355381
)
356382
}
357383

@@ -360,10 +386,7 @@ private predicate stateBarrier(NodeEx node, FlowState state, Configuration confi
360386
exists(Node n | node.asNode() = n |
361387
config.isBarrier(n, state)
362388
or
363-
exists(BarrierGuard g |
364-
config.isBarrierGuard(g, state) and
365-
n = g.getAGuardedNode()
366-
)
389+
any(BarrierGuardGuardedNodeBridge b).guardedNode(n, state, config)
367390
)
368391
}
369392

cpp/ql/lib/semmle/code/cpp/dataflow/internal/DataFlowImpl3.qll

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -90,14 +90,20 @@ abstract class Configuration extends string {
9090
/** Holds if data flow out of `node` is prohibited. */
9191
predicate isBarrierOut(Node node) { none() }
9292

93-
/** Holds if data flow through nodes guarded by `guard` is prohibited. */
94-
predicate isBarrierGuard(BarrierGuard guard) { none() }
93+
/**
94+
* DEPRECATED: Use `isBarrier` and `BarrierGuard` module instead.
95+
*
96+
* Holds if data flow through nodes guarded by `guard` is prohibited.
97+
*/
98+
deprecated predicate isBarrierGuard(BarrierGuard guard) { none() }
9599

96100
/**
101+
* DEPRECATED: Use `isBarrier` and `BarrierGuard` module instead.
102+
*
97103
* Holds if data flow through nodes guarded by `guard` is prohibited when
98104
* the flow state is `state`
99105
*/
100-
predicate isBarrierGuard(BarrierGuard guard, FlowState state) { none() }
106+
deprecated predicate isBarrierGuard(BarrierGuard guard, FlowState state) { none() }
101107

102108
/**
103109
* Holds if data may flow from `node1` to `node2` in addition to the normal data-flow steps.
@@ -335,6 +341,29 @@ private predicate outBarrier(NodeEx node, Configuration config) {
335341
)
336342
}
337343

344+
/** A bridge class to access the deprecated `isBarrierGuard`. */
345+
private class BarrierGuardGuardedNodeBridge extends Unit {
346+
abstract predicate guardedNode(Node n, Configuration config);
347+
348+
abstract predicate guardedNode(Node n, FlowState state, Configuration config);
349+
}
350+
351+
private class BarrierGuardGuardedNode extends BarrierGuardGuardedNodeBridge {
352+
deprecated override predicate guardedNode(Node n, Configuration config) {
353+
exists(BarrierGuard g |
354+
config.isBarrierGuard(g) and
355+
n = g.getAGuardedNode()
356+
)
357+
}
358+
359+
deprecated override predicate guardedNode(Node n, FlowState state, Configuration config) {
360+
exists(BarrierGuard g |
361+
config.isBarrierGuard(g, state) and
362+
n = g.getAGuardedNode()
363+
)
364+
}
365+
}
366+
338367
pragma[nomagic]
339368
private predicate fullBarrier(NodeEx node, Configuration config) {
340369
exists(Node n | node.asNode() = n |
@@ -348,10 +377,7 @@ private predicate fullBarrier(NodeEx node, Configuration config) {
348377
not config.isSink(n) and
349378
not config.isSink(n, _)
350379
or
351-
exists(BarrierGuard g |
352-
config.isBarrierGuard(g) and
353-
n = g.getAGuardedNode()
354-
)
380+
any(BarrierGuardGuardedNodeBridge b).guardedNode(n, config)
355381
)
356382
}
357383

@@ -360,10 +386,7 @@ private predicate stateBarrier(NodeEx node, FlowState state, Configuration confi
360386
exists(Node n | node.asNode() = n |
361387
config.isBarrier(n, state)
362388
or
363-
exists(BarrierGuard g |
364-
config.isBarrierGuard(g, state) and
365-
n = g.getAGuardedNode()
366-
)
389+
any(BarrierGuardGuardedNodeBridge b).guardedNode(n, state, config)
367390
)
368391
}
369392

cpp/ql/lib/semmle/code/cpp/dataflow/internal/DataFlowImpl4.qll

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -90,14 +90,20 @@ abstract class Configuration extends string {
9090
/** Holds if data flow out of `node` is prohibited. */
9191
predicate isBarrierOut(Node node) { none() }
9292

93-
/** Holds if data flow through nodes guarded by `guard` is prohibited. */
94-
predicate isBarrierGuard(BarrierGuard guard) { none() }
93+
/**
94+
* DEPRECATED: Use `isBarrier` and `BarrierGuard` module instead.
95+
*
96+
* Holds if data flow through nodes guarded by `guard` is prohibited.
97+
*/
98+
deprecated predicate isBarrierGuard(BarrierGuard guard) { none() }
9599

96100
/**
101+
* DEPRECATED: Use `isBarrier` and `BarrierGuard` module instead.
102+
*
97103
* Holds if data flow through nodes guarded by `guard` is prohibited when
98104
* the flow state is `state`
99105
*/
100-
predicate isBarrierGuard(BarrierGuard guard, FlowState state) { none() }
106+
deprecated predicate isBarrierGuard(BarrierGuard guard, FlowState state) { none() }
101107

102108
/**
103109
* Holds if data may flow from `node1` to `node2` in addition to the normal data-flow steps.
@@ -335,6 +341,29 @@ private predicate outBarrier(NodeEx node, Configuration config) {
335341
)
336342
}
337343

344+
/** A bridge class to access the deprecated `isBarrierGuard`. */
345+
private class BarrierGuardGuardedNodeBridge extends Unit {
346+
abstract predicate guardedNode(Node n, Configuration config);
347+
348+
abstract predicate guardedNode(Node n, FlowState state, Configuration config);
349+
}
350+
351+
private class BarrierGuardGuardedNode extends BarrierGuardGuardedNodeBridge {
352+
deprecated override predicate guardedNode(Node n, Configuration config) {
353+
exists(BarrierGuard g |
354+
config.isBarrierGuard(g) and
355+
n = g.getAGuardedNode()
356+
)
357+
}
358+
359+
deprecated override predicate guardedNode(Node n, FlowState state, Configuration config) {
360+
exists(BarrierGuard g |
361+
config.isBarrierGuard(g, state) and
362+
n = g.getAGuardedNode()
363+
)
364+
}
365+
}
366+
338367
pragma[nomagic]
339368
private predicate fullBarrier(NodeEx node, Configuration config) {
340369
exists(Node n | node.asNode() = n |
@@ -348,10 +377,7 @@ private predicate fullBarrier(NodeEx node, Configuration config) {
348377
not config.isSink(n) and
349378
not config.isSink(n, _)
350379
or
351-
exists(BarrierGuard g |
352-
config.isBarrierGuard(g) and
353-
n = g.getAGuardedNode()
354-
)
380+
any(BarrierGuardGuardedNodeBridge b).guardedNode(n, config)
355381
)
356382
}
357383

@@ -360,10 +386,7 @@ private predicate stateBarrier(NodeEx node, FlowState state, Configuration confi
360386
exists(Node n | node.asNode() = n |
361387
config.isBarrier(n, state)
362388
or
363-
exists(BarrierGuard g |
364-
config.isBarrierGuard(g, state) and
365-
n = g.getAGuardedNode()
366-
)
389+
any(BarrierGuardGuardedNodeBridge b).guardedNode(n, state, config)
367390
)
368391
}
369392

cpp/ql/lib/semmle/code/cpp/dataflow/internal/DataFlowImplLocal.qll

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -90,14 +90,20 @@ abstract class Configuration extends string {
9090
/** Holds if data flow out of `node` is prohibited. */
9191
predicate isBarrierOut(Node node) { none() }
9292

93-
/** Holds if data flow through nodes guarded by `guard` is prohibited. */
94-
predicate isBarrierGuard(BarrierGuard guard) { none() }
93+
/**
94+
* DEPRECATED: Use `isBarrier` and `BarrierGuard` module instead.
95+
*
96+
* Holds if data flow through nodes guarded by `guard` is prohibited.
97+
*/
98+
deprecated predicate isBarrierGuard(BarrierGuard guard) { none() }
9599

96100
/**
101+
* DEPRECATED: Use `isBarrier` and `BarrierGuard` module instead.
102+
*
97103
* Holds if data flow through nodes guarded by `guard` is prohibited when
98104
* the flow state is `state`
99105
*/
100-
predicate isBarrierGuard(BarrierGuard guard, FlowState state) { none() }
106+
deprecated predicate isBarrierGuard(BarrierGuard guard, FlowState state) { none() }
101107

102108
/**
103109
* Holds if data may flow from `node1` to `node2` in addition to the normal data-flow steps.
@@ -335,6 +341,29 @@ private predicate outBarrier(NodeEx node, Configuration config) {
335341
)
336342
}
337343

344+
/** A bridge class to access the deprecated `isBarrierGuard`. */
345+
private class BarrierGuardGuardedNodeBridge extends Unit {
346+
abstract predicate guardedNode(Node n, Configuration config);
347+
348+
abstract predicate guardedNode(Node n, FlowState state, Configuration config);
349+
}
350+
351+
private class BarrierGuardGuardedNode extends BarrierGuardGuardedNodeBridge {
352+
deprecated override predicate guardedNode(Node n, Configuration config) {
353+
exists(BarrierGuard g |
354+
config.isBarrierGuard(g) and
355+
n = g.getAGuardedNode()
356+
)
357+
}
358+
359+
deprecated override predicate guardedNode(Node n, FlowState state, Configuration config) {
360+
exists(BarrierGuard g |
361+
config.isBarrierGuard(g, state) and
362+
n = g.getAGuardedNode()
363+
)
364+
}
365+
}
366+
338367
pragma[nomagic]
339368
private predicate fullBarrier(NodeEx node, Configuration config) {
340369
exists(Node n | node.asNode() = n |
@@ -348,10 +377,7 @@ private predicate fullBarrier(NodeEx node, Configuration config) {
348377
not config.isSink(n) and
349378
not config.isSink(n, _)
350379
or
351-
exists(BarrierGuard g |
352-
config.isBarrierGuard(g) and
353-
n = g.getAGuardedNode()
354-
)
380+
any(BarrierGuardGuardedNodeBridge b).guardedNode(n, config)
355381
)
356382
}
357383

@@ -360,10 +386,7 @@ private predicate stateBarrier(NodeEx node, FlowState state, Configuration confi
360386
exists(Node n | node.asNode() = n |
361387
config.isBarrier(n, state)
362388
or
363-
exists(BarrierGuard g |
364-
config.isBarrierGuard(g, state) and
365-
n = g.getAGuardedNode()
366-
)
389+
any(BarrierGuardGuardedNodeBridge b).guardedNode(n, state, config)
367390
)
368391
}
369392

0 commit comments

Comments
 (0)