summaryrefslogtreecommitdiffstats
path: root/clang/unittests/Format/FormatTestComments.cpp
diff options
context:
space:
mode:
authorManuel Klimek <klimek@google.com>2017-12-04 08:53:16 +0000
committerManuel Klimek <klimek@google.com>2017-12-04 08:53:16 +0000
commit48c930cb1e3400d2bf8fcdf53d786e19b96bd833 (patch)
treef379e8d5263137f0d1f44adff916000b7199e15c /clang/unittests/Format/FormatTestComments.cpp
parent4520d4f8ad017935d54c68762a0c2b1adc8b282c (diff)
downloadbcm5719-llvm-48c930cb1e3400d2bf8fcdf53d786e19b96bd833.tar.gz
bcm5719-llvm-48c930cb1e3400d2bf8fcdf53d786e19b96bd833.zip
Fix bug where we wouldn't break columns over the limit.
Before, we would not break: int a = foo(/* trailing */); when the end of /* trailing */ was exactly the column limit; the reason is that block comments can have an unbreakable tail length - in this case 2, for the trailing ");"; we would unconditionally account that when calculating the column state at the end of the token, but not correctly add it into the remaining column length before, as we do for string literals. The fix is to correctly account the trailing unbreakable sequence length into our formatting decisions for block comments. Line comments cannot have a trailing unbreakable sequence, so no change is needed for them. llvm-svn: 319642
Diffstat (limited to 'clang/unittests/Format/FormatTestComments.cpp')
-rw-r--r--clang/unittests/Format/FormatTestComments.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/clang/unittests/Format/FormatTestComments.cpp b/clang/unittests/Format/FormatTestComments.cpp
index 220ce08ff53..ed11fbdb1fc 100644
--- a/clang/unittests/Format/FormatTestComments.cpp
+++ b/clang/unittests/Format/FormatTestComments.cpp
@@ -3080,6 +3080,15 @@ TEST_F(FormatTestComments, PythonStyleComments) {
getTextProtoStyleWithColumns(20)));
}
+TEST_F(FormatTestComments, BreaksBeforeTrailingUnbreakableSequence) {
+ // The end of /* trail */ is exactly at 80 columns, but the unbreakable
+ // trailing sequence ); after it exceeds the column limit. Make sure we
+ // correctly break the line in that case.
+ verifyFormat("int a =\n"
+ " foo(/* trail */);",
+ getLLVMStyleWithColumns(23));
+}
+
} // end namespace
} // end namespace format
} // end namespace clang
OpenPOWER on IntegriCloud