[clang] [Clang] enhance loop analysis to handle variable changes inside lambdas (PR #135573)
Younan Zhang via cfe-commits
cfe-commits at lists.llvm.org
Fri Apr 18 06:50:34 PDT 2025
================
@@ -299,3 +299,38 @@ void test10() {
for (auto[i, j, k] = arr; i < a; ++i) { }
for (auto[i, j, k] = arr; i < a; ++arr[0]) { }
};
+
+namespace GH132038 {
+extern void foo(int);
+void test1() {
+ int a = 0;
+ auto incr_a = [&a]() { ++a; };
+
+ for (int b = 10; a <= b; incr_a())
+ foo(a);
+
+ for (int b = 10; a <= b;)
+ incr_a();
+
+ for (int b = 10; a <= b; [&a]() { ++a; }()) { }
+ for (int b = 10; a <= b; [&a]() { }()) { }
----------------
zyn0217 wrote:
Or if that is something we can't handle at the moment, can you please add a FIXME?
https://github.com/llvm/llvm-project/pull/135573
More information about the cfe-commits
mailing list