diff options
Diffstat (limited to 'clang')
| -rw-r--r-- | clang/lib/Format/UnwrappedLineFormatter.cpp | 7 | ||||
| -rw-r--r-- | clang/unittests/Format/FormatTest.cpp | 8 |
2 files changed, 13 insertions, 2 deletions
diff --git a/clang/lib/Format/UnwrappedLineFormatter.cpp b/clang/lib/Format/UnwrappedLineFormatter.cpp index 7f644651a6a..63a0b7df59f 100644 --- a/clang/lib/Format/UnwrappedLineFormatter.cpp +++ b/clang/lib/Format/UnwrappedLineFormatter.cpp @@ -434,8 +434,11 @@ private: } else if (Limit != 0 && !Line.startsWith(tok::kw_namespace) && !startsExternCBlock(Line)) { // We don't merge short records. - if (Line.First->isOneOf(tok::kw_class, tok::kw_union, tok::kw_struct, - Keywords.kw_interface)) + FormatToken *RecordTok = + Line.First->is(tok::kw_typedef) ? Line.First->Next : Line.First; + if (RecordTok && + RecordTok->isOneOf(tok::kw_class, tok::kw_union, tok::kw_struct, + Keywords.kw_interface)) return 0; // Check that we still have three lines and they fit into the limit. diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index e6cd617abd8..bae7fba0a60 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -458,6 +458,14 @@ TEST_F(FormatTest, FormatShortBracedStatements) { "}", AllowSimpleBracedStatements); + verifyFormat("struct A2 {\n" + " int X;\n" + "};", + AllowSimpleBracedStatements); + verifyFormat("typedef struct A2 {\n" + " int X;\n" + "} A2_t;", + AllowSimpleBracedStatements); verifyFormat("template <int> struct A2 {\n" " struct B {};\n" "};", |

