From b6ccd38deecfcdb62280491553ad558efe5db6ec Mon Sep 17 00:00:00 2001 From: Krasimir Georgiev Date: Thu, 2 Feb 2017 14:36:50 +0000 Subject: [clang-format] Fix breaking of comment sections in unwrapped lines containing newlines. Summary: The breaking of line comment sections was misaligning the case where the first comment line is on an unwrapped line containing newlines. In this case, the breaking column must be based on the source column of the last token that is preceded by a newline, not on the first token of the unwrapped line. source: ``` enum A { a, // line 1 // line 2 }; ``` format before: ``` enum A { a, // line 1 // line 2 }; ``` format after: ``` enum A { a, // line 1 // line 2 }; ``` Reviewers: djasper Reviewed By: djasper Subscribers: cfe-commits, klimek Differential Revision: https://reviews.llvm.org/D29444 llvm-svn: 293891 --- clang/lib/Format/BreakableToken.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'clang/lib/Format/BreakableToken.cpp') diff --git a/clang/lib/Format/BreakableToken.cpp b/clang/lib/Format/BreakableToken.cpp index 09f17a35d07..e9dd253f3ec 100644 --- a/clang/lib/Format/BreakableToken.cpp +++ b/clang/lib/Format/BreakableToken.cpp @@ -695,7 +695,7 @@ BreakableLineCommentSection::BreakableLineCommentSection( Content[i] = Content[i].substr(0, EndOfLine); } LineTok = CurrentTok->Next; - if (CurrentTok->Next && CurrentTok->Next->NewlinesBefore > 1) { + if (CurrentTok->Next && !CurrentTok->Next->ContinuesLineCommentSection) { // A line comment section needs to broken by a line comment that is // preceded by at least two newlines. Note that we put this break here // instead of breaking at a previous stage during parsing, since that -- cgit v1.2.3