Skip to content

Commit 0f0384c

Browse files
committed
C++: Rewrite the barrier guard tests to be expression based. This is really what we expect people to write in queries.
1 parent edfe2d7 commit 0f0384c

File tree

1 file changed

+9
-5
lines changed
  • cpp/ql/test/library-tests/dataflow/dataflow-tests

1 file changed

+9
-5
lines changed

cpp/ql/test/library-tests/dataflow/dataflow-tests/test.ql

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ module AstTest {
4747
}
4848

4949
module IRTest {
50+
private import cpp
5051
private import semmle.code.cpp.ir.dataflow.DataFlow
5152
private import semmle.code.cpp.ir.IR
5253
private import semmle.code.cpp.controlflow.IRGuards
@@ -56,10 +57,13 @@ module IRTest {
5657
* S in `if (guarded(x)) S`.
5758
*/
5859
// This is tested in `BarrierGuard.cpp`.
59-
predicate testBarrierGuard(IRGuardCondition g, Instruction checked, boolean isTrue) {
60-
g.(CallInstruction).getStaticCallTarget().getName() = "guarded" and
61-
checked = g.(CallInstruction).getPositionalArgument(0) and
62-
isTrue = true
60+
predicate testBarrierGuard(IRGuardCondition g, Expr checked, boolean isTrue) {
61+
exists(Call call |
62+
call = g.getUnconvertedResultExpression() and
63+
call.getTarget().hasName("guarded") and
64+
checked = call.getArgument(0) and
65+
isTrue = true
66+
)
6367
}
6468

6569
/** Common data flow configuration to be used by tests. */
@@ -90,7 +94,7 @@ module IRTest {
9094
barrierExpr.(VariableAccess).getTarget().hasName("barrier")
9195
)
9296
or
93-
barrier = DataFlow::InstructionBarrierGuard<testBarrierGuard/3>::getABarrierNode()
97+
barrier = DataFlow::BarrierGuard<testBarrierGuard/3>::getABarrierNode()
9498
}
9599
}
96100
}

0 commit comments

Comments
 (0)