[llvm-branch-commits] [clang] [KeyInstr][Clang] For stmt atom (PR #134646)

Jeremy Morse via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Thu May 22 17:00:38 PDT 2025


================
@@ -1416,6 +1424,12 @@ void CodeGenFunction::EmitForStmt(const ForStmt &S,
 
   if (CGM.shouldEmitConvergenceTokens())
     ConvergenceTokenStack.pop_back();
+
+  if (ForBody) {
+    // Key Instructions: We want the for closing brace to be step-able on to
+    // match existing behaviour.
+    addInstToNewSourceAtom(ForBody->getTerminator(), nullptr);
----------------
jmorse wrote:

I feel that this works for the simple case, i.e. a for loop with a single block in it that is the body -- but what about the more complicated situation of more control flow in the for loop? Will the ForBody block have parts of that control flow in it?

If this is already handled (I imagine there's some abstraction in clang I'm unfamiliar with), testing for the correct behaviour would be good.

https://github.com/llvm/llvm-project/pull/134646


More information about the llvm-branch-commits mailing list