[clang] [clang-format] Reset `Line->IsModuleOrImportDecl` in `addUnwrappedLine` (PR #204565)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Jun 18 05:03:26 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang-format
Author: Damian Höster (damster101)
<details>
<summary>Changes</summary>
The `IsModuleOrImportDecl` flag was not reset in `addUnwrappedLine`. Since the parser recycles the `Line` object, this flag remained `true` for all subsequent lines in the file, which disabled wrapping (`CanBreakBefore` in `TokenAnnotator.cpp`) for expression-level constructs after any C++20 module or import statement, causing some formatting rules to not be applied in places. This patch fixes the issue by resetting the flag to `false`.
---
Full diff: https://github.com/llvm/llvm-project/pull/204565.diff
1 Files Affected:
- (modified) clang/lib/Format/UnwrappedLineParser.cpp (+1)
``````````diff
diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp
index c83e82674dee1..b3f239a3ee801 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/clang/lib/Format/UnwrappedLineParser.cpp
@@ -4718,6 +4718,7 @@ void UnwrappedLineParser::addUnwrappedLine(LineLevel AdjustLevel) {
Line->FirstStartColumn = 0;
Line->IsContinuation = false;
Line->SeenDecltypeAuto = false;
+ Line->IsModuleOrImportDecl = false;
if (ClosesWhitesmithsBlock && AdjustLevel == LineLevel::Remove)
--Line->Level;
``````````
</details>
https://github.com/llvm/llvm-project/pull/204565
More information about the cfe-commits
mailing list