r186077 - Keep trailing annotations close to their argument.
Daniel Jasper
djasper at google.com
Thu Jul 11 05:34:23 PDT 2013
Author: djasper
Date: Thu Jul 11 07:34:23 2013
New Revision: 186077
URL: http://llvm.org/viewvc/llvm-project?rev=186077&view=rev
Log:
Keep trailing annotations close to their argument.
Before:
bool aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa GUARDED_BY(
aaaaaaaaaaaa);
After:
bool aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
GUARDED_BY(aaaaaaaaaaaa);
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=186077&r1=186076&r2=186077&view=diff
==============================================================================
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Thu Jul 11 07:34:23 2013
@@ -1020,6 +1020,8 @@ unsigned TokenAnnotator::splitPenalty(co
if (Right.Type == TT_StartOfName || Right.is(tok::kw_operator)) {
if (Line.First->is(tok::kw_for) && Right.PartOfMultiVariableDeclStmt)
return 3;
+ if (Left.Type == TT_StartOfName)
+ return 20;
else if (Line.MightBeFunctionDecl && Right.BindingStrength == 1)
// FIXME: Clean up hack of using BindingStrength to find top-level names.
return Style.PenaltyReturnTypeOnItsOwnLine;
Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=186077&r1=186076&r2=186077&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Thu Jul 11 07:34:23 2013
@@ -2511,6 +2511,10 @@ TEST_F(FormatTest, BreaksFunctionDeclara
"bool aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n"
" GUARDED_BY(aaaaaaaaaaaa);",
getGoogleStyle());
+ verifyFormat(
+ "bool aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n"
+ " GUARDED_BY(aaaaaaaaaaaa);",
+ getGoogleStyle());
}
TEST_F(FormatTest, BreaksDesireably) {
More information about the cfe-commits
mailing list