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

            Bug ID: 25708
           Summary: Configure the alignment/formatting of macros
           Product: clang
           Version: trunk
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Formatter
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected],
                    [email protected]
    Classification: Unclassified

AFAIK there are no current ways of configure the alginment/formatting of
macros.

I would like to be able to configure the alignment of macros.

For example, consider the current situation:

void foo() {
#ifdef BAR
    do_something();
#endif

#pragma omp target data map ...
    {
#pragma omp target ...
#pragma omp teams ...

#pragma omp distribute
         for (int i = 0; i < size; i += num_blocks)  {
#pragma omp parallel for
             for (int j = i; j < i + num_blocks; ++j) {
                 y[i] = a * x[i] + y[i];
             }
         }
    }
}

This looks horrible _to me_. I would very much prefer:
  - macros to be indented as normal code,
  - for #ifdef ... endif blocks to span its own "scope of indentation"

resulting in: 

void foo() {
    #ifdef BAR
        do_something();  // see indentation here
    #endif

    #pragma omp target data map ...
    {
        #pragma omp target ...
        #pragma omp teams ...

        #pragma omp distribute
        for (int i = 0; i < size; i += num_blocks)  {
            #pragma omp parallel for
            for (int j = i; j < i + num_blocks; ++j) {
                y[i] = a * x[i] + y[i];
            }
        }
    }
}

which looks much better _to me_. It would be nice if there was an option (or
multiple) to switch between both styles (and maybe others like leaving the # at
the beginning of the line but indenting the body of the macro). In particular
since I work on some code bases that follow this style and which clang-format
currently "destroys".

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to