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
case tok::l_paren:
parseParens();
break;
+ case tok::l_square:
+ parseSquare();
+ break;
case tok::amp:
case tok::star:
case tok::kw_const:
"};");
verifyFormat("[]() -> Void<T...> {};");
verifyFormat("[a, b]() -> Tuple<T...> { return {}; };");
+ verifyFormat("SomeFunction({[]() -> int[] { return {}; }});");
+ verifyFormat("SomeFunction({[]() -> int *[] { return {}; }});");
+ verifyFormat("SomeFunction({[]() -> int (*)[] { return {}; }});");
+ verifyFormat("SomeFunction({[]() -> ns::type<int (*)[]> { return {}; }});");
+ verifyFormat("return int{[x = x]() { return x; }()};");
// Lambdas with explicit template argument lists.
verifyFormat(