tarantool / checkpatch

Checkpatch for Tarantool
GNU General Public License v2.0
2 stars 2 forks source link

Allow defining template functions in macros #74

Closed mkostoevr closed 2 months ago

mkostoevr commented 2 months ago

Such structure is used in the memtx tree implementation in order to automatically create iterator advancing wrappers:

template<bool FAST_OFFSET, bool USE_HINT>                                      \
static int                                                                     \
name(struct iterator *iterator, struct tuple **ret)                            \
{                                                                              \
        do {                                                                   \
                int rc = name##_base<FAST_OFFSET, USE_HINT>(iterator, ret);    \
                if (rc != 0 ||                                                 \
                    iterator->next_internal == exhausted_iterator_next)        \
                        return rc;                                             \
        } while (*ret == NULL);                                                \
        return 0;                                                              \
}                                                                              \

But the checkpatch does not recognize the end of template parameter list since it's not folowed by a newline, so it assumes the following lines of the macro are next template parameters (and they're misaligned).

This patch fixes this by making the checkpatch aware that the line a template is defined on can end on a backslash character.

mkostoevr commented 2 months ago

Thanks!