[cfe-dev] Clang Format for Ruby

Jesse Zhang via cfe-dev cfe-dev at lists.llvm.org
Thu May 20 18:05:17 PDT 2021


Samuel,
Not that this is the perfect solution, but is it acceptable to you
that you have a trailing comma after the last array element? I think
the curly brace will be placed on the next line in that case.

Cheers,
Jesse

On Thu, May 20, 2021 at 5:13 PM Samuel Williams via cfe-dev
<cfe-dev at lists.llvm.org> wrote:
>
> 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
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev


More information about the cfe-dev mailing list