This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG19d2c65ddd75: [CodeGen] Don't crash on for loops with 
cond variables and no increment (authored by bkramer).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D98980/new/

https://reviews.llvm.org/D98980

Files:
  clang/lib/CodeGen/CGStmt.cpp
  clang/test/CodeGenCXX/for-cond-var.cpp


Index: clang/test/CodeGenCXX/for-cond-var.cpp
===================================================================
--- clang/test/CodeGenCXX/for-cond-var.cpp
+++ clang/test/CodeGenCXX/for-cond-var.cpp
@@ -123,3 +123,16 @@
   // CHECK [[for_end]]:
   // CHECK: ret void
 }
+
+// CHECK: define {{.*}} void @_Z16incless_for_loopv(
+void incless_for_loop() {
+  // CHECK: br label %[[for_cond:.*]]
+  // CHECK: [[for_cond]]:
+  // CHECK:   br i1 {{.*}}, label %[[for_body:.*]], label %[[for_end:.*]]
+  // CHECK: [[for_body]]:
+  // CHECK:   br label %[[for_cond]]
+  // CHECK: [[for_end]]:
+  // CHECK:   ret void
+  // CHECK: }
+  for (; int b = 0;) continue;
+}
Index: clang/lib/CodeGen/CGStmt.cpp
===================================================================
--- clang/lib/CodeGen/CGStmt.cpp
+++ clang/lib/CodeGen/CGStmt.cpp
@@ -992,7 +992,7 @@
 
       // We have entered the condition variable's scope, so we're now able to
       // jump to the continue block.
-      Continue = getJumpDestInCurrentScope("for.inc");
+      Continue = S.getInc() ? getJumpDestInCurrentScope("for.inc") : CondDest;
       BreakContinueStack.back().ContinueBlock = Continue;
     }
 


Index: clang/test/CodeGenCXX/for-cond-var.cpp
===================================================================
--- clang/test/CodeGenCXX/for-cond-var.cpp
+++ clang/test/CodeGenCXX/for-cond-var.cpp
@@ -123,3 +123,16 @@
   // CHECK [[for_end]]:
   // CHECK: ret void
 }
+
+// CHECK: define {{.*}} void @_Z16incless_for_loopv(
+void incless_for_loop() {
+  // CHECK: br label %[[for_cond:.*]]
+  // CHECK: [[for_cond]]:
+  // CHECK:   br i1 {{.*}}, label %[[for_body:.*]], label %[[for_end:.*]]
+  // CHECK: [[for_body]]:
+  // CHECK:   br label %[[for_cond]]
+  // CHECK: [[for_end]]:
+  // CHECK:   ret void
+  // CHECK: }
+  for (; int b = 0;) continue;
+}
Index: clang/lib/CodeGen/CGStmt.cpp
===================================================================
--- clang/lib/CodeGen/CGStmt.cpp
+++ clang/lib/CodeGen/CGStmt.cpp
@@ -992,7 +992,7 @@
 
       // We have entered the condition variable's scope, so we're now able to
       // jump to the continue block.
-      Continue = getJumpDestInCurrentScope("for.inc");
+      Continue = S.getInc() ? getJumpDestInCurrentScope("for.inc") : CondDest;
       BreakContinueStack.back().ContinueBlock = Continue;
     }
 
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to