diff options
author | Alexander Kornienko <alexfh@google.com> | 2013-06-17 12:59:44 +0000 |
---|---|---|
committer | Alexander Kornienko <alexfh@google.com> | 2013-06-17 12:59:44 +0000 |
commit | 4d26b6efef3a71e583409b148506c3dd6d3a87bb (patch) | |
tree | 34cdef3dfb45841bd3467c9acb18910a02ac3609 /clang/unittests/Format/FormatTest.cpp | |
parent | 2ab0ac5360e15a5303469a871c420c3f06dea660 (diff) | |
download | bcm5719-llvm-4d26b6efef3a71e583409b148506c3dd6d3a87bb.tar.gz bcm5719-llvm-4d26b6efef3a71e583409b148506c3dd6d3a87bb.zip |
Fixes incorrect indentation of line comments after break and re-alignment.
Summary:
Selectively propagate the information about token kind in
WhitespaceManager::replaceWhitespaceInToken.For correct alignment of new
segments of line comments in order to align them correctly. Don't set
BreakBeforeParameter in breakProtrudingToken for line comments, as it introduces
a break after the _next_ parameter. Added tests for related functions.
Reviewers: klimek
Reviewed By: klimek
CC: cfe-commits
Differential Revision: http://llvm-reviews.chandlerc.com/D980
llvm-svn: 184076
Diffstat (limited to 'clang/unittests/Format/FormatTest.cpp')
-rw-r--r-- | clang/unittests/Format/FormatTest.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 32f9d95d668..a26bf607214 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -876,6 +876,16 @@ TEST_F(FormatTest, SplitsLongCxxComments) { format("// A comment before a macro definition\n" "#define a b", getLLVMStyleWithColumns(20))); + EXPECT_EQ("void ffffff(int aaaaaaaaa, // wwww\n" + " int a, int bbb, // xxxxxxx\n" + " // yyyyyyyyy\n" + " int c, int d, int e) {}", + format("void ffffff(\n" + " int aaaaaaaaa, // wwww\n" + " int a,\n" + " int bbb, // xxxxxxx yyyyyyyyy\n" + " int c, int d, int e) {}", + getLLVMStyleWithColumns(40))); } TEST_F(FormatTest, PriorityOfCommentBreaking) { @@ -2456,6 +2466,14 @@ TEST_F(FormatTest, BreaksDesireably) { " Line.Tokens[i - 1].Tok.isNot(tok::l_paren) &&\n" " Line.Tokens[i - 1].Tok.isNot(tok::l_square);\n" " }\n }\n}"); + + // Break on an outer level if there was a break on an inner level. + EXPECT_EQ("f(g(h(a, // comment\n" + " b, c),\n" + " d, e),\n" + " x, y);", + format("f(g(h(a, // comment\n" + " b, c), d, e), x, y);")); } TEST_F(FormatTest, FormatsOneParameterPerLineIfNecessary) { @@ -4565,6 +4583,18 @@ TEST_F(FormatTest, BreakStringLiterals) { format("variable = f(\"long string literal\", short, " "loooooooooooooooooooong);", getLLVMStyleWithColumns(20))); + + EXPECT_EQ("f(g(\"long string \"\n" + " \"literal\"),\n" + " b);", + format("f(g(\"long string literal\"), b);", + getLLVMStyleWithColumns(20))); + EXPECT_EQ("f(g(\"long string \"\n" + " \"literal\",\n" + " a),\n" + " b);", + format("f(g(\"long string literal\", a), b);", + getLLVMStyleWithColumns(20))); EXPECT_EQ( "f(\"one two\".split(\n" " variable));", |