<div dir="ltr"><div><span style="line-height:1.5">I'm calling this "recursive alignment", but what it really fixes is issues</span><br></div><div>with AlignConsecutiveAssignments and AlignConsecutiveDeclarations such as this:</div><div><br></div><div>OLD:</div><div>  int fun1(int a);</div><div>  double fun2(int b);</div><div><br></div><div>NEW</div><div>  int    fun1(int a);</div><div>  double fun2(int b);</div><div><br></div><div>Also...</div><div><br></div><div>OLD:</div><div>  void fun(int x = 1) {</div><div>      int y      = 2;</div><div>  }</div><div><br></div><div>NEW:</div><div>  void fun(int x = 1) {</div><div>      int y = 2;</div><div>  }</div><div>  </div><div>The old alignment function was incapable of maintaining alignment whenever</div><div>the scope changed. To illustrate - in the first example mentioned, the</div><div>alignment of fun1 is lost by entering the nested scope of (int a).</div><div>This would cause the alignment to give up, and cause fun2 to start from a</div><div>blank slate. It would also cause false alignment, which is illustrated in</div><div>the second example above.</div><div><br></div><div>This modification changes the alignment function so that it calls itself</div><div>recursively, at each change in scope depth. This allows it to maintain state</div><div>across different scope depths.</div><div><br></div><div>There are some new test cases which stress this functionality. In addition,</div><div>there were two historical test cases marked as "FIX ME", which now work as</div><div>intended.</div><div><br></div><div>In order to sense check, I have run this new implementation against the Clang</div><div>source code, with AlignConsecutiveAssignments:true and</div><div>AlignConsecutiveDeclarations:true. I then compared the old output with those</div><div>settings, vs the new output, with the same settings. All changes that I</div><div>observed are explainable by the new logic, and IMO the formatted code looks</div><div>better with the new method.</div><div><br></div><div>Regards,</div><div>Ben</div></div>