[llvm-bugs] [Bug 39677] New: clang-format inserts spurious Carriage Returns in C-style block comment

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Nov 15 08:09:46 PST 2018


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

            Bug ID: 39677
           Summary: clang-format inserts spurious Carriage Returns in
                    C-style block comment
           Product: new-bugs
           Version: 6.0
          Hardware: All
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: mark.langen at beamdog.com
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org

Created attachment 21126
  --> https://bugs.llvm.org/attachment.cgi?id=21126&action=edit
Example Code

**Issue**
When clang-format is run on a C/C++ file with a C-style block comment, if the
block comment contains a non-empty line with only spaces/tabs on it, and the
file uses CRLF line endings, then that line will have a naked Carriage Return
appended to it. Each time clang-format is run on the document an additional
Carriage Return will be added in this way.

**More Details**
The issue seems to occur with any .clang-format settings that I try, and will
never occur with Unix style line endings. Tested with version 6.0.1 and 8.0.0,
issues occurs on both.

**Example**
See attached test.cpp. Run clang-format -i test.cpp on it without a
.clang-format file present.

**Expected behavior**
The line with only 4 spaces on it is cleared (or preserved, I don't know what
the default behavior is supposed to be).

**Observed behavior**
The line with only 4 spaces on it is preserved, and an additional Carriage
Return character is added after the 4 spaces.

**Probable cause**
I'm guessing that there's a `substring(start of line, LF character)` used in
this case that catches the Carriage Return character as part of the line in
files with CRLF line endings.

-- 
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/20181115/e923eb36/attachment.html>


More information about the llvm-bugs mailing list