Open llvmbot opened 6 years ago
There are a variety of combinations that can be used with trailing return types and currently clang-format doesn't behave or have any real control on how to format this in an useful way.
We can have declarations in headers:
class A
{
private:
auto Initialize() -> bool;
}
or implementations:
auto
Initialize()
-> bool
{
}
In lambdas, etc.
I'd like to be able to set an offset/alignment.
AFAICT, upgrade to clang-format 7 should solve the problem, see http://lists.llvm.org/pipermail/cfe-users/2018-November/001421.html
There is one subtle issue though, see bug 42835
In a general case I think that more options to control the formatting of the trailing return types would be nice like aligning return types of declarations which a close to each other like:
auto func1() const -> int;
auto long_name_func() const -> int;
auto func2() const -> int;
auto funcLongName() const -> int;
I'd also like to see more control over formatting trailing return types. My wish would be to have independent continuation indentation. e.g. here with a continuation indentation of 8:
auto my_function(long::namespacing::typename foo, longer::namespacing::typename bar,
longest::namespacing::typename baz)
-> return_type
{ }
// ... to a independently configurable indentation for trailing returns, in this case 2 ...
auto my_function(long::namespacing::typename foo, longer::namespacing::typename bar,
longest::namespacing::typename baz)
-> return_type
{ }
// ... and for function declarations, perhaps also separately configurable
auto my_function()
-> return_type;
I don't know if somebody would like to quickly edit this topic title with a [clang-format]
to improve discoverability.
Extended Description
I'm having a number of issues trying to get clang-format to behave reasonably on https://github.com/Kitware/kwiver/blob/303a11ebb43c020ab8e48b6ef70407b460dba46b/vital/range/defs.h, using https://gist.github.com/mwoehlke-kitware/d8ef9466df5096a035059938aef2948d.
For this RFE, specifically, I would like an option to force a break after a the closing brace of a function's parameter list and a trailing return type specifier. For example:
// Current (unwanted) static auto end_helper( Range const& range ) -> decltype( end( range ) )
// Desired static auto end_helper( Range const& range ) -> decltype( end( range ) )