[llvm-bugs] [Bug 48280] New: ColumnLimit check for trailing comments alignment acts wrong for multi-byte UTF-8

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Nov 24 00:58:40 PST 2020


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

            Bug ID: 48280
           Summary: ColumnLimit check for trailing comments alignment acts
                    wrong for multi-byte UTF-8
           Product: clang
           Version: 11.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Formatter
          Assignee: unassignedclangbugs at nondot.org
          Reporter: seroburomalinovyi at gmail.com
                CC: djasper at google.com, klimek at google.com,
                    llvm-bugs at lists.llvm.org

.clang-format:
AlignTrailingComments: true
ColumnLimit: 80

What we have upon clang-format:

int a_short;         // some 1-byte UTF8 comment with some good and neat info
int a_veryverylong;  // some one-byte UTF8 comment breaks correctly at 80 char
                     // boundary

int a_short_rus;  // А теперь комментарии, например, на русском, 2-байта
int a_veryverylong_rus;  // Верхний коммент еще не превысил границу в 80,
однако
                         // уже отодвинут. Перенос, при этом, отрабатывает
верно
-------------

What we should have:

int a_short;         // some 1-byte UTF8 comment with some good info
int a_veryverylong;  // some one-byte UTF8 comment breaks correctly at 80 char
                     // boundary

int a_short_rus;         // А теперь комментарии, например, на русском, 2-байта
int a_veryverylong_rus;  // Верхний коммент еще не превысил границу в 80,
однако
                         // уже отодвинут. Перенос, при этом, отрабатывает
верно
-------------
Russian trailing comments go as UTF-8 2-byte characters, and, obviously,
clang-format counts their length as raw byte count when checking if line is
exceeded. As a result, comments fall back closer to code, while still having
enough space for being aligned.
This is relevant only for trailing comment alignment tirgger check. Line break
upon exceeding 80 character limit works correctly for multi-byte characters.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20201124/ee94e47f/attachment-0001.html>


More information about the llvm-bugs mailing list