summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2013-12-27 06:39:56 +0000
committerDaniel Jasper <djasper@google.com>2013-12-27 06:39:56 +0000
commit126153ab87f71d2a15dd1779f8881a9ab80626c6 (patch)
treeca5edbc758c41fa040b6b30c9c0a018ca04693bf
parent87c3a0cfa60c55541a4c602b0967eb4267e466b2 (diff)
downloadbcm5719-llvm-126153ab87f71d2a15dd1779f8881a9ab80626c6.tar.gz
bcm5719-llvm-126153ab87f71d2a15dd1779f8881a9ab80626c6.zip
clang-format: Break default arguments less eagerly.
Before: void aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(int aaaaaaaaaaaaaaaaaaaaaaaaaaaa = 1); After: void aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa( int aaaaaaaaaaaaaaaaaaaaaaaaaaaa = 1); llvm-svn: 198070
-rw-r--r--clang/lib/Format/TokenAnnotator.cpp2
-rw-r--r--clang/unittests/Format/FormatTest.cpp4
2 files changed, 6 insertions, 0 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp
index 0cc46a8cad5..c1760f32fc3 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -1214,6 +1214,8 @@ unsigned TokenAnnotator::splitPenalty(const AnnotatedLine &Line,
if (Left.is(tok::l_paren) && InFunctionDecl)
return 100;
+ if (Left.is(tok::equal) && InFunctionDecl)
+ return 110;
if (Left.opensScope())
return Left.ParameterCount > 1 ? Style.PenaltyBreakBeforeFirstCallParameter
: 19;
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index 1ef701a6eb2..d721f0d09d7 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -3031,6 +3031,10 @@ TEST_F(FormatTest, BreaksFunctionDeclarations) {
verifyGoogleFormat(
"SomeLoooooooooooooooooooooooooooooogType operator<<(\n"
" const SomeLooooooooogType &a, const SomeLooooooooogType &b);");
+ verifyFormat("void aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n"
+ " int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = 1);");
+ verifyFormat("aaaaaaaaaaaaaaaaaaaaaa\n"
+ "aaaaaaaaaaaaaaaaaaaaaaaaa(int aaaaaaaaaaaaaaaaaaaaaaaa = 1);");
}
TEST_F(FormatTest, TrailingReturnType) {
OpenPOWER on IntegriCloud