[clang] [clang-format] Fix crashes in AlignArrayOfStructures (PR #72520)

Owen Pan via cfe-commits cfe-commits at lists.llvm.org
Fri Nov 17 00:36:02 PST 2023


================
@@ -1316,6 +1316,8 @@ void WhitespaceManager::alignArrayInitializersRightJustified(
         auto Offset = std::distance(Cells.begin(), CellIter);
         for (const auto *Next = CellIter->NextColumnElement; Next;
              Next = Next->NextColumnElement) {
+          if (RowCount >= CellDescs.CellCounts.size())
+            break;
----------------
owenca wrote:

The same/similar code appeared twice in this file and once in the header file. If I were to refactor it, I might not use the same for-loop, so I'll leave it as is for now. (There are also much more cleanup that can be done with this option, but I don't know if it's worthwhile as it's so buggy even after @mydeveloperday limited it to matrices.)

https://github.com/llvm/llvm-project/pull/72520


More information about the cfe-commits mailing list