summaryrefslogtreecommitdiffstats
path: root/unittests
diff options
context:
space:
mode:
authorKrasimir Georgiev <krasimir@google.com>2017-06-04 19:27:02 +0000
committerKrasimir Georgiev <krasimir@google.com>2017-06-04 19:27:02 +0000
commit2241c1625a28a2b959a0c55d0c4d04792410f0fa (patch)
tree90d9f60684131c8dbf7a99766c6436850cbcd46d /unittests
parentdb12c722db654b9cf8dc9ef9540f95362126471b (diff)
[clang-format] Don't align too long broken trailing comments
Summary: This patch fixes a bug where clang-format will align newly broken trailing comments even if this will make them exceed the line limit. The bug was caused by a combination of unsigned arithmetic overflow and an imprecise computation of the length of broken comment lines. Reviewers: djasper, alexfh Reviewed By: alexfh Subscribers: klimek Differential Revision: https://reviews.llvm.org/D33830 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@304687 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests')
-rw-r--r--unittests/Format/FormatTestComments.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/unittests/Format/FormatTestComments.cpp b/unittests/Format/FormatTestComments.cpp
index a44a684558..09ee4645f5 100644
--- a/unittests/Format/FormatTestComments.cpp
+++ b/unittests/Format/FormatTestComments.cpp
@@ -2170,6 +2170,15 @@ TEST_F(FormatTestComments, AlignTrailingComments) {
"// long",
getLLVMStyleWithColumns(15)));
+ // Don't align newly broken trailing comments if that would put them over the
+ // column limit.
+ EXPECT_EQ("int i, j; // line 1\n"
+ "int k; // line longg\n"
+ " // long",
+ format("int i, j; // line 1\n"
+ "int k; // line longg long",
+ getLLVMStyleWithColumns(20)));
+
// Align comment line sections aligned with the next token with the next
// token.
EXPECT_EQ("class A {\n"