Index: lib/Format/TokenAnnotator.cpp =================================================================== --- lib/Format/TokenAnnotator.cpp +++ lib/Format/TokenAnnotator.cpp @@ -2647,6 +2647,7 @@ return Right.HasUnescapedNewline; if (isAllmanBrace(Left) || isAllmanBrace(Right)) return (Line.startsWith(tok::kw_enum) && Style.BraceWrapping.AfterEnum) || + (Line.startsWith(tok::kw_typedef, tok::kw_enum) && Style.BraceWrapping.AfterEnum) || (Line.startsWith(tok::kw_class) && Style.BraceWrapping.AfterClass) || (Line.startsWith(tok::kw_struct) && Style.BraceWrapping.AfterStruct); if (Left.is(TT_ObjCBlockLBrace) && !Style.AllowShortBlocksOnASingleLine) Index: unittests/Format/FormatTest.cpp =================================================================== --- unittests/Format/FormatTest.cpp +++ unittests/Format/FormatTest.cpp @@ -1324,6 +1324,32 @@ verifyFormat("enum X : std::uint32_t { A, B };"); } +TEST_F(FormatTest, FormatsTypedefEnum) { + FormatStyle Style = getLLVMStyle(); + Style.ColumnLimit = 40; + verifyFormat("typedef enum {} EmptyEnum;"); + verifyFormat("typedef enum { A, B, C } ShortEnum;"); + verifyFormat("typedef enum {\n" + " ZERO = 0,\n" + " ONE = 1,\n" + " TWO = 2,\n" + " THREE = 3\n" + "} LongEnum;", + Style); + Style.BreakBeforeBraces = FormatStyle::BS_Custom; + Style.BraceWrapping.AfterEnum = true; + verifyFormat("typedef enum {} EmptyEnum;"); + verifyFormat("typedef enum { A, B, C } ShortEnum;"); + verifyFormat("typedef enum\n" + "{\n" + " ZERO = 0,\n" + " ONE = 1,\n" + " TWO = 2,\n" + " THREE = 3\n" + "} LongEnum;", + Style); +} + TEST_F(FormatTest, FormatsNSEnums) { verifyGoogleFormat("typedef NS_ENUM(NSInteger, SomeName) { AAA, BBB }"); verifyGoogleFormat("typedef NS_ENUM(NSInteger, MyType) {\n"