Skip to content

Commit cc70817

Browse files
authored
Merge pull request #1437 from jbj/bb-shortestDistances
C++: use shortestDistances in PrimitiveBasicBlocks
2 parents 83cbad9 + 32122e8 commit cc70817

File tree

1 file changed

+5
-18
lines changed

1 file changed

+5
-18
lines changed

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

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -60,27 +60,14 @@ private cached module Cached {
6060
not n2 instanceof PrimitiveBasicBlock
6161
}
6262

63-
/** Returns the index of `node` in its `PrimitiveBasicBlock`. */
64-
private int getMemberIndex(Node node) {
65-
primitive_basic_block_entry_node(node) and
66-
result = 0
67-
or
68-
exists(Node prev |
69-
member_step(prev, node) and
70-
result = getMemberIndex(prev) + 1
71-
)
72-
}
73-
7463
/** Holds if `node` is the `pos`th control-flow node in primitive basic block `bb`. */
7564
cached
7665
predicate primitive_basic_block_member(Node node, PrimitiveBasicBlock bb, int pos) {
77-
primitive_basic_block_entry_node(bb) and
78-
(
79-
pos = 0 and
80-
node = bb
81-
or
82-
pos = getMemberIndex(node) and
83-
member_step+(bb, node)
66+
primitive_basic_block_entry_node(bb) and node = bb and pos = 0
67+
or
68+
exists(Node prev |
69+
member_step(prev, node) and
70+
primitive_basic_block_member(prev, bb, pos - 1)
8471
)
8572
}
8673

0 commit comments

Comments
 (0)