This is an archive of the discontinued LLVM Phabricator instance.

[AST] Fix formatting whitespace-only comments
Needs ReviewPublic

Authored by refi64 on Apr 1 2020, 5:49 PM.

Details

Reviewers
ilya-biryukov
Summary

If a string consisted only of whitespace, the emptiness check in
getFormattedText would fail, but DropTrailingNewLines would then
call Str.back() on an empty string. In practice, this can easily
crash clangd if an editor asks for a declaration comment that is
whitespace-only.

Diff Detail

Event Timeline

refi64 created this revision.Apr 1 2020, 5:49 PM
refi64 added a comment.Apr 1 2020, 5:56 PM

(I manually ran clang-format-diff afterwards, there were no suggested changes.)