From: Daniel Jasper Date: Mon, 28 Apr 2014 07:34:48 +0000 (+0000) Subject: clang-format: Don't wrap after @interface. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4145db1ccb327a39726edbbb1069d5585aec4d65;p=clang clang-format: Don't wrap after @interface. This fixes llvm.org/PR19450. Before: @interface BookmarkHomeHandsetViewController () { } After: @interface aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ()< aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa> { } git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@207400 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp index 52764552b0..d2b79e544e 100644 --- a/lib/Format/TokenAnnotator.cpp +++ b/lib/Format/TokenAnnotator.cpp @@ -1583,6 +1583,8 @@ bool TokenAnnotator::canBreakBefore(const AnnotatedLine &Line, const FormatToken &Left = *Right.Previous; if (Left.is(tok::at)) return false; + if (Left.Tok.getObjCKeywordID() == tok::objc_interface) + return false; if (Right.Type == TT_StartOfName || Right.is(tok::kw_operator)) return true; if (Right.isTrailingComment()) diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index d18968afd5..7d5ad9ba14 100644 --- a/unittests/Format/FormatTest.cpp +++ b/unittests/Format/FormatTest.cpp @@ -5848,6 +5848,16 @@ TEST_F(FormatTest, FormatObjCInterface) { "}\n" "+ (id)init;\n" "@end"); + + FormatStyle OnePerLine = getGoogleStyle(); + OnePerLine.BinPackParameters = false; + verifyFormat("@interface aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ()<\n" + " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,\n" + " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,\n" + " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,\n" + " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa> {\n" + "}", + OnePerLine); } TEST_F(FormatTest, FormatObjCImplementation) {