diff options
author | Manuel Klimek <klimek@google.com> | 2013-10-21 08:11:15 +0000 |
---|---|---|
committer | Manuel Klimek <klimek@google.com> | 2013-10-21 08:11:15 +0000 |
commit | d186f0b4c15d4c63e0ae7fbe6ca3207871ba2eb9 (patch) | |
tree | b3511640d7779cbcdc9701f56aa9b39336beac3d /unittests/Format | |
parent | 9541141f4f131d76be609665b2a8500f770109c9 (diff) | |
download | clang-d186f0b4c15d4c63e0ae7fbe6ca3207871ba2eb9.tar.gz |
Fixes PR17617: Crash on joining short if statements.
Now that we iterate on the formatting multiple times when we
have chains of preprocessor branches, we need to correctly reset
the token's previous and next pointer for the first / last token.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@193071 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests/Format')
-rw-r--r-- | unittests/Format/FormatTest.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index 6a2d0d89b4..a7de81b267 100644 --- a/unittests/Format/FormatTest.cpp +++ b/unittests/Format/FormatTest.cpp @@ -2329,6 +2329,19 @@ TEST_F(FormatTest, LayoutStatementsAroundPreprocessorDirectives) { "int i;"); } +TEST_F(FormatTest, FormatsJoinedLinesOnSubsequentRuns) { + FormatStyle SingleLine = getLLVMStyle(); + SingleLine.AllowShortIfStatementsOnASingleLine = true; + verifyFormat( + "#if 0\n" + "#elif 1\n" + "#endif\n" + "void foo() {\n" + " if (test) foo2();\n" + "}", + SingleLine); +} + TEST_F(FormatTest, LayoutBlockInsideParens) { EXPECT_EQ("functionCall({ int i; });", format(" functionCall ( {int i;} );")); EXPECT_EQ("functionCall({\n" |