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

Philippe Canal via cfe-dev cfe-dev at lists.llvm.org
Fri Jun 10 11:07:03 PDT 2016


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





More information about the cfe-dev mailing list