llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang-format Author: Owen Pan (owenca) <details> <summary>Changes</summary> Fixes #<!-- -->119790. --- Full diff: https://github.com/llvm/llvm-project/pull/122234.diff 2 Files Affected: - (modified) clang/lib/Format/UnwrappedLineFormatter.cpp (+1-1) - (modified) clang/unittests/Format/FormatTestSelective.cpp (+11) ``````````diff diff --git a/clang/lib/Format/UnwrappedLineFormatter.cpp b/clang/lib/Format/UnwrappedLineFormatter.cpp index ec65fea6ec3df9..cee84fb1191abb 100644 --- a/clang/lib/Format/UnwrappedLineFormatter.cpp +++ b/clang/lib/Format/UnwrappedLineFormatter.cpp @@ -1460,7 +1460,7 @@ unsigned UnwrappedLineFormatter::format( bool ContinueFormatting = TheLine.Level > RangeMinLevel || (TheLine.Level == RangeMinLevel && !PreviousRBrace && - !TheLine.startsWith(tok::r_brace)); + !TheLine.startsWith(TT_NamespaceRBrace)); bool FixIndentation = (FixBadIndentation || ContinueFormatting) && Indent != TheLine.First->OriginalColumn; diff --git a/clang/unittests/Format/FormatTestSelective.cpp b/clang/unittests/Format/FormatTestSelective.cpp index 3ae70a15d359b2..624684c7a079b8 100644 --- a/clang/unittests/Format/FormatTestSelective.cpp +++ b/clang/unittests/Format/FormatTestSelective.cpp @@ -388,6 +388,17 @@ TEST_F(FormatTestSelective, WrongIndent) { " int j;\n" // Format here. "}", 24, 0)); + EXPECT_EQ("namespace {\n" + "class C {\n" + " int i;\n" + "};\n" + "} // namespace", + format("namespace {\n" // Format here. + " class C {\n" + " int i;\n" + " };\n" + "}", + 1, 0)); } TEST_F(FormatTestSelective, AlwaysFormatsEntireMacroDefinitions) { `````````` </details> https://github.com/llvm/llvm-project/pull/122234 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits