Open llvmbot opened 6 years ago
I think it would suffice to have a new option to break between the return type, and anything preceding the return type which is not part of the return type. This would overlap with AlwaysBreakTemplateDeclarations, because turning it on would have the same effect if the template <...>
is the only such thing, but it would also trigger breaks before attributes, inline
, static
and constexpr
. (But it would have no effect on classes, so AlwaysBreakTemplateDeclarations would also still be relevant there.)
This also suggests how I could achieve exactly what I want; a new option as here described, and a 'classes only' value for AlwaysBreakTemplateDeclarations. (But again, I can live without that, especially as I probably only want template
and inline
on the same line in macro definitions as in the example file mentioned, if anywhere.)
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 have AlwaysBreakTemplateDeclarations enabled, which is good, but I also want the equivalent for non-type modifiers, e.g.
inline
,static
andconstexpr
(and probably attributes). Ideally I would like these on the same line astemplate
, but I would settle fortemplate
, attributes, and the rest of the above being on their own lines, provided that the keywords in the last category are kept on the same line. (In particular, see how clang-format butchers the end of KWIVER_RANGE_ADAPTER_TEMPLATE in the code mentioned above.)So, specifically:
// best template static
void foo()
// okay template
static
void foo()
// wrong static void foo()