[llvm-bugs] [Bug 40906] New: clang-format vertical alignment of 2d array declarations, arrays of structs, and excessively long arrays.
via llvm-bugs
llvm-bugs at lists.llvm.org
Thu Feb 28 12:35:32 PST 2019
https://bugs.llvm.org/show_bug.cgi?id=40906
Bug ID: 40906
Summary: clang-format vertical alignment of 2d array
declarations, arrays of structs, and excessively long
arrays.
Product: clang
Version: unspecified
Hardware: PC
OS: All
Status: NEW
Severity: enhancement
Priority: P
Component: Formatter
Assignee: unassignedclangbugs at nondot.org
Reporter: micasnyd at cisco.com
CC: djasper at google.com, klimek at google.com,
llvm-bugs at lists.llvm.org
Two-dimensional arrays, arrays of structs, and excessively long
single-dimension arrays that are formatted by clang-format end up being
extraordinarily lengthy as each element in each struct will be assigned a
separate line instead of being organized as a matrix.
Ideally, clang-format would format the 2nd dimension, or the entire struct (in
an array of structs), on one line, with each member variable aligned vertically
so as to appear as a table or matrix.
The following examples showing the need for this feature/improvement are from
the ClamAV project. I will note that for the time being we also disable
clang-format to align consecutive macros, which is a feature already in
[review](https://reviews.llvm.org/D28462) that I am looking forward to using.
Array of Structs Declarations:
* libclamav/filestypes.c:
*
https://github.com/Cisco-Talos/clamav-devel/blob/dev/0.102/libclamav/filetypes.c#L57
*
https://github.com/Cisco-Talos/clamav-devel/blob/dev/0.102/libclamav/filetypes.c#L226
*
https://github.com/Cisco-Talos/clamav-devel/blob/dev/0.102/libclamav/matcher.h#L183
* Note, this one contains edge case where the 2nd dimension contains an
additional struct as a member variable.
*
https://github.com/Cisco-Talos/clamav-devel/blob/dev/0.102/libclamav/msxml.c#L52
*
https://github.com/Cisco-Talos/clamav-devel/blob/dev/0.102/libclamav/swf.h#L131
2D Array Declarations:
*
https://github.com/Cisco-Talos/clamav-devel/blob/dev/0.102/libclamav/htmlnorm.c#L129
*
https://github.com/Cisco-Talos/clamav-devel/blob/dev/0.102/libclamav/pe_icons.c#L254
* libclamav/disasm.c contains many examples, although the variables in these
examples are unfortunately not aligned:
*
https://github.com/Cisco-Talos/clamav-devel/blob/dev/0.102/libclamav/disasm.c#L83
*
https://github.com/Cisco-Talos/clamav-devel/blob/dev/0.102/libclamav/disasm.c#L94
*
https://github.com/Cisco-Talos/clamav-devel/blob/dev/0.102/libclamav/disasm.c#L105
*
https://github.com/Cisco-Talos/clamav-devel/blob/dev/0.102/libclamav/disasm.c#L114
* etc...
A related issue with single-dimension arrays where existing line-breaks need to
be respected is probably not addressable.
*
https://github.com/Cisco-Talos/clamav-devel/blob/dev/0.102/libclamav/sf_base64decode.c#L31
*
https://github.com/Cisco-Talos/clamav-devel/blob/dev/0.102/libclamav/binhex.c#L36
*
https://github.com/Cisco-Talos/clamav-devel/blob/dev/0.102/libclamav/htmlnorm.c#L103
*
https://github.com/Cisco-Talos/clamav-devel/blob/dev/0.102/libclamav/matcher-ac.c#L71
*
https://github.com/Cisco-Talos/clamav-devel/blob/dev/0.102/libclamav/textdet.c#L58
Additional detail about how the ClamAV project is using clang-format are listed
in this blog post:
https://blog.clamav.net/2019/02/clamav-adopts-clang-format.html
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190228/2424fa46/attachment.html>
More information about the llvm-bugs
mailing list