Allow splitting between string literals and identifiers.
Also don't break in long include directives as that is not desired.
We can now format:
#include "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
#define LL_FORMAT "ll"
printf("aaaaa: %d, bbbbbbbbb: %" LL_FORMAT "d, cccccccc: %" LL_FORMAT
"d, ddddddddd: %" LL_FORMAT "d\n");
Before, this led to weird results.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175959 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp
index 00657e0..3cf151e 100644
--- a/unittests/Format/FormatTest.cpp
+++ b/unittests/Format/FormatTest.cpp
@@ -1460,6 +1460,11 @@
verifyFormat("a = a + \"a\"\n"
" \"a\"\n"
" \"a\";");
+
+ verifyFormat(
+ "#define LL_FORMAT \"ll\"\n"
+ "printf(\"aaaaa: %d, bbbbbb: %\" LL_FORMAT \"d, cccccccc: %\" LL_FORMAT\n"
+ " \"d, ddddddddd: %\" LL_FORMAT \"d\");");
}
TEST_F(FormatTest, AlignsPipes) {
@@ -1933,7 +1938,9 @@
"#include \"string.h\"\n"
"#include \"string.h\"\n"
"#include <a-a>\n"
- "#include < path with space >\n");
+ "#include < path with space >\n"
+ "#include \"some very long include paaaaaaaaaaaaaaaaaaaaaaath\"",
+ getLLVMStyleWithColumns(35));
verifyFormat("#import <string>");
verifyFormat("#import <a/b/c.h>");