[llvm-bugs] [Bug 33130] New: clang-format resets comment indentation before ifdefs

via llvm-bugs llvm-bugs at lists.llvm.org
Mon May 22 11:20:55 PDT 2017


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

            Bug ID: 33130
           Summary: clang-format resets comment indentation before ifdefs
           Product: clang
           Version: 4.0
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Formatter
          Assignee: unassignedclangbugs at nondot.org
          Reporter: clemensgru at gmail.com
                CC: djasper at google.com, klimek at google.com,
                    llvm-bugs at lists.llvm.org

Hi,

when running clang-format over a large in-house C source base, I noticed that
it resets the indentation of comments before ifdefs to 0, although an empty
line was placed between comment and #ifdef.
(I understand that it resets the indentation to 0 if the comment is directly
before the ifdef, because then, we can assume that the comment belongs to the
ifdef)

But if there is an empty line in between, I think the comment should instead
follow the indentation from the code before the ifdef or (if unsure),
clang-format should just keep it as it was. (?)

Example:

It changes:

void f(void)
{
 char c;

 /* Comment */

#ifdef FOO
  ...

Into:

void f(void)
{
 char c;

/* Comment */

#ifdef FOO
  ...

I am using clang-format 4.0.0 but I don't think this ever worked (tried many
versions in the past few years).

Thanks,
Clemens

-- 
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/20170522/bbe7dea9/attachment.html>


More information about the llvm-bugs mailing list