summaryrefslogtreecommitdiffstats
path: root/clang/unittests/Format/FormatTest.cpp
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2013-01-25 10:57:27 +0000
committerDaniel Jasper <djasper@google.com>2013-01-25 10:57:27 +0000
commit45797021b7eb5bb762fd9408a8e93497486919e8 (patch)
treec801ba25ba463f8c8726b841e686fd61197dada0 /clang/unittests/Format/FormatTest.cpp
parent3eb45a03afe8cb667864adb350003f08f15f680d (diff)
downloadbcm5719-llvm-45797021b7eb5bb762fd9408a8e93497486919e8.tar.gz
bcm5719-llvm-45797021b7eb5bb762fd9408a8e93497486919e8.zip
Allow breaking after "::" if absolutely necessary.
Otherwise, really long nested name specifiers can easily lead to a violation of the column limit. Not sure about the rules for indentation in those cases, so input is appreciated (see tests.). llvm-svn: 173438
Diffstat (limited to 'clang/unittests/Format/FormatTest.cpp')
-rw-r--r--clang/unittests/Format/FormatTest.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index d8a6ddcb688..2250c03b583 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -1204,6 +1204,33 @@ TEST_F(FormatTest, WrapsTemplateDeclarations) {
"void f();");
}
+TEST_F(FormatTest, WrapsAtNestedNameSpecifiers) {
+ verifyFormat(
+ "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa::\n"
+ " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa();");
+ verifyFormat(
+ "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa::\n"
+ " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n"
+ " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa());");
+
+ // FIXME: Should we have an extra indent after the second break?
+ verifyFormat(
+ "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa::\n"
+ " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa::\n"
+ " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa();");
+
+ // FIXME: Look into whether we should indent 4 from the start or 4 from
+ // "bbbbb..." here instead of what we are doing now.
+ verifyFormat(
+ "aaaaaaaaaaaaaaa(bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb::\n"
+ " cccccccccccccccccccccccccccccccccccccccccccccccccc());");
+
+ // Breaking at nested name specifiers is generally not desirable.
+ verifyFormat(
+ "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa::aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n"
+ " aaaaaaaaaaaaaaaaaaaaaaa);");
+}
+
TEST_F(FormatTest, UnderstandsTemplateParameters) {
verifyFormat("A<int> a;");
verifyFormat("A<A<A<int> > > a;");
OpenPOWER on IntegriCloud