r198559 - clang-format: Spacing inside enum braces.
Daniel Jasper
djasper at google.com
Sun Jan 5 05:23:23 PST 2014
Author: djasper
Date: Sun Jan 5 07:23:23 2014
New Revision: 198559
URL: http://llvm.org/viewvc/llvm-project?rev=198559&view=rev
Log:
clang-format: Spacing inside enum braces.
Before (in Google style):
enum ShortEnum {A, B, C};
After:
enum ShortEnum { A, B, C };
Modified:
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/unittests/Format/FormatTest.cpp
Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=198559&r1=198558&r2=198559&view=diff
==============================================================================
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Sun Jan 5 07:23:23 2014
@@ -1335,7 +1335,9 @@ bool TokenAnnotator::spaceRequiredBetwee
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;
Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=198559&r1=198558&r2=198559&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Sun Jan 5 07:23:23 2014
@@ -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) {
More information about the cfe-commits
mailing list