Skip to content

Commit 98612b9

Browse files
committed
C++: Tidy primitive_basic_block_member calculation
This change gave a slight speed-up by eliminating an unnecessary intermediate predicate.
1 parent e7234f5 commit 98612b9

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

cpp/ql/src/semmle/code/cpp/controlflow/internal/PrimitiveBasicBlocks.qll

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,13 @@ private cached module Cached {
4343
(not successors_extended(_, node) and successors_extended(node, _))
4444
}
4545

46-
pragma[noinline]
46+
/** Holds if `n2` follows `n1` in a `PrimitiveBasicBlock`. */
4747
private predicate member_step(Node n1, Node n2) {
4848
successors_extended(n1, n2) and
4949
not n2 instanceof PrimitiveBasicBlock
5050
}
5151

52+
/** Returns the index of `node` in its `PrimitiveBasicBlock`. */
5253
private int getMemberIndex(Node node) {
5354
primitive_basic_block_entry_node(node) and
5455
result = 0
@@ -59,15 +60,11 @@ private cached module Cached {
5960
)
6061
}
6162

62-
private predicate isMember(Node node, PrimitiveBasicBlock bb) {
63-
member_step*(bb, node)
64-
}
65-
6663
/** Holds if `node` is the `pos`th control-flow node in primitive basic block `bb`. */
6764
cached
6865
predicate primitive_basic_block_member(Node node, PrimitiveBasicBlock bb, int pos) {
6966
pos = getMemberIndex(node) and
70-
isMember(node, bb)
67+
member_step*(bb, node)
7168
}
7269

7370
/** Gets the number of control-flow nodes in the primitive basic block `bb`. */

0 commit comments

Comments
 (0)