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: unassignedclangb...@nondot.org
          Reporter: clemens...@gmail.com
                CC: djas...@google.com, kli...@google.com,
                    llvm-bugs@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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to