diff options
| author | Daniel Jasper <djasper@google.com> | 2014-05-22 13:25:26 +0000 |
|---|---|---|
| committer | Daniel Jasper <djasper@google.com> | 2014-05-22 13:25:26 +0000 |
| commit | bd630737bd4f55e3960b1331ead863342053680c (patch) | |
| tree | 73afdf3722c43f79825c06aa9f1cc292601dae5c | |
| parent | 15ff71deea1652f7312d899e706560544f6f7878 (diff) | |
| download | bcm5719-llvm-bd630737bd4f55e3960b1331ead863342053680c.tar.gz bcm5719-llvm-bd630737bd4f55e3960b1331ead863342053680c.zip | |
clang-format: Fix corner case in AllowShortBlocksOnASingleLine.
Before:
template <int> struct A4 { A4() { }
};
After:
template <int i> struct A4 {
A4() {}
};
This fixes llvm.org/PR19813 (at least the part that isn't working as
intended).
llvm-svn: 209438
| -rw-r--r-- | clang/lib/Format/Format.cpp | 3 | ||||
| -rw-r--r-- | clang/unittests/Format/FormatTest.cpp | 5 |
2 files changed, 6 insertions, 2 deletions
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp index 2821e4aa2c1..3df13669003 100644 --- a/clang/lib/Format/Format.cpp +++ b/clang/lib/Format/Format.cpp @@ -690,8 +690,7 @@ private: if (I[1]->Last->Type == TT_LineComment) return 0; do { - if (Tok->is(tok::l_brace) && Tok->BlockKind != BK_BracedInit && - !Style.AllowShortBlocksOnASingleLine) + if (Tok->is(tok::l_brace) && Tok->BlockKind != BK_BracedInit) return 0; Tok = Tok->Next; } while (Tok); diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 729eeaf4399..b3fb776a7a6 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -378,6 +378,11 @@ TEST_F(FormatTest, FormatShortBracedStatements) { "}", AllowSimpleBracedStatements); + verifyFormat("template <int> struct A2 {\n" + " struct B {};\n" + "};", + AllowSimpleBracedStatements); + AllowSimpleBracedStatements.AllowShortIfStatementsOnASingleLine = false; verifyFormat("if (true) {\n" " f();\n" |

