Fixes https://github.com/llvm/llvm-project/issues/43115.
Also, handle while loops with initializers (C++20) the same way as for loops.
Paths 
  |  Differential  D119648  
[clang-format] Fix PointerAlignment within lambdas in a multi-variable declaration statement. ClosedPublic Authored by curdeius on Feb 12 2022, 12:19 PM. 
Details Summary Fixes https://github.com/llvm/llvm-project/issues/43115. Also, handle while loops with initializers (C++20) the same way as for loops. 
Diff Detail 
 Event TimelineThis revision is now accepted and ready to land.Feb 12 2022, 12:57 PM Comment Actions Rebase on top of D119649, add a similar case with a leading comment. Without it (and if startsWithLoopWithInitializer didn't use startsWith that skips comments), there would be a different spacing of multi-variable initializers in loops, e.g. (-expected, +incorrect): -/*comment*/ for (int *p, *q; p != q; p = p->next) {
+/*comment*/ for (int* p, *q; p != q; p = p->next) {Comment Actions 
 True, I need to fix them in D119649 too. Comment Actions 
 Argh, I initially thought about if statements and then somehow my brain turned it into while. Let me split this revision (fixing if and not while) and clear things up. This revision is now accepted and ready to land.Feb 12 2022, 1:54 PM 
 
 Comment Actions 
 I actually thought there was. But that was a mistake. :) 
 Closed by commit rGe01f624adb0e: [clang-format] Fix PointerAlignment within lambdas in a multi-variable… (authored by curdeius).  ·  Explain WhyFeb 14 2022, 12:41 AM This revision was automatically updated to reflect the committed changes. 
Revision Contents 
 
 
Diff 408217 clang/lib/Format/TokenAnnotator.cpp
 clang/unittests/Format/FormatTest.cpp
 
  | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
But switch can have such a statement.