r207849 - Fixes issue with Allman BreakBeforeBraces for Objective C @interface
Dinesh Dwivedi
dinesh.d at samsung.com
Fri May 2 10:01:47 PDT 2014
Author: dinesh
Date: Fri May 2 12:01:46 2014
New Revision: 207849
URL: http://llvm.org/viewvc/llvm-project?rev=207849&view=rev
Log:
Fixes issue with Allman BreakBeforeBraces for Objective C @interface
Before:
@interface BSApplicationController () {
@private
id _extraIvar;
}
@end
After:
@interface BSApplicationController ()
{
@private
id _extraIvar;
}
@end
Modified:
cfe/trunk/lib/Format/UnwrappedLineParser.cpp
cfe/trunk/unittests/Format/FormatTest.cpp
Modified: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineParser.cpp?rev=207849&r1=207848&r2=207849&view=diff
==============================================================================
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original)
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Fri May 2 12:01:46 2014
@@ -1291,9 +1291,12 @@ void UnwrappedLineParser::parseObjCInter
if (FormatTok->Tok.is(tok::less))
parseObjCProtocolList();
- // If instance variables are present, keep the '{' on the first line too.
- if (FormatTok->Tok.is(tok::l_brace))
+ if (FormatTok->Tok.is(tok::l_brace)) {
+ if (Style.BreakBeforeBraces == FormatStyle::BS_Allman ||
+ Style.BreakBeforeBraces == FormatStyle::BS_GNU)
+ addUnwrappedLine();
parseBlock(/*MustBeDeclaration=*/true);
+ }
// With instance variables, this puts '}' on its own line. Without instance
// variables, this ends the @interface line.
Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=207849&r1=207848&r2=207849&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Fri May 2 12:01:46 2014
@@ -7444,6 +7444,14 @@ TEST_F(FormatTest, AllmanBraceBreaking)
"}\n",
BreakBeforeBrace);
+ verifyFormat("@interface BSApplicationController ()\n"
+ "{\n"
+ "@private\n"
+ " id _extraIvar;\n"
+ "}\n"
+ "@end\n",
+ BreakBeforeBrace);
+
BreakBeforeBrace.ColumnLimit = 19;
verifyFormat("void f() { int i; }", BreakBeforeBrace);
BreakBeforeBrace.ColumnLimit = 18;
@@ -7564,6 +7572,14 @@ TEST_F(FormatTest, GNUBraceBreaking) {
" Y = 0,\n"
"}\n",
GNUBraceStyle);
+
+ verifyFormat("@interface BSApplicationController ()\n"
+ "{\n"
+ "@private\n"
+ " id _extraIvar;\n"
+ "}\n"
+ "@end\n",
+ GNUBraceStyle);
}
TEST_F(FormatTest, CatchExceptionReferenceBinding) {
verifyFormat("void f() {\n"
More information about the cfe-commits
mailing list