This is an archive of the discontinued LLVM Phabricator instance.

clang-format: fix a crash in comment wraps.
ClosedPublic

Authored by mprobst on Aug 2 2018, 4:19 AM.

Details

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.

Diff Detail

Event Timeline

mprobst created this revision.Aug 2 2018, 4:19 AM
krasimir accepted this revision.Aug 2 2018, 4:22 AM

Great! Thank you!

This revision is now accepted and ready to land.Aug 2 2018, 4:22 AM
This revision was automatically updated to reflect the committed changes.