[llvm-bugs] [Bug 25708] New: Configure the alignment/formatting of	macros
    via llvm-bugs 
    llvm-bugs at lists.llvm.org
       
    Wed Dec  2 05:19:12 PST 2015
    
    
  
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: unassignedclangbugs at nondot.org
          Reporter: gonzalobg88 at gmail.com
                CC: djasper at google.com, klimek at google.com,
                    llvm-bugs at lists.llvm.org
    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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20151202/5f723217/attachment.html>
    
    
More information about the llvm-bugs
mailing list