================
@@ -3101,7 +3101,19 @@ void ExprEngine::processSwitch(const SwitchStmt *Switch,
ExplodedNode *Pred,
std::optional<NonLoc> CondNL = CondV.getAs<NonLoc>();
- for (const CFGBlock *Block : Builder) {
+ // The reversed iteration order was arbitrarily introduced in 2008 by
+ // commit 80ebc1d1c95704b0ff0386b3a3cbc8b3ff960654 (which added support for
+ // control flow in switch statements). I don't see any advantage of this
+ // iteration order, but changing it would change the order of insertion
+ // into the work list, which would perturb the analyzer results.
+ // FIXME: With forward iterators it would be possible to replace this
+ // convoluted code with a simple range-based for loop over
+ // CFGBlock::succs().
+ using iterator = CFGBlock::const_succ_reverse_iterator;
+ iterator LastCase = getCurrBlock()->succ_rbegin() + 1;
----------------
NagyDonat wrote:
I felt that it is "not our job" to sanity check the invariants of the `CFG` (if
it is crooked, a few isolated checks won't save us), but as you ask I will
re-add this assertion, because why not.
https://github.com/llvm/llvm-project/pull/188096
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits