[cfe-dev] [clang-format] Allow breaking before a return type of template functions.

Daniel Jasper via cfe-dev cfe-dev at lists.llvm.org
Mon Jul 18 00:49:00 PDT 2016


No, there is no way at the moment and I also don't know whether this can
even be done (considering that clang-format doesn't have type information
and doesn't really understand macros).

On Fri, Jun 10, 2016 at 8:07 PM, Philippe Canal via cfe-dev <
cfe-dev at lists.llvm.org> wrote:

> Hi,
>
> Given the two functions:
>
>    SOMEMACRO
>    Precision One() const;
>
>    inline
>    Precision Two() const;
>
>    __device__
>    Precision Three() const;
>
>    template <bool ForInnerSurface>
>    SOMEMACRO
>    Precision TemplateOne() const;
>
>    template <bool ForInnerSurface>
>    inline
>    Precision TemplateTwo() const;
>
>    template <bool ForInnerSurface>
>    __device__
>    Precision TemplateThree() const;
>
> with AlwaysBreakTemplateDeclarations set to true, I would like the code to
> remained unchanged after process via clang-format. However the result is
>
>    SOMEMACRO
>    Precision One() const;
>
>    inline Precision Two() const;
>
>    __device__ Precision Three() const;
>
>    template <bool ForInnerSurface>
>    SOMEMACRO Precision TemplateOne() const;
>
>    template <bool ForInnerSurface>
>    inline Precision TemplateTwo() const;
>
>    template <bool ForInnerSurface>
>    __device__ Precision TemplateThree() const;
>
> Note that the macro and the keyword are treated differently for the
> regular function (see One() vs Two()).
>
> In practice, clang-format seems to leave the placement of SOMEMACRO
> unchanged (i.e. if it was originally on the same line as the function decl,
> it stays there).
>
> Is there a way to force a break *before* the return type?
>
> Thanks,
> Philippe
>
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20160718/08ee75e8/attachment.html>


More information about the cfe-dev mailing list