[PATCH] D80176: [clang-format][PR45816] Add AlignConsecutiveBitFields
Jake Merdich via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon May 18 21:08:54 PDT 2020
JakeMerdichAMD created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
The following revision follows https://reviews.llvm.org/D80115 since
@MyDeveloperDay and I apparently both had the same idea at the same
time, for https://bugs.llvm.org/show_bug.cgi?id=45816 and my efforts
on tooling support for AMDVLK, respectively.
This option aligns adjacent bitfield separators across lines, in a
manner similar to AlignConsecutiveAssignments and friends.
Example:
struct RawFloat {
uint32_t sign : 1;
uint32_t exponent : 8;
uint32_t mantissa : 23;
};
would become
struct RawFloat {
uint32_t sign : 1;
uint32_t exponent : 8;
uint32_t mantissa : 23;
};
This also handles c++2a style bitfield-initializers with
AlignConsecutiveAssignments.
struct RawFloat {
uint32_t sign : 1 = 0;
uint32_t exponent : 8 = 127;
uint32_t mantissa : 23 = 0;
}; // defaults to 1.0f
Things this change does not do:
- Align multiple comma-chained bitfield variables. None of the other AlignConsecutive* options seem to implement that either.
- Detect bitfields that have a width specified with something other than a numeric literal (ie, 'int a : SOME_MACRO;'). That'd be fairly difficult to parse and is rare.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D80176
Files:
clang/docs/ClangFormatStyleOptions.rst
clang/docs/ReleaseNotes.rst
clang/include/clang/Format/Format.h
clang/lib/Format/Format.cpp
clang/lib/Format/WhitespaceManager.cpp
clang/lib/Format/WhitespaceManager.h
clang/unittests/Format/FormatTest.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D80176.264780.patch
Type: text/x-patch
Size: 7324 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200519/000923a3/attachment-0001.bin>
More information about the cfe-commits
mailing list