[PATCH] D119599: Add option to align compound assignments like `+=`

sstwcw via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Feb 11 15:06:07 PST 2022


sstwcw created this revision.
sstwcw added reviewers: curdeius, HazardyKnusperkeks.
sstwcw added projects: clang-format, clang-tools-extra.
sstwcw requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

About the column limit option in the test AlignConsecutiveDeclarations.
Previously, the test worked when the column limit was set to 0.
However, when the column limit is less than the length of a single line,
the formatter is supposed to give up aligning stuff.  Previously it
aligned things due to a bug.  In the function AlignTokens:

  unsigned ChangeMaxColumn = Style.ColumnLimit - LineLengthAfter;
  
  // If we are restricted by the maximum column width, end the sequence.
  if (ChangeMinColumn > MaxColumn || ChangeMaxColumn < MinColumn ||
      CommasBeforeLastMatch != CommasBeforeMatch) {
    AlignCurrentSequence();
    StartOfSequence = i;
  }

`ChangeMaxColumn` would wrap around 0.  `ChangeMaxColumn < MinColumn`
would fail.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D119599

Files:
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/lib/Format/WhitespaceManager.cpp
  clang/unittests/Format/FormatTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D119599.408066.patch
Type: text/x-patch
Size: 11102 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220211/7c41f5ef/attachment.bin>


More information about the cfe-commits mailing list