[all-commits] [llvm/llvm-project] e2b6e2: [clang-format] Fix incorrect formatting of lambdas...

Marek Kurdej via All-commits all-commits at lists.llvm.org
Mon Jan 3 23:28:24 PST 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: e2b6e21f19da6fe0da9349264e43286f0441b4ca
      https://github.com/llvm/llvm-project/commit/e2b6e21f19da6fe0da9349264e43286f0441b4ca
  Author: Marek Kurdej <marek.kurdej+llvm.org at gmail.com>
  Date:   2022-01-04 (Tue, 04 Jan 2022)

  Changed paths:
    M clang/lib/Format/UnwrappedLineParser.cpp
    M clang/unittests/Format/FormatTest.cpp

  Log Message:
  -----------
  [clang-format] Fix incorrect formatting of lambdas inside brace initialisation

Fixes https://github.com/llvm/llvm-project/issues/27146.
Fixes https://github.com/llvm/llvm-project/issues/52943.

Before:

```
namespace ns {

void foo() {
  std::variant<int, double> v;
  std::visit(overloaded{[](auto &&) -> int (*)[] { return nullptr; }}, v);
}

} // namespace ns

int break_me() {
  int x = 42;
  return int{[x = x]() {
    return x;
  }()};
}
```

got formatted as:
```
namespace ns {

void foo() {
  std::variant<int, double> v;
  std::visit(overloaded{[](auto &&) -> int (*)[] { return nullptr;
}
} // namespace ns
, v);
}

} // namespace ns

int break_me() {
  int x = 42;
  return int{[x = x](){return x;
}
()
}
;
}
```

Reviewed By: HazardyKnusperkeks, owenpan

Differential Revision: https://reviews.llvm.org/D116553




More information about the All-commits mailing list