summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2013-12-02 09:19:27 +0000
committerDaniel Jasper <djasper@google.com>2013-12-02 09:19:27 +0000
commit0e81f1ad43e1bf87b70ac6500bd360b00db378fa (patch)
tree888225c12b239d44d3e23c3c075812cb49e3eb88 /clang
parent08b9cf56be30b483f35c0401a8997473f456e025 (diff)
downloadbcm5719-llvm-0e81f1ad43e1bf87b70ac6500bd360b00db378fa.tar.gz
bcm5719-llvm-0e81f1ad43e1bf87b70ac6500bd360b00db378fa.zip
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. llvm-svn: 196080
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/Format/Format.cpp1
-rw-r--r--clang/unittests/Format/FormatTest.cpp7
2 files changed, 8 insertions, 0 deletions
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index 7f912394778..28ef19e192f 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/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/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index 9fac17bc9e5..17972c62f8a 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/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) {
OpenPOWER on IntegriCloud