diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index 6b6f4edee2388f2c544f61133c6057304e188425..00d404ba4c4ed4363a72bc21b4815b166e5c68b5 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -1335,7 +1335,9 @@ bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line, return false; if (Left.is(tok::l_brace) && Right.is(tok::r_brace)) return !Left.Children.empty(); // No spaces in "{}". - if (Left.is(tok::l_brace) || Right.is(tok::r_brace)) + if ((Left.is(tok::l_brace) && Left.BlockKind != BK_Block) || + (Right.is(tok::r_brace) && Right.MatchingParen && + Right.MatchingParen->BlockKind != BK_Block)) return !Style.Cpp11BracedListStyle; if (Left.Type == TT_BlockComment && Left.TokenText.endswith("=*/")) return false; diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 685c9022dad689b1fecb673826236143a15ba8cf..5086bd7b4029d2eeadcc2a96fd161d5e33ec1c68 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -1654,6 +1654,7 @@ TEST_F(FormatTest, FormatsEnum) { getLLVMStyleWithColumns(30)); verifyFormat("enum ShortEnum { A, B, C };"); + verifyGoogleFormat("enum ShortEnum { A, B, C };"); } TEST_F(FormatTest, FormatsEnumsWithErrors) {