[llvm-bugs] [Bug 39646] New: clang-format sorts headers even when /* clang-format off */ is used

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Nov 13 04:35:50 PST 2018


            Bug ID: 39646
           Summary: clang-format sorts headers even when /* clang-format
                    off */ is used
           Product: clang
           Version: 7.0
          Hardware: Macintosh
                OS: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: Formatter
          Assignee: unassignedclangbugs at nondot.org
          Reporter: nick.randall at booking.com
                CC: djasper at google.com, klimek at google.com,
                    llvm-bugs at lists.llvm.org

When files include "/* clang-format off */" right at the top, this is ignored
and headers are sorted anyway.

Changing this instead to "// clang-format off" makes it work as expected and
not sort the headers.

Looking through Format.cpp, in sortCppIncludes, there is an explicit check for
"// clang-format off" but not the former version, when both should work. 

Formatting is disabled as expected:

// clang-format off
#include "b.h"
#include "a.h"

Formatting re-orders headers when it shouldn't:

/* clang-format off */
#include "b.h"
#include "a.h"   <- these will be sorted

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/20181113/a486fac5/attachment.html>

More information about the llvm-bugs mailing list