diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index 52764552b0db..d2b79e544e34 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/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/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index d18968afd5a7..7d5ad9ba14a1 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/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) {