Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions shared/controlflow/codeql/controlflow/Guards.qll
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,11 @@ module Make<
Guard guard, GuardValue v, SsaPhiDefinition phi, Expr input
) {
exists(GuardValue dv, SsaExplicitWrite inp |
guardControlsPhiBranch(guard, v, phi, inp) and
// The `forall` below implies that there's only one `inp` guarded by
// `guard == v`, but checking this upfront using `unique` as opposed to
// merely stating `guardControlsPhiBranch(guard, v, phi, inp)` improves
// performance of the `forall` check.
inp = unique(SsaDefinition inp0 | guardControlsPhiBranch(guard, v, phi, inp0)) and
inp.getValue() = input and
dv = v.getDualValue() and
forall(SsaDefinition other | phi.hasInputFromBlock(other, _) and other != inp |
Expand Down Expand Up @@ -741,7 +745,7 @@ module Make<
possibleValue(v, false, e, k) and
not possibleValue(v, true, e, k) and
// there's only one expression with the value `k`
1 = strictcount(Expr e0 | possibleValue(v, _, e0, k)) and
e = unique(Expr e0 | possibleValue(v, _, e0, k)) and
// and `v` has at least two possible values
2 <= strictcount(GuardValue k0 | possibleValue(v, _, _, k0))
}
Expand Down
Loading