[clang] [dataflow] CXXForRangeStmt should extend flow condition (PR #80989)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Feb 7 05:29:51 PST 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Paul Semel (paulsemel)
<details>
<summary>Changes</summary>
This is needed in order to correctly assume implicit iterator validity in the iterator checker.
---
Full diff: https://github.com/llvm/llvm-project/pull/80989.diff
1 Files Affected:
- (modified) clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp (+6-3)
``````````diff
diff --git a/clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp b/clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
index 4c88c46142d64d..f02c65094113ec 100644
--- a/clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
+++ b/clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
@@ -103,9 +103,12 @@ class TerminatorVisitor
return {nullptr, false};
}
- TerminatorVisitorRetTy VisitCXXForRangeStmt(const CXXForRangeStmt *) {
- // Don't do anything special for CXXForRangeStmt, because the condition
- // (being implicitly generated) isn't visible from the loop body.
+ TerminatorVisitorRetTy VisitCXXForRangeStmt(const CXXForRangeStmt *S) {
+ // Even though the condition isn't visible from the loop body, analysis
+ // might depend on the implicit implicit statements implied by the loop.
+ auto *Cond = S->getCond();
+ if (Cond != nullptr)
+ return extendFlowCondition(*Cond);
return {nullptr, false};
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/80989
More information about the cfe-commits
mailing list