summaryrefslogtreecommitdiffstats
path: root/clang/unittests/Format/FormatTest.cpp
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2013-10-18 16:34:40 +0000
committerDaniel Jasper <djasper@google.com>2013-10-18 16:34:40 +0000
commitd8c36d09b18d3103e91d66a4ec0a355d30f5a7f3 (patch)
treeb3ffeb90747cb53422cacfbeed0b0d64a358bee2 /clang/unittests/Format/FormatTest.cpp
parent5a366fb4dca613da243d00cf3426ebb44492c2ee (diff)
downloadbcm5719-llvm-d8c36d09b18d3103e91d66a4ec0a355d30f5a7f3.tar.gz
bcm5719-llvm-d8c36d09b18d3103e91d66a4ec0a355d30f5a7f3.zip
Make clang-format slightly more willing to break before trailing annotations.
Specifically, prefer breaking before trailing annotations over breaking before the first parameter. Before: void ffffffffffffffffffffffff( int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) OVERRIDE; After: void ffffffffffffffffffffffff(int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) OVERRIDE; llvm-svn: 192983
Diffstat (limited to 'clang/unittests/Format/FormatTest.cpp')
-rw-r--r--clang/unittests/Format/FormatTest.cpp35
1 files changed, 19 insertions, 16 deletions
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index cf5c2324815..15d05f5575e 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -2840,33 +2840,36 @@ TEST_F(FormatTest, TrailingReturnType) {
}
TEST_F(FormatTest, BreaksFunctionDeclarationsWithTrailingTokens) {
- // Avoid breaking before trailing 'const'.
- verifyFormat("void someLongFunction(\n"
- " int someLongParameter) const {}",
- getLLVMStyleWithColumns(46));
+ // Avoid breaking before trailing 'const' or other trailing annotations, if
+ // they are not function-like.
FormatStyle Style = getGoogleStyle();
Style.ColumnLimit = 47;
verifyFormat("void\n"
"someLongFunction(int someLongParameter) const {\n}",
getLLVMStyleWithColumns(47));
- verifyFormat("void someLongFunction(\n"
- " int someLongParameter) const {}",
- Style);
verifyFormat("LoooooongReturnType\n"
"someLoooooooongFunction() const {}",
getLLVMStyleWithColumns(47));
verifyFormat("LoooooongReturnType someLoooooooongFunction()\n"
" const {}",
Style);
-
- // Avoid breaking before other trailing annotations, if they are not
- // function-like.
- verifyFormat("void SomeFunction(aaaaaaaaaaaaaaaaaaaaaaaaaa,\n"
- " aaaaaaaaaaaaaaaaaaaaaaaaaa) OVERRIDE;");
- verifyFormat("void SomeFunction(aaaaaaaaaaaaaaaaaaaaaaaaaa,\n"
- " aaaaaaaaaaaaaaaaaaaaaaaaaa) OVERRIDE FINAL;");
- verifyFormat("void SomeFunction(aaaaaaaaaaaaaaaaaaaaaaaaaa,\n"
- " aaaaaaaaaaaaaaaaaaaaaaaaaa) override final;");
+ verifyFormat("void SomeFunction(aaaaa aaaaaaaaaaaaaaaaaaaa,\n"
+ " aaaaa aaaaaaaaaaaaaaaaaaaa) OVERRIDE;");
+ verifyFormat("void SomeFunction(aaaaa aaaaaaaaaaaaaaaaaaaa,\n"
+ " aaaaa aaaaaaaaaaaaaaaaaaaa) OVERRIDE FINAL;");
+ verifyFormat("void SomeFunction(aaaaa aaaaaaaaaaaaaaaaaaaa,\n"
+ " aaaaa aaaaaaaaaaaaaaaaaaaa) override final;");
+
+ // Unless this would lead to the first parameter being broken.
+ verifyFormat("void someLongFunction(int someLongParameter)\n"
+ " const {}",
+ getLLVMStyleWithColumns(46));
+ verifyFormat("void someLongFunction(int someLongParameter)\n"
+ " const {}",
+ Style);
+ verifyFormat("void SomeFunction(aaaaaaaaaa aaaaaaaaaaaaaaa,\n"
+ " aaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)\n"
+ " LONG_AND_UGLY_ANNOTATION;");
// Breaking before function-like trailing annotations is fine to keep them
// close to their arguments.
OpenPOWER on IntegriCloud