summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format/ContinuationIndenter.cpp
diff options
context:
space:
mode:
authorKrasimir Georgiev <krasimir@google.com>2017-08-22 14:40:05 +0000
committerKrasimir Georgiev <krasimir@google.com>2017-08-22 14:40:05 +0000
commitfe268fc1c892d28f95aec842390e0a69c2074b5a (patch)
treee112d70258050939251c397e26237dfdc8c220bd /clang/lib/Format/ContinuationIndenter.cpp
parent5fb51ddf293b7eb0da5589d0bc4844eba7c17229 (diff)
downloadbcm5719-llvm-fe268fc1c892d28f95aec842390e0a69c2074b5a.tar.gz
bcm5719-llvm-fe268fc1c892d28f95aec842390e0a69c2074b5a.zip
[clang-format] Break non-trailing block comments
Summary: This patch is an alternative to https://reviews.llvm.org/D36614, by resolving a non-idempotency issue by breaking non-trailing comments: Consider formatting the following code with column limit at `V`: ``` V const /* comment comment */ A = B; ``` The comment is not a trailing comment, breaking before it doesn't bring it under the column limit. The formatter breaks after it, resulting in: ``` V const /* comment comment */ A = B; ``` For a next reformat, the formatter considers the comment as a trailing comment, so it is free to break it further, resulting in: ``` V const /* comment comment */ A = B; ``` This patch improves the situation by directly producing the third case. Reviewers: djasper Reviewed By: djasper Subscribers: cfe-commits, klimek Differential Revision: https://reviews.llvm.org/D37007 llvm-svn: 311457
Diffstat (limited to 'clang/lib/Format/ContinuationIndenter.cpp')
-rw-r--r--clang/lib/Format/ContinuationIndenter.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp
index d8ae82c1843..206be294c9e 100644
--- a/clang/lib/Format/ContinuationIndenter.cpp
+++ b/clang/lib/Format/ContinuationIndenter.cpp
@@ -1282,7 +1282,7 @@ unsigned ContinuationIndenter::breakProtrudingToken(const FormatToken &Current,
return 0;
}
} else if (Current.is(TT_BlockComment)) {
- if (!Current.isTrailingComment() || !Style.ReflowComments ||
+ if (!Style.ReflowComments ||
// If a comment token switches formatting, like
// /* clang-format on */, we don't want to break it further,
// but we may still want to adjust its indentation.
OpenPOWER on IntegriCloud