r209438 - clang-format: Fix corner case in AllowShortBlocksOnASingleLine.
Daniel Jasper
djasper at google.com
Thu May 22 06:25:26 PDT 2014
Author: djasper
Date: Thu May 22 08:25:26 2014
New Revision: 209438
URL: http://llvm.org/viewvc/llvm-project?rev=209438&view=rev
Log:
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).
Modified:
cfe/trunk/lib/Format/Format.cpp
cfe/trunk/unittests/Format/FormatTest.cpp
Modified: cfe/trunk/lib/Format/Format.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=209438&r1=209437&r2=209438&view=diff
==============================================================================
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Thu May 22 08:25:26 2014
@@ -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);
Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=209438&r1=209437&r2=209438&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Thu May 22 08:25:26 2014
@@ -378,6 +378,11 @@ TEST_F(FormatTest, FormatShortBracedStat
"}",
AllowSimpleBracedStatements);
+ verifyFormat("template <int> struct A2 {\n"
+ " struct B {};\n"
+ "};",
+ AllowSimpleBracedStatements);
+
AllowSimpleBracedStatements.AllowShortIfStatementsOnASingleLine = false;
verifyFormat("if (true) {\n"
" f();\n"
More information about the cfe-commits
mailing list