File tree Expand file tree Collapse file tree 1 file changed +19
-6
lines changed
cpp/ql/src/semmle/code/cpp/controlflow/internal Expand file tree Collapse file tree 1 file changed +19
-6
lines changed Original file line number Diff line number Diff line change @@ -43,15 +43,28 @@ private cached module Cached {
4343 ( not successors_extended ( _, node ) and successors_extended ( node , _) )
4444 }
4545
46+ /** Holds if `n2` follows `n1` in a `PrimitiveBasicBlock`. */
47+ private predicate member_step ( Node n1 , Node n2 ) {
48+ successors_extended ( n1 , n2 ) and
49+ not n2 instanceof PrimitiveBasicBlock
50+ }
51+
52+ /** Returns the index of `node` in its `PrimitiveBasicBlock`. */
53+ private int getMemberIndex ( Node node ) {
54+ primitive_basic_block_entry_node ( node ) and
55+ result = 0
56+ or
57+ exists ( Node prev |
58+ member_step ( prev , node ) and
59+ result = getMemberIndex ( prev ) + 1
60+ )
61+ }
62+
4663 /** Holds if `node` is the `pos`th control-flow node in primitive basic block `bb`. */
4764 cached
4865 predicate primitive_basic_block_member ( Node node , PrimitiveBasicBlock bb , int pos ) {
49- ( node = bb and pos = 0 )
50- or
51- ( not ( node instanceof PrimitiveBasicBlock ) and
52- exists ( Node pred
53- | successors_extended ( pred , node )
54- | primitive_basic_block_member ( pred , bb , pos - 1 ) ) )
66+ pos = getMemberIndex ( node ) and
67+ member_step * ( bb , node )
5568 }
5669
5770 /** Gets the number of control-flow nodes in the primitive basic block `bb`. */
You can’t perform that action at this time.
0 commit comments