[llvm-bugs] [Bug 41783] New: [clang-format] BreakConstructorInitializers doesn't preserve NOLINT comments

via llvm-bugs llvm-bugs at lists.llvm.org
Tue May 7 00:59:17 PDT 2019


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

            Bug ID: 41783
           Summary: [clang-format] BreakConstructorInitializers doesn't
                    preserve NOLINT comments
           Product: new-bugs
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: dennis.felsing at sap.com
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org

$ cat .clang-format
Language: Cpp
BreakConstructorInitializers: AfterColon
CommentPragmas: 'NOLINT'
$ cat x.cpp
class C
{
public:
    C(C&& rhs) : // NOLINT(performance-noexcept-move-constructor)
      x(rhs.x),
      y(rhs.y)
    {}

private:
    int x;
    int y;
};
$ clang-format x.cpp
class C {
public:
  C(C &&rhs) :
      // NOLINT(performance-noexcept-move-constructor)
      x(rhs.x), y(rhs.y) {}

private:
  int x;
  int y;
};

After clang-format's reformatting the NOLINT marker loses its meaning for
clang-tidy. In this instance a NOLINTNEXTLINE could be used instead as a
workaround from clang-tidy's side.

Unfortunately even CommentPragma can't preserve the comment on the same line.
The only workaround I found is setting BreakConstructorInitializers:
BeforeComma, but in our case this is not wished.

Ideally the comment would stay on the same line and only the x(rhs.x), ... part
be broken over to the next line.

-- 
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/20190507/11804766/attachment.html>


More information about the llvm-bugs mailing list