[cfe-commits] r171705 - in /cfe/trunk: lib/Format/Format.cpp unittests/Format/FormatTest.cpp
Daniel Jasper
djasper at google.com
Sun Jan 6 23:13:20 PST 2013
Author: djasper
Date: Mon Jan 7 01:13:20 2013
New Revision: 171705
URL: http://llvm.org/viewvc/llvm-project?rev=171705&view=rev
Log:
Put a higher penalty on breaking before "." or "->".
This fixes llvm.org/PR14823.
Before:
local_state->SetString(prefs::kApplicationLocale, parent_local_state
->GetString(prefs::kApplicationLocale));
After:
local_state->SetString(
prefs::kApplicationLocale,
parent_local_state->GetString(prefs::kApplicationLocale));
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=171705&r1=171704&r2=171705&view=diff
==============================================================================
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Mon Jan 7 01:13:20 2013
@@ -99,7 +99,7 @@
Annotations(Annotations), Replaces(Replaces),
StructuralError(StructuralError) {
Parameters.PenaltyIndentLevel = 15;
- Parameters.PenaltyLevelDecrease = 10;
+ Parameters.PenaltyLevelDecrease = 30;
}
/// \brief Formats an \c UnwrappedLine.
@@ -369,7 +369,7 @@
return Level;
if (Right.Tok.is(tok::arrow) || Right.Tok.is(tok::period))
- return 50;
+ return 150;
return 3;
}
Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=171705&r1=171704&r2=171705&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Mon Jan 7 01:13:20 2013
@@ -713,9 +713,14 @@
"function(LoooooooooooooooooooooooooooooooooooongObject\n"
" ->loooooooooooooooooooooooooooooooooooooooongFunction());");
+ // Here, it is not necessary to wrap at "." or "->".
verifyFormat("if (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaa) ||\n"
" aaaa.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) {\n"
"}");
+ verifyFormat(
+ "aaaaaaaaaaa->aaaaaaaaa(\n"
+ " aaaaaaaaaaaaaaaaaaaaaaaaa,\n"
+ " aaaaaaaaaaaaaaaaaa->aaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaa));\n");
}
TEST_F(FormatTest, WrapsTemplateDeclarations) {
More information about the cfe-commits
mailing list