diff --git a/csharp/ql/lib/semmle/code/csharp/controlflow/Guards.qll b/csharp/ql/lib/semmle/code/csharp/controlflow/Guards.qll index 031a48906869..2c214b11e904 100644 --- a/csharp/ql/lib/semmle/code/csharp/controlflow/Guards.qll +++ b/csharp/ql/lib/semmle/code/csharp/controlflow/Guards.qll @@ -22,6 +22,10 @@ private module GuardsInput implements SharedGuards::InputSig ... | true | Logic.java:37:17:39:5 | { ... } | +| Logic.java:44:9:44:10 | !... | false | Logic.java:43:23:43:31 | Normal Exit | +| Logic.java:44:9:44:10 | !... | true | Logic.java:44:33:44:35 | msg | | Logic.java:44:10:44:10 | b | false | Logic.java:44:33:44:35 | msg | | Logic.java:44:10:44:10 | b | true | Logic.java:43:23:43:31 | Normal Exit | | Logic.java:48:5:48:22 | checkTrue(...) | exception | Logic.java:47:23:47:32 | Exceptional Exit | @@ -68,6 +70,8 @@ | Logic.java:53:21:53:26 | g(...) | false | Logic.java:54:17:56:5 | { ... } | | Logic.java:53:21:53:26 | g(...) | false | Logic.java:57:5:57:18 | var ...; | | Logic.java:54:9:54:14 | ... > ... | true | Logic.java:54:17:56:5 | { ... } | +| Logic.java:61:9:61:10 | !... | false | Logic.java:60:23:60:31 | Normal Exit | +| Logic.java:61:9:61:10 | !... | true | Logic.java:61:33:61:35 | msg | | Logic.java:61:10:61:10 | b | false | Logic.java:61:33:61:35 | msg | | Logic.java:61:10:61:10 | b | true | Logic.java:60:23:60:31 | Normal Exit | | Logic.java:65:5:65:22 | checkTrue(...) | exception | Logic.java:64:23:64:32 | Exceptional Exit | diff --git a/shared/controlflow/codeql/controlflow/Guards.qll b/shared/controlflow/codeql/controlflow/Guards.qll index 7550363f0ea2..70095115d845 100644 --- a/shared/controlflow/codeql/controlflow/Guards.qll +++ b/shared/controlflow/codeql/controlflow/Guards.qll @@ -78,6 +78,11 @@ signature module InputSig; @@ -1057,6 +1087,13 @@ module Make< ) } + private predicate guardControlsBlock(Guard guard, BasicBlock bb, GuardValue v) { + exists(Guard g0, GuardValue v0 | + midBlockGuard(g0, bb, v0) and + BranchImplies::guardControls(guard, v, g0, v0) + ) + } + /** * Holds if `def` evaluating to `v` controls the control-flow branch * edge from `bb1` to `bb2`. That is, following the edge from `bb1` to @@ -1080,6 +1117,12 @@ module Make< dominatingEdge(guard, succ) and succ.dominates(bb) ) + or + exists(Guard g0, BasicBlock guardbb, GuardValue v0 | + midBlockGuard(g0, guardbb, v0) and + BranchImplies::ssaControls(def, v, g0, v0) and + guardbb.dominates(bb) + ) } private import DisjunctiveGuard @@ -1532,6 +1575,11 @@ module Make< dominatingEdge(guard, succ) and succ.dominates(bb) ) + or + exists(BasicBlock guard | + guardControlsBlock(this, guard, v) and + guard.dominates(bb) + ) } /**