From 1a148b49220beb546ec4817138fc735b2b5dce68 Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Sun, 5 Jan 2014 13:23:23 +0000 Subject: [PATCH] clang-format: Spacing inside enum braces. Before (in Google style): enum ShortEnum {A, B, C}; After: enum ShortEnum { A, B, C }; llvm-svn: 198559 --- clang/lib/Format/TokenAnnotator.cpp | 4 +++- clang/unittests/Format/FormatTest.cpp | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index 6b6f4edee238..00d404ba4c4e 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 685c9022dad6..5086bd7b4029 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) { -- GitLab