diff options
| author | Daniel Jasper <djasper@google.com> | 2014-01-05 13:23:23 +0000 |
|---|---|---|
| committer | Daniel Jasper <djasper@google.com> | 2014-01-05 13:23:23 +0000 |
| commit | 1a148b49220beb546ec4817138fc735b2b5dce68 (patch) | |
| tree | b0615ebdbffcf6ab8b768439305cad1d4a989a9b | |
| parent | 9697281eecdc8204c53f4be6b778f9e5988a41c8 (diff) | |
| download | bcm5719-llvm-1a148b49220beb546ec4817138fc735b2b5dce68.tar.gz bcm5719-llvm-1a148b49220beb546ec4817138fc735b2b5dce68.zip | |
clang-format: Spacing inside enum braces.
Before (in Google style):
enum ShortEnum {A, B, C};
After:
enum ShortEnum { A, B, C };
llvm-svn: 198559
| -rw-r--r-- | clang/lib/Format/TokenAnnotator.cpp | 4 | ||||
| -rw-r--r-- | clang/unittests/Format/FormatTest.cpp | 1 |
2 files changed, 4 insertions, 1 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index 6b6f4edee23..00d404ba4c4 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 685c9022dad..5086bd7b402 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) { |

