[PATCH] D120188: Fix extraneous whitespace addition in line comments on clang-format directives
Marek Kurdej via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sat Feb 19 14:59:09 PST 2022
curdeius added inline comments.
================
Comment at: clang/lib/Format/BreakableToken.cpp:818
const auto FirstNonSpace = Lines[i][IndentPrefix.size()];
const auto AllowsSpaceChange =
+ (!LineTok || !switchesFormatting(*LineTok)) &&
----------------
curdeius wrote:
> HazardyKnusperkeks wrote:
> > This slowly gets hard to read. Could you maybe split it up? Either in giving the multiple parts their own name. Or to keep the short circuiting have something like:
> > ```
> > auto AllowsSpaceChange = ...;
> > AllowsSpaceChange = AllowsSpaceChange || ...;
> > AllowsSpaceChange = AllowsSpaceChange || ...;
> > ```
> Or use a lambda (with a series of ifs for instance) to initialize it.
While here, please change `auto` to `bool`.
================
Comment at: clang/lib/Format/BreakableToken.cpp:818-822
const auto AllowsSpaceChange =
- SpacesInPrefix != 0 ||
- (!NoSpaceBeforeFirstCommentChar() ||
- (FirstNonSpace == '}' && FirstLineSpaceChange != 0));
+ (!LineTok || !switchesFormatting(*LineTok)) &&
+ (SpacesInPrefix != 0 ||
+ (!NoSpaceBeforeFirstCommentChar() ||
+ (FirstNonSpace == '}' && FirstLineSpaceChange != 0)));
----------------
HazardyKnusperkeks wrote:
> This slowly gets hard to read. Could you maybe split it up? Either in giving the multiple parts their own name. Or to keep the short circuiting have something like:
> ```
> auto AllowsSpaceChange = ...;
> AllowsSpaceChange = AllowsSpaceChange || ...;
> AllowsSpaceChange = AllowsSpaceChange || ...;
> ```
Or use a lambda (with a series of ifs for instance) to initialize it.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D120188/new/
https://reviews.llvm.org/D120188
More information about the cfe-commits
mailing list