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