[clang-format] Fix consecutive alignments in #else blocks
authorOwen Pan <owenpiano@gmail.com>
Sat, 6 May 2023 23:29:16 +0000 (16:29 -0700)
committerOwen Pan <owenpiano@gmail.com>
Tue, 9 May 2023 02:45:30 +0000 (19:45 -0700)
commita4c87f8ccaccc76fd7d1c6c2e639ca84b9ec7794
treec89bb4413c94ab6ce3f343e5e86a038fdddfb193
parente494ebf9d09b1112dcf4f22984bdb51bbf5d8cd7
[clang-format] Fix consecutive alignments in #else blocks

Since 3.8 or earlier, clang-format has been lumping all #else, #elif,
etc blocks together when doing whitespace replacements and causing
consecutive alignments across #else blocks.

Commit c077975 partially addressed the problem but also triggered
"regressions".

This patch fixes the root cause of the problem and "reverts" c077975
(except for the unit tests).

Fixes #36070.
Fixes #55265.
Fixes #60721.
Fixes #61498.

Differential Revision: https://reviews.llvm.org/D150057
clang/lib/Format/WhitespaceManager.cpp
clang/unittests/Format/FormatTest.cpp
clang/unittests/Format/FormatTestComments.cpp