[PATCH] D53197: [clang-format] Fix BraceWrapping AfterFunction for ObjC methods
hultman created this revision. Herald added a subscriber: cfe-commits. > clang-format --version > clang-format version 7.0.0 (tags/RELEASE_700/final) > echo "@implementation Foo\n- (void)foo:(id)bar\n{\n}\n@end\n" |clang-format > -style='{BreakBeforeBraces: Custom, BraceWrapping: {AfterFunction: true}}' @implementation Foo - (void)foo:(id)bar { } @end with patch: > bin/clang-format --version > clang-format version 8.0.0 (trunk 344285) > echo "@implementation Foo\n- (void)foo:(id)bar\n{\n}\n@end\n" > |bin/clang-format -style='{BreakBeforeBraces: Custom, BraceWrapping: > {AfterFunction: true}}' @implementation Foo - (void)foo:(id)bar { } @end Repository: rC Clang https://reviews.llvm.org/D53197 Files: lib/Format/UnwrappedLineParser.cpp unittests/Format/FormatTestObjC.cpp Index: unittests/Format/FormatTestObjC.cpp === --- unittests/Format/FormatTestObjC.cpp +++ unittests/Format/FormatTestObjC.cpp @@ -584,6 +584,16 @@ " a:(a)yyy\n" " bbb:(d);"); 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 @@ " a:(a)yyy\n" " bbb:(d);"); 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; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D53197: [clang-format] Fix BraceWrapping AfterFunction for ObjC methods
hultman added reviewers: benhamilton, jolesiak, klimek, Wizard. hultman added a comment. This bug was introduced in revision 333553, authored by benhamilton, reviewed by jolesiak, klimek. Repository: rC Clang https://reviews.llvm.org/D53197 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D53197: [clang-format] Fix BraceWrapping AfterFunction for ObjC methods
hultman added a comment. @benhamilton Could you land this patch? Repository: rC Clang https://reviews.llvm.org/D53197 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D56909: [clang-format] Fix line parsing for noexcept lambdas
hultman created this revision. hultman added reviewers: benhamilton, jolesiak, klimek, Wizard. Herald added a subscriber: cfe-commits. > $ echo "int c = [b]() mutable noexcept { return [&b] { return b++; }(); }();" > |clang-format int c = [b]() mutable noexcept { return [&b] { return b++; }(); } (); with patch: > $ echo "int c = [b]() mutable noexcept { return [&b] { return b++; }(); }();" > |bin/clang-format int c = [b]() mutable noexcept { return [&b] { return b++; }(); }(); Repository: rC Clang https://reviews.llvm.org/D56909 Files: lib/Format/UnwrappedLineParser.cpp unittests/Format/FormatTest.cpp Index: unittests/Format/FormatTest.cpp === --- unittests/Format/FormatTest.cpp +++ unittests/Format/FormatTest.cpp @@ -11723,6 +11723,8 @@ TEST_F(FormatTest, FormatsLambdas) { verifyFormat("int c = [b]() mutable { return [&b] { return b++; }(); }();\n"); + verifyFormat( + "int c = [b]() mutable noexcept { return [&b] { return b++; }(); }();\n"); verifyFormat("int c = [&] { [=] { return b++; }(); }();\n"); verifyFormat("int c = [&, &a, a] { [=, c, &d] { return b++; }(); }();\n"); verifyFormat("int c = [&a, &a, a] { [=, a, b, &c] { return b++; }(); }();\n"); Index: lib/Format/UnwrappedLineParser.cpp === --- lib/Format/UnwrappedLineParser.cpp +++ lib/Format/UnwrappedLineParser.cpp @@ -1419,6 +1419,7 @@ case tok::numeric_constant: case tok::coloncolon: case tok::kw_mutable: +case tok::kw_noexcept: nextToken(); break; case tok::arrow: Index: unittests/Format/FormatTest.cpp === --- unittests/Format/FormatTest.cpp +++ unittests/Format/FormatTest.cpp @@ -11723,6 +11723,8 @@ TEST_F(FormatTest, FormatsLambdas) { verifyFormat("int c = [b]() mutable { return [&b] { return b++; }(); }();\n"); + verifyFormat( + "int c = [b]() mutable noexcept { return [&b] { return b++; }(); }();\n"); verifyFormat("int c = [&] { [=] { return b++; }(); }();\n"); verifyFormat("int c = [&, &a, a] { [=, c, &d] { return b++; }(); }();\n"); verifyFormat("int c = [&a, &a, a] { [=, a, b, &c] { return b++; }(); }();\n"); Index: lib/Format/UnwrappedLineParser.cpp === --- lib/Format/UnwrappedLineParser.cpp +++ lib/Format/UnwrappedLineParser.cpp @@ -1419,6 +1419,7 @@ case tok::numeric_constant: case tok::coloncolon: case tok::kw_mutable: +case tok::kw_noexcept: nextToken(); break; case tok::arrow: ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D56909: [clang-format] Fix line parsing for noexcept lambdas
hultman added a comment. @benhamilton Would you mind landing the patch? Repository: rC Clang CHANGES SINCE LAST ACTION https://reviews.llvm.org/D56909/new/ https://reviews.llvm.org/D56909 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D56909: [clang-format] Fix line parsing for noexcept lambdas
hultman added a comment. Ping Repository: rC Clang CHANGES SINCE LAST ACTION https://reviews.llvm.org/D56909/new/ https://reviews.llvm.org/D56909 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits