[PATCH] D119625: Fix integer underflow bug when aligning code in clang-format

Björn Schäpers via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Feb 12 09:20:01 PST 2022


HazardyKnusperkeks added a reviewer: HazardyKnusperkeks.
HazardyKnusperkeks requested changes to this revision.
HazardyKnusperkeks added inline comments.
This revision now requires changes to proceed.


================
Comment at: clang/lib/Format/WhitespaceManager.cpp:578
     }
-    unsigned ChangeMaxColumn = Style.ColumnLimit - LineLengthAfter;
+    int ChangeMaxColumn = Style.ColumnLimit - LineLengthAfter;
 
----------------
Could you elaborate the problem? Add a test/assert?


================
Comment at: clang/unittests/Format/FormatTest.cpp:16854
+  // that things still get aligned.
+  Alignment.ColumnLimit = 20;
   EXPECT_EQ("int    a(int   x,\n"
----------------
I disagree. Limit 0 and Limit != 0 behaves differently and you should not remove the old test.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D119625/new/

https://reviews.llvm.org/D119625



More information about the cfe-commits mailing list