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

            Bug ID: 34151
           Summary: Clang-Format: Option AlignConsecutiveAssignments not
                    working with Statement-Expressions
           Product: clang
           Version: 5.0
          Hardware: Macintosh
                OS: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: Formatter
          Assignee: unassignedclangb...@nondot.org
          Reporter: sebastiankel...@fastmail.net
                CC: djas...@google.com, kli...@google.com,
                    llvm-bugs@lists.llvm.org

Created attachment 18963
  --> https://bugs.llvm.org/attachment.cgi?id=18963&action=edit
clang-format configuration file

Hello,

it seems like the open `AlignConsecutiveAssignments` in combination with
statement expressions is not working correctly (anymore).

All equal signs are placed on the first lines equal sign, if possible.

This leads to some weird formatting if the name is too short or very long.




```
#include <stdio.h>

int test() {
  // If the name (a) is short the formatting is off
  int a = ({
    int b= 1;
    int c= b + 1;
    int d= c + 1;
    d
  });

  /**
   * Is it possible to have it that way?
   */
  //  int a = ({
  //    int b = 1;
  //    int c = b + 1;
  //    int d = c + 1;
  //    d
  //  });

  // ------------------------------

  // It seems not so bad here, but if the longerName gets event longer it
  // becomes worse
  int longerName = ({
    int bb       = 1;
    int cccc     = b + 1;
    int dd       = c + 1;
    d;
  });

  int somethingRidiculousLongProbablyWithBadNamingAndATpyo = ({
    int bb                                                 = 1;
    int cccc                                               = b + 1;
    int dd                                                 = c + 1;
    d;
  });

  /**
   * I think this would be the right formatting.
   */
  //  int somethingRidiculousLongProbablyWithBadNamingAndATpyo = ({
  //    int bb   = 1;
  //    int cccc = b + 1;
  //    int dd   = c + 1;
  //    d;
  //  });

  return a;
}
```

The .clang-format file is as following
```
---
Language:         Cpp
BasedOnStyle:  Google
AlignConsecutiveAssignments: true
...
```

Thank you very much!

-- 
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