[PATCH] D120188: Fix extraneous whitespace addition in line comments on clang-format directives

Björn Schäpers via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Feb 19 12:57:34 PST 2022


HazardyKnusperkeks added inline comments.


================
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)));
----------------
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 || ...;
```


================
Comment at: clang/unittests/Format/FormatTestComments.cpp:98
+                   "// clang-format on\n",
+                   getLLVMStyleWithColumns(20)));
+
----------------
Why the limit?


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