diff options
author | Martin Probst <martin@probst.io> | 2018-08-02 11:52:08 +0000 |
---|---|---|
committer | Martin Probst <martin@probst.io> | 2018-08-02 11:52:08 +0000 |
commit | 9d7178139c4c8d28818cb48af7c0b01fda49d60e (patch) | |
tree | 845ed7c2cecd8e12a79ba40ec5942ab20a5164f4 /clang/unittests/Format/FormatTestComments.cpp | |
parent | 1a721eb3a21f9950e7c6c3103eac6928f829b864 (diff) | |
download | bcm5719-llvm-9d7178139c4c8d28818cb48af7c0b01fda49d60e.tar.gz bcm5719-llvm-9d7178139c4c8d28818cb48af7c0b01fda49d60e.zip |
clang-format: fix a crash in comment wraps.
Summary:
Previously, clang-format would crash if it tried to wrap an overlong
single line comment, because two parts of the code inserted a break in
the same location.
/** heregoesalongcommentwithnospace */
This wasn't previously noticed as it could only trigger for an overlong
single line comment that did have no breaking opportunities except for a
whitespace at the very beginning.
This also introduces a check for JavaScript to not ever wrap a comment
before an opening curly brace:
/** @mods {donotbreakbeforethecurly} */
This is because some machinery parsing these tags sometimes supports
breaks before a possible `{`, but in some other cases does not.
Previously clang-format was careful never to wrap a line with certain
tags on it. The better solution is to specifically disable wrapping
before the problematic token: this allows wrapping and aligning comments
but still avoids the problem.
Reviewers: krasimir
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D50177
llvm-svn: 338706
Diffstat (limited to 'clang/unittests/Format/FormatTestComments.cpp')
-rw-r--r-- | clang/unittests/Format/FormatTestComments.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/clang/unittests/Format/FormatTestComments.cpp b/clang/unittests/Format/FormatTestComments.cpp index 2b07dedf670..9f43677b70d 100644 --- a/clang/unittests/Format/FormatTestComments.cpp +++ b/clang/unittests/Format/FormatTestComments.cpp @@ -1254,6 +1254,12 @@ TEST_F(FormatTestComments, SplitsLongLinesInComments) { " */", getLLVMStyleWithColumns(20))); + // This reproduces a crashing bug where both adaptStartOfLine and + // getCommentSplit were trying to wrap after the "/**". + EXPECT_EQ("/** multilineblockcommentwithnowrapopportunity */", + format("/** multilineblockcommentwithnowrapopportunity */", + getLLVMStyleWithColumns(20))); + EXPECT_EQ("/*\n" "\n" "\n" |