summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/lib/Format/Format.cpp5
-rw-r--r--clang/unittests/Format/FormatTest.cpp7
2 files changed, 11 insertions, 1 deletions
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index 4128785f637..7f78ac0bcf0 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -111,7 +111,10 @@ public:
Comments.back().Tok = Tok.FormatTok;
Comments.back().Spaces = Spaces;
Comments.back().NewLines = NewLines;
- Comments.back().MinColumn = WhitespaceStartColumn + Spaces;
+ if (NewLines == 0)
+ Comments.back().MinColumn = WhitespaceStartColumn + Spaces;
+ else
+ Comments.back().MinColumn = Spaces;
Comments.back().MaxColumn =
Style.ColumnLimit - Spaces - Tok.FormatTok.TokenLength;
return;
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index 160126ba3d9..10742a26090 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -485,6 +485,13 @@ TEST_F(FormatTest, UnderstandsSingleLineComments) {
" parameter));");
verifyGoogleFormat("#endif // HEADER_GUARD");
+
+ verifyFormat("const char *test[] = {\n"
+ " // A\n"
+ " \"aaaa\",\n"
+ " // B\n"
+ " \"aaaaa\",\n"
+ "};");
}
TEST_F(FormatTest, UnderstandsMultiLineComments) {
OpenPOWER on IntegriCloud