diff options
| author | Daniel Jasper <djasper@google.com> | 2013-07-16 18:22:10 +0000 |
|---|---|---|
| committer | Daniel Jasper <djasper@google.com> | 2013-07-16 18:22:10 +0000 |
| commit | 6ab5468637453ffc90fcc8036e40615c1e04b775 (patch) | |
| tree | f4b6b7fd02c89c4117b16554bb53bbdef078d6f5 /clang/unittests/Format/FormatTest.cpp | |
| parent | 3d527d80b86d98ae80b50db0814d2dc075227bd9 (diff) | |
| download | bcm5719-llvm-6ab5468637453ffc90fcc8036e40615c1e04b775.tar.gz bcm5719-llvm-6ab5468637453ffc90fcc8036e40615c1e04b775.zip | |
Revamp the formatting of C++11 braced init lists.
The fundamental concept is:
Format as if the braced init list was a function call (with parentheses
replaced by braces). If there is no name/type before the opening brace
(e.g. if the braced list is nested), assume a zero-length identifier
just before the opening brace.
This behavior is gated on a new style flag, which for now replaces the
SpacesInBracedLists style flag. Activate this style flag for Google
style to reflect recent style guide changes.
llvm-svn: 186433
Diffstat (limited to 'clang/unittests/Format/FormatTest.cpp')
| -rw-r--r-- | clang/unittests/Format/FormatTest.cpp | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 747a140846b..aa2a70987ba 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -1637,10 +1637,9 @@ TEST_F(FormatTest, NestedStaticInitializers) { " { kGlobalRef, UNKNOWN_CODE, NULL, NULL, NULL }\n" "};"); verifyGoogleFormat("SomeType Status::global_reps[3] = {\n" - " {kGlobalRef, OK_CODE, NULL, NULL, NULL},\n" - " {kGlobalRef, CANCELLED_CODE, NULL, NULL, NULL},\n" - " {kGlobalRef, UNKNOWN_CODE, NULL, NULL, NULL}\n" - "};"); + " {kGlobalRef, OK_CODE, NULL, NULL, NULL},\n" + " {kGlobalRef, CANCELLED_CODE, NULL, NULL, NULL},\n" + " {kGlobalRef, UNKNOWN_CODE, NULL, NULL, NULL}};"); verifyFormat( "CGRect cg_rect = { { rect.fLeft, rect.fTop },\n" " { rect.fRight - rect.fLeft, rect.fBottom - rect.fTop" @@ -1659,11 +1658,11 @@ TEST_F(FormatTest, NestedStaticInitializers) { " 333333333333333333333333333333 } },\n" " { { 1, 2, 3 } }, { { 1, 2, 3 } } };"); verifyGoogleFormat( - "SomeArrayOfSomeType a = {{{1, 2, 3}}, {{1, 2, 3}},\n" - " {{111111111111111111111111111111,\n" - " 222222222222222222222222222222,\n" - " 333333333333333333333333333333}},\n" - " {{1, 2, 3}}, {{1, 2, 3}}};"); + "SomeArrayOfSomeType a = {\n" + " {{1, 2, 3}}, {{1, 2, 3}},\n" + " {{111111111111111111111111111111, 222222222222222222222222222222,\n" + " 333333333333333333333333333333}},\n" + " {{1, 2, 3}}, {{1, 2, 3}}};"); // FIXME: We might at some point want to handle this similar to parameter // lists, where we have an option to put each on a single line. @@ -3902,7 +3901,7 @@ TEST_F(FormatTest, LayoutCxx11ConstructorBraceInitializers) { " });"); FormatStyle NoSpaces = getLLVMStyle(); - NoSpaces.SpacesInBracedLists = false; + NoSpaces.Cpp11BracedListStyle = true; verifyFormat("vector<int> x{1, 2, 3, 4};", NoSpaces); verifyFormat("vector<T> x{{}, {}, {}, {}};", NoSpaces); verifyFormat("f({1, 2});", NoSpaces); @@ -5307,7 +5306,7 @@ TEST_F(FormatTest, ParsesConfiguration) { CHECK_PARSE_BOOL(IndentCaseLabels); CHECK_PARSE_BOOL(ObjCSpaceBeforeProtocolList); CHECK_PARSE_BOOL(PointerBindsToType); - CHECK_PARSE_BOOL(SpacesInBracedLists); + CHECK_PARSE_BOOL(Cpp11BracedListStyle); CHECK_PARSE_BOOL(UseTab); CHECK_PARSE_BOOL(IndentFunctionDeclarationAfterType); |

