[PATCH] D50177: clang-format: fix a crash in comment wraps.
Martin Probst via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Aug 2 04:19:57 PDT 2018
mprobst created this revision.
mprobst added a reviewer: krasimir.
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.
Repository:
rC Clang
https://reviews.llvm.org/D50177
Files:
lib/Format/BreakableToken.cpp
unittests/Format/FormatTestComments.cpp
unittests/Format/FormatTestJS.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D50177.158724.patch
Type: text/x-patch
Size: 7748 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180802/06c42e39/attachment.bin>
More information about the cfe-commits
mailing list