Issue 145161
Summary Add clang-format option for formatting single statement function on one line with braces
Labels clang-format
Assignees
Reporter void2012
    Hello! I want to format my C++ code with custom formatting style specified in .clang-format file. The clang-format documentation says there is an option that allows to put short function bodies on the same line with functions. 
https://clang.llvm.org/docs/ClangFormatStyleOptions.html#allowshortfunctionsonasingleline
However, this is not what I want. I want the function body braces to be put on the same line with function body itself, not the whole thing with signature.

With `AllowShortFunctionsOnASingleLine: All`:
```cpp
inline const char* GetBuildingName(TTownType townType, type_building_id buildingId) { return FASTCALL_2(const char*, 0x460CC0, townType, buildingId); } // everything on the same line, ugly
```

With `AllowShortFunctionsOnASingleLine: None`:
```cpp
inline const char* GetBuildingName(TTownType townType, type_building_id buildingId)
{ 
return FASTCALL_2(const char*, 0x460CC0, townType, buildingId); // I need it on the single line
}
```

Desired behavior:
```cpp
inline const char* GetBuildingName(TTownType townType, type_building_id buildingId)
{ return FASTCALL_2(const char*, 0x460CC0, townType, buildingId); } // what I want, but only for single-line body functions
```

It would be also great to have such an option for structs/classes that contain only a single line of code inside their bodies. Thanks!
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to