This revision was automatically updated to reflect the committed changes. Closed by commit rC344406: [clang-format] Fix BraceWrapping AfterFunction for ObjC methods (authored by benhamilton, committed by ).
Repository: rC Clang https://reviews.llvm.org/D53197 Files: lib/Format/UnwrappedLineParser.cpp unittests/Format/FormatTestObjC.cpp Index: lib/Format/UnwrappedLineParser.cpp =================================================================== --- lib/Format/UnwrappedLineParser.cpp +++ lib/Format/UnwrappedLineParser.cpp @@ -2164,6 +2164,8 @@ addUnwrappedLine(); return; } else if (FormatTok->Tok.is(tok::l_brace)) { + if (Style.BraceWrapping.AfterFunction) + addUnwrappedLine(); parseBlock(/*MustBeDeclaration=*/false); addUnwrappedLine(); return; Index: unittests/Format/FormatTestObjC.cpp =================================================================== --- unittests/Format/FormatTestObjC.cpp +++ unittests/Format/FormatTestObjC.cpp @@ -584,6 +584,16 @@ " aaaaa:(a)yyy\n" " bbb:(d)cccc;"); verifyFormat("- (void)drawRectOn:(id)surface ofSize:(aaa)height:(bbb)width;"); + + // BraceWrapping AfterFunction is respected for ObjC methods + Style = getGoogleStyle(FormatStyle::LK_ObjC); + Style.BreakBeforeBraces = FormatStyle::BS_Custom; + Style.BraceWrapping.AfterFunction = true; + verifyFormat("@implementation Foo\n" + "- (void)foo:(id)bar\n" + "{\n" + "}\n" + "@end\n"); } TEST_F(FormatTestObjC, FormatObjCMethodExpr) {
Index: lib/Format/UnwrappedLineParser.cpp =================================================================== --- lib/Format/UnwrappedLineParser.cpp +++ lib/Format/UnwrappedLineParser.cpp @@ -2164,6 +2164,8 @@ addUnwrappedLine(); return; } else if (FormatTok->Tok.is(tok::l_brace)) { + if (Style.BraceWrapping.AfterFunction) + addUnwrappedLine(); parseBlock(/*MustBeDeclaration=*/false); addUnwrappedLine(); return; Index: unittests/Format/FormatTestObjC.cpp =================================================================== --- unittests/Format/FormatTestObjC.cpp +++ unittests/Format/FormatTestObjC.cpp @@ -584,6 +584,16 @@ " aaaaa:(a)yyy\n" " bbb:(d)cccc;"); verifyFormat("- (void)drawRectOn:(id)surface ofSize:(aaa)height:(bbb)width;"); + + // BraceWrapping AfterFunction is respected for ObjC methods + Style = getGoogleStyle(FormatStyle::LK_ObjC); + Style.BreakBeforeBraces = FormatStyle::BS_Custom; + Style.BraceWrapping.AfterFunction = true; + verifyFormat("@implementation Foo\n" + "- (void)foo:(id)bar\n" + "{\n" + "}\n" + "@end\n"); } TEST_F(FormatTestObjC, FormatObjCMethodExpr) {
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits