From d4ec7c1bfb287ee99988d5f1efb8f03f714f424c Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Mon, 2 Dec 2013 09:19:27 +0000 Subject: [PATCH] clang-format: Fix excessive formatting caused by r195954. Due to a bug in the patch, clang-format would more or less simply format all multi-line comments. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@196080 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Format/Format.cpp | 1 + unittests/Format/FormatTest.cpp | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/lib/Format/Format.cpp b/lib/Format/Format.cpp index 7f91239477..28ef19e192 100644 --- a/lib/Format/Format.cpp +++ b/lib/Format/Format.cpp @@ -1457,6 +1457,7 @@ private: bool IsContinuedComment = Line->First->is(tok::comment) && Line->First->Next == NULL && Line->First->NewlinesBefore < 2 && PreviousLine && + PreviousLine->Affected && PreviousLine->Last->is(tok::comment); if (SomeTokenAffected || SomeFirstChildAffected || LineMoved || diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index 9fac17bc9e..17972c62f8 100644 --- a/unittests/Format/FormatTest.cpp +++ b/unittests/Format/FormatTest.cpp @@ -859,6 +859,13 @@ TEST_F(FormatTest, CanFormatCommentsLocally) { "\n" " // This is unrelated", 0, 0, getLLVMStyle())); + EXPECT_EQ("int a;\n" + "// This is\n" + "// not formatted. ", + format("int a;\n" + "// This is\n" + "// not formatted. ", + 0, 0, getLLVMStyle())); } TEST_F(FormatTest, RemovesTrailingWhitespaceOfComments) { -- 2.40.0