Index: lib/Format/UnwrappedLineFormatter.cpp =================================================================== --- lib/Format/UnwrappedLineFormatter.cpp +++ lib/Format/UnwrappedLineFormatter.cpp @@ -365,9 +365,14 @@ } 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)) - return 0; + { + FormatToken *Tok = + Line.First->is(tok::kw_typedef) ? Line.First->Next : Line.First; + if (Tok && + Tok->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. if (I + 2 == E || I[2]->Type == LT_Invalid) Index: unittests/Format/FormatTest.cpp =================================================================== --- unittests/Format/FormatTest.cpp +++ unittests/Format/FormatTest.cpp @@ -443,6 +443,14 @@ "}", AllowSimpleBracedStatements); + verifyFormat("struct A2 {\n" + " int X;\n" + "};", + AllowSimpleBracedStatements); + verifyFormat("typedef struct A2 {\n" + " int X;\n" + "} A2_t;", + AllowSimpleBracedStatements); verifyFormat("template struct A2 {\n" " struct B {};\n" "};",