diff options
author | Daniel Jasper <djasper@google.com> | 2013-01-25 10:57:27 +0000 |
---|---|---|
committer | Daniel Jasper <djasper@google.com> | 2013-01-25 10:57:27 +0000 |
commit | 63f003644420fff0ea3d463e68aee83f2f5842cd (patch) | |
tree | 8b7eaf9aca3c6befad7315831d6dd17550d439da /unittests/Format/FormatTest.cpp | |
parent | ae04222bc5143756c45c399cc8e504c8b12dc6fc (diff) |
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.).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173438 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests/Format/FormatTest.cpp')
-rw-r--r-- | unittests/Format/FormatTest.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index d8a6ddcb68..2250c03b58 100644 --- a/unittests/Format/FormatTest.cpp +++ b/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;"); |