From 424d6212ab4c0f921979ea65e7475c2dca933373 Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Mon, 24 Aug 2015 15:10:01 +0000 Subject: [PATCH] clang-format: Always allow break after leading annotations. Before: DEPRECATED("Use NewClass::NewFunction instead.") int OldFunction( const string ¶meter) {} Could not be formatted at all, as clang-format would both require and disallow the break before "int". git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@245846 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Format/TokenAnnotator.cpp | 2 +- unittests/Format/FormatTest.cpp | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp index 50e04310b6..ac34df2455 100644 --- a/lib/Format/TokenAnnotator.cpp +++ b/lib/Format/TokenAnnotator.cpp @@ -2236,7 +2236,7 @@ bool TokenAnnotator::canBreakBefore(const AnnotatedLine &Line, return Left.isNot(tok::period); // FIXME: Properly parse ObjC calls. if (Left.is(tok::r_paren) && Line.Type == LT_ObjCProperty) return true; - if (Left.ClosesTemplateDeclaration) + if (Left.ClosesTemplateDeclaration || Left.is(TT_FunctionAnnotationRParen)) return true; if (Right.isOneOf(TT_RangeBasedForLoopColon, TT_OverloadedOperatorLParen, TT_OverloadedOperator)) diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index 3751697392..2bcc678cbb 100644 --- a/unittests/Format/FormatTest.cpp +++ b/unittests/Format/FormatTest.cpp @@ -3899,6 +3899,8 @@ TEST_F(FormatTest, BreaksFunctionDeclarationsWithTrailingTokens) { } TEST_F(FormatTest, FunctionAnnotations) { + verifyFormat("DEPRECATED(\"Use NewClass::NewFunction instead.\")\n" + "int OldFunction(const string ¶meter) {}"); verifyFormat("DEPRECATED(\"Use NewClass::NewFunction instead.\")\n" "string OldFunction(const string ¶meter) {}"); verifyFormat("template \n" -- 2.40.0