summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/Format/UnwrappedLineParser.cpp7
-rw-r--r--clang/unittests/Format/FormatTest.cpp16
2 files changed, 21 insertions, 2 deletions
diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp
index 8dd32d5f717..0467b3a1662 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/clang/lib/Format/UnwrappedLineParser.cpp
@@ -1291,9 +1291,12 @@ void UnwrappedLineParser::parseObjCInterfaceOrImplementation() {
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.
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index 02a77af4f75..62534c6fbae 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -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"
OpenPOWER on IntegriCloud