r236602 - clang-format: Consider operator precedence as penalty when breaking
Daniel Jasper
djasper at google.com
Wed May 6 07:23:39 PDT 2015
Author: djasper
Date: Wed May 6 09:23:38 2015
New Revision: 236602
URL: http://llvm.org/viewvc/llvm-project?rev=236602&view=rev
Log:
clang-format: Consider operator precedence as penalty when breaking
before operators.
This fixes llvm.org/23382.
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=236602&r1=236601&r2=236602&view=diff
==============================================================================
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Wed May 6 09:23:38 2015
@@ -1686,6 +1686,9 @@ unsigned TokenAnnotator::splitPenalty(co
prec::Level Level = Left.getPrecedence();
if (Level != prec::Unknown)
return Level;
+ Level = Right.getPrecedence();
+ if (Level != prec::Unknown)
+ return Level;
return 3;
}
Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=236602&r1=236601&r2=236602&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Wed May 6 09:23:38 2015
@@ -3500,6 +3500,10 @@ TEST_F(FormatTest, ExpressionIndentation
" + cc;",
Style);
+ verifyFormat("aaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n"
+ " = aaaaaaaaaaaaaaaaaaaa + aaaaaaaaaaaaaaaaaaaaaaaaaaaa;",
+ Style);
+
// Forced by comments.
verifyFormat(
"unsigned ContentSize =\n"
More information about the cfe-commits
mailing list