OSDN Git Service

[clang-format] Fix line lengths w/ comments in align
authormydeveloperday <mydeveloperday@gmail.com>
Wed, 20 May 2020 06:22:01 +0000 (07:22 +0100)
committermydeveloperday <mydeveloperday@gmail.com>
Wed, 20 May 2020 06:22:01 +0000 (07:22 +0100)
commite71c537a487cacaa00265e1acb765235943d5172
tree57da973e0c40ee246c34c62fd6db7e37e6baf02c
parent58684fbb6f2e6871f3f96ac8c7166a7d7486e971
[clang-format] Fix line lengths w/ comments in align

Summary:
https://bugs.llvm.org/show_bug.cgi?id=43845

When a '//comment' trails a consecutive alignment, it adds a whitespace
replacement within the comment token. This wasn't handled correctly in
the alignment code, which treats it as a whole token and thus double
counts it.

This can wrongly trigger the "line too long, it'll wrap" alignment-break
condition with specific lengths, causing the alignment to break for
seemingly no reason.

Patch By:  JakeMerdichAMD

Reviewed By: MyDeveloperDay

Subscribers: kostyakozko, cfe-commits

Tags: #clang, #clang-format

Differential Revision: https://reviews.llvm.org/D79465
clang/lib/Format/WhitespaceManager.cpp
clang/unittests/Format/FormatTest.cpp