r215442 - clang-format: Avoid bad line break.
Daniel Jasper
djasper at google.com
Tue Aug 12 06:22:27 PDT 2014
Author: djasper
Date: Tue Aug 12 08:22:26 2014
New Revision: 215442
URL: http://llvm.org/viewvc/llvm-project?rev=215442&view=rev
Log:
clang-format: Avoid bad line break.
Before:
int
aaaaaaaaaaaaaaaaaaaaaaaaaaaaa(const
typename aaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaa);
After:
int aaaaaaaaaaaaaaaaaaaaaaaaaaaaa(
const typename aaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaa);
Modified:
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/unittests/Format/FormatTest.cpp
Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=215442&r1=215441&r2=215442&view=diff
==============================================================================
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Tue Aug 12 08:22:26 2014
@@ -1813,14 +1813,15 @@ bool TokenAnnotator::canBreakBefore(cons
return true;
if (Left.Type == TT_ArrayInitializerLSquare)
return true;
+ if (Right.is(tok::kw_typename) && Left.isNot(tok::kw_const))
+ return true;
return (Left.isBinaryOperator() &&
!Left.isOneOf(tok::arrowstar, tok::lessless) &&
!Style.BreakBeforeBinaryOperators) ||
Left.isOneOf(tok::comma, tok::coloncolon, tok::semi, tok::l_brace,
tok::kw_class, tok::kw_struct) ||
Right.isMemberAccess() ||
- Right.isOneOf(tok::lessless, tok::colon, tok::l_square, tok::at,
- tok::kw_typename) ||
+ Right.isOneOf(tok::lessless, tok::colon, tok::l_square, tok::at) ||
(Left.is(tok::r_paren) &&
Right.isOneOf(tok::identifier, tok::kw_const)) ||
(Left.is(tok::l_paren) && !Right.is(tok::r_paren));
Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=215442&r1=215441&r2=215442&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Tue Aug 12 08:22:26 2014
@@ -4493,6 +4493,8 @@ TEST_F(FormatTest, WrapsTemplateDeclarat
" B>*>(\n"
"\n"
" );"));
+ verifyFormat("int aaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n"
+ " const typename aaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaa);");
FormatStyle AlwaysBreak = getLLVMStyle();
AlwaysBreak.AlwaysBreakTemplateDeclarations = true;
More information about the cfe-commits
mailing list