[cfe-dev] Clang Format for Ruby

Samuel Williams via cfe-dev cfe-dev at lists.llvm.org
Thu May 20 17:12:52 PDT 2021


Hello,

I am from the Ruby core team and I want to propose to everyone on that
project that we use clang format.

I'm trying to get a configuration which is consistent but also tries
to follow the existing conventions.

At this time, I'm stuck on trying to get this relatively common format:

static struct dwarf_section *
obj_dwarf_section_at(obj_info_t *obj, int n)
{
    struct dwarf_section *ary[] = {
        &obj->debug_abbrev,
        &obj->debug_info,
        &obj->debug_line,
        &obj->debug_ranges,
        &obj->debug_rnglists,
        &obj->debug_str
    };
    if (n < 0 || DWARF_SECTION_COUNT <= n) {
        abort();
    }
    return ary[n];
}

The trailing curly brace on the ary initialization always wants to go
on  the previous line, i.e. after `debug_str`.

I'd like to try and retain the curly brace being on a line by itself
because it's the prevailing convention of the source code.

I couldn't find an option to do this.

Any help would be most welcome!

Thanks
Samuel


More information about the cfe-dev mailing list