[clang] [Clang][Sema] Refactor checks on for/while loops (NFC) (PR #226101)

via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 24 03:09:28 PDT 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Expertcoderz (Expertcoderz)

<details>
<summary>Changes</summary>

This is an NFC refactor of `clang/lib/Sema/SemaStmt.cpp` based on @<!-- -->Sirraide's suggestion in https://github.com/llvm/llvm-project/pull/225748#discussion_r4083103871.

- For both `Sema::ActOnForStmt` and `Sema::ActOnWhileStmt`, `CommaVisitor` visiting and empty loop handling have been factored out into a new `CheckConditionalLoop()` function to reduce duplication.

- Also added clarifying comments to explain the need for `setHasEmptyLoopBodies()` usage in the specific cases of `for`/`while` loops.

This PR is intended to be merged prior to #<!-- -->225748, which will benefit from this refactor by having the redundant-defer checks for both `for`/`while` loops in the same `CheckConditionalLoop()` function instead of duplicating them.

---
Full diff: https://github.com/llvm/llvm-project/pull/226101.diff


1 Files Affected:

- (modified) clang/lib/Sema/SemaStmt.cpp (+35-16) 


``````````diff
The server is unavailable at this time. Please wait a few minutes before you try again.
``````````

</details>


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


More information about the cfe-commits mailing list