diff options
Diffstat (limited to 'clang')
| -rw-r--r-- | clang/lib/Format/UnwrappedLineParser.cpp | 10 | ||||
| -rw-r--r-- | clang/lib/Format/UnwrappedLineParser.h | 2 | ||||
| -rw-r--r-- | clang/unittests/Format/FormatTest.cpp | 4 |
3 files changed, 13 insertions, 3 deletions
diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp index f7332ee7707..758f8193ca4 100644 --- a/clang/lib/Format/UnwrappedLineParser.cpp +++ b/clang/lib/Format/UnwrappedLineParser.cpp @@ -319,7 +319,7 @@ void UnwrappedLineParser::parseStructuralElement() { return; case tok::kw_struct: // fallthrough case tok::kw_class: - parseStructOrClass(); + parseStructClassOrBracedList(); return; case tok::semi: nextToken(); @@ -565,7 +565,7 @@ void UnwrappedLineParser::parseEnum() { } while (!eof()); } -void UnwrappedLineParser::parseStructOrClass() { +void UnwrappedLineParser::parseStructClassOrBracedList() { nextToken(); do { switch (FormatTok.Tok.getKind()) { @@ -578,6 +578,12 @@ void UnwrappedLineParser::parseStructOrClass() { nextToken(); addUnwrappedLine(); return; + case tok::equal: + nextToken(); + if (FormatTok.Tok.is(tok::l_brace)) { + parseBracedList(); + } + break; default: nextToken(); break; diff --git a/clang/lib/Format/UnwrappedLineParser.h b/clang/lib/Format/UnwrappedLineParser.h index 837b5391f67..cfd0608ba2e 100644 --- a/clang/lib/Format/UnwrappedLineParser.h +++ b/clang/lib/Format/UnwrappedLineParser.h @@ -146,7 +146,7 @@ private: void parseNamespace(); void parseAccessSpecifier(); void parseEnum(); - void parseStructOrClass(); + void parseStructClassOrBracedList(); void parseObjCProtocolList(); void parseObjCUntilAtEnd(); void parseObjCInterfaceOrImplementation(); diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index a16f66cd086..71fa83ccb14 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -1163,6 +1163,10 @@ TEST_F(FormatTest, PullTrivialFunctionDefinitionsIntoSingleLine) { "}"); } +TEST_F(FormatTest, BracedInitListWithElaboratedTypeSpecifier) { + verifyFormat("struct foo a = { bar };\nint n;"); +} + // FIXME: This breaks the order of the unwrapped lines: // TEST_F(FormatTest, OrderUnwrappedLines) { // verifyFormat("{\n" |

