Add option to align escaped newlines left.
This enables formattings like:
#define A \
int aaaa; \
int b; \
int ccc; \
int dddddddddd;
Enabling this for Google/Chromium styles only as I don't know whether it
is desired for Clang/LLVM.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@180253 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp
index 97539d9..97d4df8 100644
--- a/unittests/Format/FormatTest.cpp
+++ b/unittests/Format/FormatTest.cpp
@@ -2974,16 +2974,16 @@
format("if (true)\nreturn 42;", AllowsMergedIf));
FormatStyle ShortMergedIf = AllowsMergedIf;
ShortMergedIf.ColumnLimit = 25;
- verifyFormat("#define A \\\n"
+ verifyFormat("#define A \\\n"
" if (true) return 42;",
ShortMergedIf);
- verifyFormat("#define A \\\n"
- " f(); \\\n"
+ verifyFormat("#define A \\\n"
+ " f(); \\\n"
" if (true)\n"
"#define B",
ShortMergedIf);
- verifyFormat("#define A \\\n"
- " f(); \\\n"
+ verifyFormat("#define A \\\n"
+ " f(); \\\n"
" if (true)\n"
"g();",
ShortMergedIf);
@@ -3800,6 +3800,15 @@
"\"pathat/\"\n"
"\"slashes\"",
format("\"split/pathat/slashes\"", getLLVMStyleWithColumns(10)));
+
+ FormatStyle AlignLeft = getLLVMStyleWithColumns(12);
+ AlignLeft.AlignEscapedNewlinesLeft = true;
+ EXPECT_EQ(
+ "#define A \\\n"
+ " \"some \" \\\n"
+ " \"text \" \\\n"
+ " \"other\";",
+ format("#define A \"some text other\";", AlignLeft));
}
TEST_F(FormatTest, DoNotBreakStringLiteralsInEscapeSequence) {