Skip to content

Commit 98d80de

Browse files
committed
CPP: Improved solution (mostly performance).
1 parent 47ff38e commit 98d80de

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

cpp/ql/src/semmle/code/cpp/controlflow/LocalScopeVariableReachability.qll

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -139,16 +139,17 @@ private predicate bbLoopEntryConditionAlwaysTrueAt(BasicBlock bb, int i, Control
139139
* within a complex loop condition are not matched by this predicate.
140140
*/
141141
private predicate bbLoopConditionAlwaysTrueUponEntrySuccessor(BasicBlock pred, BasicBlock succ, boolean skipsLoop) {
142-
exists(ControlFlowNode loop |
143-
loopConditionAlwaysTrueUponEntry(loop, _) and
142+
exists(Expr cond |
143+
loopConditionAlwaysTrueUponEntry(_, cond) and
144+
cond.getAChild*() = pred.getEnd() and
145+
succ = pred.getASuccessor() and
146+
not cond.getAChild*() = succ.getStart() and
144147
(
145148
(
146-
not succ = loop.(Loop).getStmt() and
147-
pred.getAFalseSuccessor() = succ and
149+
succ = pred.getAFalseSuccessor() and
148150
skipsLoop = true
149151
) or (
150-
succ = loop.(Loop).getStmt() and
151-
pred.getATrueSuccessor() = succ and
152+
succ = pred.getATrueSuccessor() and
152153
skipsLoop = false
153154
)
154155
)

0 commit comments

Comments
 (0)