Issue 81592
Summary [clang-format] Feature request: Put curly brace on next line if function arguments are multiline AND start on new line.
Labels clang-format
Assignees
Reporter mcourteaux
    Having short function signatures, I prefer the curly brace at then end of it:

```cpp
void Grid::e_grid_edit_focussed(int index) {
    if (filter_grid(m_app)) {
        silvernode::ui::workspaces::GridWorkspace *gws =
 m_app->main_window()->get_grid_workspace();
```

When the function signature becomes longer, and the arguments span multiple lines, but still start on the same line as the function name with opening parenthesis, it's still fine:

```cpp
void Grid::e_ui_workspace_changed(silvernode::ui::workspaces::Type from,
 silvernode::ui::workspaces::Type to) {
    if (from == silvernode::ui::workspaces::GRID) {
 silvernode::ui::workspaces::GridWorkspace *gws =
 m_app->main_window()->get_grid_workspace();

```

But once the first argument also begins on a new line, under the function name and opening parenthesis, the indent of the function arguments, and the function body match, and it's super unclear to the eye where the arguments stop, and where the function begins:

```cpp
PhotoPreloadHandle Application::preload_photo(
    const std::shared_ptr<photo::Photo> &photo) {
    ZoneScoped;
    const std::string photo_path = photo->path().string();
    ZoneText(photo_path.c_str(), photo_path.size());

    photo::launch_initialization(photo, engine()->job_system());

```

So, instead, I'd rather see one of these options:

```cpp
PhotoPreloadHandle Application::preload_photo(
    const std::shared_ptr<photo::Photo> &photo)
{
    ZoneScoped;
    const std::string photo_path = photo->path().string();
    ZoneText(photo_path.c_str(), photo_path.size());

    photo::launch_initialization(photo, engine()->job_system());

```

or

```cpp
PhotoPreloadHandle Application::preload_photo(
    const std::shared_ptr<photo::Photo> &photo
) {
    ZoneScoped;
    const std::string photo_path = photo->path().string();
    ZoneText(photo_path.c_str(), photo_path.size());

    photo::launch_initialization(photo, engine()->job_system());

```

I can't seem to configure that in clang-format right now.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to