llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang-format Author: Owen Pan (owenca) <details> <summary>Changes</summary> Fixes #<!-- -->69237. --- Full diff: https://github.com/llvm/llvm-project/pull/69897.diff 2 Files Affected: - (modified) clang/lib/Format/TokenAnnotator.cpp (+1-1) - (modified) clang/unittests/Format/FormatTest.cpp (+19) ``````````diff diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index 7f85f48de2ed2ed..8d3d622bca035a3 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -3544,7 +3544,7 @@ void TokenAnnotator::calculateFormattingInformation(AnnotatedLine &Line) const { } } } - } else if (Current->SpacesRequiredBefore == 0 && + } else if (!Current->Finalized && Current->SpacesRequiredBefore == 0 && spaceRequiredBefore(Line, *Current)) { Current->SpacesRequiredBefore = 1; } diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 0a87cfc4f1d6af9..d5711782a23ef5b 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -26459,6 +26459,25 @@ TEST_F(FormatTest, AllowBreakBeforeNoexceptSpecifier) { Style); } +TEST_F(FormatTest, PPBranchesInBracedInit) { + verifyFormat("A a_{kFlag1,\n" + "#if BUILD_FLAG\n" + " kFlag2,\n" + "#else\n" + " kFlag3,\n" + "#endif\n" + " kFlag4};", + "A a_{\n" + " kFlag1,\n" + "#if BUILD_FLAG\n" + " kFlag2,\n" + "#else\n" + " kFlag3,\n" + "#endif\n" + " kFlag4\n" + "};"); +} + } // namespace } // namespace test } // namespace format `````````` </details> https://github.com/llvm/llvm-project/pull/69897 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits