[llvm-bugs] [Bug 35262] New: Clang-Format fails with multi-line comments

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Nov 9 03:59:23 PST 2017


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

            Bug ID: 35262
           Summary: Clang-Format fails with multi-line comments
           Product: clang
           Version: 5.0
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Formatter
          Assignee: unassignedclangbugs at nondot.org
          Reporter: alex at grundis.de
                CC: djasper at google.com, klimek at google.com,
                    llvm-bugs at lists.llvm.org

Created attachment 19392
  --> https://bugs.llvm.org/attachment.cgi?id=19392&action=edit
File to test

Clang-format fails when using multi-line comments in a define where it should
align the escaped newlines.

There are 2 possible failures: 

- It fails to format the code in question completely (mostly untouched)
- It adds another escaped newline. And again on next format, and again, and
again...

Testcase that triggers both:

        #define FOO \
         /* \
         * Multi-line-comment: \
         */

#define BAR \
/*\
* Multi-line-comment\
*/


Save as clangFormat.cpp (see attachment) and run `clang-format.exe
-style="{AlignEscapedNewlines: Left}" clangFormat.cpp`

Result:

#define FOO                \
  /* \                     \
   * Multi-line-comment: \ \
   */

#define BAR \
/*\
* Multi-line-comment\
*/


On a related note: It will also add an extra newline before an opening brace in
a define and again fail to align the escaped newlines:

#define BAR \
{\
}

->

#define BAR \
  \
{\
}

-- 
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/20171109/dbe55f05/attachment-0001.html>


More information about the llvm-bugs mailing list