File tree Expand file tree Collapse file tree 2 files changed +28
-0
lines changed
lib/codeql/ruby/controlflow
test/library-tests/dataflow/barrier-guards Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -252,6 +252,30 @@ private module Cached {
252252 cfn .isJoin ( )
253253 or
254254 cfn .getAPredecessor ( ) .isBranch ( )
255+ or
256+ /*
257+ * In cases such as
258+ *
259+ * ```rb
260+ * if x or y
261+ * foo
262+ * else
263+ * bar
264+ * ```
265+ *
266+ * we have a CFG that looks like
267+ *
268+ * x --false--> [false] x or y --false--> bar
269+ * \ |
270+ * --true--> y --false--
271+ * \
272+ * --true--> [true] x or y --true--> foo
273+ *
274+ * and we want to ensure that both `foo` and `bar` start a new basic block,
275+ * in order to get a `ConditionalBlock` out of the disjunction.
276+ */
277+
278+ exists ( cfn .getAPredecessor ( any ( SuccessorTypes:: ConditionalSuccessor s ) ) )
255279 }
256280
257281 /**
Original file line number Diff line number Diff line change @@ -49,4 +49,8 @@ controls
4949| barrier-guards.rb:100:4:100:21 | call to include? | barrier-guards.rb:103:5:103:7 | foo | false |
5050| barrier-guards.rb:106:4:106:4 | call to x | barrier-guards.rb:106:4:106:9 | [false] ... or ... | false |
5151| barrier-guards.rb:106:4:106:4 | call to x | barrier-guards.rb:106:9:106:9 | self | false |
52+ | barrier-guards.rb:106:4:106:4 | call to x | barrier-guards.rb:109:5:109:7 | foo | false |
53+ | barrier-guards.rb:106:4:106:9 | [false] ... or ... | barrier-guards.rb:109:5:109:7 | foo | false |
54+ | barrier-guards.rb:106:4:106:9 | [true] ... or ... | barrier-guards.rb:107:5:107:7 | foo | true |
5255| barrier-guards.rb:106:9:106:9 | call to y | barrier-guards.rb:106:4:106:9 | [false] ... or ... | false |
56+ | barrier-guards.rb:106:9:106:9 | call to y | barrier-guards.rb:109:5:109:7 | foo | false |
You can’t perform that action at this time.
0 commit comments