[llvm-bugs] [Bug 39688] New: AlignAfterOpen: Align does not align body of lambda as function param with following params

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Nov 16 06:09:05 PST 2018


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

            Bug ID: 39688
           Summary: AlignAfterOpen: Align does not align body of lambda as
                    function param with following params
           Product: clang
           Version: unspecified
          Hardware: Macintosh
                OS: MacOS X
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Formatter
          Assignee: unassignedclangbugs at nondot.org
          Reporter: moorecr3 at gmail.com
                CC: djasper at google.com, klimek at google.com,
                    llvm-bugs at lists.llvm.org

Behavior is identical on clang-format versions 5,6,7

When a lambda is passed as a function argument and is opened on the same line
as the function's open paren, the lambda body is not aligned with the rest of
the arguments.  This makes sense when the lambda is the final argument, but not
with following args.


input.cpp / expected output:
{
  test_long_function([&] {
                       if (true) {
                         dothis();
                       } else {
                         dothat();
                       }
                     },
                     secondArg);

}


ouput.cpp / actual output:
{
  test_long_function([&] {
    if (true) {
      dothis();
    } else {
      dothat();
    }
  },
                     secondArg);
}


.clang-format:
---
ColumnLimit:     0
AlignAfterOpenBracket: Align



note, if the lambda is not on the same line as the open paren, it formats as
expected:

{
  test_long_function(firstarg,
                     [&] {
                       if (condition()) {
                         dothis();
                       } else {
                         dothat();
                       }
                     },
                     thirdarg);
}

-- 
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/20181116/973d1c06/attachment-0001.html>


More information about the llvm-bugs mailing list