summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format
diff options
context:
space:
mode:
authorKrasimir Georgiev <krasimir@google.com>2017-02-03 10:18:25 +0000
committerKrasimir Georgiev <krasimir@google.com>2017-02-03 10:18:25 +0000
commitd105b72df64ed394b6fb98c13467a2096c1b68e7 (patch)
tree742034f2130e14cc5f16c1c9824442da78c9134b /clang/lib/Format
parent82c489f2a6c73dbe1391954d422ffd9bbdc2dab9 (diff)
downloadbcm5719-llvm-d105b72df64ed394b6fb98c13467a2096c1b68e7.tar.gz
bcm5719-llvm-d105b72df64ed394b6fb98c13467a2096c1b68e7.zip
[clang-format] Re-align broken comment lines where appropriate.
Summary: The comment aligner was skipping over newly broken comment lines. This patch fixes that. source: ``` int ab; // line int a; // long long ``` format with column limit 15 before: ``` int ab; // line int a; // long // long ``` format with column limit 15 after: ``` int ab; // line int a; // long // long ``` Reviewers: djasper Reviewed By: djasper Subscribers: cfe-commits, klimek Differential Revision: https://reviews.llvm.org/D29486 llvm-svn: 293997
Diffstat (limited to 'clang/lib/Format')
-rw-r--r--clang/lib/Format/WhitespaceManager.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/clang/lib/Format/WhitespaceManager.cpp b/clang/lib/Format/WhitespaceManager.cpp
index 3fd92eaf785..93a2e490c66 100644
--- a/clang/lib/Format/WhitespaceManager.cpp
+++ b/clang/lib/Format/WhitespaceManager.cpp
@@ -164,8 +164,9 @@ void WhitespaceManager::calculateLineBreakInformation() {
const WhitespaceManager::Change *LastBlockComment = nullptr;
for (auto &Change : Changes) {
// Reset the IsTrailingComment flag for changes inside of trailing comments
- // so they don't get realigned later.
- if (Change.IsInsideToken)
+ // so they don't get realigned later. Comment line breaks however still need
+ // to be aligned.
+ if (Change.IsInsideToken && Change.NewlinesBefore == 0)
Change.IsTrailingComment = false;
Change.StartOfBlockComment = nullptr;
Change.IndentationOffset = 0;
OpenPOWER on IntegriCloud