clang-format: Return type in its own line for function definitions

Hi,

Our code standards ask for the return type in its own line for function definitions (if not inside the class declaration), how can I make that work?

Header:
class A
{
    int a() { }
    int b();
}

Source:
int
{
    // something
}

Thanks,
Damian

There's the *AlwaysBreakAfterDefinitionReturnType * style option. It (along
with the others) is documented at:
http://clang.llvm.org/docs/ClangFormatStyleOptions.html

Eli

There's the AlwaysBreakAfterDefinitionReturnType style option. It (along with the others) is documented at: http://clang.llvm.org/docs/ClangFormatStyleOptions.html

That option doesn’t do what I need, because it also adds the break if the function is defined inside the class declaration, so I get this:

class A
{
    int
    a()
    {
    }
    int b();
}

There is no option to control what you are looking for yet. If you want to contribute one, you can roughly look at how the “Inline” mode for AllowShortFunctionsOnASingleLine is implemented.

Cheers,
Daniel

I’ll take a look and see if I can contribute it when I have some time. For now I’ll try to push this as it is (with break after type enabled) and see what happens, I’m sure the benefits of automatic formatting overweight the small issues I’m finding. Thanks!