diff options
| author | Daniel Jasper <djasper@google.com> | 2013-07-11 12:34:23 +0000 |
|---|---|---|
| committer | Daniel Jasper <djasper@google.com> | 2013-07-11 12:34:23 +0000 |
| commit | 40db06af64570f0c4e627d5c0cd6a3e388ca3ccb (patch) | |
| tree | d32ad7b360c09643b6e6b0112b9ff9d83a57b147 /clang | |
| parent | 69278e9ac8b7046969bc6576f56c2c9e53fea69c (diff) | |
| download | bcm5719-llvm-40db06af64570f0c4e627d5c0cd6a3e388ca3ccb.tar.gz bcm5719-llvm-40db06af64570f0c4e627d5c0cd6a3e388ca3ccb.zip | |
Keep trailing annotations close to their argument.
Before:
bool aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa GUARDED_BY(
aaaaaaaaaaaa);
After:
bool aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
GUARDED_BY(aaaaaaaaaaaa);
llvm-svn: 186077
Diffstat (limited to 'clang')
| -rw-r--r-- | clang/lib/Format/TokenAnnotator.cpp | 2 | ||||
| -rw-r--r-- | clang/unittests/Format/FormatTest.cpp | 4 |
2 files changed, 6 insertions, 0 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index f5b6fbde7c9..1e4de6eb943 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -1020,6 +1020,8 @@ unsigned TokenAnnotator::splitPenalty(const AnnotatedLine &Line, 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; diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index b87393a9da2..8435c94a0fe 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -2511,6 +2511,10 @@ TEST_F(FormatTest, BreaksFunctionDeclarationsWithTrailingTokens) { "bool aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" " GUARDED_BY(aaaaaaaaaaaa);", getGoogleStyle()); + verifyFormat( + "bool aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" + " GUARDED_BY(aaaaaaaaaaaa);", + getGoogleStyle()); } TEST_F(FormatTest, BreaksDesireably) { |

