Skip to content

Commit b227aa8

Browse files
committed
[dataflow] CXXForRangeStmt should extend flow condition
This is needed in order to correctly assume implicit iterator validity in the iterator checker.
1 parent 1b87ebc commit b227aa8

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,12 @@ class TerminatorVisitor
103103
return {nullptr, false};
104104
}
105105

106-
TerminatorVisitorRetTy VisitCXXForRangeStmt(const CXXForRangeStmt *) {
107-
// Don't do anything special for CXXForRangeStmt, because the condition
108-
// (being implicitly generated) isn't visible from the loop body.
106+
TerminatorVisitorRetTy VisitCXXForRangeStmt(const CXXForRangeStmt *S) {
107+
// Even though the condition isn't visible from the loop body, analysis
108+
// might depend on the implicit implicit statements implied by the loop.
109+
auto *Cond = S->getCond();
110+
if (Cond != nullptr)
111+
return extendFlowCondition(*Cond);
109112
return {nullptr, false};
110113
}
111114

0 commit comments

Comments
 (0)