This is an archive of the discontinued LLVM Phabricator instance.

[clang-format] Fix crash while reflowing backslash in comments
ClosedPublic

Authored by krasimir on Jun 12 2018, 12:13 PM.

Details

Summary

The added test case was currently crashing with an assertion:

krasimir@krasimir> cat test.cc                                                                                                                                                              ~
// How to run:
// bbbbb run \
// rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr \
// <log_file> -- --output_directory="<output_directory>"
krasimir@krasimir> ~/work/llvm-build/bin/clang-format test.cc                                                                                                                               ~
clang-format: /usr/local/google/home/krasimir/work/llvm/tools/clang/lib/Format/WhitespaceManager.cpp:117: void clang::format::WhitespaceManager::calculateLineBreakInformation(): Assertion `PreviousOriginalWhitespaceEndOffset <= OriginalWhitespaceStartOffset' failed.

The root cause was that BreakableToken was not considering the case of a reflow between an unescaped newline in a line comment.

Diff Detail

Repository
rC Clang

Event Timeline

krasimir created this revision.Jun 12 2018, 12:13 PM
krasimir edited the summary of this revision. (Show Details)Jun 12 2018, 12:14 PM
krasimir edited the summary of this revision. (Show Details)
This revision was not accepted when it landed; it landed in state Needs Review.Jun 12 2018, 12:37 PM
This revision was automatically updated to reflect the committed changes.