Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions clang/lib/Format/ContinuationIndenter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1457,6 +1457,11 @@ unsigned ContinuationIndenter::getNewLineColumn(const LineState &State) {
!Current.isOneOf(tok::colon, tok::comment)) {
return ContinuationIndent;
}
if (Style.isCpp() && Current.is(TT_TrailingReturnArrow) &&
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also think you can drop the isCpp.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Previous.isOneOf(tok::kw_noexcept, tok::kw_mutable, tok::kw_constexpr,
tok::kw_consteval, tok::kw_static)) {
return ContinuationIndent;
}
if (Current.is(TT_ProtoExtensionLSquare))
return CurrentState.Indent;
if (Current.isBinaryOperator() && CurrentState.UnindentOperator) {
Expand Down
28 changes: 28 additions & 0 deletions clang/unittests/Format/FormatTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22858,6 +22858,34 @@ TEST_F(FormatTest, FormatsLambdas) {
" //\n"
" });");

verifyFormat("int main() {\n"
" very_long_function_name_yes_it_is_really_long(\n"
" [](auto n)\n"
" -> std::unordered_map<very_long_type_name_A,\n"
" very_long_type_name_B> {\n"
" really_do_something();\n"
" });\n"
"}",
getLLVMStyleWithColumns(60));
verifyFormat("int main() {\n"
" very_long_function_name_yes_it_is_really_long(\n"
" [](auto n) noexcept\n"
" -> std::unordered_map<very_long_type_name_A,\n"
" very_long_type_name_B> {\n"
" really_do_something();\n"
" });\n"
"}",
getLLVMStyleWithColumns(60));
verifyFormat("int main() {\n"
" very_long_function_name_yes_it_is_really_long(\n"
" [](auto n) constexpr\n"
" -> std::unordered_map<very_long_type_name_A,\n"
" very_long_type_name_B> {\n"
" really_do_something();\n"
" });\n"
"}",
getLLVMStyleWithColumns(60));

FormatStyle DoNotMerge = getLLVMStyle();
DoNotMerge.AllowShortLambdasOnASingleLine = FormatStyle::SLS_None;
verifyFormat("auto c = []() {\n"
Expand Down