clang-format: Fix comment formatting bugs in nested blocks.
This fixes two issues:
1) The indent of a line comment was not adapted to the subsequent
statement as it would be outside of a nested block.
2) A missing DryRun flag caused actualy breaks to be inserted in
overly long comments while trying to come up with the best line
breaking decisions.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190123 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp
index 6d953eb..3eaa69a 100644
--- a/unittests/Format/FormatTest.cpp
+++ b/unittests/Format/FormatTest.cpp
@@ -564,6 +564,17 @@
" }\n"
"#undef OPERATION_CASE\n"
"}");
+ verifyFormat("DEBUG({\n"
+ " switch (x) {\n"
+ " case A:\n"
+ " f();\n"
+ " break;\n"
+ " // On B:\n"
+ " case B:\n"
+ " g();\n"
+ " break;\n"
+ " }\n"
+ "});");
}
TEST_F(FormatTest, FormatsLabels) {
@@ -2241,6 +2252,24 @@
" for (int i = 0; i < 10; ++i)\n"
" return;\n"
"}");
+ verifyFormat("call(parameter, {\n"
+ " something();\n"
+ " // Comment using all columns.\n"
+ " somethingelse();\n"
+ "});",
+ getLLVMStyleWithColumns(40));
+ EXPECT_EQ("call(parameter, {\n"
+ " something();\n"
+ " // Comment too\n"
+ " // looooooooooong.\n"
+ " somethingElse();\n"
+ "});",
+ format("call(parameter, {\n"
+ " something();\n"
+ " // Comment too looooooooooong.\n"
+ " somethingElse();\n"
+ "});",
+ getLLVMStyleWithColumns(29)));
}
TEST_F(FormatTest, PutEmptyBlocksIntoOneLine) {